473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

change bullets!

59
i need some help with java. i am creating a game where i have a player and he shoot bullets. u can also change u types of bullet.
bullets are just fillOval. and change types of bullets is different colo.

i have created a class bullet. which just create one bullet.
than if player hit space bar. than create a bullet and store in arraylist.

Expand|Select|Wrap|Line Numbers
  1. if(space)
  2. {
  3.     bulletObject = new Bullet();    //create bullet
  4.     bulletStore.add(bulletObject);  //store in arraylist
  5. }
now to change bullets. i have create a variable call bulletName. if it has a value of 1 than its bullet type is 1. If it has value of 2 than its bullet type is 2.

if user hit 'f' key than change bullet type.
Expand|Select|Wrap|Line Numbers
  1. if(f)
  2. {
  3.     bulletName ++;  //go to next bullet type
  4. }
now to draw the bullets.
Expand|Select|Wrap|Line Numbers
  1. pubic void paint(Graphics g)
  2. {
  3.     if(bulletName == 1)
  4.         g.setColor(Color.green); 
  5.    if(bulletName == 2)
  6.         g.setColor(Color.blue);
  7.     if(bulletName == 3)
  8.         g.setColor(Color.red);
  9.  
  10.      g.fillOval(x,y,width,height);    
  11. }
The problem is that if user hit space bar than it will shoot one bullet. than if user hit 'f' key than it will change color of all bullets on screen.

i want it so that it doesnt change color of bullets on screen. it only change color of bullet that are about to get shoot.change
Apr 9 '13 #1
1 1269
r035198x
13,262 8TB
Difficult to say without seeing the structure of your code and the order of your events.
Apr 9 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: gogaz | last post by:
Hello, I am facing one strange problem. I am using RichTextBox control in my VB6.0 application and have provided one button giving functionality to set bullets on the selected text. When i type...
1
by: Tyler | last post by:
When I am making an unordered list (using bullets), is there a way to make the bullets small pictures that I can choose. <ul type=??> <li></li> </ul>
6
by: Stephen Miller | last post by:
Hi, How can I configure an ordered list so that the bullet is placed on the right hand side of the list item. ie: list item 1 * list item 2 * list item 3 * Thanks,
1
by: Johannes Theile | last post by:
Hi, is it possible to show the bullets in a list (ul), although it is possitioned as an inline element? Greetings, Johannes
1
by: P Creyghton | last post by:
Does anyone know how to change the distance between a list item and the accompanying text??? example. 1.------item1 2.------item2 should be:
2
by: Wiz | last post by:
Greetings the group! I see from a few previous postings that I am not the only person having a problem with hidden list item bullets. This question applies to both IE 6, current version, and...
3
by: Jordan Peterson | last post by:
When using {list-style: none} to hide the bullets in a <ul>, the bullets disappear but they are still accounted-for when positioning text. Specifically, I have: <div style='text-align:...
3
by: dingbat | last post by:
A relatively common piece of CSS is to style a list to be displayed in-line: li { display: inline; } However this also removes any bullets from the <li>s, as they're no longer "list items". ...
0
by: raj | last post by:
Hello , I have a problem, rich text bullets are not displayed in Crystal report. Environment : VS .NET 2003 CrystalDecisions.CrystalReports.Engine Version 9.1.5000.0 ( it came with ..NET...
1
by: Helena | last post by:
Hello there, I have a project that need to export data from a datagrid to MS Word and with bullets on each line. I know how to export data to word but don't know how to add bullets on each...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.