Strange things about moving object

BlitzPlus Forums/BlitzPlus Programming/Strange things about moving object

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.

Hallo to all.
I have a problem with my movements function.
I have tried to modify my functions with the various hint from my previous posts(about the function that return multiple values...)but when i execute my program...something goes very wrong.
I have 3 function that made different movements:up&down,left&right,circular.
Here's the code.....i don't know how to explayn the effects,but if you cut&paste the code and you press the mouse button....well.....i don't know why the speed movements double itself!!!

Type alieno
	Field posizionex#
	Field posizioney#
	Field velocita#
	Field percorso
End Type
Function crea_alieno(xpos,ypos,speed,movimento)
	a.alieno=New alieno
	a\posizionex=xpos
	a\posizioney=ypos
	a\velocita#=speed
	a\percorso=movimento
End Function

Function muovi_alieno()
	For a.alieno=Each alieno
		Select a\percorso
			Case 1
			circleMov()
			Case 2
			strightMov()
			Case 3
			updownMov()
		End Select
	Next
End Function

Global a.alieno






Const scrX=640,scrY=480
;------------------------------------
Global r1#,r2#,r3#
;------------------------------------
;setup
Graphics scrX,scrY,32,2
SetBuffer BackBuffer()
;------------------------------------
AutoMidHandle True 
;loadgrafx
Global backGnd=LoadImage("go.bmp")
Global enemys=LoadImage("enemy.bmp")
;------------------------------------

;loop
;crea_alieno(100,300,4,1)
;crea_alieno(15,15,1,1)

While Not KeyDown(1)
If MouseHit(1)=True
crea_alieno(50,50,1,1)
crea_alieno(200,400,1,1)
crea_alieno(200,200,2,2)
crea_alieno(100,100,4,3)
EndIf
Cls
TileImage backGnd,ixTim,iyTim 
muovi_alieno()

Flip
Wend
End
;Circle Motion
Function circleMov()
	xpos#=a\posizionex+Sin(r1)*100
					
					
	ypos#=a\posizioney+Cos(r1)*100
	speed1#=a\velocita
	DrawImage enemys,xpos,ypos
	r1=r1+speed1#
	If r1=>359 Then r1=0
End Function
;------------------------------------
;Forward & Backward Motion
Function strightMov()
	xpos#=a\posizionex+Sin(r2)*100
	ypos#=a\posizioney
	speed2#=a\velocita
	DrawImage enemys,xpos#,ypos#
	r2=r2+speed2#
	If r2=>359 Then r2=0
End Function
;------------------------------------
;Up & Down Motion
Function updownMov()
	xpos#=a\posizionex
	ypos#=a\posizioney+Cos(r3)*100
	speed3#=a\velocita
	DrawImage enemys,xpos#,ypos#
	r3=r3+speed3#
	If r3=>359 Then r3=0
End Function




I can call crea_alieno many times,but if i call crea_alieno with the same movement function.....it seems that the alien add their speed and go at speed=alien1speed+alien2speed
I also don't know if the position are correctly calculated.....
I hope i have translated well,and that the effect i'm trying to explain is visible to all.
Thanks