Je vous partage une simulation de serpent

Voici le code :
Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Coded with Purebasic v.6.11 by threedslider 16/07/2024
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Test for Snake :)
InitSprite()
InitKeyboard()
OpenWindow(1, 0,0,800/ DesktopResolutionX(),600/ DesktopResolutionY(),"Snake", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
SetFrameRate(30)
Repeat
ExamineKeyboard()
event = WindowEvent()
ClearScreen(RGB(0,0,0))
StartDrawing(ScreenOutput())
For x = 0 To 360
move.f + 1/10000
snake_x.f = 10* Cos(30*Cos(move-((x/5)))/10)
snake_y.f = 10 *(move*2-x)-x
Box( snake_x+400, snake_y+x, 5*Cos(x/4)/2, Cos(x/4)*5, RGB(255, 0, 0) )
Next
StopDrawing()
Delay(1) : FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End