With Lua, I expose “high level” functions to the scripts (such as
init_screen(width, height, depth, fullscreen)) and use them to program what
I want. init_screen would init SDL with video and audio, init the mixer,
SDL_ttf and anything else that is needed for the game to run. You got the
The event queue is processed and cleared when flip is called, which happens
in each game loop iteration.
If you study hard the Lua API, it’s even possible to write callbacks in Lua
for SDL assynchronous events, such as when a music ends playing. And with
it’s garbage collector and using metamethods, you can make resources such as
images and sounds to be automatically freed when no longer needed.
Lua is known for having a small footprint, being easily embeded and
performing very fast. It has been used in a number of commercial games.
Check www.lua.org for more info.
Date: Thu, 20 Nov 2008 17:42:27 +0100
From: David Olofson
Subject: Re: [SDL] Scripting (2)
To: sdl at lists.libsdl.org
Message-ID: <200811201742.27253.david at olofson.net>
Content-Type: text/plain; charset=“iso-8859-6”
On Thursday 20 November 2008, julien CLEMENT wrote:
I’ve successfully created a tiny example application in Perl, using
SWIG to interface with SDL. I have 3 functions:
In poll_events, I don’t go in an infinite loop since I want the
script to handle the main loop.
I simply do a “while( SDL_PollEvent(&evt) > 0 )” loop.
I was surprised to see that no event were lost. Can someone clarify
how SDL can handle events whilst the execution continuously switches
between the Perl script and the SDL code ?
SDL uses a dedicated thread for collecting events from various
sources, at least on some platforms - but even without that, there
wouldn’t be a problem. Events are queued up in the order they occur,
so the application can read them whenever it gets around to it. No
sensible API will drop events just because you don’t read
them “instantly”. That just wouldn’t work in a non real time OS.
//David Olofson - Programmer, Composer, Open Source Advocate
…------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --’
Mensagem enviada pelo Microlink Webmail 12.7.8p3