[Tux4kids-commits] r1445 - branches/commonification/tuxmath/trunk/src
Bolesław Kulbabiński
bolekk-guest at alioth.debian.org
Sun Aug 16 18:04:24 UTC 2009
Author: bolekk-guest
Date: 2009-08-16 18:04:24 +0000 (Sun, 16 Aug 2009)
New Revision: 1445
Modified:
branches/commonification/tuxmath/trunk/src/factoroids.c
branches/commonification/tuxmath/trunk/src/game.c
Log:
removed all occurrences of 'images', 'sprites' and 'screen' globals from TuxMath's games
Modified: branches/commonification/tuxmath/trunk/src/factoroids.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/factoroids.c 2009-08-16 17:22:45 UTC (rev 1444)
+++ branches/commonification/tuxmath/trunk/src/factoroids.c 2009-08-16 18:04:24 UTC (rev 1445)
@@ -43,7 +43,7 @@
#define FPS 15 /* 15 frames per second */
#define MS_PER_FRAME (1000 / FPS)
-#define BASE_RES_X 1280
+#define BASE_RES_X 1280
#define MAX_LASER 5
#define MAX_ASTEROIDS 50
@@ -205,7 +205,7 @@
static void draw_console_image(SDL_Surface* img);
static SDL_Surface* current_bkgd()
- { return screen->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; }
+ { return GetScreen()->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; }
static void FF_add_level(void);
static int FF_over(int game_status);
@@ -229,33 +229,33 @@
/************** factors(): The factor main function ********************/
void factors(void)
{
- Uint32 last_time, now_time;
-
+ Uint32 last_time, now_time;
+
quit = 0;
counter = 0;
- sprites[ANIM_TUX_CONSOLE]->cur = 0;
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[0];
+ GetSprite(ANIM_TUX_CONSOLE)->cur = 0;
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[0];
DEBUGMSG(debug_factoroids, "Entering factors():\n");
FF_game = FACTOROIDS_GAME;
-
+
if (!FF_init())
{
fprintf(stderr, "FF_init() failed!\n");
FF_exit_free();
return;
- }
+ }
while (game_status == GAME_IN_PROGRESS)
{
last_time = SDL_GetTicks();
- counter++;
-
+ counter++;
+
if(counter%15 == 0)
{
- NextFrame(sprites[ANIM_TUX_CONSOLE]);
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[sprites[ANIM_TUX_CONSOLE]->cur];
+ NextFrame(GetSprite(ANIM_TUX_CONSOLE));
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[GetSprite(ANIM_TUX_CONSOLE)->cur];
}
game_handle_user_events();
@@ -264,7 +264,7 @@
FF_handle_asteroids();
FF_handle_answer();
FF_draw();
- SDL_Flip(screen);
+ SDL_Flip(GetScreen());
game_status = check_exit_conditions();
@@ -307,13 +307,12 @@
/************** fractions(): The fractions main function ********************/
void fractions(void)
{
+ Uint32 last_time, now_time;
- Uint32 last_time, now_time;
-
quit = 0;
counter = 0;
- sprites[ANIM_TUX_CONSOLE]->cur = 0;
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[0];
+ GetSprite(ANIM_TUX_CONSOLE)->cur = 0;
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[0];
DEBUGMSG(debug_factoroids, "Entering factors():\n");
/*****Initalizing the Factor activiy *****/
@@ -324,7 +323,7 @@
fprintf(stderr, "FF_init() failed!\n");
FF_exit_free();
return;
- }
+ }
/************ Main Loop **************/
while (game_status == GAME_IN_PROGRESS)
@@ -334,8 +333,8 @@
if(counter%15 == 0)
{
- NextFrame(sprites[ANIM_TUX_CONSOLE]);
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[sprites[ANIM_TUX_CONSOLE]->cur];
+ NextFrame(GetSprite(ANIM_TUX_CONSOLE));
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[GetSprite(ANIM_TUX_CONSOLE)->cur];
}
game_handle_user_events();
@@ -344,7 +343,7 @@
FF_handle_asteroids();
FF_handle_answer();
FF_draw();
- SDL_Flip(screen);
+ SDL_Flip(GetScreen());
game_status = check_exit_conditions();
@@ -388,15 +387,15 @@
int i;
float zoom;
- SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
- SDL_Flip(screen);
+ SDL_FillRect(GetScreen(), NULL, SDL_MapRGB(GetScreen()->format, 0, 0, 0));
+ SDL_Flip(GetScreen());
FF_intro();
- if(screen->h < 600 && screen->w < 800)
+ if(GetScreen()->h < 600 && GetScreen()->w < 800)
zoom = 0.65;
else
- zoom=(float)screen->w/(float)BASE_RES_X;
+ zoom=(float)GetScreen()->w/(float)BASE_RES_X;
printf("The zoome rate is: %f\n", zoom);
@@ -405,30 +404,30 @@
for(i = 0; i < NUM_OF_ROTO_IMGS; i++)
{
//rotozoomSurface (SDL_Surface *src, double angle, double zoom, int smooth);
- IMG_tuxship[i] = rotozoomSurface(images[IMG_SHIP01], i * DEG_PER_ROTATION, zoom, 1);
+ IMG_tuxship[i] = rotozoomSurface(GetImage(IMG_SHIP01), i * DEG_PER_ROTATION, zoom, 1);
if (IMG_tuxship[i] == NULL)
{
fprintf(stderr,
- "\nError: rotozoomSurface() of images[IMG_SHIP01] for i = %d returned NULL\n", i);
+ "\nError: rotozoomSurface() of GetImage(IMG_SHIP01) for i = %d returned NULL\n", i);
return 0;
}
- IMG_asteroids1[i] = rotozoomSurface(images[IMG_ASTEROID1], i * DEG_PER_ROTATION, zoom, 1);
+ IMG_asteroids1[i] = rotozoomSurface(GetImage(IMG_ASTEROID1), i * DEG_PER_ROTATION, zoom, 1);
if (IMG_asteroids1[i] == NULL)
{
fprintf(stderr,
- "\nError: rotozoomSurface() of images[IMG_ASTEROID1] for i = %d returned NULL\n", i);
+ "\nError: rotozoomSurface() of GetImage(IMG_ASTEROID1) for i = %d returned NULL\n", i);
return 0;
}
- IMG_asteroids2[i] = rotozoomSurface(images[IMG_ASTEROID2], i*DEG_PER_ROTATION, zoom, 1);
+ IMG_asteroids2[i] = rotozoomSurface(GetImage(IMG_ASTEROID2), i*DEG_PER_ROTATION, zoom, 1);
if (IMG_asteroids2[i] == NULL)
{
fprintf(stderr,
- "\nError: rotozoomSurface() of images[IMG_ASTEROID2] for i = %d returned NULL\n", i);
+ "\nError: rotozoomSurface() of GetImage(IMG_ASTEROID2) for i = %d returned NULL\n", i);
return 0;
}
}
@@ -462,22 +461,22 @@
NUM_ASTEROIDS = 4;
/**************Setting up the ship values! **************/
- tuxship.x = ((screen->w)/2) - 20;
- tuxship.y = ((screen->h)/2) - 20;
+ tuxship.x = ((GetScreen()->w)/2) - 20;
+ tuxship.y = ((GetScreen()->h)/2) - 20;
tuxship.lives = TUXSHIP_LIVES;
tuxship.hurt = 0;
tuxship.hurt_count = 0;
tuxship.angle = 90;
tuxship.xspeed = 0;
tuxship.yspeed = 0;
- tuxship.radius = (images[IMG_SHIP01]->h)/2;
+ tuxship.radius = (GetImage(IMG_SHIP01)->h)/2;
- tuxship.x1 = images[IMG_SHIP01]->w-(images[IMG_SHIP01]->w/8);
- tuxship.y1 = images[IMG_SHIP01]->h/2;
- tuxship.x2 = images[IMG_SHIP01]->w/8;
- tuxship.y2 = images[IMG_SHIP01]->h/8;
- tuxship.x3 = images[IMG_SHIP01]->w/8;
- tuxship.y3 = images[IMG_SHIP01]->h-(images[IMG_SHIP01]->h/8);
+ tuxship.x1 = GetImage(IMG_SHIP01)->w-(GetImage(IMG_SHIP01)->w/8);
+ tuxship.y1 = GetImage(IMG_SHIP01)->h/2;
+ tuxship.x2 = GetImage(IMG_SHIP01)->w/8;
+ tuxship.y2 = GetImage(IMG_SHIP01)->h/8;
+ tuxship.x3 = GetImage(IMG_SHIP01)->w/8;
+ tuxship.y3 = GetImage(IMG_SHIP01)->h-(GetImage(IMG_SHIP01)->h/8);
/* --- reset all controls: --- */
left_pressed = 0;
@@ -534,32 +533,32 @@
float zoom;
- if(screen->h < 600 && screen->w < 800)
+ if(GetScreen()->h < 600 && GetScreen()->w < 800)
zoom = 0.65;
else
- zoom=(float)screen->w/(float)BASE_RES_X;
-
- IMG_factors = rotozoomSurface(images[IMG_FACTOROIDS], 0, zoom, 1);
- IMG_fractions = rotozoomSurface(images[IMG_FACTORS], 0, zoom, 1);
+ zoom=(float)GetScreen()->w/(float)BASE_RES_X;
+ IMG_factors = rotozoomSurface(GetImage(IMG_FACTOROIDS), 0, zoom, 1);
+ IMG_fractions = rotozoomSurface(GetImage(IMG_FACTORS), 0, zoom, 1);
+
FF_draw_bkgr();
if(FF_game == FACTOROIDS_GAME)
{
- rect.x = (screen->w/2) - (IMG_factors->w/2);
- rect.y = (screen->h)/7;
- SDL_BlitSurface(IMG_factors, NULL, screen, &rect);
+ rect.x = (GetScreen()->w/2) - (IMG_factors->w/2);
+ rect.y = (GetScreen()->h)/7;
+ SDL_BlitSurface(IMG_factors, NULL, GetScreen(), &rect);
FF_ShowMessage(_("FACTOROIDS: to win, you need destroy all the asteroids."),
_("Use the arrow keys to turn or go forward. Aim at an asteroid,"),
_("type one of its factors, and press space or return"),
_("to split it into its factors. Rocks with prime numbers are destroyed!"));
- SDL_BlitSurface(IMG_asteroids1[3],NULL,screen,&rect);
+ SDL_BlitSurface(IMG_asteroids1[3],NULL,GetScreen(),&rect);
}
else if (FF_game == FRACTIONS_GAME)
{
- rect.x = (screen->w/2)-(IMG_fractions->w/2);
- rect.y = (screen->h)/7;
- SDL_BlitSurface(IMG_fractions,NULL,screen,&rect);
+ rect.x = (GetScreen()->w/2)-(IMG_fractions->w/2);
+ rect.y = (GetScreen()->h)/7;
+ SDL_BlitSurface(IMG_fractions,NULL,GetScreen(),&rect);
FF_ShowMessage(_("FRACTIONS: to win, you need destroy all the asteroids"),
_("Use the arrow keys to turn or go forward. Aim at an asteroid,"),
_("type a number that can simplify the fraction, and press space or return"),
@@ -648,17 +647,17 @@
tuxship.x = tuxship.x + tuxship.xspeed;
tuxship.y = tuxship.y + tuxship.yspeed;
-/*************** Wrap ship around edges of screen ****************/
+/*************** Wrap ship around edges of GetScreen() ****************/
- if(tuxship.x >= (screen->w))
- tuxship.x = tuxship.x - (screen->w);
+ if(tuxship.x >= (GetScreen()->w))
+ tuxship.x = tuxship.x - (GetScreen()->w);
else if (tuxship.x < -60)
- tuxship.x = tuxship.x + (screen->w);
+ tuxship.x = tuxship.x + (GetScreen()->w);
- if(tuxship.y >= (screen->h))
- tuxship.y = tuxship.y - (screen->h);
+ if(tuxship.y >= (GetScreen()->h))
+ tuxship.y = tuxship.y - (GetScreen()->h);
else if (tuxship.y < -60)
- tuxship.y = tuxship.y + (screen->h);
+ tuxship.y = tuxship.y + (GetScreen()->h);
/**************** Shoot ***************/
if(shoot_pressed)
@@ -701,15 +700,15 @@
// Wrap asteroid around edges of screen:
- if (asteroid[i].x >= (screen->w))
- asteroid[i].rx = asteroid[i].rx - (screen->w);
+ if (asteroid[i].x >= (GetScreen()->w))
+ asteroid[i].rx = asteroid[i].rx - (GetScreen()->w);
else if (asteroid[i].x < 0)
- asteroid[i].rx = asteroid[i].rx + (screen->w);
+ asteroid[i].rx = asteroid[i].rx + (GetScreen()->w);
- if (asteroid[i].y >= (screen->h))
- asteroid[i].ry = asteroid[i].ry - (screen->h);
+ if (asteroid[i].y >= (GetScreen()->h))
+ asteroid[i].ry = asteroid[i].ry - (GetScreen()->h);
else if (asteroid[i].ry < 0)
- asteroid[i].ry = asteroid[i].ry + (screen->h);
+ asteroid[i].ry = asteroid[i].ry + (GetScreen()->h);
/**************Center Asteroids**************/
asteroid[i].centerx=((surf->w)/2)+(asteroid[i].x-5);
@@ -781,7 +780,7 @@
SDL_Surface* surf;
SDL_Rect dest;
- SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+ SDL_FillRect(GetScreen(), NULL, SDL_MapRGB(GetScreen()->format, 0, 0, 0));
/************ Draw Background ***************/
@@ -814,7 +813,7 @@
dest.w = IMG_tuxship[tuxship.angle/DEG_PER_ROTATION]->w;
dest.h = IMG_tuxship[tuxship.angle/DEG_PER_ROTATION]->h;
- SDL_BlitSurface(IMG_tuxship[tuxship.angle/DEG_PER_ROTATION], NULL, screen, &dest);
+ SDL_BlitSurface(IMG_tuxship[tuxship.angle/DEG_PER_ROTATION], NULL, GetScreen(), &dest);
}
/************* Draw Asteroids ***************/
for(i=0; i<MAX_ASTEROIDS; i++){
@@ -831,12 +830,12 @@
dest.w = surf->w;
dest.h = surf->h;
- SDL_BlitSurface(surf, NULL, screen, &dest);
+ SDL_BlitSurface(surf, NULL, GetScreen(), &dest);
// Wrap the numbers of the asteroids
- if((asteroid[i].centery)>23 && (asteroid[i].centery)<screen->h)
+ if((asteroid[i].centery)>23 && (asteroid[i].centery)<GetScreen()->h)
{
- if((asteroid[i].centerx)>0 && (asteroid[i].centerx)<screen->w)
+ if((asteroid[i].centerx)>0 && (asteroid[i].centerx)<GetScreen()->w)
{
xnum=asteroid[i].centerx-3;
ynum=asteroid[i].centery;
@@ -845,8 +844,8 @@
xnum=20;
ynum=asteroid[i].centery;
}
- else if((asteroid[i].centerx)<=screen->w){
- xnum=screen->w-20;
+ else if((asteroid[i].centerx)<=GetScreen()->w){
+ xnum=GetScreen()->w-20;
ynum=asteroid[i].centery;
}
}
@@ -855,10 +854,10 @@
xnum=asteroid[i].centerx;
ynum=23;
}
- else if((asteroid[i].centery)>=screen->h)
+ else if((asteroid[i].centery)>=GetScreen()->h)
{
xnum=asteroid[i].centerx;
- ynum=screen->h-7;
+ ynum=GetScreen()->h-7;
}
//Draw Numbers
@@ -879,12 +878,12 @@
}
}
/*************** Draw Steam ***************/
-
+
if(isdead)
{
dest.x = xdead;
dest.y = ydead;
- SDL_BlitSurface(sprites[ANIM_STEAM]->frame[countdead], NULL, screen, &dest);
+ SDL_BlitSurface(GetSprite(ANIM_STEAM)->frame[countdead], NULL, GetScreen(), &dest);
countdead++;
if(countdead > 5)
{
@@ -895,54 +894,53 @@
/* Draw wave: */
if (1)//Opts_BonusCometInterval())
- offset = images[IMG_EXTRA_LIFE]->w + 5;
+ offset = GetImage(IMG_EXTRA_LIFE)->w + 5;
else
offset = 0;
dest.x = offset;
dest.y = 0;
- dest.w = images[IMG_WAVE]->w;
- dest.h = images[IMG_WAVE]->h;
+ dest.w = GetImage(IMG_WAVE)->w;
+ dest.h = GetImage(IMG_WAVE)->h;
- SDL_BlitSurface(images[IMG_WAVE], NULL, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_WAVE), NULL, GetScreen(), &dest);
sprintf(str, "%d", wave);
- draw_numbers(str, offset+images[IMG_WAVE]->w + (images[IMG_NUMBERS]->w / 10), 0);
+ draw_numbers(str, offset+GetImage(IMG_WAVE)->w + (GetImage(IMG_NUMBERS)->w / 10), 0);
/* Draw "score" label: */
- dest.x = (screen->w - ((images[IMG_NUMBERS]->w/10) * 7) -
- images[IMG_SCORE]->w -
- images[IMG_STOP]->w - 5);
+ dest.x = (GetScreen()->w - ((GetImage(IMG_NUMBERS)->w/10) * 7) -
+ GetImage(IMG_SCORE)->w -
+ GetImage(IMG_STOP)->w - 5);
dest.y = 0;
- dest.w = images[IMG_SCORE]->w;
- dest.h = images[IMG_SCORE]->h;
+ dest.w = GetImage(IMG_SCORE)->w;
+ dest.h = GetImage(IMG_SCORE)->h;
- SDL_BlitSurface(images[IMG_SCORE], NULL, screen, &dest);
-
+ SDL_BlitSurface(GetImage(IMG_SCORE), NULL, GetScreen(), &dest);
+
sprintf(str, "%.6d", score);
draw_numbers(str,
- screen->w - ((images[IMG_NUMBERS]->w / 10) * 6) - images[IMG_STOP]->w - 5,
+ GetScreen()->w - ((GetImage(IMG_NUMBERS)->w / 10) * 6) - GetImage(IMG_STOP)->w - 5,
0);
/* Draw stop button: */
// if (!help_controls.x_is_blinking || (frame % 10 < 5)) {
- dest.x = (screen->w - images[IMG_STOP]->w);
+ dest.x = (GetScreen()->w - GetImage(IMG_STOP)->w);
dest.y = 0;
- dest.w = images[IMG_STOP]->w;
- dest.h = images[IMG_STOP]->h;
-
- SDL_BlitSurface(images[IMG_STOP], NULL, screen, &dest);
+ dest.w = GetImage(IMG_STOP)->w;
+ dest.h = GetImage(IMG_STOP)->h;
+
+ SDL_BlitSurface(GetImage(IMG_STOP), NULL, GetScreen(), &dest);
// }
/************* Draw pre answer ************/
-
- if(screen->w < 800 && screen->h < 600)
+ if(GetScreen()->w < 800 && GetScreen()->h < 600)
{
sprintf(str, "%.3d", num);
- draw_numbers(str, ((screen->w)/2) - 50, (screen->h) - 30);
- }
+ draw_numbers(str, ((GetScreen()->w)/2) - 50, (GetScreen()->h) - 30);
+ }
else
{
FF_draw_led_console();
@@ -950,22 +948,22 @@
}
/************** Draw lives ***************/
- dest.y = screen->h;
+ dest.y = GetScreen()->h;
dest.x = 0;
for(i = 1; i <= tuxship.lives; i++)
{
if(tuxship.lives <= 5)
{
- dest.y = dest.y - (images[IMG_TUX_LITTLE]->h);
- SDL_BlitSurface(images[IMG_TUX_LITTLE], NULL, screen, &dest);
+ dest.y = dest.y - (GetImage(IMG_TUX_LITTLE)->h);
+ SDL_BlitSurface(GetImage(IMG_TUX_LITTLE), NULL, GetScreen(), &dest);
}
else if(tuxship.lives > 4)
{
- dest.y = screen->h - (images[IMG_TUX_LITTLE]->h);
- SDL_BlitSurface(images[IMG_TUX_LITTLE], NULL, screen, &dest);
+ dest.y = GetScreen()->h - (GetImage(IMG_TUX_LITTLE)->h);
+ SDL_BlitSurface(GetImage(IMG_TUX_LITTLE), NULL, GetScreen(), &dest);
sprintf(str, "%d", tuxship.lives);
- draw_numbers(str, 10, (screen->h) - 30);
+ draw_numbers(str, 10, (GetScreen()->h) - 30);
}
}
}
@@ -978,18 +976,18 @@
int y;
/* draw new console image with "monitor" for LED numbers: */
- draw_console_image(images[IMG_CONSOLE_LED]);
+ draw_console_image(GetImage(IMG_CONSOLE_LED));
/* set y to draw LED numbers into Tux's "monitor": */
- y = (screen->h
- - images[IMG_CONSOLE_LED]->h
+ y = (GetScreen()->h
+ - GetImage(IMG_CONSOLE_LED)->h
+ 4); /* "monitor" has 4 pixel margin */
/* begin drawing so as to center display depending on whether minus */
/* sign needed (4 digit slots) or not (3 digit slots) DSB */
if (MC_GetOpt(ALLOW_NEGATIVES) )
- dest.x = ((screen->w - ((images[IMG_LEDNUMS]->w) / 10) * 4) / 2);
+ dest.x = ((GetScreen()->w - ((GetImage(IMG_LEDNUMS)->w) / 10) * 4) / 2);
else
- dest.x = ((screen->w - ((images[IMG_LEDNUMS]->w) / 10) * 3) / 2);
+ dest.x = ((GetScreen()->w - ((GetImage(IMG_LEDNUMS)->w) / 10) * 3) / 2);
for (i = -1; i < MC_MAX_DIGITS; i++) /* -1 is special case to allow minus sign */
/* with minimal modification of existing code DSB */
@@ -999,36 +997,36 @@
if (MC_GetOpt(ALLOW_NEGATIVES))
{
if (neg_answer_picked)
- src.x = (images[IMG_LED_NEG_SIGN]->w) / 2;
+ src.x = (GetImage(IMG_LED_NEG_SIGN)->w) / 2;
else
src.x = 0;
src.y = 0;
- src.w = (images[IMG_LED_NEG_SIGN]->w) / 2;
- src.h = images[IMG_LED_NEG_SIGN]->h;
+ src.w = (GetImage(IMG_LED_NEG_SIGN)->w) / 2;
+ src.h = GetImage(IMG_LED_NEG_SIGN)->h;
dest.y = y;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_LED_NEG_SIGN], &src, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_LED_NEG_SIGN), &src, GetScreen(), &dest);
/* move "cursor" */
dest.x += src.w;
}
}
else
{
- src.x = digits[i] * ((images[IMG_LEDNUMS]->w) / 10);
+ src.x = digits[i] * ((GetImage(IMG_LEDNUMS)->w) / 10);
src.y = 0;
- src.w = (images[IMG_LEDNUMS]->w) / 10;
- src.h = images[IMG_LEDNUMS]->h;
+ src.w = (GetImage(IMG_LEDNUMS)->w) / 10;
+ src.h = GetImage(IMG_LEDNUMS)->h;
/* dest.x already set */
dest.y = y;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_LEDNUMS], &src, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_LEDNUMS), &src, GetScreen(), &dest);
/* move "cursor" */
dest.x += src.w;
}
@@ -1040,20 +1038,20 @@
{
SDL_Rect dest;
- dest.x = (screen->w - img->w) / 2;
- dest.y = (screen->h - img->h);
+ dest.x = (GetScreen()->w - img->w) / 2;
+ dest.y = (GetScreen()->h - img->h);
dest.w = img->w;
dest.h = img->h;
- SDL_BlitSurface(img, NULL, screen, &dest);
+ SDL_BlitSurface(img, NULL, GetScreen(), &dest);
}
static void FF_draw_bkgr(void)
{
- SDL_BlitSurface(current_bkgd(), NULL, screen, NULL);
+ SDL_BlitSurface(current_bkgd(), NULL, GetScreen(), NULL);
//if(bgSrc.y>bkg_h)
- // SDL_BlitSurface(images[BG_STARS], NULL, screen, &bgScreen);
+ // SDL_BlitSurface(GetImage(BG_STARS), NULL, screen, &bgScreen);
}
@@ -1136,9 +1134,9 @@
else
NUM_ASTEROIDS=MAX_ASTEROIDS;
- width = screen->w;
- if (screen->h < width)
- width = screen->h;
+ width = GetScreen()->w;
+ if (GetScreen()->h < width)
+ width = GetScreen()->h;
// Define the "safety radius" as one third of the screen width
safety_radius2 = width/3;
@@ -1155,10 +1153,10 @@
// Generate the new position, avoiding the location of the ship
ok = 0;
while (!ok) {
- x = rand()%(screen->w);
- y = rand()%(screen->h);
- dx = modwrap(x - tuxship.x,screen->w);
- dy = modwrap(y - tuxship.y,screen->h);
+ x = rand()%(GetScreen()->w);
+ y = rand()%(GetScreen()->h);
+ dx = modwrap(x - tuxship.x,GetScreen()->w);
+ dy = modwrap(y - tuxship.y,GetScreen()->h);
if (dx*dx + dy*dy > safety_radius2)
ok = 1;
}
@@ -1198,11 +1196,11 @@
while(i < 35)
{
i++;
- rect.x=(screen->w/2)-(images[IMG_GOOD]->w/2);
- rect.y=(screen->h/2)-(images[IMG_GOOD]->h/2);
+ rect.x=(GetScreen()->w/2)-(GetImage(IMG_GOOD)->w/2);
+ rect.y=(GetScreen()->h/2)-(GetImage(IMG_GOOD)->h/2);
FF_draw();
- SDL_BlitSurface(images[IMG_GOOD],NULL,screen,&rect);
- SDL_Flip(screen);
+ SDL_BlitSurface(GetImage(IMG_GOOD),NULL,GetScreen(),&rect);
+ SDL_Flip(GetScreen());
last_time = now_time;
now_time = SDL_GetTicks();
@@ -1235,10 +1233,10 @@
int looping = 1;
// int frame;
/* set up victory message: */
- dest_message.x = (screen->w - images[IMG_GAMEOVER_WON]->w) / 2;
- dest_message.y = (screen->h - images[IMG_GAMEOVER_WON]->h) / 2;
- dest_message.w = images[IMG_GAMEOVER_WON]->w;
- dest_message.h = images[IMG_GAMEOVER_WON]->h;
+ dest_message.x = (GetScreen()->w - GetImage(IMG_GAMEOVER_WON)->w) / 2;
+ dest_message.y = (GetScreen()->h - GetImage(IMG_GAMEOVER_WON)->h) / 2;
+ dest_message.w = GetImage(IMG_GAMEOVER_WON)->w;
+ dest_message.h = GetImage(IMG_GAMEOVER_WON)->h;
do
{
@@ -1248,11 +1246,11 @@
/* draw flashing victory message: */
//if (((frame / 2) % 4))
//{
- SDL_BlitSurface(images[IMG_GAMEOVER_WON], NULL, screen, &dest_message);
+ SDL_BlitSurface(GetImage(IMG_GAMEOVER_WON), NULL, GetScreen(), &dest_message);
//}
- SDL_Flip(screen);
+ SDL_Flip(GetScreen());
while (1)
{
@@ -1285,18 +1283,18 @@
int looping = 1;
/* set up GAMEOVER message: */
- dest_message.x = (screen->w - images[IMG_GAMEOVER]->w) / 2;
- dest_message.y = (screen->h - images[IMG_GAMEOVER]->h) / 2;
- dest_message.w = images[IMG_GAMEOVER]->w;
- dest_message.h = images[IMG_GAMEOVER]->h;
+ dest_message.x = (GetScreen()->w - GetImage(IMG_GAMEOVER)->w) / 2;
+ dest_message.y = (GetScreen()->h - GetImage(IMG_GAMEOVER)->h) / 2;
+ dest_message.w = GetImage(IMG_GAMEOVER)->w;
+ dest_message.h = GetImage(IMG_GAMEOVER)->h;
do
{
//frame++;
last_time = SDL_GetTicks();
- SDL_BlitSurface(images[IMG_GAMEOVER], NULL, screen, &dest_message);
- SDL_Flip(screen);
+ SDL_BlitSurface(GetImage(IMG_GAMEOVER), NULL, GetScreen(), &dest_message);
+ SDL_Flip(GetScreen());
while (1)
{
@@ -1462,9 +1460,9 @@
const float inside_factor = 0.9*0.9;
- screensize = screen->w;
- if (screensize < screen->h)
- screensize = screen->h;
+ screensize = GetScreen()->w;
+ if (screensize < GetScreen()->h)
+ screensize = GetScreen()->h;
for(i=0; i<=MAX_LASER; i++)
{
@@ -1476,12 +1474,12 @@
laser[i].y=tuxship.centery;
laser[i].angle=tuxship.angle;
laser[i].count=15;
-
+
ux = cos((float)laser[i].angle * DEG_TO_RAD);
uy = -sin((float)laser[i].angle * DEG_TO_RAD);
laser[i].destx = laser[i].x + (int)(ux * screensize);
laser[i].desty = laser[i].y + (int)(uy * screensize);
-
+
// Check to see if it hits asteroids---we only check when it
// just starts firing, "drift" later doesn't count!
// We describe the laser path as p = p0 + s*u, where
@@ -1592,12 +1590,12 @@
}
if(new_wave){
- if(tuxship.x-50<asteroid[i].x+80 &&
- tuxship.x+50>asteroid[i].x &&
- tuxship.y-50<asteroid[i].y+80 &&
+ if(tuxship.x-50<asteroid[i].x+80 &&
+ tuxship.x+50>asteroid[i].x &&
+ tuxship.y-50<asteroid[i].y+80 &&
tuxship.y+50>asteroid[i].y &&
tuxship.lives>0 &&
- asteroid[i].alive){
+ asteroid[i].alive){
asteroid[i].rx=asteroid[i].rx+300;
asteroid[i].ry=asteroid[i].ry+300;
}
@@ -1606,19 +1604,19 @@
if(asteroid[i].isprime)
{
asteroid[i].size=0;
- asteroid[i].centerx=(images[IMG_ASTEROID1]->w/2)+asteroid[i].x;
- asteroid[i].centery=(images[IMG_ASTEROID1]->h/2)+asteroid[i].y;
- asteroid[i].radius=(images[IMG_ASTEROID1]->h/2);
+ asteroid[i].centerx=(GetImage(IMG_ASTEROID1)->w/2)+asteroid[i].x;
+ asteroid[i].centery=(GetImage(IMG_ASTEROID1)->h/2)+asteroid[i].y;
+ asteroid[i].radius=(GetImage(IMG_ASTEROID1)->h/2);
}
else if(!asteroid[i].isprime)
{
asteroid[i].size=1;
- asteroid[i].centerx=(images[IMG_ASTEROID2]->w/2)+asteroid[i].x;
- asteroid[i].centery=(images[IMG_ASTEROID2]->h/2)+asteroid[i].y;
- asteroid[i].radius=(images[IMG_ASTEROID1]->h/2);
+ asteroid[i].centerx=(GetImage(IMG_ASTEROID2)->w/2)+asteroid[i].x;
+ asteroid[i].centery=(GetImage(IMG_ASTEROID2)->h/2)+asteroid[i].y;
+ asteroid[i].radius=(GetImage(IMG_ASTEROID1)->h/2);
}
-
+
while (asteroid[i].xspeed==0)
{
asteroid[i].xspeed = ((rand() % 3) - 1)*2;
@@ -1719,31 +1717,31 @@
/* Draw lines of text (do after drawing Tux so text is in front): */
if (s1)
{
- loc.x = (screen->w / 2) - (s1->w/2);
- loc.y = (screen->h / 2) + 10;
- SDL_BlitSurface( s1, NULL, screen, &loc);
+ loc.x = (GetScreen()->w / 2) - (s1->w/2);
+ loc.y = (GetScreen()->h / 2) + 10;
+ SDL_BlitSurface( s1, NULL, GetScreen(), &loc);
}
if (s2)
{
- loc.x = (screen->w / 2) - (s2->w/2);
- loc.y = (screen->h / 2) + 80;
- SDL_BlitSurface( s2, NULL, screen, &loc);
+ loc.x = (GetScreen()->w / 2) - (s2->w/2);
+ loc.y = (GetScreen()->h / 2) + 80;
+ SDL_BlitSurface( s2, NULL, GetScreen(), &loc);
}
if (s3)
{
- loc.x = (screen->w / 2) - (s3->w/2);
- loc.y = (screen->h / 2) + 130;
- SDL_BlitSurface( s3, NULL, screen, &loc);
+ loc.x = (GetScreen()->w / 2) - (s3->w/2);
+ loc.y = (GetScreen()->h / 2) + 130;
+ SDL_BlitSurface( s3, NULL, GetScreen(), &loc);
}
if (s4)
{
- loc.x = (screen->w / 2) - (s4->w/2);
- loc.y = (screen->h / 2) + 180;
- SDL_BlitSurface( s4, NULL, screen, &loc);
+ loc.x = (GetScreen()->w / 2) - (s4->w/2);
+ loc.y = (GetScreen()->h / 2) + 180;
+ SDL_BlitSurface( s4, NULL, GetScreen(), &loc);
}
/* and update: */
- SDL_UpdateRect(screen, 0, 0, 0, 0);
+ SDL_UpdateRect(GetScreen(), 0, 0, 0, 0);
SDL_FreeSurface(s1);
@@ -1973,18 +1971,18 @@
/* Check to see if user clicked exit button: */
/* The exit button is in the upper right corner of the screen: */
- if ((event.button.x >= (screen->w - images[IMG_STOP]->w))
- &&(event.button.y <= images[IMG_STOP]->h))
+ if ((event.button.x >= (GetScreen()->w - GetImage(IMG_STOP)->w))
+ &&(event.button.y <= GetImage(IMG_STOP)->h))
{
key = SDLK_ESCAPE;
//game_key_event(key);
escape_received = 1;
quit = 1;
return -1;
- }
+ }
/* get out unless we really are using keypad */
- if ( level_start_wait
+ if ( level_start_wait
|| Opts_DemoMode()
|| !Opts_GetGlobalOpt(USE_KEYPAD))
{
@@ -1997,22 +1995,22 @@
/* of game() rather than with every mouse click */
if (1)//MC_AllowNegatives())
{
- if (!images[IMG_KEYPAD])
+ if (!GetImage(IMG_KEYPAD))
return -1;
else
{
- keypad_w = images[IMG_KEYPAD]->w;
- keypad_h = images[IMG_KEYPAD]->h;
+ keypad_w = GetImage(IMG_KEYPAD)->w;
+ keypad_h = GetImage(IMG_KEYPAD)->h;
}
}
else
{
- if (!images[IMG_KEYPAD_NO_NEG])
+ if (!GetImage(IMG_KEYPAD_NO_NEG))
return -1;
else
{
- keypad_w = images[IMG_KEYPAD]->w;
- keypad_h = images[IMG_KEYPAD]->h;
+ keypad_w = GetImage(IMG_KEYPAD)->w;
+ keypad_h = GetImage(IMG_KEYPAD)->h;
}
}
@@ -2024,13 +2022,13 @@
/* only proceed if click falls within keypad: */
if (!((event.button.x >=
- (screen->w / 2) - (keypad_w / 2) &&
+ (GetScreen()->w / 2) - (keypad_w / 2) &&
event.button.x <=
- (screen->w / 2) + (keypad_w / 2) &&
+ (GetScreen()->w / 2) + (keypad_w / 2) &&
event.button.y >=
- (screen->h / 2) - (keypad_h / 2) &&
+ (GetScreen()->h / 2) - (keypad_h / 2) &&
event.button.y <=
- (screen->h / 2) + (keypad_h / 2))))
+ (GetScreen()->h / 2) + (keypad_h / 2))))
/* click outside of keypad - do nothing */
{
return -1;
@@ -2038,8 +2036,8 @@
else /* click was within keypad */
{
- x = (event.button.x - ((screen->w / 2) - (keypad_w / 2)));
- y = (event.button.y - ((screen->h / 2) - (keypad_h / 2)));
+ x = (event.button.x - ((GetScreen()->w / 2) - (keypad_w / 2)));
+ y = (event.button.y - ((GetScreen()->h / 2) - (keypad_h / 2)));
/* Now determine what onscreen key was pressed */
/* */
Modified: branches/commonification/tuxmath/trunk/src/game.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/game.c 2009-08-16 17:22:45 UTC (rev 1444)
+++ branches/commonification/tuxmath/trunk/src/game.c 2009-08-16 18:04:24 UTC (rev 1445)
@@ -143,7 +143,7 @@
static SDL_Surface* scaled_bkgd = NULL; //native resolution (fullscreen)
static SDL_Surface* current_bkgd()
- { return screen->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; }
+ { return GetScreen()->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; }
static game_message s1, s2, s3, s4, s5;
static int start_message_chosen = 0;
@@ -222,7 +222,7 @@
}
rt.w = 10000; /* these images may be long */
- rt.h = CONSOLE_SCREEN_H * images[IMG_CONSOLE_LED]->h;
+ rt.h = CONSOLE_SCREEN_H * GetImage(IMG_CONSOLE_LED)->h;
if(!SetImage(IMG_LEDNUMS, &rt))
return 0;
if(!SetImage(IMG_LED_NEG_SIGN, &rt))
@@ -242,7 +242,7 @@
DEBUGMSG(debug_game, "Entering game():\n");
//see if the option matches the actual screen
- if (Opts_GetGlobalOpt(FULLSCREEN) == !(screen->flags & SDL_FULLSCREEN) )
+ if (Opts_GetGlobalOpt(FULLSCREEN) == !(GetScreen()->flags & SDL_FULLSCREEN) )
{
;//SwitchScreenMode();
}
@@ -353,10 +353,10 @@
int tux_step = -3;
/* set up victory message: */
- dest_message.x = (screen->w - images[IMG_GAMEOVER_WON]->w) / 2;
- dest_message.y = (screen->h - images[IMG_GAMEOVER_WON]->h) / 2;
- dest_message.w = images[IMG_GAMEOVER_WON]->w;
- dest_message.h = images[IMG_GAMEOVER_WON]->h;
+ dest_message.x = (GetScreen()->w - GetImage(IMG_GAMEOVER_WON)->w) / 2;
+ dest_message.y = (GetScreen()->h - GetImage(IMG_GAMEOVER_WON)->h) / 2;
+ dest_message.w = GetImage(IMG_GAMEOVER_WON)->w;
+ dest_message.h = GetImage(IMG_GAMEOVER_WON)->h;
do
{
@@ -374,30 +374,30 @@
}
if (current_bkgd() )
- SDL_BlitSurface(current_bkgd(), NULL, screen, NULL);
+ SDL_BlitSurface(current_bkgd(), NULL, GetScreen(), NULL);
/* draw flashing victory message: */
if (((frame / 2) % 4))
{
- SDL_BlitSurface(images[IMG_GAMEOVER_WON], NULL, screen, &dest_message);
+ SDL_BlitSurface(GetImage(IMG_GAMEOVER_WON), NULL, GetScreen(), &dest_message);
}
/* draw dancing tux: */
- draw_console_image(images[IMG_CONSOLE_BASH]);
+ draw_console_image(GetImage(IMG_CONSOLE_BASH));
/* walk tux back and forth */
tux_offset += tux_step;
/* select tux_egypt images according to which way tux is headed: */
if (tux_step < 0)
{
- num_frames = sprites[ANIM_TUX_EGYPT_LEFT]->num_frames;
- tux_img = sprites[ANIM_TUX_EGYPT_LEFT]->frame[(frame / 3) % num_frames];
+ num_frames = GetSprite(ANIM_TUX_EGYPT_LEFT)->num_frames;
+ tux_img = GetSprite(ANIM_TUX_EGYPT_LEFT)->frame[(frame / 3) % num_frames];
}
else
{
- num_frames = sprites[ANIM_TUX_EGYPT_LEFT]->num_frames;
- tux_img = sprites[ANIM_TUX_EGYPT_RIGHT]->frame[(frame / 3) % num_frames];
+ num_frames = GetSprite(ANIM_TUX_EGYPT_LEFT)->num_frames;
+ tux_img = GetSprite(ANIM_TUX_EGYPT_RIGHT)->frame[(frame / 3) % num_frames];
}
/* turn around if we go far enough: */
@@ -437,10 +437,10 @@
int looping = 1;
/* set up GAMEOVER message: */
- dest_message.x = (screen->w - images[IMG_GAMEOVER]->w) / 2;
- dest_message.y = (screen->h - images[IMG_GAMEOVER]->h) / 2;
- dest_message.w = images[IMG_GAMEOVER]->w;
- dest_message.h = images[IMG_GAMEOVER]->h;
+ dest_message.x = (GetScreen()->w - GetImage(IMG_GAMEOVER)->w) / 2;
+ dest_message.y = (GetScreen()->h - GetImage(IMG_GAMEOVER)->h) / 2;
+ dest_message.w = GetImage(IMG_GAMEOVER)->w;
+ dest_message.h = GetImage(IMG_GAMEOVER)->h;
do
{
@@ -457,8 +457,8 @@
}
}
- SDL_BlitSurface(images[IMG_GAMEOVER], NULL, screen, &dest_message);
- SDL_Flip(screen);
+ SDL_BlitSurface(GetImage(IMG_GAMEOVER), NULL, GetScreen(), &dest_message);
+ SDL_Flip(GetScreen());
now_time = SDL_GetTicks();
@@ -514,10 +514,10 @@
void game_set_start_message(const char* m1, const char* m2,
const char* m3, const char* m4)
{
- game_set_message(&s1, m1, -1, screen->h * 2 / 10);
- game_set_message(&s2, m2, screen->w / 2 - 40, screen->h * 3 / 10);
- game_set_message(&s3, m3, screen->w / 2 - 40, screen->h * 4 / 10);
- game_set_message(&s4, m4, screen->w / 2 - 40, screen->h * 5 / 10);
+ game_set_message(&s1, m1, -1, GetScreen()->h * 2 / 10);
+ game_set_message(&s2, m2, GetScreen()->w / 2 - 40, GetScreen()->h * 3 / 10);
+ game_set_message(&s3, m3, GetScreen()->w / 2 - 40, GetScreen()->h * 4 / 10);
+ game_set_message(&s4, m4, GetScreen()->w / 2 - 40, GetScreen()->h * 5 / 10);
start_message_chosen = 1;
}
@@ -528,8 +528,8 @@
DEBUGMSG(debug_game,"Entering game_initialize()\n");
/* Clear window: */
- SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
- SDL_Flip(screen);
+ SDL_FillRect(GetScreen(), NULL, SDL_MapRGB(GetScreen()->format, 0, 0, 0));
+ SDL_Flip(GetScreen());
game_status = GAME_IN_PROGRESS;
gameover_counter = -1;
@@ -590,15 +590,15 @@
return 0;
}
-
+
/* Write pre-game info to game summary file: */
if (Opts_SaveSummary())
{
write_pregame_summary();
}
-
+
/* Prepare to start the game: */
- city_expl_height = screen->h - images[IMG_CITY_BLUE]->h;
+ city_expl_height = GetScreen()->h - GetImage(IMG_CITY_BLUE)->h;
/* Initialize feedback parameters */
comet_feedback_number = 0;
@@ -632,22 +632,22 @@
/* Left vs. Right - makes room for Tux and the console */
if (i < NUM_CITIES / 2)
{
- cities[i].x = (((screen->w / (NUM_CITIES + 1)) * i) +
- ((images[img] -> w) / 2));
+ cities[i].x = (((GetScreen()->w / (NUM_CITIES + 1)) * i) +
+ ((GetImage(img) -> w) / 2));
}
else
{
- cities[i].x = (screen->w -
- ((((screen->w / (NUM_CITIES + 1)) *
+ cities[i].x = (GetScreen()->w -
+ ((((GetScreen()->w / (NUM_CITIES + 1)) *
(i - (NUM_CITIES / 2)) +
- ((images[img] -> w) / 2)))));
+ ((GetImage(img) -> w) / 2)))));
}
}
num_cities_alive = NUM_CITIES;
num_comets_alive = 0;
- igloo_vertical_offset = images[IMG_CITY_BLUE]->h - images[IMG_IGLOO_INTACT]->h;
+ igloo_vertical_offset = GetImage(IMG_CITY_BLUE)->h - GetImage(IMG_IGLOO_INTACT)->h;
/* Create and position the penguins and steam */
for (i = 0; i < NUM_CITIES; i++) {
@@ -681,7 +681,7 @@
paused = 0;
doing_answer = 0;
tux_pressing = 0;
- tux_img = images[IMG_TUX_RELAX];
+ tux_img = GetImage(IMG_TUX_RELAX);
tux_anim = NULL;
tux_anim_frame = 0;
@@ -751,7 +751,7 @@
// Here are some things that have to happen before we can safely
// draw the screen
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[0];
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[0];
old_tux_img = tux_img;
tux_pressing = 0;
frame = 0;
@@ -829,7 +829,7 @@
game_clear_message(&s5);
help_add_comet("3 * 3 = ?", "9");
- comets[0].y = 2*(screen->h)/3; // start it low down
+ comets[0].y = 2*(GetScreen()->h)/3; // start it low down
while ((comets[0].expl == -1) && !(quit_help = help_renderframe_exit())); // wait 3 secs
if (quit_help)
return;
@@ -854,7 +854,7 @@
game_clear_message(&s3);
help_add_comet("56 / 8 = ?", "7");
- comets[0].y = 2*(screen->h)/3; // start it low down
+ comets[0].y = 2*(GetScreen()->h)/3; // start it low down
while (comets[0].alive && !(quit_help = help_renderframe_exit()));
if (quit_help)
return;
@@ -993,13 +993,13 @@
rect.w = surf->w;
rect.h = surf->h;
if (msg->x < 0)
- rect.x = (screen->w/2) - (rect.w/2); // centered
+ rect.x = (GetScreen()->w/2) - (rect.w/2); // centered
else
rect.x = msg->x; // left justified
rect.y = msg->y;
//FIXME alpha blending doesn't seem to work properly
SDL_SetAlpha(surf, SDL_SRCALPHA, msg->alpha);
- SDL_BlitSurface(surf, NULL, screen, &rect);
+ SDL_BlitSurface(surf, NULL, GetScreen(), &rect);
SDL_FreeSurface(surf);
//SDL_UpdateRect(screen, rect.x, rect.y, rect.w, rect.h);
}
@@ -1195,7 +1195,7 @@
{
MC_AnsweredCorrectly(&(comets[lowest].flashcard));
- /* Store the time the question was present on screen (do this */
+ /* Store the time the question was present on GetScreen() (do this */
/* in a way that avoids storing it if the time wrapped around */
ctime = SDL_GetTicks();
if (ctime > comets[lowest].time_started) {
@@ -1208,8 +1208,8 @@
comets[lowest].zapped = 1;
/* Fire laser: */
laser.alive = LASER_START;
- laser.x1 = screen->w / 2;
- laser.y1 = screen->h;
+ laser.x1 = GetScreen()->w / 2;
+ laser.y1 = GetScreen()->h;
laser.x2 = comets[lowest].x;
laser.y2 = comets[lowest].y;
PlaySound(sounds[SND_LASER]);
@@ -1233,9 +1233,9 @@
{
/* ... pick an animation to play: */
if ((rand() % 10) < 5)
- tux_anim = sprites[ANIM_TUX_YES];
+ tux_anim = GetSprite(ANIM_TUX_YES);
else
- tux_anim = sprites[ANIM_TUX_YAY];
+ tux_anim = GetSprite(ANIM_TUX_YAY);
tux_anim_frame = tux_anim->num_frames * ANIM_FRAME_LENGTH;
}
@@ -1245,24 +1245,24 @@
/* [ the higher the better ] */
/* FIXME looks like it might score a bit differently based on screen mode? */
add_score(25 * comets[lowest].flashcard.difficulty *
- (screen->h - comets[lowest].y + 1) /
- screen->h);
+ (GetScreen()->h - comets[lowest].y + 1) /
+ GetScreen()->h);
}
else
{
/* Didn't hit anything! */
laser.alive = LASER_START;
- laser.x1 = screen->w / 2;
- laser.y1 = screen->h;
+ laser.x1 = GetScreen()->w / 2;
+ laser.y1 = GetScreen()->h;
laser.x2 = laser.x1;
laser.y2 = 0;
PlaySound(sounds[SND_LASER]);
PlaySound(sounds[SND_BUZZ]);
if ((rand() % 10) < 5)
- tux_img = images[IMG_TUX_DRAT];
+ tux_img = GetImage(IMG_TUX_DRAT);
else
- tux_img = images[IMG_TUX_YIPE];
+ tux_img = GetImage(IMG_TUX_YIPE);
}
/* Clear digits: */
@@ -1287,11 +1287,11 @@
level_start_wait--;
if (level_start_wait > LEVEL_START_WAIT_START / 4)
- tux_img = images[IMG_TUX_RELAX];
+ tux_img = GetImage(IMG_TUX_RELAX);
else if (level_start_wait > 0)
- tux_img = images[IMG_TUX_ALARM];
+ tux_img = GetImage(IMG_TUX_ALARM);
else
- tux_img = images[IMG_TUX_SIT];
+ tux_img = GetImage(IMG_TUX_SIT);
if (level_start_wait == LEVEL_START_WAIT_START / 4)
{
@@ -1307,10 +1307,10 @@
/* If Tux pressed a button, pick a new (different!) stance: */
if (tux_pressing)
{
- num_frames = sprites[ANIM_TUX_CONSOLE]->num_frames;
+ num_frames = GetSprite(ANIM_TUX_CONSOLE)->num_frames;
do
{
- tux_img = sprites[ANIM_TUX_CONSOLE]->frame[rand() % num_frames];
+ tux_img = GetSprite(ANIM_TUX_CONSOLE)->frame[rand() % num_frames];
}
while (tux_img == old_tux_img);
@@ -1333,7 +1333,7 @@
tux_same_counter++;
if (tux_same_counter >= 20)
{
- tux_img = images[IMG_TUX_SIT];
+ tux_img = GetImage(IMG_TUX_SIT);
}
}
else
@@ -1368,16 +1368,16 @@
if (comets[i].bonus)
{
comets[i].y += speed * Opts_BonusSpeedRatio() *
- city_expl_height / (screen->h - images[IMG_CITY_BLUE]->h);
+ city_expl_height / (GetScreen()->h - GetImage(IMG_CITY_BLUE)->h);
}
else /* Regular comet: */
{
comets[i].y += speed *
- city_expl_height / (screen->h - images[IMG_CITY_BLUE]->h);
+ city_expl_height / (GetScreen()->h - GetImage(IMG_CITY_BLUE)->h);
}
/* Does it threaten a city? */
- if (comets[i].y > 3 * screen->h / 4)
+ if (comets[i].y > 3 * GetScreen()->h / 4)
cities[this_city].threatened = 1;
/* Did it hit a city? */
@@ -1415,7 +1415,7 @@
PlaySound(sounds[SND_IGLOO_SIZZLE]);
cities[this_city].counter = IGLOO_SWITCH_START;
steam[this_city].status = STEAM_ON;
- steam[this_city].counter = STEAM_FRAME_LENGTH * sprites[ANIM_STEAM]->num_frames;
+ steam[this_city].counter = STEAM_FRAME_LENGTH * GetSprite(ANIM_STEAM)->num_frames;
}
else {
if (cities[comets[i].city].hits_left == 2) {
@@ -1442,7 +1442,7 @@
slowdown = 1;
}
- tux_anim = sprites[ANIM_TUX_FIST];
+ tux_anim = GetSprite(ANIM_TUX_FIST);
tux_anim_frame = tux_anim->num_frames * ANIM_FRAME_LENGTH;
/* Destroy comet: */
@@ -1453,7 +1453,7 @@
if (comets[i].expl >= 0)
{
comets[i].expl++;
- if (comets[i].expl >= sprites[ANIM_COMET_EXPL]->num_frames * 2) {
+ if (comets[i].expl >= GetSprite(ANIM_COMET_EXPL)->num_frames * 2) {
comets[i].alive = 0;
comets[i].expl = -1;
if (bonus_comet_counter > 1 && comets[i].zapped) {
@@ -1673,10 +1673,10 @@
direction = 1-2*(i < NUM_CITIES/2);
penguins[i].x += direction*PENGUIN_WALK_SPEED;
if (direction < 0) {
- if (penguins[i].x + images[IMG_PENGUIN_WALK_OFF1]->w/2 < 0)
+ if (penguins[i].x + GetImage(IMG_PENGUIN_WALK_OFF1)->w/2 < 0)
penguins[i].status = PENGUIN_OFFSCREEN;
} else {
- if (penguins[i].x - images[IMG_PENGUIN_WALK_OFF1]->w/2 > screen->w)
+ if (penguins[i].x - GetImage(IMG_PENGUIN_WALK_OFF1)->w/2 > GetScreen()->w)
penguins[i].status = PENGUIN_OFFSCREEN;
}
penguins[i].layer = 3;
@@ -1713,7 +1713,7 @@
if (steam[i].status == STEAM_OFF)
steam[i].img = NULL;
else {
- steam[i].img = sprites[ANIM_STEAM]->frame[sprites[ANIM_STEAM]->num_frames - 1 - (steam[i].counter / STEAM_FRAME_LENGTH)];
+ steam[i].img = GetSprite(ANIM_STEAM)->frame[GetSprite(ANIM_STEAM)->num_frames - 1 - (steam[i].counter / STEAM_FRAME_LENGTH)];
steam[i].layer = 2;
}
}
@@ -1744,19 +1744,19 @@
/* Begin the extra life sequence */
extra_life_earned = 0;
cloud.status = EXTRA_LIFE_ON;
- cloud.y = screen->h/3;
+ cloud.y = GetScreen()->h/3;
cloud.city = fewest_index;
bonus_comet_counter = Opts_BonusCometInterval()+1;
DEBUGMSG(debug_game, "Bonus comet counter restored to %d\n",bonus_comet_counter);
if (cloud.city < NUM_CITIES/2)
- cloud.x = -images[IMG_CLOUD]->w/2; /* come in from the left */
+ cloud.x = -GetImage(IMG_CLOUD)->w/2; /* come in from the left */
else
- cloud.x = screen->w + images[IMG_CLOUD]->w/2; /* come from the right */
+ cloud.x = GetScreen()->w + GetImage(IMG_CLOUD)->w/2; /* come from the right */
penguins[cloud.city].status = PENGUIN_WALKING_ON;
/* initialize the snowflakes */
- snow_width = images[IMG_CLOUD]->w - images[IMG_SNOW1]->w;
+ snow_width = GetImage(IMG_CLOUD)->w - GetImage(IMG_SNOW1)->w;
for (i = 0; i < NUM_SNOWFLAKES; i++) {
cloud.snowflake_y[i] = cloud.y - i*SNOWFLAKE_SEPARATION;
cloud.snowflake_x[i] = - snow_width/2 + (rand() % snow_width);
@@ -1792,8 +1792,8 @@
else {
// Cloud is "parked," handle the snowfall and igloo rebuilding
cities[cloud.city].status = CITY_REBUILDING;
- igloo_top = screen->h - igloo_vertical_offset
- - images[IMG_IGLOO_INTACT]->h;
+ igloo_top = GetScreen()->h - igloo_vertical_offset
+ - GetImage(IMG_IGLOO_INTACT)->h;
for (i = 0, num_below_igloo = 0; i < NUM_SNOWFLAKES; i++) {
cloud.snowflake_y[i] += SNOWFLAKE_SPEED;
if (cloud.snowflake_y[i] > igloo_top)
@@ -1811,7 +1811,7 @@
num_below_igloo = 0; // Don't show progress until a few have fallen
cities[cloud.city].img = -((float) (num_below_igloo)/NUM_SNOWFLAKES) * NUM_BLENDED_IGLOOS;
}
- if (cloud.snowflake_y[NUM_SNOWFLAKES-1] > screen->h - igloo_vertical_offset) {
+ if (cloud.snowflake_y[NUM_SNOWFLAKES-1] > GetScreen()->h - igloo_vertical_offset) {
/* exit rebuilding when last snowflake at igloo bottom */
cloud.status = EXTRA_LIFE_OFF;
cities[cloud.city].status = CITY_PRESENT;
@@ -1863,11 +1863,11 @@
}
/* now draw it: */
- dest.x = (screen->w - images[keypad_image]->w) / 2;
- dest.y = (screen->h - images[keypad_image]->h) / 2;
- dest.w = images[keypad_image]->w;
- dest.h = images[keypad_image]->h;
- SDL_BlitSurface(images[keypad_image], NULL, screen, &dest);
+ dest.x = (GetScreen()->w - GetImage(keypad_image)->w) / 2;
+ dest.y = (GetScreen()->h - GetImage(keypad_image)->h) / 2;
+ dest.w = GetImage(keypad_image)->w;
+ dest.h = GetImage(keypad_image)->h;
+ SDL_BlitSurface(GetImage(keypad_image), NULL, GetScreen(), &dest);
}
/* Draw console, LED numbers, & tux: */
@@ -1878,7 +1878,7 @@
game_write_messages();
/* Swap buffers: */
- SDL_Flip(screen);
+ SDL_Flip(GetScreen());
}
void game_draw_background(void)
@@ -1888,40 +1888,40 @@
SDL_Rect dest;
if (fgcolor == 0)
- fgcolor = SDL_MapRGB(screen->format, 64, 96, 64);
+ fgcolor = SDL_MapRGB(GetScreen()->format, 64, 96, 64);
if (old_wave != wave)
{
DEBUGMSG(debug_game,"Wave %d\n", wave)
old_wave = wave;
- bgcolor = SDL_MapRGB(screen->format,
+ bgcolor = SDL_MapRGB(GetScreen()->format,
64,
64 + ((wave * 32) % 192),
128 - ((wave * 16) % 128) );
DEBUGMSG(debug_game,"Filling screen with color %d\n", bgcolor);
}
- if (current_bkgd() == NULL || (current_bkgd()->w != screen->w &&
- current_bkgd()->h != screen->h) )
+ if (current_bkgd() == NULL || (current_bkgd()->w != GetScreen()->w &&
+ current_bkgd()->h != GetScreen()->h) )
{
dest.x = 0;
dest.y = 0;
- dest.w = screen->w;
- dest.h = ((screen->h) / 4) * 3;
+ dest.w = GetScreen()->w;
+ dest.h = ((GetScreen()->h) / 4) * 3;
- SDL_FillRect(screen, &dest, bgcolor);
+ SDL_FillRect(GetScreen(), &dest, bgcolor);
- dest.y = ((screen->h) / 4) * 3;
- dest.h = (screen->h) / 4;
+ dest.y = ((GetScreen()->h) / 4) * 3;
+ dest.h = (GetScreen()->h) / 4;
- SDL_FillRect(screen, &dest, fgcolor);
+ SDL_FillRect(GetScreen(), &dest, fgcolor);
}
if (current_bkgd())
{
- dest.x = (screen->w - current_bkgd()->w) / 2;
- dest.y = (screen->h - current_bkgd()->h) / 2;
- SDL_BlitSurface(current_bkgd(), NULL, screen, &dest);
+ dest.x = (GetScreen()->w - current_bkgd()->w) / 2;
+ dest.y = (GetScreen()->h - current_bkgd()->h) / 2;
+ SDL_BlitSurface(current_bkgd(), NULL, GetScreen(), &dest);
}
}
@@ -1943,10 +1943,10 @@
if (comets[i].expl == -1)
{
/* Decide which image to display: */
- img = sprites[ANIM_COMET]->frame[(frame + i) % sprites[ANIM_COMET]->num_frames];
+ img = GetSprite(ANIM_COMET)->frame[(frame + i) % GetSprite(ANIM_COMET)->num_frames];
/* Display the formula (flashing, in the bottom half
of the screen) */
- if (comets[i].y < screen->h / 2 || frame % 8 < 6)
+ if (comets[i].y < GetScreen()->h / 2 || frame % 8 < 6)
{
comet_str = comets[i].flashcard.formula_string;
}
@@ -1958,7 +1958,7 @@
else
{
/* show each frame of explosion twice */
- img = sprites[ANIM_COMET_EXPL]->frame[comets[i].expl / 2];
+ img = GetSprite(ANIM_COMET_EXPL)->frame[comets[i].expl / 2];
comet_str = comets[i].flashcard.answer_string;
}
@@ -1968,7 +1968,7 @@
dest.w = img->w;
dest.h = img->h;
- SDL_BlitSurface(img, NULL, screen, &dest);
+ SDL_BlitSurface(img, NULL, GetScreen(), &dest);
if (comet_str != NULL)
{
draw_nums(comet_str, comets[i].x, comets[i].y);
@@ -1984,10 +1984,10 @@
if (comets[i].expl == -1)
{
/* Decide which image to display: */
- img = sprites[ANIM_BONUS_COMET]->frame[(frame + i) % sprites[ANIM_BONUS_COMET]->num_frames];
+ img = GetSprite(ANIM_BONUS_COMET)->frame[(frame + i) % GetSprite(ANIM_BONUS_COMET)->num_frames];
/* Display the formula (flashing, in the bottom half
of the screen) */
- if (comets[i].y < screen->h / 2 || frame % 8 < 6)
+ if (comets[i].y < GetScreen()->h / 2 || frame % 8 < 6)
{
comet_str = comets[i].flashcard.formula_string;
}
@@ -1998,11 +1998,11 @@
}
else
{
- img = sprites[ANIM_BONUS_COMET_EXPL]->frame[comets[i].expl / 2];
+ img = GetSprite(ANIM_BONUS_COMET_EXPL)->frame[comets[i].expl / 2];
comet_str = comets[i].flashcard.answer_string;
}
- /* Move images[] index to bonus range: */
+ /* Move image index to bonus range: */
/* Draw it! */
dest.x = comets[i].x - (img->w / 2);
@@ -2010,7 +2010,7 @@
dest.w = img->w;
dest.h = img->h;
- SDL_BlitSurface(img, NULL, screen, &dest);
+ SDL_BlitSurface(img, NULL, GetScreen(), &dest);
if (comet_str != NULL)
{
draw_nums(comet_str, comets[i].x, comets[i].y);
@@ -2044,20 +2044,20 @@
if (cities[i].img <= 0)
this_image = blended_igloos[-cities[i].img];
else
- this_image = images[cities[i].img];
+ this_image = GetImage(cities[i].img);
//this_image = blended_igloos[frame % NUM_BLENDED_IGLOOS];
dest.x = cities[i].x - (this_image->w / 2);
- dest.y = (screen->h) - (this_image->h) - igloo_vertical_offset;
+ dest.y = (GetScreen()->h) - (this_image->h) - igloo_vertical_offset;
if (cities[i].img == IMG_IGLOO_MELTED3 ||
cities[i].img == IMG_IGLOO_MELTED2)
- dest.y -= (images[IMG_IGLOO_MELTED1]->h - this_image->h)/2;
+ dest.y -= (GetImage(IMG_IGLOO_MELTED1)->h - this_image->h)/2;
dest.w = (this_image->w);
dest.h = (this_image->h);
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
}
if (penguins[i].layer == current_layer &&
penguins[i].status != PENGUIN_OFFSCREEN) {
- this_image = images[penguins[i].img];
+ this_image = GetImage(penguins[i].img);
if (penguins[i].status == PENGUIN_WALKING_OFF ||
penguins[i].status == PENGUIN_WALKING_ON) {
/* With walking penguins, we have to use flipped images
@@ -2067,32 +2067,32 @@
reliable way is the align them all on the tip of the
beak (the right border of the unflipped image) */
dest.x = penguins[i].x - (this_image->w / 2);
- dest.y = (screen->h) - (this_image->h);
+ dest.y = (GetScreen()->h) - (this_image->h);
if ((i<NUM_CITIES/2 && penguins[i].status==PENGUIN_WALKING_OFF) ||
(i>=NUM_CITIES/2 && penguins[i].status==PENGUIN_WALKING_ON)) {
/* walking left */
this_image = flipped_images[flipped_img_lookup[penguins[i].img]];
- dest.x = penguins[i].x - images[IMG_PENGUIN_WALK_OFF2]->w/2;
+ dest.x = penguins[i].x - GetImage(IMG_PENGUIN_WALK_OFF2)->w/2;
} else
dest.x = penguins[i].x - this_image->w
- + images[IMG_PENGUIN_WALK_OFF2]->w/2; /* walking right */
+ + GetImage(IMG_PENGUIN_WALK_OFF2)->w/2; /* walking right */
}
else {
dest.x = penguins[i].x - (this_image->w / 2);
- dest.y = (screen->h) - (5*(this_image->h))/4 - igloo_vertical_offset;
+ dest.y = (GetScreen()->h) - (5*(this_image->h))/4 - igloo_vertical_offset;
}
dest.w = (this_image->w);
dest.h = (this_image->h);
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
}
if (steam[i].layer == current_layer &&
steam[i].status == STEAM_ON) {
this_image = steam[i].img;
dest.x = cities[i].x - (this_image->w / 2);
- dest.y = (screen->h) - this_image->h - ((4 * images[IMG_IGLOO_INTACT]->h) / 7);
+ dest.y = (GetScreen()->h) - this_image->h - ((4 * GetImage(IMG_IGLOO_INTACT)->h) / 7);
dest.w = (this_image->w);
dest.h = (this_image->h);
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
}
}
current_layer++;
@@ -2101,48 +2101,48 @@
/* Render cloud & snowflakes */
for (i = 0; i < NUM_SNOWFLAKES; i++) {
if (cloud.snowflake_y[i] > cloud.y &&
- cloud.snowflake_y[i] < screen->h - igloo_vertical_offset) {
- this_image = images[IMG_SNOW1+cloud.snowflake_size[i]];
+ cloud.snowflake_y[i] < GetScreen()->h - igloo_vertical_offset) {
+ this_image = GetImage(IMG_SNOW1+cloud.snowflake_size[i]);
dest.x = cloud.snowflake_x[i] - this_image->w/2 + cloud.x;
dest.y = cloud.snowflake_y[i] - this_image->h/2;
dest.w = this_image->w;
dest.h = this_image->h;
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
}
}
- this_image = images[IMG_CLOUD];
+ this_image = GetImage(IMG_CLOUD);
dest.x = cloud.x - this_image->w/2;
dest.y = cloud.y - this_image->h/2;
dest.w = this_image->w;
dest.h = this_image->h;
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
}
}
else {
/* We're drawing original city graphics, for which there are no
layering issues, but has special handling for the shields */
for (i = 0; i < NUM_CITIES; i++) {
- this_image = images[cities[i].img];
+ this_image = GetImage(cities[i].img);
dest.x = cities[i].x - (this_image->w / 2);
- dest.y = (screen->h) - (this_image->h);
+ dest.y = (GetScreen()->h) - (this_image->h);
dest.w = (this_image->w);
dest.h = (this_image->h);
- SDL_BlitSurface(this_image, NULL, screen, &dest);
+ SDL_BlitSurface(this_image, NULL, GetScreen(), &dest);
/* Draw sheilds: */
if (cities[i].hits_left > 1) {
- for (j = (frame % 3); j < images[IMG_SHIELDS]->h; j = j + 3) {
+ for (j = (frame % 3); j < GetImage(IMG_SHIELDS)->h; j = j + 3) {
src.x = 0;
src.y = j;
- src.w = images[IMG_SHIELDS]->w;
+ src.w = GetImage(IMG_SHIELDS)->w;
src.h = 1;
- dest.x = cities[i].x - (images[IMG_SHIELDS]->w / 2);
- dest.y = (screen->h) - (images[IMG_SHIELDS]->h) + j;
+ dest.x = cities[i].x - (GetImage(IMG_SHIELDS)->w / 2);
+ dest.y = (GetScreen()->h) - (GetImage(IMG_SHIELDS)->h) + j;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_SHIELDS], &src, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_SHIELDS), &src, GetScreen(), &dest);
}
}
}
@@ -2160,12 +2160,12 @@
/* Draw "Demo" */
if (Opts_DemoMode())
{
- dest.x = (screen->w - images[IMG_DEMO]->w) / 2;
- dest.y = (screen->h - images[IMG_DEMO]->h) / 2;
- dest.w = images[IMG_DEMO]->w;
- dest.h = images[IMG_DEMO]->h;
+ dest.x = (GetScreen()->w - GetImage(IMG_DEMO)->w) / 2;
+ dest.y = (GetScreen()->h - GetImage(IMG_DEMO)->h) / 2;
+ dest.w = GetImage(IMG_DEMO)->w;
+ dest.h = GetImage(IMG_DEMO)->h;
- SDL_BlitSurface(images[IMG_DEMO], NULL, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_DEMO), NULL, GetScreen(), &dest);
}
/* If we are playing through a defined list of questions */
@@ -2179,53 +2179,53 @@
/* Draw extra life earned icon */
dest.x = 0;
dest.y = 0;
- dest.w = images[IMG_EXTRA_LIFE]->w;
- dest.h = images[IMG_EXTRA_LIFE]->h;
- SDL_BlitSurface(images[IMG_EXTRA_LIFE], NULL, screen, &dest);
+ dest.w = GetImage(IMG_EXTRA_LIFE)->w;
+ dest.h = GetImage(IMG_EXTRA_LIFE)->h;
+ SDL_BlitSurface(GetImage(IMG_EXTRA_LIFE), NULL, GetScreen(), &dest);
} else if (bonus_comet_counter) {
/* Draw extra life progress bar */
dest.x = 0;
- dest.y = images[IMG_EXTRA_LIFE]->h/4;
- dest.h = images[IMG_EXTRA_LIFE]->h/2;
+ dest.y = GetImage(IMG_EXTRA_LIFE)->h/4;
+ dest.h = GetImage(IMG_EXTRA_LIFE)->h/2;
dest.w = ((Opts_BonusCometInterval() + 1 - bonus_comet_counter)
- * images[IMG_EXTRA_LIFE]->w) / Opts_BonusCometInterval();
- SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 255, 0));
+ * GetImage(IMG_EXTRA_LIFE)->w) / Opts_BonusCometInterval();
+ SDL_FillRect(GetScreen(), &dest, SDL_MapRGB(GetScreen()->format, 0, 255, 0));
}
/* Draw wave: */
if (Opts_BonusCometInterval())
- offset = images[IMG_EXTRA_LIFE]->w + 5;
+ offset = GetImage(IMG_EXTRA_LIFE)->w + 5;
else
offset = 0;
dest.x = offset;
dest.y = glyph_offset;
- dest.w = images[IMG_WAVE]->w;
- dest.h = images[IMG_WAVE]->h;
+ dest.w = GetImage(IMG_WAVE)->w;
+ dest.h = GetImage(IMG_WAVE)->h;
- SDL_BlitSurface(images[IMG_WAVE], NULL, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_WAVE), NULL, GetScreen(), &dest);
sprintf(str, "%d", wave);
- draw_numbers(str, offset+images[IMG_WAVE]->w + (images[IMG_NUMBERS]->w / 10), 0);
+ draw_numbers(str, offset+GetImage(IMG_WAVE)->w + (GetImage(IMG_NUMBERS)->w / 10), 0);
if (Opts_KeepScore() )
{
/* Draw "score" label: */
- dest.x = (screen->w - ((images[IMG_NUMBERS]->w / 10) * 7) -
- images[IMG_SCORE]->w -
- images[IMG_STOP]->w - 5);
+ dest.x = (GetScreen()->w - ((GetImage(IMG_NUMBERS)->w / 10) * 7) -
+ GetImage(IMG_SCORE)->w -
+ GetImage(IMG_STOP)->w - 5);
dest.y = glyph_offset;
- dest.w = images[IMG_SCORE]->w;
- dest.h = images[IMG_SCORE]->h;
- SDL_BlitSurface(images[IMG_SCORE], NULL, screen, &dest);
-
+ dest.w = GetImage(IMG_SCORE)->w;
+ dest.h = GetImage(IMG_SCORE)->h;
+ SDL_BlitSurface(GetImage(IMG_SCORE), NULL, GetScreen(), &dest);
+
/* Draw score numbers: */
sprintf(str, "%.6d", score);
draw_numbers(str,
- screen->w - ((images[IMG_NUMBERS]->w / 10) * 6) - images[IMG_STOP]->w - 5,
+ GetScreen()->w - ((GetImage(IMG_NUMBERS)->w / 10) * 6) - GetImage(IMG_STOP)->w - 5,
0);
}
-
+
/* Draw other players' scores */
if (mp_get_parameter(PLAYERS) && mp_get_parameter(MODE) == SCORE_SWEEP )
{
@@ -2237,23 +2237,23 @@
if(score)
{
SDL_Rect loc;
- loc.w = screen->w - score->w;
+ loc.w = GetScreen()->w - score->w;
loc.h = score->h * (i + 2);
loc.x = 0;
loc.y = 0;
- SDL_BlitSurface(score, NULL, screen, &loc);
+ SDL_BlitSurface(score, NULL, GetScreen(), &loc);
}
}
}
-
+
/* Draw stop button: */
if (!help_controls.x_is_blinking || (frame % 10 < 5)) {
- dest.x = (screen->w - images[IMG_STOP]->w);
+ dest.x = (GetScreen()->w - GetImage(IMG_STOP)->w);
dest.y = 0;
- dest.w = images[IMG_STOP]->w;
- dest.h = images[IMG_STOP]->h;
+ dest.w = GetImage(IMG_STOP)->w;
+ dest.h = GetImage(IMG_STOP)->h;
- SDL_BlitSurface(images[IMG_STOP], NULL, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_STOP), NULL, GetScreen(), &dest);
}
}
@@ -2544,7 +2544,7 @@
/* Look for a free comet slot and see if all live comets are far */
/* enough down to avoid overlap and keep formulas legible: */
found = -1;
- y_spacing = (images[IMG_NUMS]->h) * 1.5;
+ y_spacing = (GetImage(IMG_NUMS)->h) * 1.5;
for (i = 0; i < MAX_COMETS && found == -1; i++)
{
@@ -2661,7 +2661,7 @@
/* IMG_NUMS now consists of 10 digit graphics, NUM_OPERS (i.e. 4) */
/* operation symbols, and the '=' and '?' symbols, all side by side. */
/* char_width is the width of a single symbol. */
- char_width = (images[IMG_NUMS]->w / (16));
+ char_width = (GetImage(IMG_NUMS)->w / (16));
/* Calculate image_length, taking into account that the string will */
/* usually have four empty spaces that are only half as wide: */
image_length = str_length * char_width - (char_width * 0.5 * 4);
@@ -2672,8 +2672,8 @@
if (cur_x < 8)
cur_x = 8;
if (cur_x + (image_length) >=
- (screen->w - 8))
- cur_x = ((screen->w - 8) -
+ (GetScreen()->w - 8))
+ cur_x = ((GetScreen()->w - 8) -
(image_length));
@@ -2715,15 +2715,15 @@
src.x = c * char_width;
src.y = 0;
src.w = char_width;
- src.h = images[IMG_NUMS]->h;
+ src.h = GetImage(IMG_NUMS)->h;
dest.x = cur_x;
- dest.y = y - images[IMG_NUMS]->h;
+ dest.y = y - GetImage(IMG_NUMS)->h;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_NUMS], &src,
- screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_NUMS), &src,
+ GetScreen(), &dest);
/* Move the 'cursor' one character width: */
cur_x = cur_x + char_width;
}
@@ -2764,23 +2764,22 @@
if (c != -1)
{
- src.x = c * (images[IMG_NUMBERS]->w / 10);
+ src.x = c * (GetImage(IMG_NUMBERS)->w / 10);
src.y = 0;
- src.w = (images[IMG_NUMBERS]->w / 10);
- src.h = images[IMG_NUMBERS]->h;
+ src.w = (GetImage(IMG_NUMBERS)->w / 10);
+ src.h = GetImage(IMG_NUMBERS)->h;
dest.x = cur_x;
dest.y = y;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_NUMBERS], &src,
- screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_NUMBERS), &src,
+ GetScreen(), &dest);
/* Move the 'cursor' one character width: */
-
- cur_x = cur_x + (images[IMG_NUMBERS]->w / 10);
+ cur_x = cur_x + (GetImage(IMG_NUMBERS)->w / 10);
}
}
}
@@ -2806,14 +2805,14 @@
pause_done = 0;
pause_quit = 0;
- dest.x = (screen->w - images[IMG_PAUSED]->w) / 2;
- dest.y = (screen->h - images[IMG_PAUSED]->h) / 2;
- dest.w = images[IMG_PAUSED]->w;
- dest.h = images[IMG_PAUSED]->h;
+ dest.x = (GetScreen()->w - GetImage(IMG_PAUSED)->w) / 2;
+ dest.y = (GetScreen()->h - GetImage(IMG_PAUSED)->h) / 2;
+ dest.w = GetImage(IMG_PAUSED)->w;
+ dest.h = GetImage(IMG_PAUSED)->h;
DarkenScreen(1); // cut all channels by half
- SDL_BlitSurface(images[IMG_PAUSED], NULL, screen, &dest);
- SDL_UpdateRect(screen, 0, 0, 0, 0);
+ SDL_BlitSurface(GetImage(IMG_PAUSED), NULL, GetScreen(), &dest);
+ SDL_UpdateRect(GetScreen(), 0, 0, 0, 0);
#ifndef NOSOUND
@@ -2859,12 +2858,12 @@
Uint32 pixel;
SDL_Rect dest;
- pixel = SDL_MapRGB(screen->format, red, grn, blu);
+ pixel = SDL_MapRGB(GetScreen()->format, red, grn, blu);
dx = x2 - x1;
dy = y2 - y1;
- putpixel(screen, x1, y1, pixel);
+ putpixel(GetScreen(), x1, y1, pixel);
if (dx != 0)
{
@@ -2881,7 +2880,7 @@
x1 = x1 + dx;
y1 = m * x1 + b;
- putpixel(screen, x1, y1, pixel);
+ putpixel(GetScreen(), x1, y1, pixel);
}
}
else
@@ -2898,7 +2897,7 @@
dest.w = 3;
dest.h = y2 - y1;
- SDL_FillRect(screen, &dest, pixel);
+ SDL_FillRect(GetScreen(), &dest, pixel);
}
}
@@ -2973,12 +2972,12 @@
{
SDL_Rect dest;
- dest.x = (screen->w - img->w) / 2;
- dest.y = (screen->h - img->h);
+ dest.x = (GetScreen()->w - img->w) / 2;
+ dest.y = (GetScreen()->h - img->h);
dest.w = img->w;
dest.h = img->h;
- SDL_BlitSurface(img, NULL, screen, &dest);
+ SDL_BlitSurface(img, NULL, GetScreen(), &dest);
}
@@ -2995,21 +2994,21 @@
SDL_Rect dest;
/* Calculate placement based on image widths: */
- nums_width = (images[IMG_NUMBERS]->w / 10) * 4; /* displaying 4 digits */
- comet_width = sprites[ANIM_COMET_MINI]->frame[0]->w;
- comet_x = (screen->w)/2 - (comet_width + nums_width)/2;
+ nums_width = (GetImage(IMG_NUMBERS)->w / 10) * 4; /* displaying 4 digits */
+ comet_width = GetSprite(ANIM_COMET_MINI)->frame[0]->w;
+ comet_x = (GetScreen()->w)/2 - (comet_width + nums_width)/2;
nums_x = comet_x + comet_width;
/* Draw mini comet symbol: */
/* Decide which image to display: */
- comet_img = sprites[ANIM_COMET_MINI]->frame[frame % sprites[ANIM_COMET_MINI]->num_frames];
+ comet_img = GetSprite(ANIM_COMET_MINI)->frame[frame % GetSprite(ANIM_COMET_MINI)->num_frames];
/* Draw it! */
dest.x = comet_x;
dest.y = 0;
dest.w = comet_width;
dest.h = comet_img->h;
- SDL_BlitSurface(comet_img, NULL, screen, &dest);
+ SDL_BlitSurface(comet_img, NULL, GetScreen(), &dest);
/* draw number of remaining questions: */
questions_left = MC_TotalQuestionsLeft();
@@ -3025,17 +3024,17 @@
int y;
/* draw new console image with "monitor" for LED numbers: */
- draw_console_image(images[IMG_CONSOLE_LED]);
+ draw_console_image(GetImage(IMG_CONSOLE_LED));
/* set y to draw LED numbers into Tux's "monitor": */
- y = (screen->h
- - images[IMG_CONSOLE_LED]->h * (1.0 - CONSOLE_BORDER));
+ y = (GetScreen()->h
+ - GetImage(IMG_CONSOLE_LED)->h * (1.0 - CONSOLE_BORDER));
/* begin drawing so as to center display depending on whether minus */
/* sign needed (4 digit slots) or not (3 digit slots) DSB */
if (MC_GetOpt(ALLOW_NEGATIVES) )
- dest.x = ((screen->w - ((images[IMG_LEDNUMS]->w) / 10) * 4) / 2);
+ dest.x = ((GetScreen()->w - ((GetImage(IMG_LEDNUMS)->w) / 10) * 4) / 2);
else
- dest.x = ((screen->w - ((images[IMG_LEDNUMS]->w) / 10) * 3) / 2);
+ dest.x = ((GetScreen()->w - ((GetImage(IMG_LEDNUMS)->w) / 10) * 3) / 2);
for (i = -1; i < MC_MAX_DIGITS; i++) /* -1 is special case to allow minus sign */
/* with minimal modification of existing code DSB */
@@ -3045,36 +3044,36 @@
if (MC_GetOpt(ALLOW_NEGATIVES))
{
if (neg_answer_picked)
- src.x = (images[IMG_LED_NEG_SIGN]->w) / 2;
+ src.x = (GetImage(IMG_LED_NEG_SIGN)->w) / 2;
else
src.x = 0;
src.y = 0;
- src.w = (images[IMG_LED_NEG_SIGN]->w) / 2;
- src.h = images[IMG_LED_NEG_SIGN]->h;
+ src.w = (GetImage(IMG_LED_NEG_SIGN)->w) / 2;
+ src.h = GetImage(IMG_LED_NEG_SIGN)->h;
dest.y = y;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_LED_NEG_SIGN], &src, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_LED_NEG_SIGN), &src, GetScreen(), &dest);
/* move "cursor" */
dest.x += src.w;
}
}
else
{
- src.x = digits[i] * ((images[IMG_LEDNUMS]->w) / 10);
+ src.x = digits[i] * ((GetImage(IMG_LEDNUMS)->w) / 10);
src.y = 0;
- src.w = (images[IMG_LEDNUMS]->w) / 10;
- src.h = images[IMG_LEDNUMS]->h;
+ src.w = (GetImage(IMG_LEDNUMS)->w) / 10;
+ src.h = GetImage(IMG_LEDNUMS)->h;
/* dest.x already set */
dest.y = y;
dest.w = src.w;
dest.h = src.h;
- SDL_BlitSurface(images[IMG_LEDNUMS], &src, screen, &dest);
+ SDL_BlitSurface(GetImage(IMG_LEDNUMS), &src, GetScreen(), &dest);
/* move "cursor" */
dest.x += src.w;
}
@@ -3093,8 +3092,8 @@
/* Check to see if user clicked exit button: */
/* The exit button is in the upper right corner of the screen: */
- if ((event.button.x >= (screen->w - images[IMG_STOP]->w))
- &&(event.button.y <= images[IMG_STOP]->h))
+ if ((event.button.x >= (GetScreen()->w - GetImage(IMG_STOP)->w))
+ &&(event.button.y <= GetImage(IMG_STOP)->h))
{
key = SDLK_ESCAPE;
game_key_event(key);
@@ -3115,22 +3114,22 @@
/* of game() rather than with every mouse click */
if (MC_GetOpt(ALLOW_NEGATIVES))
{
- if (!images[IMG_KEYPAD])
+ if (!GetImage(IMG_KEYPAD))
return;
else
{
- keypad_w = images[IMG_KEYPAD]->w;
- keypad_h = images[IMG_KEYPAD]->h;
+ keypad_w = GetImage(IMG_KEYPAD)->w;
+ keypad_h = GetImage(IMG_KEYPAD)->h;
}
}
else
{
- if (!images[IMG_KEYPAD_NO_NEG])
+ if (!GetImage(IMG_KEYPAD_NO_NEG))
return;
else
{
- keypad_w = images[IMG_KEYPAD]->w;
- keypad_h = images[IMG_KEYPAD]->h;
+ keypad_w = GetImage(IMG_KEYPAD)->w;
+ keypad_h = GetImage(IMG_KEYPAD)->h;
}
}
@@ -3142,13 +3141,13 @@
/* only proceed if click falls within keypad: */
if (!((event.button.x >=
- (screen->w / 2) - (keypad_w / 2) &&
+ (GetScreen()->w / 2) - (keypad_w / 2) &&
event.button.x <=
- (screen->w / 2) + (keypad_w / 2) &&
+ (GetScreen()->w / 2) + (keypad_w / 2) &&
event.button.y >=
- (screen->h / 2) - (keypad_h / 2) &&
+ (GetScreen()->h / 2) - (keypad_h / 2) &&
event.button.y <=
- (screen->h / 2) + (keypad_h / 2))))
+ (GetScreen()->h / 2) + (keypad_h / 2))))
/* click outside of keypad - do nothing */
{
return;
@@ -3156,8 +3155,8 @@
else /* click was within keypad */
{
- x = (event.button.x - ((screen->w / 2) - (keypad_w / 2)));
- y = (event.button.y - ((screen->h / 2) - (keypad_h / 2)));
+ x = (event.button.x - ((GetScreen()->w / 2) - (keypad_w / 2)));
+ y = (event.button.y - ((GetScreen()->h / 2) - (keypad_h / 2)));
/* Now determine what onscreen key was pressed */
/* */
@@ -3476,23 +3475,23 @@
/* Left vs. Right - makes room for Tux and the console */
if (i < NUM_CITIES / 2)
{
- cities[i].x = (((screen->w / (NUM_CITIES + 1)) * i) +
- ((images[img] -> w) / 2));
+ cities[i].x = (((GetScreen()->w / (NUM_CITIES + 1)) * i) +
+ ((GetImage(img) -> w) / 2));
DEBUGMSG(debug_game,"%d,", cities[i].x)
}
else
{
- cities[i].x = screen->w -
- (screen->w / (NUM_CITIES + 1) *
+ cities[i].x = GetScreen()->w -
+ (GetScreen()->w / (NUM_CITIES + 1) *
(i - NUM_CITIES / 2) +
- images[img]->w / 2);
+ GetImage(img)->w / 2);
DEBUGMSG(debug_game,"%d,", cities[i].x);
}
penguins[i].x = cities[i].x;
}
- city_expl_height = screen->h - images[IMG_CITY_BLUE]->h;
+ city_expl_height = GetScreen()->h - GetImage(IMG_CITY_BLUE)->h;
//move comets to a location 'equivalent' to where they were
//i.e. with the same amount of time left before impact
for (i = 0; i < MAX_COMETS; ++i)
More information about the Tux4kids-commits
mailing list