Search the Community
Showing results for tags 'Colliding'.
-
I'm having some difficulties with a game. It's kinda like CurveFever (Achtung Die Kurve), but I just want it for personal 1P usage. The problem is just that I can't figure out a way to check if the line is colliding with any point of where it has been before. I know there are lots of ways to do it, but I always end up with the game running slow because of bad methods such as searching for pixels etc. Any suggestions on a faster method? (You would probably have to test the code yourself to know what I'm saying if you want to help :/ ) #include <misc.au3> #include <GDIPlus.au3> HotKeySet("{ESC}", "Terminate") #Region Win $WinWidth=895 $WinHeight=895 $hGUI=GUICreate("", $WinWidth, $WinHeight, -1, -1) GUISetBkColor(0x000000, $hGUI) GUISetState() #EndRegion #Region GDIPLUS _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) $hPen = _GDIPlus_PenCreate(0x9900FF00, 5) $hPenBorder = _GDIPlus_PenCreate(0xFFFFFFFF, 5) _GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $WinWidth-1, $WinHeight-1, $hPenBorder) #EndRegion #Region Vars $Width=56 $SpeedTime=100 $Switch=1 $x=5 $y=5 $VektorX=0 $VektorY=Sqrt($Width^2-($VektorX^2)) $Hole_Count=1 $Hole_MakeHole=Random(10, 1000, 1) Global $SpeedTime _GDIPlus_GraphicsDrawEllipse($hGraphic, $x, $y, 2.4, 2.4, $hPen) #EndRegion Sleep(1000) $Timer=TimerInit() While 1 If _IsPressed(25) Then TurnLeft() EndIf If _IsPressed(27) Then TurnRight() EndIf $x+=$VektorX/30 $y+=$VektorY/30 DrawLine() While TimerDiff($Timer)<$SpeedTime/6 WEnd $Timer=TimerInit() WEnd Func DrawLine() ;~ $Hole_Count+=1 If $Hole_Count>$Hole_MakeHole Then If $Hole_Count>$Hole_MakeHole+15 Then $Hole_Count=0 $Hole_MakeHole=Random(10, 1000, 1) EndIf Else _GDIPlus_GraphicsDrawEllipse($hGraphic, $x, $y, 2.4, 2.4, $hPen) EndIf EndFunc Func TurnLeft() If $Switch>0 Then $VektorX+=(2.5*$VektorY*$Switch)/$Width+0.0005 If $Switch<0 Then $VektorX-=(2.5*$VektorY*$Switch)/$Width+0.0005 If $VektorX>=$Width Then $Switch*=-1 $VektorX=$Width EndIf If $VektorX<=-$Width Then $Switch*=-1 $VektorX=-$Width EndIf $VektorY=Sqrt($Width^2-($VektorX^2))*$Switch EndFunc Func TurnRight() If $Switch>0 Then $VektorX-=(2.5*$VektorY*$Switch)/$Width+0.0005 If $Switch<0 Then $VektorX+=(2.5*$VektorY*$Switch)/$Width+0.0005 If $VektorX>=$Width Then $Switch*=-1 $VektorX=$Width EndIf If $VektorX<=-$Width Then $Switch*=-1 $VektorX=-$Width EndIf $VektorY=Sqrt($Width^2-($VektorX^2))*$Switch EndFunc Func Terminate() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() Exit EndFunc