Computer Science Canada Firing |
Author: | Nitrix [ Wed Jun 08, 2005 8:23 pm ] | ||||
Post subject: | Firing | ||||
Ok, I have created a graphic to use as a bullet but the problem is that the bullet graphic doesn't move vertically but stays stationary. Mind you this accident allows me to use it as a muzzle flash for when the player presses the shoot button Part of my Input Procedure
the actual Procedure responsible for the bullet
|
Author: | Delos [ Wed Jun 08, 2005 8:34 pm ] | ||
Post subject: | |||
Here's what you'll want to do. Your 'bullet' is an object, with a cartesian cordinate, a velocity, and perhaps other attributes as well. So:
Now, when your bullet is created, you assign each of the fields of the record (eg. my_bullet.pX := 5) however you need. Probably 'fired' will be initially false. Now, your check for input sets the boolean to true (as a note, you don't need to include the comparison check with booleans: 'if fired then' is the same as 'if fired=true then') and you draw your object. By this time of course, you've also initialized the velocity components - allowing you both vertical and angled movement. Just make sure that at regular intervals, the 'pX' of the object has the 'vX' added to it (and the same for the y-components). Check out the tutorials on records and types, as well as on arrays. |
Author: | vagyb [ Wed Jun 08, 2005 9:07 pm ] | ||||
Post subject: | Re: Firing | ||||
you have to make the change of the bullet X coordinate after the weopon_fired : = true Nitrix wrote:
the actual Procedure responsible for the bullet
|
Author: | vagyb [ Wed Jun 08, 2005 9:07 pm ] |
Post subject: | |
also if ur doing a shooter game check my thread on this forum (it should be on this page) , i'm pretty sure it'll help u a bit. |
Author: | Nitrix [ Thu Jun 09, 2005 2:55 pm ] |
Post subject: | |
Ok I got my ship to shoot but the problem is that it will only works randomly and when it does it will only fire once. Forgive but I am a total noob when it comes to arrays(especiallyt when they involve pictures). |
Author: | vagyb [ Thu Jun 09, 2005 8:25 pm ] |
Post subject: | |
Nitrix wrote: Ok I got my ship to shoot but the problem is that it will only works randomly and when it does it will only fire once. Forgive but I am a total noob when it comes to arrays(especiallyt when they involve pictures).
post the code? |
Author: | Nitrix [ Thu Jun 09, 2005 8:40 pm ] | ||
Post subject: | |||
|
Author: | vagyb [ Thu Jun 09, 2005 8:46 pm ] | ||
Post subject: | |||
Nitrix wrote:
okay why are u changing ur bullet Y value? u only change the bullet X value when u shoot, do not draw the bullet in that if statement, and make new statement if weopon fired false then bullet x : = charx etc... [/code] |