Posted: Fri Jan 14, 2011 11:12 pm Post subject: Re: HELP!!! Making an if key pressed statement execute repeatedly after pressing the key only once!?
to answer your question, try this:
%THIS IS PURPOSELY IN TEXT GRAPHICS, YOU HAVE FIGURE OUT THE REST YOURSELF IF YYOU WANT IT IN PIXEL GRAPHICS
View.Set("offscreenonly")
var bulletvelocity:int:=%set speed of bullet%
var playerx,playery:int:=20
var bulletx, bullety:int
var chars : array char of boolean
var bullet:boolean:=false
loop
Input.KeyDown
%
put movement code here
%
if chars(' ') then
bulletx:=playerx %When the fire key is pressed the bullet coordinates will be the player's current position
bullety:=playery
bullet:=true %this allows one bullet per player on screen; prevents spamming
end if
if bullet=true then
bulletx:=bulletx+bulletvelocity %This example will shoot the bullet right
if bulletx>maxx then
locate(bulletx,maxcol)
put" " %Clears the bullet if bullet is about to go off screen
else
locate(bullety,bulletx)
put"-" %Draws the bullet if it is not off screen
end if
delay(50)
View.Update
end loop
TokenHerbz
Posted: Sat Jan 15, 2011 12:49 am Post subject: RE:HELP!!! Making an if key pressed statement execute repeatedly after pressing the key only once!?
spawn at character --> move to destination... die when destination is reached....
nick4563
Posted: Sat Jan 15, 2011 9:57 am Post subject: RE:HELP!!! Making an if key pressed statement execute repeatedly after pressing the key only once!?
Thank you all bullet velocity was my missing factor thank you!!!
Dragon20942
Posted: Tue Jan 18, 2011 7:59 pm Post subject: RE:HELP!!! Making an if key pressed statement execute repeatedly after pressing the key only once!?
I'm currently making a shooting game for my culminating. Create another variable for the initial Y position of the bullet. Moving the bullet is just basic loop stuff.