2D against GUI

BlitzPlus Forums/BlitzPlus Programming/2D against GUI

Davo(Posted 2004) [#1]
As some of you already know, I'm trying to create an application in 2D mode seeing as GUI mode is very limited.

I've created a fairly decent design, which Im proud of but this is where the problem lies...

Seeing as I cant use the WaitEvent() command (I dont think I can anyway), I have to use the repeat/forever or while/wend commands.

Now the very first window you'd come to in this program is just a simple background with a few buttons on, which link to other windows. So I quickly bashed up a window with a small loop that, at the moment, only includes Cls:FlipCanvas (Canvas). This isnt really a problem, except, when I check the current CPU state, its at a constant 100% when I have the program running.

If anyone of you could give me a few tips to help me on this part, it'd be cool. Thanks.

Edit: I forgot to mention, these buttons will have a simple 'roll-over' effect, and when I've scrapped it down on paper, comes to more than a couple IF commands.


REDi(Posted 2004) [#2]
Try chucking a delay into your main loop, this will free up some cpu time.


skn3(Posted 2004) [#3]
Graphics 640,480,0,2
SetBuffer BackBuffer()

timer_input  = CreateTimer(10) ; checks 10 times a second for user input
timer_screen = CreateTimer(4)  ; redraws the screen 4 times a second

font         = LoadFont("Arial",60)
SetFont(font)

Repeat
	Select WaitEvent()
		;timer event
		Case $4001
			Select EventSource()
				;Update user input
				Case timer_input
					If KeyDown(1)
						FreeTimer(timer_input)
						FreeTimer(timer_screen)
						FreeFont(font)
						End
					End If
				
				;Update screen
				Case timer_screen
					ClsColor Rand(0,255),Rand(0,255),Rand(0,255)
					Cls
					Color Rand(0,255),Rand(0,255),Rand(0,255)
					Text 5,5,"Press esc to quit"
					Flip
			End Select
	End Select
Forever