Dessiner une Pyramide
Publié : lun. 03/avr./2023 10:12
Hello,
Voici un code en Purebasic qui dessine une pyramide ^^
Happy coding !
Voici un code en Purebasic qui dessine une pyramide ^^
Code : Tout sélectionner
;
;; Created by threedslider 02/04/2023
;
InitSprite()
InitKeyboard()
Procedure Triangle(X, Y)
Line(X, Y, 100, 1, RGB(255,0,0))
Line(X, Y, 50, -100, RGB(255,0,0))
Line(X+100, Y, -50, -100, RGB(255,0,0))
EndProcedure
Procedure Pyramide(X, Y, Iter)
Triangle(X,Y)
If Iter = 0
ProcedureReturn
Else
Pyramide(X-50, Y+100, iter-1)
Pyramide(X+50, Y+100, iter-1)
EndIf
EndProcedure
OpenWindow(1, 0,0,800,600,"Drawing pyramide", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
Repeat
ExamineKeyboard()
event = WindowEvent()
ClearScreen(RGB(255,200,0))
StartDrawing(ScreenOutput())
Pyramide(350, 150, 4)
StopDrawing()
FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End