diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-10 21:33:00 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-10 21:37:01 +0100 |
commit | c3e0eaf45432f62b423cee2170a09b5d1aac135b (patch) | |
tree | 71da9bdcb5b55a5fb71fab5aef524ab12c1330d4 /rpg.c | |
parent | d98cf9e97a61b175649fa9fe656cb8ec2874686c (diff) |
allow to pass the resolution as arguments
example (for my netbook):
$ ./a.out 1024 600
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'rpg.c')
-rw-r--r-- | rpg.c | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -181,12 +181,12 @@ static void Finitialiserpositions (POSITIONS *positions, const SURFACES *surface int i,y=0,z=0; positions->Vpositionmenu.x = 0; positions->Vpositionmenu.y = 0; - positions->Vpositionmenupretre.x = XWIN/2 - surfaces->Ppretre->w/2; - positions->Vpositionmenupretre.y = YWIN - 20 - surfaces->Ppretre->h; + positions->Vpositionmenupretre.x = surfaces->screen->w / 2 - surfaces->Ppretre->w / 2; + positions->Vpositionmenupretre.y = surfaces->screen->h - 20 - surfaces->Ppretre->h; positions->Vpositionmenupaladin.x = positions->Vpositionmenupretre.x/2 - surfaces->Ppaladin->w/2; - positions->Vpositionmenupaladin.y = YWIN - 20 - surfaces->Ppaladin->h; - positions->Vpositionmenuvoleur.x = XWIN/4*3 - surfaces->Pvoleur->w/2; - positions->Vpositionmenuvoleur.y = YWIN - 20 - surfaces->Pvoleur->h; + positions->Vpositionmenupaladin.y = surfaces->screen->h - 20 - surfaces->Ppaladin->h; + positions->Vpositionmenuvoleur.x = surfaces->screen->w / 4 * 3 - surfaces->Pvoleur->w / 2; + positions->Vpositionmenuvoleur.y = surfaces->screen->h - 20 - surfaces->Pvoleur->h; positions->Vpositiontextemenu.y = 362; positions->Vpositioncurseurennemis.x=1024; positions->Vpositioncurseurennemis.y=768; @@ -195,11 +195,11 @@ static void Finitialiserpositions (POSITIONS *positions, const SURFACES *surface positions->Vpositioncurseurennemis.w = surfaces->Pcurseurennemis->w; positions->Vpositioncurseurennemis.h = surfaces->Pcurseurennemis->h; positions->Vpositioncadrecible.y = 15; - positions->Vpositioncadrecible.x = XWIN/2-50-surfaces->Pcadrecible->w/2; + positions->Vpositioncadrecible.x = surfaces->screen->w / 2 - 50 - surfaces->Pcadrecible->w / 2; positions->Vpositioncadrecible.w = surfaces->Pcadrecible->w; positions->Vpositioncadrecible.h = surfaces->Pcadrecible->h; - positions->Vpositioncadreactions.y = YWIN-surfaces->Pcadreactions->h; - positions->Vpositioncadreactions.x = XWIN/2-50-surfaces->Pcadreactions->w/2; + positions->Vpositioncadreactions.y = surfaces->screen->h - surfaces->Pcadreactions->h; + positions->Vpositioncadreactions.x = surfaces->screen->w / 2 - 50 - surfaces->Pcadreactions->w / 2; positions->Vpositioncadreactions.w = surfaces->Pcadreactions->w; positions->Vpositioncadreactions.h = surfaces->Pcadreactions->h; positions->Vpositionpvcible.x = 380; @@ -233,7 +233,7 @@ static void Finitialiserpositions (POSITIONS *positions, const SURFACES *surface positions->last_cursor = (SDL_Rect){0, 0, 0, 0}; } -static int rpg_init(void) +static int rpg_init(int width, int height) { if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "SDL_Init: %s\n", SDL_GetError()); @@ -261,7 +261,7 @@ static int rpg_init(void) return -1; } - rpg_g.screen = SDL_SetVideoMode(XWIN, YWIN, 0, SDL_HWSURFACE | SDL_DOUBLEBUF); + rpg_g.screen = SDL_SetVideoMode(width, height, 0, SDL_HWSURFACE | SDL_DOUBLEBUF); if (rpg_g.screen == NULL) { fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError()); @@ -344,13 +344,18 @@ static void rpg_shutdown(void) int main (int argc, char *argv[]) { - /* XXX argc and argv are required in some implementations of the SDL library */ - (void) argc; - (void) argv; + int width = DEFAULT_WIDTH; + int height = DEFAULT_HEIGHT; + + /* TODO handle arguments properly */ + if (argc >= 3) { + width = atoi(argv[1]); + height = atoi(argv[2]); + } srand(time(NULL)); - if (rpg_init() >= 0) { + if (rpg_init(width, height) >= 0) { Fmenuprincipal(&rpg_g.surfaces, &rpg_g.positions); } |