Figure The flat plane becomes a full rotating cube

Pyopengl Glrotatef Spin

Let's say you wanted to speed up and twist your rotating cube around a bit more. It's easy to fiddle with MatrixMode, especially since you've thought ahead and included a number of variables with which to do it x,y, and z rots are the rotations on each axis xrot yrot zrot 0.0 These variables, xrot, yrot, and zrot, can be used to rotate the cube in a new way on the x-, y-, and x-axes. Do so by adding a few lines to the top of drawgraphics glLoadidentity glTranslatef 0.0, 0.0, -5.0 global rquad...

Python Adventure Writing System

The Python Adventure Writing System PAWS is a text adventure system developed by Roger Plowman. As with many Python-based game tools, PAWS is aimed at the non-programmer and consists of a game engine, a world library, and a play module. PAWS is fairly well documented, and comes with a few sample games and two great explanatory texts, one aimed towards first-time game writers and another, aimed towards code-heads, that explains how the Python sources work. Even the source code itself is well...

Drawing a Square

Our third function is the code that actually draws the display, so let's call it drawgraphics . This function will actually display everything that goes onto the screen, so it will be doing most of the work in each example. First you glclear to clear the screen to a color, clear the buffer, and then reset with glLoadidentity. glLoadidentity actually moves you to the center of the screen, which is 0,0 on the x- and y-axis. Left and down are negative numbers, and right and up would be positive...

The Cyclon Online Gaming Engine

The Cyclon Online Gaming Engine COG for short is an open-source computer game-authoring system. The system comes with a development application to facilitate game creation, a fill-in-the-blanks GUI that brings up windows in which you set up the game information, player information, rooms, directions, items, events, and even define action verbs that can be taken in by the text parser. The development application is shown in Figure 5.1. Figure 5.1. The COG development application Figure 5.1. The...

The Engine and the Game Loop

A number of actions must happen in the engine and game loop, and these actions should correspond to a codeable function. You must have a function to remove any sprites that aren't being used and add any new ones, a function to render the screen and background, a function that keeps track of time and updates the game state, a function that does the blitting, and a function that listens for player keystrokes render_frame. Updates and redraws. engine_init. Sets screen and video. engine_loop. Main...

Lua Pros and Cons

Lua is probably the fastest of the three languages and usually uses the least amount of runtime memory. Lau has the smallest memory footprint for bundling. The Lau C API is very well documented and has good examples for integrating with C. The documentation has improved but is still a bit sketchy overall. Of the three languages, Lua it is probably the least documented the API being the exception , with the least amount of code comments. This makes for the largest ramp-up time to learn, and...

Gravity A Lua SDL Game

I first introduced SDL way back in Chapter 4, where you used it with Python to do some pretty amazing stuff. Lua's SDL bindings aren't quite as complete, and unfortunately they are also a little out-of-date. The bindings are still in beta Version 0.3 as of this writing and were put together using the Lua 4 interpreter the binary module has been pre-packaged with the toLua tool . Because of this, all of the necessary Lua scripts are bundled with the game inside the folder so you don't try...

Memory Performance and Speed

Lua Table And Stack

Like most high-level languages, Lua manages memory automatically, so that you don't have to worry about allocating memory for new objects and freeing it when the objects are no longer needed. Lua manages memory automatically by running a garbage collector from time to time to collect any objects that are no longer accessible to Lua. The garbage collector picks up all of Lua's objects, including threads, tables, and so on. Although this is not an issue when running the Lua interpreter, when...