event loop and canvas buffer
BlitzPlus Forums/BlitzPlus Programming/event loop and canvas buffer
| ||
| Hi There, I'm in need of some good advice. Hope someone can help me. I want to make a game in blitzplus which has the following design elements: 1- a canvas which refreshes at 30 fps and shows the actual game action (moving objects, etc). 2- lots of buttons for which I want to use the blitzplus event handler. 3- a textbox in which the player can type commands which affect the game. Now what I want to know is, what would the framework look like? Do I create an event loop and place the flip canvasbuffer inside that loop? But how can I guarantee the 30fps in that case? Or should I make an flip canvasbuffer loop and try somehow to place an event loop inside it? Simply put: I don't know how to Can someone please help me? write the game loop in pseudo-code? thanks in advance, Andrik |
| ||
app=CreateWindow("bla",0,0,640,480)
Global cnv=CreateCanvas(32,32,400,300,app),r=255,g=255,b=255
timer=CreateTimer(30)
Global txt=CreateTextField(32,340,64,24,app)
button1=CreateButton("new color",128,340,64,24,app)
Repeat
WaitEvent()
If EventID()=$803 quit=True
If EventID()=$4001 ; timer
updatecanvas()
EndIf
If EventID()=$401
If EventSource()=button1
r=Rnd(255)
g=Rnd(255)
b=Rnd(255)
EndIf
EndIf
Until quit
End
Function updatecanvas()
SetBuffer CanvasBuffer(cnv)
Cls
; random stuph
Color r,g,b
For k=0 To 31
Rect Rnd(200),Rnd(150),100,100,True
Next
Color 255,255,255
Text 0,0,TextFieldText$(txt)
FlipCanvas cnv
End Function
|
| ||
| Thanx! I have seen the light ;-) |
| ||
| then go in peace my son :) |
| ||
| an action like that should be incremented into the command references examples.. |