Sunday, September 23, 2007

PyWeek Postmortem


So pyweek is all over for real now and as I actually participated I guess I'll have to write a few lines about it..

My game is a story driven shoot em up with the semi-intelligent name Kill Those Junkies.

I sure as hell didn't win the contest but at least I finished the game, and I'm quite satisfied with the result.

One good thing about contests like this is the warm and constructive criticism. I really like this comment: "This game is quite disturbing..". It kind of makes me proud in some perverted way, it sure must have made an impression on that player ;)

Anyway it was really fun to participate and I'd like to thank everyone who made it possible.

Thursday, August 23, 2007

Rabbyt Tutorial

This is a basic, hello world application for Rabbyt. It'll create a window and display a sprite.


import rabbyt
import pygame
from pygame.locals import *

#setup window
rabbyt.init_display(size=(640, 480))
rabbyt.set_viewport((640, 480))

#load our sprite
mySprite = rabbyt.Sprite("test.png")

#the gameloop
keepRunning = True

while keepRunning:
#messagepump
for event in pygame.event.get():
if event.type == QUIT:
keepRunning = False
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
keepRunning = False

#the actual rendering code
rabbyt.clear() #clear the screen

mySprite.render() #render the sprite

pygame.display.flip() #flip the buffers

That's it! So, what does it really do?


import rabbyt
import pygame
from pygame.locals import *
Well, of course we need to import rabbyt, but we also need pygame because we use it to handle our window.

#setup window
rabbyt.init_display(size=(640, 480))
This line creates a window with the size 640x480 and initializes OpenGL on it.


#load our sprite
mySprite = rabbyt.Sprite("test.png")
Loads the image test.png and assigns it to a new sprite named mySprite.


rabbyt.clear() #clear the screen
Yup, just as it says, it clears the screen. It clears to black by default, but by giving a tuple with the desired rgba value (ie. (r, g, b, a) ) you get to choose which color to clear to.


mySprite.render() #render the sprite
Draws our sprite. Where it gets drawn is depending on the coordinates given in mySprite.x and mySprite.y, which determines the center of the sprite. They default to zero, which means our image will show up centered on the screen.


pygame.display.flip() #flip the buffers

This performs a OpenGL buffer swap, everything we have drawn to the backbuffer finally shows up on screen.

That'd be all that's needed to get Rabbyt up and running and drawing a sprite.

More detailed info about Rabbyt can be found at its homepage.

Got a question or just want to make yourself heard? Please drop a comment!