Creating A Laser

BlitzPlus Forums/BlitzPlus Beginners Area/Creating A Laser

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Try

Function LaserUp(x,y)
If Millisecs() > LaserTimer + 3000 ;do if you havent shot a laser in 3 seconds
color 9,233,251 ;Set color to blue
for z = 0 to 4
Line x+z,y,x+z,0 ;draw a laser from the player to the top of the screen
next
color 0,0,0 ;reset color for any text or whatever later
endif
end function

;the following code will go in the main loop

if keydown(57)
space = 1 ;if the space key is pressed then prepare for laser
LaserTimer = millisecs()
endif
if space > 0
LaserUp() ;draw laser
space = space + 1 ;increase count so laser doesn't last forever or one frame
end if
if space > 10 then space = 0 ;set this so the laser will dissapear after 10 frames


;Variable declarations!!! Place the following at the top of your code

LaserTimer = millisecs()
space = 0


;P.S. Be Sure to Replace Playerx And Playery with your player coordinates