Tuesday, March 17, 2009

First Jython experiment

W00t! Got first Jython program working with GTGE:
# Test of Jython and GTGE.

# Java Foundation Classes (JFC)
from java.awt import *

from com.golden.gamedev import *

* The basic skeleton of Golden T Game Engine (GTGE).
* Objective: show how to set up a new game.

class Test(Game):

def initResources(self):
# initialize game variables

def update(self,elapsedTime):
# update game variables

def render(self,g):
# render to the screen

def main():
game = GameLoader()
game.setup(Test(), Dimension(640,480), False)


I decided on GTGE because it seems like it has been used for a lot of games so far, and so is fairly mature. It has also just been released as open source and seems to fairly well supported. We'll see.

Anyway, have a working Jython program that create a GTGE window. Admittedly the authors of GTGE did all the work and I just converted a Java tutorial into Python. Original Java code:
// JFC
import java.awt.*;

import com.golden.gamedev.*;

* Game in Windowed Mode Environment.
* Objective: show how to set up a windowed mode game
public class Tutorial5_1 extends Game {

/************ GAME SKELETON ************/

public void initResources() {

public void update(long elapsedTime) {

public void render(Graphics2D g) {

/********** START-POINT ***************/

public static void main(String[] args) {
GameLoader game = new GameLoader();
game.setup(new Tutorial5_1(), new Dimension(640,480), false);


No comments: