View Full Version : coding for landscape mode
moridh
01-08-2007, 05:57 AM
hi. can anybody help.
currently i'm trying to use gapi for a program in landscape mode.
can't seem to make it display in landscape 320 w x 240 h.
right now as a workaround i have to modify all graphics to rotate 90 deg ccw.
btw i'm using ppl 1.10.
mmtbb
01-08-2007, 02:10 PM
look at your
InitGameAPIEx(h$, NULL, 240, 320, false, 0, 0);
line. Are you changing the deminsions here?
moridh
01-08-2007, 05:54 PM
i read somewhere (old thread) to use g_init to initialize landscape mode. can this function still work in the new version?
anybody can post sample code to use g_init? thanx..
mmtbb
01-08-2007, 06:10 PM
have you tried this:
InitGameAPIEx(h$, NULL, 320, 240, false, 0, 0);
as for G_INIT:
g_init(hWnd$, Proc$, width$, height$, orientation$, Speed$, FpsSpeed$, fullscreen$);
orientation$ will be the one you will play with these constants:
ORIENTATION_NORTH
ORIENTATION_WEST
ORIENTATION_SOUTH
ORIENTATION_EAST
moridh
01-08-2007, 06:45 PM
i tried g_init, it displayed the graphics in lanscape mode just fine. even the fps appeared in landscape orientation. but now cant seem to make the buttons to work. everytime i pushed any button, an error occur (opcode pushvar).
something to do with the Proc$ in g_init i guess. what should i put there anyways? currently have no idea what to put so i leave it at NULL.
mmtbb
01-08-2007, 09:47 PM
The Proc for g_init should be &GameProc
This is where drawing occurs. You don't actually need to have button response in GameProc. But sometimes you can in the WM_TIMER: event under GameProc
moridh
01-09-2007, 02:45 AM
still having problem with button presses.
check out the code:
#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;
WM_LBUTTONDOWN:
if(wParam$-OriginX >= 0 AND wParam$-OriginX <= 50 AND lParam$-OriginY >= 190 AND lParam$-OriginY <= 240)
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;
end;
return (ok$);
end;
func GameProc(hWnd$, Msg$, wParam$, lParam$)
case (Msg$)
WM_PAINT:
// Render all loaded sprites on screen.
RenderSprites;
WM_TIMER:
// Check the keys if they are pressed.
if (KeysPressed$[keys.vkLeft$] AND OriginX > 0)
SetOriginX(OriginX - ScrollSpeed$);
end;
if (KeysPressed$[keys.vkRight$] AND OriginX <= 304)
SetOriginX(OriginX + ScrollSpeed$);
end;
if (KeysPressed$[keys.vkA$])
PostMessage(hWnd$, WM_CLOSE, 0, 0);
end;
end;
return (true);
end;
func WinMain
// Create a new form that will hold the GAPI.
h$ = newform({GAPI}, {GAPIClass}, &mainproc);
ShowWindow(h$, SW_SHOW);
// Initialize GameAPI.
G_INIT(h$, GameProc$, 240, 320, ORIENTATION_WEST, 5, 60, true);
// Make background sprite and sprite structure variables global.
Global(WorldMap$, ScrollSpeed$);
ScrollSpeed$ = 8;
FirstTime$ = true;
// Load background sprite from disk.
WorldMap$ = loadsprite(AppPath$ + "WorldMap2.gif", -1, 1, 0, NULL);
MoveSprite(WorldMap$, 94, 70);
SetSpriteAutoScrollX(WorldMap$, 1);
return (true);
end;
thanx..
mmtbb
01-11-2007, 12:15 AM
in the G_INIT you are using a variable GameProc$ which is local. Replace this with &GameProc. That should work.
moridh
01-11-2007, 12:45 AM
never mind. already solved the problem.
i dived into gameapi.ddl it seems that initgameapiex also calls g_init but with orientation_north by defaul. i revert back to using initgameapiex but modified it a bit in gameapi.ppl to call g_init using orientation_west.
it works great now.
thanx..
mmtbb
01-11-2007, 01:12 AM
Good. I assume you are ready changed the GameProc$ to &GameProc then.
Also, just realize that if you change the GameAPI.ppl, every time you uppate PPL, you will have to replace GameAPI.ppl with your version to make it work.
moridh
01-11-2007, 01:59 AM
THANX.. the funny thing is i didn't change from GameProc$ to &GameProc.. it works just fine.. hmm...
and yeah, all the other demo programs that came with ppl were screwed up after i modified gameapi.ppl. oh well, i'll deal with that later..
PointOfLight
01-11-2007, 02:45 AM
Once the latest version of PPL is released, the override function should be working again. Once that's in place you can just add the following to your program:
override proc InitGameAPIEx(parameters)
_init(your modified parameters here);
end;
That way you don't have to modify the gameapi.ppl file every time there's an update.
mmtbb
01-11-2007, 02:57 AM
That is weird?!? I just tested it. There is no reason it should work. Hey, Kornalius, if you read this, do you know why GameProc$ would work just like &GameProc? &GameProc is a pointer to the Func GameProc. GameProc, even if set as a global variable is nothing really.
Moridh, go to your Gameproc function and place ShowMessage("hello"); in the WM_TIMER. Run the game. Is the messagebox going off? It really shouln't.
moridh
01-11-2007, 03:03 AM
OOPS! my bad.. my code is actually &GameProc, not GameProc$. probably thats why it didn't work when i used G_INIT in the first place. har2..
thanx all!
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.