~J~
01-31-2009, 11:09 PM
I've been playing about for a number of weeks now with a program, and while I'm in the middle of testing, just wrote a very simple test program to see what the speed would be like on the PocketPC.
My phone is an Orbit2 (or Polaris for the official HTC name) so quite a decent bit of kit.
However, the following code runs absolutely lousy on the device!!!! Almost unusable.
Is there any immediate mistakes or things to take into consideration? Should I remove string draws to the screen, should I not be performing a constant calculation and simple set velocities on X and Y to zero if they fall below a minimum threashold rather than going into .#########th of a float?
// Default Advanced Game API skeleton
#include "GameAPI.ppl"
func mainproc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case (Msg$)
WM_CLOSE:
// Shutdown the GameAPI.
ShutGameAPI(hWnd$);
WM_KEYDOWN:
KeysPressed$[wParam$] = 1;
WM_KEYUP:
if (wParam$ == keys.vkB$)
if (KeysPressed$[keys.vkB$])
FirstTime$ = not FirstTime$;
end;
end;
KeysPressed$[wParam$] = 0;
end;
return (ok$);
end;
func GameProc(hWnd$, Msg$, wParam$, lParam$)
case (Msg$)
WM_PAINT:
// Clear screen first
G_Clear(0);
// Render all loaded sprites on screen.
RenderSprites;
g_textout(NULL, SpriteVelX(s$), DVT_CENTER, 0, 2, g_rgb(255, 255, 0));
g_textout(NULL, svx$, DVT_CENTER, 0, 20, g_rgb(255, 255, 0));
g_textout(NULL, SpriteVelY(s$), DVT_CENTER, 0, 40, g_rgb(255, 255, 0));
WM_TIMER:
// Check the keys if they are pressed.
if (KeysPressed$[keys.vkUp$])
if (SpriteVelY(s$)>-1.5)
SetSpriteVelY(s$,SpriteVelY(s$)-power$);
end;
end;
if (KeysPressed$[keys.vkDown$])
end;
if (KeysPressed$[keys.vkLeft$])
SetSpriteVelX(s$,SpriteVelX(s$)-0.01);
end;
if (KeysPressed$[keys.vkRight$])
SetSpriteVelX(s$,SpriteVelX(s$)+0.01);
end;
if (NOT KeysPressed$[Keys.vkUp$])
end;
end;
return (true);
end;
func LoadImages
s$ = loadsprite(AppPath$ + "ball.bmp", G_RGB(255, 0, 255), 1, 0, NULL);
AddSpriteOption(s$, SO_OVAL | SO_CHECKCOLLIDE | SO_PIXELCHECK | SO_BORDER | SO_KINETIC);
SetSpriteMass(s$, 0.05);
SetSpriteVelLimits(s$, 0, 05);
MoveSprite(s$,10,10);
SetSpriteCollide(s$, "player");
SetSpriteId(s$, "player");
t$ = loadsprite(AppPath$ + "ball.bmp", G_RGB(255, 0, 255), 1, 0, NULL);
AddSpriteOption(t$, SO_OVAL | SO_CHECKCOLLIDE | SO_PIXELCHECK | SO_BORDER | SO_KINETIC);
SetSpriteCollide(t$, "object");
SetSpriteId(t$, "object");
SetSpriteCollide(s$, "object");
MoveSprite(t$,50,100);
end;
func WinMain
// Create a new form that will hold the GAPI.
h$ = newform({GAPI}, {GAPIClass}, &mainproc);
ShowWindow(h$, SW_SHOW);
// Activate FPS display in white.
ShowFPS(true, G_RGB(255, 255, 255));
// Initialize GameAPI.
InitGameAPIEx(h$, &GameProc, 240, 320, true, 5, 360);
SetFriction(0.001);
SetGravity(0.01);
power$=0.03;
Global(s$,power$);
GameCollide(true);
LoadImages;
return (true);
end;
My phone is an Orbit2 (or Polaris for the official HTC name) so quite a decent bit of kit.
However, the following code runs absolutely lousy on the device!!!! Almost unusable.
Is there any immediate mistakes or things to take into consideration? Should I remove string draws to the screen, should I not be performing a constant calculation and simple set velocities on X and Y to zero if they fall below a minimum threashold rather than going into .#########th of a float?
// Default Advanced Game API skeleton
#include "GameAPI.ppl"
func mainproc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;
case (Msg$)
WM_CLOSE:
// Shutdown the GameAPI.
ShutGameAPI(hWnd$);
WM_KEYDOWN:
KeysPressed$[wParam$] = 1;
WM_KEYUP:
if (wParam$ == keys.vkB$)
if (KeysPressed$[keys.vkB$])
FirstTime$ = not FirstTime$;
end;
end;
KeysPressed$[wParam$] = 0;
end;
return (ok$);
end;
func GameProc(hWnd$, Msg$, wParam$, lParam$)
case (Msg$)
WM_PAINT:
// Clear screen first
G_Clear(0);
// Render all loaded sprites on screen.
RenderSprites;
g_textout(NULL, SpriteVelX(s$), DVT_CENTER, 0, 2, g_rgb(255, 255, 0));
g_textout(NULL, svx$, DVT_CENTER, 0, 20, g_rgb(255, 255, 0));
g_textout(NULL, SpriteVelY(s$), DVT_CENTER, 0, 40, g_rgb(255, 255, 0));
WM_TIMER:
// Check the keys if they are pressed.
if (KeysPressed$[keys.vkUp$])
if (SpriteVelY(s$)>-1.5)
SetSpriteVelY(s$,SpriteVelY(s$)-power$);
end;
end;
if (KeysPressed$[keys.vkDown$])
end;
if (KeysPressed$[keys.vkLeft$])
SetSpriteVelX(s$,SpriteVelX(s$)-0.01);
end;
if (KeysPressed$[keys.vkRight$])
SetSpriteVelX(s$,SpriteVelX(s$)+0.01);
end;
if (NOT KeysPressed$[Keys.vkUp$])
end;
end;
return (true);
end;
func LoadImages
s$ = loadsprite(AppPath$ + "ball.bmp", G_RGB(255, 0, 255), 1, 0, NULL);
AddSpriteOption(s$, SO_OVAL | SO_CHECKCOLLIDE | SO_PIXELCHECK | SO_BORDER | SO_KINETIC);
SetSpriteMass(s$, 0.05);
SetSpriteVelLimits(s$, 0, 05);
MoveSprite(s$,10,10);
SetSpriteCollide(s$, "player");
SetSpriteId(s$, "player");
t$ = loadsprite(AppPath$ + "ball.bmp", G_RGB(255, 0, 255), 1, 0, NULL);
AddSpriteOption(t$, SO_OVAL | SO_CHECKCOLLIDE | SO_PIXELCHECK | SO_BORDER | SO_KINETIC);
SetSpriteCollide(t$, "object");
SetSpriteId(t$, "object");
SetSpriteCollide(s$, "object");
MoveSprite(t$,50,100);
end;
func WinMain
// Create a new form that will hold the GAPI.
h$ = newform({GAPI}, {GAPIClass}, &mainproc);
ShowWindow(h$, SW_SHOW);
// Activate FPS display in white.
ShowFPS(true, G_RGB(255, 255, 255));
// Initialize GameAPI.
InitGameAPIEx(h$, &GameProc, 240, 320, true, 5, 360);
SetFriction(0.001);
SetGravity(0.01);
power$=0.03;
Global(s$,power$);
GameCollide(true);
LoadImages;
return (true);
end;