Computer Science Canada How to take a "snapshot" of the XY coordinates to fire a bullet from an oval |
Author: | vapour99 [ Sun Jun 01, 2008 6:44 pm ] | ||
Post subject: | How to take a "snapshot" of the XY coordinates to fire a bullet from an oval | ||
I am currently coding a SHUMP (spaceship shooter) game for my Grade 10 coding class and have encountered a simple problem: When I move the ship, the bullets shot from the ship move as well. The game is in its very early stages with simple titles and animations, but I need to solve this problem before I can continue programming the logic part of the game. here is the code:
I also have a minor problem with View.Update on the "bullets" (flashing) Any help given to a "newbe" programmer is much appreciated. I hope to contribute to the community as I learn. -Regards; paul |
Author: | TheWanderer [ Sun Jun 01, 2008 10:35 pm ] |
Post subject: | Re: How to take a "snapshot" of the XY coordinates to fire a bullet from an oval |
very good start (' ')b looks like you're only keeping track of the bullets' x location with a single variable solution contains many things to look into: - you'll have to set a limit of bullets to be able to be shot from the ship - you'll have to set a delay between firing a bullet, otherwise you'll start lagging for the next idea - set up an array up to the limit of bullets that will keep track of bullet locations - add to this array when the ship fires its a little difficult for gr 10, but if you're determined, its not that hard to figure out in the end. i think the major problem you'll encounter is going beyond array limits another solution for you is to create just one bullet that moves very fast keep track of its location separate from your ship position. but it'd be very boring right? XD yes.. easy takes away from cool XD |
Author: | vapour99 [ Mon Jun 02, 2008 7:43 am ] |
Post subject: | RE:How to take a "snapshot" of the XY coordinates to fire a bullet from an oval |
I am going to have to use the array option as a delay in the process halts the entire program and a delay in the if statements with the forks will create delays in the entire program is the key is pressed Ill look into Arrays then. You mention keeping track of a bullets position seperate from the ships position; how are you doing that without moving the ship as well? |
Author: | Insectoid [ Mon Jun 02, 2008 7:57 am ] |
Post subject: | RE:How to take a "snapshot" of the XY coordinates to fire a bullet from an oval |
INstead of a delay, use a counter. Every time the game loops, the counter goes down by one. when it reches zero, reset it and fire another bullet! |
Author: | vapour99 [ Mon Jun 02, 2008 8:32 am ] | ||
Post subject: | RE:How to take a "snapshot" of the XY coordinates to fire a bullet from an oval | ||
it should work, but now I cannot see the bullets; here is the code after today's class (i am trying to fixc the bullets before I try to fix the enemies)
|
Author: | vapour99 [ Mon Jun 02, 2008 3:57 pm ] |
Post subject: | RE:How to take a "snapshot" of the XY coordinates to fire a bullet from an oval |
I have implemented the correct array code; thanks for the recommendation TheWanderer |