Hi !
In my game i want add satellites (red) to the player ship (white). (LMB to create a satellite). My problem : Red satellites don't follow exatly the player movement (see the white twist, cord, tie up (sorry for bad english : Systran translation ;-))
In my game i want add satellites (red) to the player ship (white). (LMB to create a satellite). My problem : Red satellites don't follow exatly the player movement (see the white twist, cord, tie up (sorry for bad english : Systran translation ;-))
Strict Graphics 800,600 Global jposx Global jposy Global Liste_satellites:TList = CreateList() Type TSatellite Field x Field y Field Distance Function Creer:TSatellite (x:Int, y:Int, Distance : Int) Local n:TSatellite = New TSatellite n.x = x n.y = y n.distance = Distance ListAddLast Liste_satellites, n Return n End Function Function Maj() Local ax, ay ax = jposX ay = jposY For Local s:TSatellite = EachIn Liste_Satellites Local adx,ady, ndx, ndy ndx = s.x - jPosX ndy = s.y - jPosY If Abs(ndx) > s.Distance Then If ndx < 0 Then s.x = jPosX - s.Distance Else s.x = jPosX + s.Distance End If End If If Abs(ndy) > s.Distance Then If ndy < 0 Then s.y = jPosY - s.Distance Else s.y = jPosY + s.Distance End If End If SetColor 255, 0,0 DrawOval s.x-10, s.y-3, 20,6 SetColor 255,255,255 DrawLine ax,ay, s.x, s.y ax = s.x ay = s.y Next End Function End Type Local ld = 40 Local ax, ay ax = MouseX()- ld ay = MouseY()- ld While Not KeyDown(KEY_ESCAPE) Cls jposx = MouseX() jposy = MouseY() SetColor 255,255,255 DrawOval MouseX(), MouseY(), 10,10 TSatellite.Maj() If MouseDown(1) Then Local s1:TSatellite = TSatellite.Creer (ax, ay, ld) ax = MouseX()- ld ay = MouseY()- ld ld = ld + 20 FlushMouse() End If Flip Wend