Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Bonsai - it aint' dead yet...

Sign in to follow this  


Tonight I took it upon myself to do some coding, a rare event indeed of late (aside from work, where I have burst of activity during the day between reading web comics and playing vectorTD).

I figured it was time I hacked the event system into Bonsai, if only because at some point I need to process keyboard input and the events are kinda important for that [grin]

I decided to model it on the PyGame method; you ask for events and then you can process them as you want. When you ask for the events you run the event pump as well to get the events moving.

At the moment the event system is very tied to my OpenGL Window Framework's way of working; at some point I'll do some voodoo on this so that other systems can be compiled/plugged in instead, such as *shudder* SDL or some other windowing library to let games work on other platforms (well, GTL is cross platform and so is Lua so it'd be a shame to have the windowing code screw things up).

However, regardless of what happens in the backend I intend to keep the main loop looking like this;

quit = false
while(quit == false)
events = bonsai.getEvents()
for i = 1, #events
if events.message == bonsai.Event.types.quit
quit = true




"getEvents" returns a table with a number of event tables in it; each event table has 'message', 'param1' and 'param2' entries in them so that you can extract the event information. The params aren't always valid for all messages.

Right now it supports all the messages OGLWFW does, which is kinda 'the big 6';
- quit
- close
- destroy
- size
- move
- active

At some point I'll add support for mouse move, click and scroll events as well as keyboard input, with the final one being top of my list right now as I need it for the game.

Returning to the 'plugable' idea, I'll probably just have a system where I'll get Lua to load a windowing DLL for me, which would nicely isolate the main Bonsai code from the windowing system; end of the day it doesn't need to know HOW you handle events or make a window, just that it's done in a sane way; from there any windowing system implimenting the correct interface could be used.

I'll puzzle out the refactoring for that tomorrow I think, for now I'm feeling happy with the code and I'm going to bed.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!