|
Post by Guilect on Apr 28, 2007 8:03:03 GMT -5
Once you become familiar with Brutus2D commands you can save a little bit of type with the following tip:
You can set a variable equal to any of the B2D main objects. compare the two examples.
Traditional Method:option explicit
dim bRunning bRunning = True
sub main()
if (graphics.initialize <> True) then exit sub graphics.setTitle "Demo - press [ESC] to exit" key.initialize do while bRunning = True if key.pressed(1) or key.pressed(0) = True then bRunning = False graphics.clear &hFFFFFF ' white ' rectangle graphics.SetRect 100,40,100,40,&hFF000000
graphics.display loop key.terminate graphics.terminate
end sub
Call Main()
Short cut method:
option explicit
dim bRunning bRunning = True
Dim g Set g = graphics
sub main()
if (g.initialize <> True) then exit sub g.setTitle "Demo - press [ESC] to exit" key.initialize do while bRunning = True if key.pressed(1) or key.pressed(0) = True then bRunning = False g.clear &hFFFFFF ' white ' rectangle g.SetRect 100,40,100,40,&hFF000000
g.display loop key.terminate g.terminate
end sub
Call Main()
Notice above the : Dim g Set g = graphics
From there we can use the variable 'g' just like we would the full B2D object 'graphics'
The down side of this short cut is that the autocomplete does not appear.
|
|
|
Post by hartnell on Apr 29, 2007 0:29:54 GMT -5
That's neat. Thanks for the tip. -- hartnell
|
|