PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Simple GAME api demo.

As promised here is a simple (very-simple) demo for the game api that will come with PPL. It doesn't do much but gives an idea how the programming with the game api is going to be like.

Code:

func mainproc(hWnd$, Msg$, wParam$, lParam$)
case(Msg$)
WM_MOUSEMOVE:
movesprite(i$, LOWORD(lParam$), HIWORD(lParam$));
WM_KEYDOWN:
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;
return(true);
end;

proc main
h$=newform({GAPI}, {GAPIClass}, &mainproc;);
g_init(h$, NULL, true);

b$ = loadsprite({background.bmp}, -1);
i$ = loadsprite({image.bmp}, RGB(255,0,255));

mainloop;

g_shut(h$);
end;


Regards,
Kornalius
Hey man, this is looking really nice.

I'm very excited about PPL, thanks for your hard work and fingers crossed for a release soon!
Thanx.

I would like to cross my fingers too but I can't, I need to write some more code before the release! :D

Seriously, the beta should come out next week or the one after.

Regards,
Kornalius
Here is the demo code revisited to adapt to the new UI engine changes:

Code:
func mainproc(hWnd$, Msg$, wParam$, lParam$)
case(Msg$)
WM_DESTROY:
g_shut(h$);
WM_MOUSEMOVE:
movesprite(i$, LOWORD(lParam$), HIWORD(lParam$));
WM_KEYDOWN:
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;
return(true);
end;

proc WinMain
h$=newform({GAPI}, {GAPIClass}, &mainproc;);
g_init(h$, NULL, true);
ShowWindow(h$);

b$ = loadsprite({background.bmp}, -1);
i$ = loadsprite({image.bmp}, RGB(255,0,255));
end;


By assigning a proc WinMain, PPL knows that your are building a window application and therefore the program is not exited at the end of the WinMain procedure. PPL now has the full control on your Windows and application. If the main window (of your program) is closed then the application is stopped and remove from memory.

You can then have as many UI programs as you like inside the same PPL thread and have complete control over them at anytime.

Regards,
Kornalius