Moving object from point A to B...

BlitzPlus Forums/BlitzPlus Programming/Moving object from point A to B...

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.

Ok i have incorporated your examples and my code and the result is:
Graphics 640,480,32,1
SetBuffer BackBuffer()

Global sfondo=LoadImage("d:\sfondo.bmp")
Global nemico=LoadImage("d:\torretta.bmp")
Global aereo=LoadImage("d:\jet.tga")
Global bullet=LoadImage("d:\bullet1.bmp")
Global pulsante
Global jetx
Global jety

MidHandle sfondo
MidHandle nemico
MidHandle aereo
MidHandle bullet

Type bullet
	Field x1,y1,x2,y2,durata
End Type



;MAIN

While Not KeyHit(1)

jetx=MouseX()
jety=MouseY()

Cls

DrawImage aereo,jetx,jety
DrawImage nemico,100,100

If MouseHit(1)
	pulsante=1
	create_bullet(100,100,jetx,jety,200)
EndIf
move_bullet()
Flip

Wend

End
;END MAIN


Function create_bullet(xfrom,yfrom,xto,yto,life)
b.bullet = New bullet 
b\x1 = xfrom 
b\y1 = yfrom 
b\x2 =xto
b\y2 =yto
b\durata=life
End Function 

Function move_bullet()
For b.bullet=Each bullet
If b\x1 < b\x2 Then b\x1 = b\x1 + 1 
If b\x1 > b\x2 Then b\x1 = b\x1 - 1 
If b\y1 < b\y2 Then b\y1 = b\y1 + 1 
If b\y1 > b\y2 Then b\y1 = b\y1 - 1 
DrawImage bullet,b\x1,b\y1 
If b\x1 = b\x2 And b\y1 = b\y2 Then Delete b
; what ever you want to do when bullet is there 
;End If 
Exit
Next
End Function 


The problem is that i don't know why start only a bullet at one time even if i hit multiple time the mouse button!
The bullets start to move when each bullet is expired respectively...so only one at time show-up!
And the movement are not "stright" but go up (or down) until the differences of the two y coords are satisfied..after the y coords start to compare the x coords and the missile start to do left(or right).
What i search is a real "line"not a segmented line.
Thanks.