Results 1 to 2 of 2
Thread: 1st Game
- 09-05-2010, 10:27 PM #1Member
- Join Date
- Sep 2010
- Rep Power
I am creating a shooting game which involves a spaceship (the shooter) and asteroids (the target). I managed to display the spaceship the way I want and I am also able to move it on the screen using the keyboard the way I want. However, I am having problems loading the asteroids. I am using a timer to do the animation. Here's what I am trying to do with the asteroids: I want there to be 4 asteroids coming down the screen (from top to bottom). When one of the asteroids has reached the end of the screen, 4 more asteroids come down (at random positions on the screen). I have one timer object which calls the paintComponent() method every 25 milliseconds. Although this works fine for the movement of the spaceship and the firing of the bullets, it's way too fast for the asteroids (meaning the asteroids come down so fast). So, I was wondering whether it would be possible for the bullet animation to occur at a different speed then the asteroid animation (i.e. for the asteroids, I don't want the timer to call the paintComponent() method every 25 ms).
Thank-You in advance.
I know nothing about games, so hopefully a game pro will come around to help, but I would think that you could give each moving object a speed, perhaps an x and and a y speed, and using the system clock and these speeds, move only a certain distance for each slice of time.
- By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM
- By deathnote202 in forum Java GamingReplies: 4Last Post: 06-10-2010, 08:06 AM
- By Manikyr in forum New To JavaReplies: 6Last Post: 06-06-2009, 11:09 AM
- By led1433 in forum Java 2DReplies: 5Last Post: 02-10-2009, 06:00 AM
- By amith in forum AWT / SwingReplies: 0Last Post: 05-19-2008, 05:16 PM