Jetpac laser problem

BlitzPlus Forums/BlitzPlus Beginners Area/Jetpac laser problem

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.

Basically, you should store the Y coordinate of the new laser, then use that to update it, instead of using the players Y position, which obviously, you are.

Something like this may give you the general jist on how to go about it:-

Type laser
	Field laserX
	Field laserY 
End Type

Graphics 640,480,16,2

Global countLasers = 0

Repeat
Cls
mx = MouseX()
my = MouseY()

If MouseHit(1)
	CreateLaser(mx,my)
End If

UpdateLasers()

Text 0,0,"Lasers Amount:"+countLasers

Flip 
Until KeyDown(1)

Function CreateLaser(startX,startY)
	newLaser.laser = New laser
	newLaser\laserX = startX
	newLaser\laserY = startY
End Function

Function UpdateLasers()
	countLasers = 0
	For loopLasers.laser = Each laser
		Line 0,loopLasers\laserY,loopLasers\laserX,loopLasers\laserY
		loopLasers\laserX = loopLasers\laserX - 5
		If loopLasers\laserX =< 0
			Delete loopLasers
		Else
			countLasers = countLasers + 1
		End If
	Next 
End Function