#include #include "Astroids.h" #include "GameData.h" pascal void AstroidsLoop( EventLoopTimerRef timer, void *data) { typedef GameData* DataPrtType; DataPrtType GDP=(DataPrtType)data; SetPort(GetWindowPort(GDP->getGameWindowRef())); // This is where everything happens. // Right now, nothing happens. GDP->update(); } pascal OSStatus KeyDown(EventHandlerCallRef handlerRef, EventRef event, void *data) { char ch=0; typedef GameData* MyDataPrtType; MyDataPrtType GDP=(MyDataPrtType)data; // Get the char pressed from the event: GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(ch), NULL, &ch); // Tell the data class what key was pressed: GDP->keyDown(ch); return noErr; } pascal OSStatus KeyUp(EventHandlerCallRef handlerRef, EventRef event, void *data) { char ch=0; typedef GameData* DataPrtType; DataPrtType GDP=(DataPrtType)data; // Get the char released from the event: GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(ch), NULL, &ch); // Tell the data class what key was release: GDP->keyUp(ch); return noErr; }