Game Development Reference
In-Depth Information
}
public static void setListener(EventListener l) {
listener = l;
}
// Native Main game sub (takes an array of arguments)
public static native int WolfMain(String[] argv);
// Native Key press. It sends a pc scan code
public static native int keyPress(int key);
// Native Key release. It sends a pc scan code
public static native int keyRelease(int key);
/***********************************************************
* C - Callbacks
***********************************************************/
// This fires on messages from the C layer
private static void OnMessage(String text) {
if (listener != null)
listener.OnMessage(text);
}
// Fires on init graphics: receives the width and height of the video
private static void OnInitGraphics(int w, int h) {
if (listener != null)
listener.OnInitGraphics(w, h);
}
// Fires on image update: receives the video RGBA pixels plus x,y
// coordinates and width and height of the image
private static void OnImageUpdate(int[] pixels, int x, int y,
int w, int h) {
if (listener != null)
listener.OnImageUpdate(pixels, x, y, w, h);
}
// Fires when the C lib calls exit()
private static void OnSysError(String message) {
if (listener != null)
listener.OnSysError(message
+ " - Please report this error.");
}
// Fires when a sound is requested in the C layer.
// Receives a sound index
private static void OnStartSound(int idx) {
if (listener != null)
Search WWH ::




Custom Search