
-----------------------------------
Nitrix
Wed Jun 08, 2005 8:23 pm

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
    if chars (' ') then
        Weapon_fired :=true
   end if 
end P1_CheckKeys

the actual Procedure responsible for the bullet
procedure Shoot
    if Weapon_fired =true then
    Bullet_X := charX+18
    Bullet_Y := charY+Bullet_Speed
    Pic.Draw(Tracer,Bullet_X,Bullet_Y,picMerge)
    Weapon_fired :=false
    end if
end Shoot    

-----------------------------------
Delos
Wed Jun 08, 2005 8:34 pm


-----------------------------------
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:

type bullet:
  record
    pX, pY : int
    vX, vY : int
    fired : boolean
    col : int
  end record


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.

-----------------------------------
vagyb
Wed Jun 08, 2005 9:07 pm

Re: Firing
-----------------------------------
you have to make the change of the bullet X coordinate after the weopon_fired : = true


    if chars (' ') then
        Weapon_fired :=true
(here put ur bullet X and Y coordinates for example)
   if chars (' ') then
            isShooting := true
           bulletx += 93
        
        end if
end P1_CheckKeys


the actual Procedure responsible for the bullet
procedure Shoot
    if Weapon_fired =true then
    Bullet_X := charX+18
    Bullet_Y := charY+Bullet_Speed
    Pic.Draw(Tracer,Bullet_X,Bullet_Y,picMerge)
    Weapon_fired :=false
    end if
end Shoot    

-----------------------------------
vagyb
Wed Jun 08, 2005 9:07 pm


-----------------------------------
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.

-----------------------------------
Nitrix
Thu Jun 09, 2005 2:55 pm


-----------------------------------
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).

-----------------------------------
vagyb
Thu Jun 09, 2005 8:25 pm


-----------------------------------
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?

-----------------------------------
Nitrix
Thu Jun 09, 2005 8:40 pm


-----------------------------------
    if Weapon_fired =true then
    Bullet_X := charX+18
    Bullet_Y := charY+48
    Pic.Draw(Tracer,Bullet_X,Bullet_Y+Bullet_Speed,picMerge)
    Weapon_fired :=false
    Bullet_X := charX
    Bullet_Y := charY
    end if

-----------------------------------
vagyb
Thu Jun 09, 2005 8:46 pm


-----------------------------------
    if Weapon_fired =true then
    Bullet_X := charX+18
    Bullet_Y := charY+48
    Pic.Draw(Tracer,Bullet_X,Bullet_Y+Bullet_Speed,picMerge)
    Weapon_fired :=false
    Bullet_X := charX
    Bullet_Y := charY
    end if

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]
