Hi, i am in the middle of creating a game for a first year university project. I have had trouble geting a bullet to fire out of a moving sprite which is controlled by the keyboard arrows. Here is the script attached to the moving sprite,
property pMySprite, pSpeed
on beginsprite me
pSpeed = 5
pMySprite = sprite([login to view URL])
end
on exitframe
case TRUE of
(keypressed(124)) : [login to view URL] = [login to view URL] + pSpeed
[login to view URL] = 1
(keypressed(123)) : [login to view URL] = [login to view URL] - pSpeed
[login to view URL] = 0
(keypressed(125)) : [login to view URL] = [login to view URL] + pSpeed
(keypressed(126)) : [login to view URL] = [login to view URL] - pSpeed
end case
end
The above code simply moves the sprite arround the screen, below is the code ive attached to the bullet...
property pTankShell , pSpeed, pTop, pBottom, pFire
on beginsprite me
pTankShell = sprite([login to view URL])
pSpeed = 15
pTop = - 10
pBottom = 610
pFire = false
end
on exitframe me
if keypressed (49) then
Shoot
if [login to view URL] > pBottom then
[login to view URL] = pTop
pShoot = false
end if
end if
on Shoot
[login to view URL] = sprite(3).locv + pSpeed
[login to view URL] = sprite(3).loch
end
All this code seems to do is relocate the bullet to the postition of the moving sprite. how could i have the bullet moving down to the bottom of the stage from the position of the moving sprite, then reseting to the top of stage until the key is pressed again.
Any help would be appriceated for this project needs to be in for monday.
thanks very much,