pbad->base.width = 32;
pbad->base.height = 32;
pbad->mode = NORMAL;
- pbad->dying = NO;
+ pbad->dying = DYING_NOT;
pbad->kind = kind;
pbad->base.x = x;
pbad->base.y = y;
pbad->base.ym = 4.8;
pbad->old_base = pbad->base;
pbad->dir = LEFT;
- pbad->seen = NO;
- timer_init(&pbad->timer,YES);
+ pbad->seen = false;
+ timer_init(&pbad->timer, true);
physic_init(&pbad->physic);
}
/* --- BLUE SCREEN OF DEATH MONSTER: --- */
/* Move left/right: */
-
- if (pbad->dying == NO ||
- pbad->dying == FALLING)
+ if (pbad->dying == DYING_NOT ||
+ pbad->dying == DYING_FALLING)
{
if (pbad->dir == RIGHT)
pbad->base.x = pbad->base.x + pbad->base.xm * frame_ratio;
pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio;
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
/* Fall if we get off the ground: */
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
{
if (!issolid(pbad->base.x+16, pbad->base.y + 32))
{
if (pbad->mode == NORMAL || pbad->mode == KICK)
{
- if (pbad->dying == NO ||
- pbad->dying == FALLING)
+ if (pbad->dying == DYING_NOT ||
+ pbad->dying == DYING_FALLING)
{
if (pbad->dir == RIGHT)
pbad->base.x = pbad->base.x + pbad->base.xm * frame_ratio;
if(pbad->mode != HELD)
pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio;
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
bad_guys.erase(static_cast<std::vector<bad_guy_type>::iterator>(pbad));
/* Fall if we get off the ground: */
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
{
if (!issolid(pbad->base.x+16, pbad->base.y + 32))
{
pbad->base.y = pbad->base.y + pbad->base.ym * frame_ratio;
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
collision_swept_object_map(&pbad->old_base,&pbad->base);
if (pbad->base.y > screen->h)
physic_set_start_vy(&pbad->physic,0.);
}
- if (pbad->dying != FALLING)
+ if (pbad->dying != DYING_FALLING)
{
if(issolid(pbad->base.x, pbad->base.y + 32))
{
/* Handle dying timer: */
- if (pbad->dying == SQUISHED)
+ if (pbad->dying == DYING_SQUISHED)
{
/* Remove it if time's up: */
if(!timer_check(&pbad->timer))
/* Once it's on screen, it's activated! */
if (pbad->base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE)
- pbad->seen = YES;
+ pbad->seen = true;
}
/*}*/
}
{
/* --- BLUE SCREEN OF DEATH MONSTER: --- */
- if (pbad->dying == NO)
+ if (pbad->dying == DYING_NOT)
{
/* Alive: */
NO_UPDATE);
}
}
- else if (pbad->dying == FALLING)
+ else if (pbad->dying == DYING_FALLING)
{
/* Falling: */
NO_UPDATE);
}
}
- else if (pbad->dying == SQUISHED)
+ else if (pbad->dying == DYING_SQUISHED)
{
/* Dying - Squished: */
{
/* --- LAPTOP MONSTER: --- */
- if (pbad->dying == NO)
+ if (pbad->dying == DYING_NOT)
{
/* Alive: */
}
}
}
- else if (pbad->dying == FALLING)
+ else if (pbad->dying == DYING_FALLING)
{
/* Falling: */
switch (c_object)
{
case CO_BULLET:
- pbad->dying = FALLING;
+ pbad->dying = DYING_FALLING;
pbad->base.ym = -8;
/* Gain some points: */
/* We're in kick mode, kill the other guy
and yourself(wuahaha) : */
- pbad_c->dying = FALLING;
+ pbad_c->dying = DYING_FALLING;
pbad_c->base.ym = -8;
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
add_score(pbad->base.x - scroll_x,
pbad->base.y, 100);
- pbad_c->dying = FALLING;
+ pbad_c->dying = DYING_FALLING;
- pbad->dying = FALLING;
+ pbad->dying = DYING_FALLING;
pbad->base.ym = -8;
add_score(pbad_c->base.x - scroll_x,
{
if (pbad->kind == BAD_BSOD)
{
- pbad->dying = SQUISHED;
+ pbad->dying = DYING_SQUISHED;
timer_start(&pbad->timer,4000);
physic_set_state(&pplayer_c->vphysic,PH_VT);
physic_set_start_vy(&pplayer_c->vphysic,2.);
typedef struct bad_guy_type
{
int mode;
- int dying;
+ DyingType dying;
int kind;
- int seen;
+ bool seen;
int dir;
int frame;
base_type base;
pbutton->h = pbutton->icon.h;
pbutton->tag = -1;
pbutton->state = BUTTON_NONE;
- pbutton->show_info = NO;
+ pbutton->show_info = false;
pbutton->bkgd = NULL;
}
texture_draw(pbutton->bkgd,pbutton->x,pbutton->y,NO_UPDATE);
}
texture_draw(&pbutton->icon,pbutton->x,pbutton->y,NO_UPDATE);
- if(pbutton->show_info == YES)
+ if(pbutton->show_info)
{
char str[80];
int i = -32;
}
else
{
- pbutton->show_info = YES;
+ pbutton->show_info = true;
}
}
else if(event->type == SDL_MOUSEBUTTONUP)
}
else if(event->button.button != SDL_BUTTON_LEFT && pbutton->state != BUTTON_PRESSED)
{
- pbutton->show_info = YES;
+ pbutton->show_info = true;
}
}
pbutton->state = BUTTON_NONE;
if(pbutton->show_info)
{
- pbutton->show_info = NO;
+ pbutton->show_info = false;
}
}
if(pbutton->show_info)
{
- pbutton->show_info = NO;
+ pbutton->show_info = false;
}
}
}
pbutton_panel->y = y;
pbutton_panel->w = w;
pbutton_panel->h = h;
- pbutton_panel->hidden = NO;
+ pbutton_panel->hidden = false;
}
button_type* button_panel_event(button_panel_type* pbutton_panel, SDL_Event* event)
{
- if(pbutton_panel->hidden == NO)
+ if(pbutton_panel->hidden == false)
{
int i;
for(i = 0; i < pbutton_panel->num_items; ++i)
void button_panel_draw(button_panel_type* pbutton_panel)
{
- if(pbutton_panel->hidden == NO)
+ if(pbutton_panel->hidden == false)
{
int i;
fillrect(pbutton_panel->x,pbutton_panel->y,pbutton_panel->w,pbutton_panel->h,100,100,100,200);
texture_type* bkgd;
char *info;
SDLKey shortcut;
- int x;
- int y;
- int w;
- int h;
- int show_info;
+ int x;
+ int y;
+ int w;
+ int h;
+ bool show_info;
ButtonState state;
int tag;
}
#include "bitmask.h"
#include "scene.h"
-int rectcollision(base_type* one, base_type* two)
+bool rectcollision(base_type* one, base_type* two)
{
-
- if (one->x >= two->x - one->width + 1 &&
- one->x <= two->x + two->width - 1 &&
- one->y >= two->y - one->height + 1&&
- one->y <= two->y + two->height - 1)
- {
- return YES;
- }
- else
- {
- return NO;
- }
+ return (one->x >= two->x - one->width + 1 &&
+ one->x <= two->x + two->width - 1 &&
+ one->y >= two->y - one->height + 1 &&
+ one->y <= two->y + two->height - 1);
}
-int rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y)
+bool rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y)
{
- if (one->x >= two->x - one->width +off_x + 1 &&
- one->x <= two->x + two->width + off_x - 1 &&
- one->y >= two->y - one->height + off_y + 1 &&
- one->y <= two->y + two->height + off_y - 1)
- {
- return YES;
- }
- else
- {
- return NO;
- }
+ return (one->x >= two->x - one->width +off_x + 1 &&
+ one->x <= two->x + two->width + off_x - 1 &&
+ one->y >= two->y - one->height + off_y + 1 &&
+ one->y <= two->y + two->height + off_y - 1);
}
-int collision_object_map(base_type* pbase)
+bool collision_object_map(base_type* pbase)
{
int v,h,i;
issolid(pbase->x + pbase->width -1, pbase->y + 1) ||
issolid(pbase->x +1, pbase->y + pbase->height -1) ||
issolid(pbase->x + pbase->width -1, pbase->y + pbase->height - 1))
- return YES;
+ return true;
for(i = 1; i < h; ++i)
{
if(issolid(pbase->x + i*16,pbase->y + 1))
- return YES;
+ return true;
}
for(i = 1; i < h; ++i)
{
if( issolid(pbase->x + i*16,pbase->y + pbase->height - 1))
- return YES;
+ return true;
}
for(i = 1; i < v; ++i)
{
if( issolid(pbase->x + 1, pbase->y + i*16))
- return YES;
+ return true;
}
for(i = 1; i < v; ++i)
{
if( issolid(pbase->x + pbase->width - 1, pbase->y + i*16))
- return YES;
+ return true;
}
- return NO;
+ return false;
}
-int collision_swept_object_map(base_type* old, base_type* current)
+void collision_swept_object_map(base_type* old, base_type* current)
{
int steps; /* Used to speed up the collision tests, by stepping every 16pixels in the path. */
int h;
if(old->x == current->x && old->y == current->y)
{
- return 0;
+ return;
}
else if(old->x == current->x && old->y != current->y)
{
h = 1;
xd = 0;
-
}
else if(old->x != current->x && old->y == current->y)
{
}
*old = *current;
-return 0;
}
void collision_handler()
/* CO_BULLET & CO_BADGUY check */
for(i = 0; i < bullets.size(); ++i)
{
- for(j = 0; j < bad_guys.size(); ++j)
+ for(j = 0; j < bad_guys.size(); ++j)
+ {
+ if(bad_guys[j].dying == DYING_NOT)
{
- if(bad_guys[j].dying == NO)
+ if(rectcollision(&bullets[i].base,&bad_guys[j].base))
{
- if(rectcollision(&bullets[i].base,&bad_guys[j].base) == YES)
- {
- /* We have detected a collision and now call the collision functions of the collided objects. */
- bullet_collision(&bullets[i], CO_BADGUY);
- badguy_collision(&bad_guys[j], &bullets[i], CO_BULLET);
- }
+ /* We have detected a collision and now call the collision functions of the collided objects. */
+ bullet_collision(&bullets[i], CO_BADGUY);
+ badguy_collision(&bad_guys[j], &bullets[i], CO_BULLET);
}
}
+ }
}
/* CO_BADGUY & CO_BADGUY check */
for(i = 0; i < bad_guys.size(); ++i)
{
- if(bad_guys[i].dying == NO)
+ if(bad_guys[i].dying == DYING_NOT)
{
for(j = i+1; j < bad_guys.size(); ++j)
{
- if(j != i && bad_guys[j].dying == NO)
+ if(j != i && !bad_guys[j].dying)
{
- if(rectcollision(&bad_guys[i].base,&bad_guys[j].base) == YES)
+ if(rectcollision(&bad_guys[i].base, &bad_guys[j].base))
{
/* We have detected a collision and now call the collision functions of the collided objects. */
badguy_collision(&bad_guys[j], &bad_guys[i], CO_BADGUY);
/* CO_BADGUY & CO_PLAYER check */
for(i = 0; i < bad_guys.size(); ++i)
{
- if(bad_guys[i].dying == NO && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0) == YES )
+ if(bad_guys[i].dying == DYING_NOT && rectcollision_offset(&bad_guys[i].base,&tux.base,0,0))
+ {
+ /* We have detected a collision and now call the collision functions of the collided objects. */
+ if (tux.previous_base.y < tux.base.y &&
+ tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 &&
+ bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD)
{
- /* We have detected a collision and now call the collision functions of the collided objects. */
- if (tux.previous_base.y < tux.base.y &&
- tux.previous_base.y + tux.previous_base.height < bad_guys[i].base.y + bad_guys[i].base.height/2 &&
- bad_guys[i].kind != BAD_MONEY && bad_guys[i].mode != HELD)
- {
- badguy_collision(&bad_guys[i], &tux, CO_PLAYER);
- }
- else
- {
- player_collision(&tux, &bad_guys[i], CO_BADGUY);
- }
+ badguy_collision(&bad_guys[i], &tux, CO_PLAYER);
}
+ else
+ {
+ player_collision(&tux, &bad_guys[i], CO_BADGUY);
+ }
+ }
}
/* CO_UPGRADE & CO_PLAYER check */
for(i = 0; i < upgrades.size(); ++i)
{
- if(rectcollision(&upgrades[i].base,&tux.base) == YES)
- {
- /* We have detected a collision and now call the collision functions of the collided objects. */
- upgrade_collision(&upgrades[i], &tux, CO_PLAYER);
- }
+ if(rectcollision(&upgrades[i].base,&tux.base))
+ {
+ /* We have detected a collision and now call the collision functions of the collided objects. */
+ upgrade_collision(&upgrades[i], &tux, CO_PLAYER);
+ }
}
}
CO_PLAYER
};
-int rectcollision(base_type* one, base_type* two);
-int rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y);
-int collision_swept_object_map(base_type* old, base_type* current);
-int collision_object_map(base_type* object);
+bool rectcollision(base_type* one, base_type* two);
+bool rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y);
+void collision_swept_object_map(base_type* old, base_type* current);
+bool collision_object_map(base_type* object);
/* Checks for all possible collisions.
And calls the collision_handlers, which the collision_objects provide for this case (or not). */
#define JOY_X 0
#define JOY_Y 1
-
-/* Booleans: */
-
-#define NO 0
-#define YES 1
-
/* Direction (keyboard/joystick) states: */
#define UP 0
/* Dying types: */
/* ---- NO 0 */
-#define SQUISHED 1
-#define FALLING 2
+enum DyingType {
+ DYING_NOT = 0,
+ DYING_SQUISHED = 1,
+ DYING_FALLING = 2
+};
/* Hurt modes: */
/* extern variables */
st_level current_level;
-int game_started = NO;
+int game_started = false;
/* Local variables: */
}
break;
case SDLK_TAB:
- if(debug_mode == YES)
+ if(debug_mode)
{
tux.size = !tux.size;
if(tux.size == BIG)
}
break;
case SDLK_END:
- if(debug_mode == YES)
+ if(debug_mode)
distros += 50;
break;
case SDLK_SPACE:
- if(debug_mode == YES)
+ if(debug_mode)
next_level = 1;
break;
case SDLK_DELETE:
- if(debug_mode == YES)
+ if(debug_mode)
tux.got_coffee = 1;
break;
case SDLK_INSERT:
- if(debug_mode == YES)
+ if(debug_mode)
timer_start(&tux.invincible_timer,TUX_INVINCIBLE_TIME);
break;
case SDLK_l:
- if(debug_mode == YES)
+ if(debug_mode)
--tux.lives;
break;
case SDLK_s:
- if(debug_mode == YES)
+ if(debug_mode)
score += 1000;
case SDLK_f:
- if(debug_fps == YES)
- debug_fps = NO;
+ if(debug_fps)
+ debug_fps = false;
else
- debug_fps = YES;
+ debug_fps = true;
break;
default:
break;
/* Handle distro counting: */
- if (counting_distros == YES)
+ if (counting_distros)
{
distro_counter--;
{
int fps_cnt, jump, done;
timer_type fps_timer, frame_timer;
- timer_init(&fps_timer, YES);
- timer_init(&frame_timer, YES);
+ timer_init(&fps_timer, true);
+ timer_init(&frame_timer, true);
- game_started = YES;
+ game_started = true;
st_gl_mode = mode;
level = levelnb;
if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE)
levelintro();
- timer_init(&time_left,YES);
+ timer_init(&time_left,true);
start_timers();
if(st_gl_mode == ST_GL_LOAD_GAME)
/* --- MAIN GAME LOOP!!! --- */
- jump = NO;
+ jump = false;
done = 0;
quit = 0;
frame = 0;
game_pause = 0;
- timer_init(&fps_timer,YES);
- timer_init(&frame_timer,YES);
+ timer_init(&fps_timer,true);
+ timer_init(&frame_timer,true);
fps_cnt = 0;
/* Clear screen: */
game_draw();
do
{
- jump = NO;
+ jump = false;
/* Calculate the movement-factor */
frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE);
st_pause_ticks_stop();
break;
case 3:
- update_load_save_game_menu(&save_game_menu, NO);
+ update_load_save_game_menu(&save_game_menu, false);
break;
case 4:
- update_load_save_game_menu(&load_game_menu, YES);
+ update_load_save_game_menu(&load_game_menu, true);
break;
case 7:
st_pause_ticks_stop();
}
else if(current_menu == &save_game_menu )
{
- process_save_load_game_menu(YES);
+ process_save_load_game_menu(true);
}
else if(current_menu == &load_game_menu )
{
- process_save_load_game_menu(NO);
+ process_save_load_game_menu(false);
}
}
SDL_Delay(50);
}
- if(debug_mode && debug_fps == YES)
+ if(debug_mode && debug_fps == true)
SDL_Delay(60);
/*Draw the current scene to the screen */
/*if( ! fps_fps < 50.0 )
game_draw();
else
- jump = YES;*/ /*FIXME: Implement this tweak right.*/
+ jump = true;*/ /*FIXME: Implement this tweak right.*/
game_draw();
/* Time stops in pause mode */
/* Pause till next frame, if the machine running the game is too fast: */
/* FIXME: Works great for in OpenGl mode, where the CPU doesn't have to do that much. But
the results in SDL mode aren't perfect (thought the 100 FPS are reached), even on an AMD2500+. */
- if(last_update_time >= update_time - 12 && jump != YES )
+ if(last_update_time >= update_time - 12 && !jump)
SDL_Delay(10);
/*if((update_time - last_update_time) < 10)
SDL_Delay((11 - (update_time - last_update_time))/2);*/
unloadshared();
arrays_free();
- game_started = NO;
+ game_started = false;
return(quit);
}
/* Is is ground? */
-int issolid(float x, float y)
+bool issolid(float x, float y)
{
- if (isbrick(x, y) ||
- isice(x, y) ||
- (shape(x, y) == '[') ||
- (shape(x, y) == '=') ||
- (shape(x, y) == ']') ||
- (shape(x, y) == 'A') ||
- (shape(x, y) == 'B') ||
- (shape(x, y) == '!') ||
- (shape(x, y) == 'a'))
- {
- return YES;
- }
-
- return NO;
+ return (isbrick(x, y) ||
+ isice(x, y) ||
+ (shape(x, y) == '[') ||
+ (shape(x, y) == '=') ||
+ (shape(x, y) == ']') ||
+ (shape(x, y) == 'A') ||
+ (shape(x, y) == 'B') ||
+ (shape(x, y) == '!') ||
+ (shape(x, y) == 'a'));
}
-
/* Is it a brick? */
-int isbrick(float x, float y)
+bool isbrick(float x, float y)
{
- if (shape(x, y) == 'X' ||
- shape(x, y) == 'x' ||
- shape(x, y) == 'Y' ||
- shape(x, y) == 'y')
- {
- return YES;
- }
-
- return NO;
+ return (shape(x, y) == 'X' ||
+ shape(x, y) == 'x' ||
+ shape(x, y) == 'Y' ||
+ shape(x, y) == 'y');
}
/* Is it ice? */
-int isice(float x, float y)
+bool isice(float x, float y)
{
- if (shape(x, y) == '#')
- {
- return YES;
- }
-
- return NO;
+ return (shape(x, y) == '#');
}
-
/* Is it a full box? */
-int isfullbox(float x, float y)
+bool isfullbox(float x, float y)
{
- if (shape(x, y) == 'A' ||
- shape(x, y) == 'B' ||
- shape(x, y) == '!')
- {
- return YES;
- }
-
- return NO;
+ return (shape(x, y) == 'A' ||
+ shape(x, y) == 'B' ||
+ shape(x, y) == '!');
}
/* Break a brick: */
add_bouncy_distro(((int)(x + 1) / 32) * 32,
(int)(y / 32) * 32);
- if (counting_distros == NO)
+ if (!counting_distros)
{
- counting_distros = YES;
+ counting_distros = true;
distro_counter = 50;
}
if (bad_guys[i].kind == BAD_BSOD ||
bad_guys[i].kind == BAD_LAPTOP)
{
- bad_guys[i].dying = FALLING;
+ bad_guys[i].dying = DYING_FALLING;
bad_guys[i].base.ym = -8;
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
}
void savegame(int slot);
void loadgame(int slot);
void slotinfo(char **pinfo, int slot);
-int issolid(float x, float y);
-int isbrick(float x, float y);
-int isice(float x, float y);
-int isfullbox(float x, float y);
-int rectcollision(base_type* one, base_type* two);
+bool issolid(float x, float y);
+bool isbrick(float x, float y);
+bool isice(float x, float y);
+bool isfullbox(float x, float y);
+bool rectcollision(base_type* one, base_type* two);
void drawshape(float x, float y, unsigned char c);
unsigned char shape(float x, float y);
void bumpbrick(float x, float y);
SDL_Surface * screen;
text_type black_text, gold_text, blue_text, red_text, yellow_nums, white_text, white_small_text, white_big_text;
-int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps;
+bool use_gl;
+bool use_joystick;
+bool use_fullscreen;
+bool debug_mode;
+bool show_fps;
int joystick_num = 0;
char* level_startup_file = 0;
extern SDL_Surface * screen;
extern text_type black_text, gold_text, white_text, white_small_text, white_big_text, blue_text, red_text, yellow_nums;
-extern int use_gl, use_joystick, use_fullscreen, debug_mode, show_fps;
+extern bool use_gl;
+extern bool use_joystick;
+extern bool use_fullscreen;
+extern bool debug_mode;
+extern bool show_fps;
/** The number of the joystick that will be use in the game */
extern int joystick_num;
scene = 0;
i = 0;
- timer_init(&timer,NO);
+ timer_init(&timer, false);
timer_start(&timer,10000);
while (timer_check(&timer) && !done && !quit)
/* leveleditor internals */
static string_list_type level_subsets;
-static int le_level_changed; /* if changes, ask for saving, when quiting*/
+static bool le_level_changed; /* if changes, ask for saving, when quiting*/
static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
static st_level* le_current_level;
static texture_type le_selection;
static int done;
static char le_current_tile;
-static int le_mouse_pressed[2];
+static bool le_mouse_pressed[2];
static button_type le_save_level_bt;
static button_type le_test_level_bt;
static button_type le_next_level_bt;
while (SDL_PollEvent(&event))
{}
- while(YES)
+ while(true)
{
last_time = SDL_GetTicks();
le_frame++;
switch (menu_check(&leveleditor_menu))
{
case 2:
- show_menu = NO;
+ show_menu = false;
break;
case 3:
update_subset_settings_menu();
menu_set_current(&leveleditor_menu);
break;
default:
- show_menu = YES;
+ show_menu = true;
break;
}
}
le_set_defaults();
level_load_gfx(le_current_level);
le_activate_bad_guys();
- show_menu = YES;
+ show_menu = true;
}
break;
}
level_load_gfx(le_current_level);
le_activate_bad_guys();
menu_item_change_input(&subset_new_menu.item[2],"");
- show_menu = YES;
+ show_menu = true;
break;
}
}
{
case 5:
save_subset_settings_menu();
- show_menu = YES;
+ show_menu = true;
break;
}
}
bkgd_files = dfiles(pathname,"bkgd-", NULL);
string_list_sort(&bkgd_files);
- le_bkgd_panel.hidden = YES;
+ le_bkgd_panel.hidden = true;
key = SDLK_a;
for(i = 0; i < bkgd_files.num_items; ++i)
{
string_list_type bad_files;
level_subsets = dsubdirs("/levels", "info");
- le_show_grid = YES;
+ le_show_grid = true;
/* level_changed = NO;*/
fire = DOWN;
done = 0;
le_frame = 0; /* support for frames in some tiles, like waves and bad guys */
- le_level_changed = NO;
+ le_level_changed = false;
le_current_level = NULL;
le_current_tile = '.';
- le_mouse_pressed[LEFT] = NO;
- le_mouse_pressed[RIGHT] = NO;
+ le_mouse_pressed[LEFT] = false;
+ le_mouse_pressed[RIGHT] = false;
texture_load(&le_selection, datadir + "/images/leveleditor/select.png", USE_ALPHA);
string_list_sort(&bkgd_files);
button_panel_init(&le_bkgd_panel, screen->w - 64,98, 64, 318);
- le_bkgd_panel.hidden = YES;
+ le_bkgd_panel.hidden = true;
key = SDLK_a;
for(i = 0; i < bkgd_files.num_items; ++i)
{
string_list_add_item(&bad_files,"laptop-left-0.png");
string_list_add_item(&bad_files,"bag-left-0.png");
button_panel_init(&le_bad_panel, screen->w - 64,98, 64, 318);
- le_bad_panel.hidden = YES;
+ le_bad_panel.hidden = true;
key = SDLK_a;
for(i = 0; i < bad_files.num_items; ++i)
{
menu_reset();
menu_set_current(&leveleditor_menu);
- show_menu = YES;
+ show_menu = true;
menu_init(&subset_load_menu);
menu_additem(&subset_load_menu,MN_LABEL,"Load Level Subset",0,0);
menu_additem(&subset_settings_menu,MN_BACK,"Back",0,0);
menu_init(&level_settings_menu);
- level_settings_menu.arrange_left = YES;
+ level_settings_menu.arrange_left = true;
menu_additem(&level_settings_menu,MN_LABEL,"Level Settings",0,0);
menu_additem(&level_settings_menu,MN_HL,"",0,0);
menu_additem(&level_settings_menu,MN_TEXTFIELD,"Name ",0,0);
void apply_level_settings_menu()
{
int i,y,j;
- i = NO;
+ i = false;
le_current_level->name = level_settings_menu.item[2].input;
if(le_current_level->bkgd_image.compare(string_list_active(level_settings_menu.item[5].list)) != 0)
{
le_current_level->bkgd_image = string_list_active(level_settings_menu.item[5].list);
- i = YES;
+ i = true;
}
if(le_current_level->theme.compare(string_list_active(level_settings_menu.item[3].list)) != 0)
{
le_current_level->theme = string_list_active(level_settings_menu.item[3].list);
le_update_buttons(le_current_level->theme.c_str());
- i = YES;
+ i = true;
}
- if(i == YES)
+ if(i == true)
{
level_free_gfx();
level_load_gfx(le_current_level);
void le_quit(void)
{
- /*if(level_changed == YES)
+ /*if(level_changed == true)
if(askforsaving() == CANCEL)
return;*/ //FIXME
}
else
{
- if(show_menu == NO)
+ if(show_menu == false)
text_draw(&white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1, NO_UPDATE);
else
text_draw(&white_small_text, "No Level Subset loaded", 10, 430, 1, NO_UPDATE);
menu_event(&event.key.keysym);
if(key == SDLK_ESCAPE)
{
- show_menu = NO;
+ show_menu = false;
menu_set_current(&leveleditor_menu);
}
break;
{
case SDLK_ESCAPE:
if(!show_menu)
- show_menu = YES;
+ show_menu = true;
else
- show_menu = NO;
+ show_menu = false;
break;
case SDLK_LEFT:
if(fire == DOWN)
case SDL_MOUSEBUTTONDOWN:
if(event.button.button == SDL_BUTTON_LEFT)
{
- le_mouse_pressed[LEFT] = YES;
+ le_mouse_pressed[LEFT] = true;
selection.x1 = event.motion.x + pos_x;
selection.y1 = event.motion.y;
selection.y2 = event.motion.y;
}
else if(event.button.button == SDL_BUTTON_RIGHT)
- le_mouse_pressed[RIGHT] = YES;
+ le_mouse_pressed[RIGHT] = true;
break;
case SDL_MOUSEBUTTONUP:
if(event.button.button == SDL_BUTTON_LEFT)
- le_mouse_pressed[LEFT] = NO;
+ le_mouse_pressed[LEFT] = false;
else if(event.button.button == SDL_BUTTON_RIGHT)
- le_mouse_pressed[RIGHT] = NO;
+ le_mouse_pressed[RIGHT] = false;
break;
case SDL_MOUSEMOTION:
if(!show_menu)
cursor_x = ((int)(pos_x + x) / 32) * 32;
cursor_y = ((int) y / 32) * 32;
- if(le_mouse_pressed[LEFT] == YES)
+ if(le_mouse_pressed[LEFT] == true)
{
selection.x2 = x + pos_x;
selection.y2 = y;
}
- if(le_mouse_pressed[RIGHT] == YES)
+ if(le_mouse_pressed[RIGHT] == true)
{
pos_x += -1 * event.motion.xrel;
}
if(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP || ((event.type == SDL_MOUSEBUTTONDOWN || SDL_MOUSEMOTION) && (event.motion.x > screen->w-64 && event.motion.x < screen->w &&
event.motion.y > 0 && event.motion.y < screen->h)))
{
- le_mouse_pressed[LEFT] = NO;
- le_mouse_pressed[RIGHT] = NO;
+ le_mouse_pressed[LEFT] = false;
+ le_mouse_pressed[RIGHT] = false;
- if(show_menu == NO)
+ if(show_menu == false)
{
/* Check for button events */
button_event(&le_test_level_bt,&event);
button_event(&le_bad_bt,&event);
if(button_get_state(&le_bad_bt) == BUTTON_CLICKED)
{
- le_bad_panel.hidden = NO;
- le_fgd_panel.hidden = YES;
- le_bkgd_panel.hidden = YES;
+ le_bad_panel.hidden = false;
+ le_fgd_panel.hidden = true;
+ le_bkgd_panel.hidden = true;
}
button_event(&le_fgd_bt,&event);
if(button_get_state(&le_fgd_bt) == BUTTON_CLICKED)
{
- le_bad_panel.hidden = YES;
- le_fgd_panel.hidden = NO;
- le_bkgd_panel.hidden = YES;
+ le_bad_panel.hidden = true;
+ le_fgd_panel.hidden = false;
+ le_bkgd_panel.hidden = true;
}
button_event(&le_bkgd_bt,&event);
if(button_get_state(&le_bkgd_bt) == BUTTON_CLICKED)
{
- le_bad_panel.hidden = YES;
- le_fgd_panel.hidden = YES;
- le_bkgd_panel.hidden = NO;
+ le_bad_panel.hidden = true;
+ le_fgd_panel.hidden = true;
+ le_bkgd_panel.hidden = false;
}
button_event(&le_settings_bt,&event);
if(button_get_state(&le_settings_bt) == BUTTON_CLICKED)
{
- if(show_menu == NO)
+ if(show_menu == false)
{
update_level_settings_menu();
menu_set_current(&level_settings_menu);
- show_menu = YES;
+ show_menu = true;
}
else
{
menu_set_current(&leveleditor_menu);
- show_menu = NO;
+ show_menu = false;
}
}
if((pbutton = button_panel_event(&le_bkgd_panel,&event)) != NULL)
button_event(&le_settings_bt,&event);
if(button_get_state(&le_settings_bt) == BUTTON_CLICKED)
{
- if(show_menu == NO)
+ if(show_menu == false)
{
update_level_settings_menu();
menu_set_current(&level_settings_menu);
- show_menu = YES;
+ show_menu = true;
}
else
{
menu_set_current(&leveleditor_menu);
- show_menu = NO;
+ show_menu = false;
}
}
}
}
- if(show_menu == NO)
+ if(show_menu == false)
{
button_event(&le_move_left_bt,&event);
button_event(&le_move_right_bt,&event);
}
}
}
- if(show_menu == NO)
+ if(show_menu == false)
{
if(button_get_state(&le_move_left_bt) == BUTTON_PRESSED)
{
int x1, x2, y1, y2;
unsigned int i;
- /* level_changed = YES; */
+ /* level_changed = true; */
switch(le_selection_mode)
{
/* (global) menu variables */
MenuAction menuaction;
-int show_menu;
-int menu_change;
+bool show_menu;
+bool menu_change;
texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
menu_type main_menu, game_menu, options_menu, highscore_menu, load_game_menu, save_game_menu;
{
if(pmenu != current_menu)
{
- menu_change = YES;
+ menu_change = true;
last_menu = current_menu;
current_menu = pmenu;
timer_start(&pmenu->effect, 500);
if(kind == MN_TOGGLE)
pnew_item->toggled = init_toggle;
else
- pnew_item->toggled = NO;
+ pnew_item->toggled = false;
pnew_item->target_menu = target_menu;
pnew_item->input = (char*) malloc(sizeof(char));
pnew_item->input[0] = '\0';
pmenu->num_items = 0;
pmenu->active_item = 0;
pmenu->item = NULL;
- timer_init(&pmenu->effect,NO);
+ timer_init(&pmenu->effect,false);
}
/* Add an item to a menu */
else if(item.kind == MN_TOGGLE)
{
item.toggled = !item.toggled;
- menu_change = YES;
+ menu_change = true;
}
else if(item.kind == MN_ACTION || item.kind == MN_TEXTFIELD || item.kind == MN_NUMFIELD)
{
- item.toggled = YES;
+ item.toggled = true;
}
else if(item.kind == MN_BACK)
{
if(pmenu->num_items != 0 && pmenu->item != NULL)
{
- if((item.kind == MN_ACTION || item.kind == MN_TEXTFIELD || item.kind == MN_NUMFIELD) && item.toggled == YES)
+ if((item.kind == MN_ACTION || item.kind == MN_TEXTFIELD || item.kind == MN_NUMFIELD) && item.toggled == true)
{
- item.toggled = NO;
+ item.toggled = false;
show_menu = 0;
return pmenu->active_item;
}
int list_width = strlen(string_list_active(pitem.list)) * font_width;
text_type* text_font = &white_text;
- if(pmenu->arrange_left == YES)
+ if(pmenu->arrange_left == true)
x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2;
if(index == pmenu->active_item)
{
text_draw_align(text_font, pitem.text, x_pos, y_pos, A_HMIDDLE, A_VMIDDLE, shadow_size);
- if(pitem.toggled == YES)
+ if(pitem.toggled == true)
texture_draw(&checkbox_checked,
x_pos + (text_width+font_width)/2,
y_pos - 8);
/* Reset/Set global defaults */
void menu_reset(void)
{
- menu_change = NO;
- show_menu = NO;
+ menu_change = false;
+ show_menu = false;
menuaction = MENU_ACTION_NONE;
current_menu = NULL;
last_menu = NULL;
/* Draw the current menu and execute the (menu)events */
void menu_process_current(void)
{
- menu_change = NO;
+ menu_change = false;
if(current_menu != NULL)
{
{
case SDLK_UP: /* Menu Up */
menuaction = MENU_ACTION_UP;
- menu_change = YES;
+ menu_change = true;
break;
case SDLK_DOWN: /* Menu Down */
menuaction = MENU_ACTION_DOWN;
- menu_change = YES;
+ menu_change = true;
break;
case SDLK_LEFT: /* Menu Up */
menuaction = MENU_ACTION_LEFT;
- menu_change = YES;
+ menu_change = true;
break;
case SDLK_RIGHT: /* Menu Down */
menuaction = MENU_ACTION_RIGHT;
- menu_change = YES;
+ menu_change = true;
break;
case SDLK_SPACE:
if(current_menu->item[current_menu->active_item].kind == MN_TEXTFIELD)
{
menuaction = MENU_ACTION_INPUT;
- menu_change = YES;
+ menu_change = true;
mn_input_char = ' ';
break;
}
case SDLK_RETURN: /* Menu Hit */
menuaction = MENU_ACTION_HIT;
- menu_change = YES;
+ menu_change = true;
break;
case SDLK_DELETE:
case SDLK_BACKSPACE:
menuaction = MENU_ACTION_REMOVE;
- menu_change = YES;
+ menu_change = true;
delete_character++;
break;
default:
if( (key >= SDLK_0 && key <= SDLK_9) || (key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_SPACE && key <= SDLK_SLASH))
{
menuaction = MENU_ACTION_INPUT;
- menu_change = YES;
+ menu_change = true;
mn_input_char = *ch;
}
else
/* (global) menu variables */
extern MenuAction menuaction;
-extern int show_menu;
-extern int menu_change;
+extern bool show_menu;
+extern bool menu_change;
extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
extern menu_type main_menu, game_menu, options_menu, highscore_menu, load_game_menu, save_game_menu;
int physic_is_set(physic_type* pphysic)
{
- if(pphysic->state != -1)
- return YES;
- else
- return NO;
+ return (pphysic->state != -1);
}
float physic_get_velocity(physic_type* pphysic)
pplayer->base.height = 32;
pplayer->size = SMALL;
- pplayer->got_coffee = NO;
+ pplayer->got_coffee = false;
pplayer->base.x = 0;
pplayer->base.y = 240;
pplayer->base.ym = 0;
pplayer->old_base = pplayer->base;
pplayer->dir = RIGHT;
- pplayer->duck = NO;
+ pplayer->duck = false;
- pplayer->dying = NO;
- pplayer->jumping = NO;
+ pplayer->dying = DYING_NOT;
+ pplayer->jumping = false;
pplayer->frame_main = 0;
pplayer->frame = 0;
pplayer->keymap.right = SDLK_RIGHT;
pplayer->keymap.fire = SDLK_LCTRL;
- timer_init(&pplayer->invincible_timer,YES);
- timer_init(&pplayer->skidding_timer,YES);
- timer_init(&pplayer->safe_timer,YES);
- timer_init(&pplayer->frame_timer,YES);
+ timer_init(&pplayer->invincible_timer,true);
+ timer_init(&pplayer->skidding_timer,true);
+ timer_init(&pplayer->safe_timer,true);
+ timer_init(&pplayer->frame_timer,true);
physic_init(&pplayer->hphysic);
physic_init(&pplayer->vphysic);
}
if(key == pplayer->keymap.right)
{
pplayer->input.right = state;
- return YES;
+ return true;
}
else if( key == pplayer->keymap.left)
{
pplayer->input.left = state;
- return YES;
+ return true;
}
else if(key == pplayer->keymap.jump)
{
pplayer->input.up = state;
- return YES;
+ return true;
}
else if(key == pplayer->keymap.duck)
{
pplayer->input.down = state;
- return YES;
+ return true;
}
else if(key == pplayer->keymap.fire)
{
pplayer->input.fire = state;
- return YES;
+ return true;
}
else
- return NO;
+ return false;
}
void player_level_begin(player_type* pplayer)
player_input_init(&pplayer->input);
- timer_init(&pplayer->invincible_timer,YES);
- timer_init(&pplayer->skidding_timer,YES);
- timer_init(&pplayer->safe_timer,YES);
- timer_init(&pplayer->frame_timer,YES);
+ timer_init(&pplayer->invincible_timer,true);
+ timer_init(&pplayer->skidding_timer,true);
+ timer_init(&pplayer->safe_timer,true);
+ timer_init(&pplayer->frame_timer,true);
physic_init(&pplayer->hphysic);
physic_init(&pplayer->vphysic);
}
void player_action(player_type* pplayer)
{
- int jumped_in_solid;
- jumped_in_solid = NO;
+ bool jumped_in_solid = false;
/* --- HANDLE TUX! --- */
{
physic_set_state(&pplayer->vphysic,PH_VT);
physic_set_start_vy(&pplayer->vphysic,0);
- jumped_in_solid = YES;
+ jumped_in_solid = true;
}
else
{
score_multiplier = 1;
}
- if(jumped_in_solid == YES)
+ if(jumped_in_solid == true)
{
if (isbrick(pplayer->base.x, pplayer->base.y) ||
add_bouncy_distro((((int)pplayer->base.x)
/ 32) * 32,
((int)pplayer->base.y / 32) * 32);
- if (counting_distros == NO)
+ if (counting_distros == false)
{
- counting_distros = YES;
+ counting_distros = true;
distro_counter = 100;
}
add_bouncy_distro((((int)pplayer->base.x + 31)
/ 32) * 32,
((int)pplayer->base.y / 32) * 32);
- if (counting_distros == NO)
+ if (counting_distros == false)
{
- counting_distros = YES;
+ counting_distros = true;
distro_counter = 100;
}
}
player_grabdistros(pplayer);
- if(jumped_in_solid == YES)
+ if(jumped_in_solid == true)
{
++pplayer->base.y;
++pplayer->old_base.y;
if(player_on_ground(pplayer))
{
/* Make sure jumping is off. */
- pplayer->jumping = NO;
+ pplayer->jumping = false;
}
}
}
-int player_on_ground(player_type *pplayer)
+bool player_on_ground(player_type *pplayer)
{
- if( issolid(pplayer->base.x + pplayer->base.width / 2, pplayer->base.y + pplayer->base.height) ||
- issolid(pplayer->base.x + 1, pplayer->base.y + pplayer->base.height) ||
- issolid(pplayer->base.x + pplayer->base.width - 1, pplayer->base.y + pplayer->base.height) )
- {
- return YES;
- }
- else
- {
- return NO;
- }
+ return ( issolid(pplayer->base.x + pplayer->base.width / 2, pplayer->base.y + pplayer->base.height) ||
+ issolid(pplayer->base.x + 1, pplayer->base.y + pplayer->base.height) ||
+ issolid(pplayer->base.x + pplayer->base.width - 1, pplayer->base.y + pplayer->base.height) );
}
-int player_under_solid(player_type *pplayer)
+bool player_under_solid(player_type *pplayer)
{
- if( issolid(pplayer->base.x + pplayer->base.width / 2, pplayer->base.y) ||
- issolid(pplayer->base.x + 1, pplayer->base.y) ||
- issolid(pplayer->base.x + pplayer->base.width - 1, pplayer->base.y) )
- {
- return YES;
- }
- else
- {
- return NO;
- }
+ return ( issolid(pplayer->base.x + pplayer->base.width / 2, pplayer->base.y) ||
+ issolid(pplayer->base.x + 1, pplayer->base.y) ||
+ issolid(pplayer->base.x + pplayer->base.width - 1, pplayer->base.y) );
}
void player_handle_horizontal_input(player_type *pplayer, int dir)
physic_set_state(&pplayer->vphysic,PH_VT);
physic_set_start_vy(&pplayer->vphysic,5.5);
--pplayer->base.y;
- pplayer->jumping = YES;
+ pplayer->jumping = true;
if (pplayer->size == SMALL)
play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
else
}
}
}
- else if(pplayer->input.up == UP && pplayer->jumping == YES)
+ else if(pplayer->input.up == UP && pplayer->jumping == true)
{
if (player_on_ground(pplayer))
{
physic_init(&pplayer->vphysic);
- pplayer->jumping = NO;
+ pplayer->jumping = false;
}
else
{
- pplayer->jumping = NO;
+ pplayer->jumping = false;
if(physic_is_set(&pplayer->vphysic))
{
if(physic_get_velocity(&pplayer->vphysic) < 0.)
{
/* Handle key and joystick state: */
- if(pplayer->duck == NO)
+ if(pplayer->duck == false)
{
if (pplayer->input.right == DOWN && pplayer->input.left == UP)
{
/* Jump/jumping? */
- if ( pplayer->input.up == DOWN || (pplayer->input.up == UP && pplayer->jumping == YES))
+ if ( pplayer->input.up == DOWN || (pplayer->input.up == UP && pplayer->jumping == true))
{
player_handle_vertical_input(pplayer);
}
if (pplayer->input.down == DOWN)
{
- if (pplayer->size == BIG && pplayer->duck != YES)
+ if (pplayer->size == BIG && pplayer->duck != true)
{
- pplayer->duck = YES;
+ pplayer->duck = true;
pplayer->base.height = 32;
pplayer->base.y += 32;
}
}
else
{
- if (pplayer->size == BIG && pplayer->duck == YES)
+ if (pplayer->size == BIG && pplayer->duck == true)
{
/* Make sure we're not standing back up into a solid! */
pplayer->base.height = 64;
if (!collision_object_map(&pplayer->base) /*issolid(pplayer->base.x + 16, pplayer->base.y - 16)*/)
{
- pplayer->duck = NO;
+ pplayer->duck = false;
pplayer->base.height = 64;
pplayer->old_base.y -= 32;
pplayer->old_base.height = 64;
}
else
{
- pplayer->duck = NO;
+ pplayer->duck = false;
}
}
}
else
{
- pbad_c->dying = FALLING;
+ pbad_c->dying = DYING_FALLING;
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
add_score(pbad_c->base.x - scroll_x,
pbad_c->base.y,
}
else
{
- pbad_c->dying = FALLING;
+ pbad_c->dying = DYING_FALLING;
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
add_score(pbad_c->base.x - scroll_x,
pbad_c->base.y,
if (mode == SHRINK && pplayer->size == BIG)
{
if (pplayer->got_coffee)
- pplayer->got_coffee = NO;
+ pplayer->got_coffee = false;
pplayer->size = SMALL;
pplayer->base.height = 32;
}
else
{
- pplayer->dying = 1;
+ pplayer->dying = DYING_SQUISHED;
}
}
--pplayer->lives;
player_remove_powerups(pplayer);
- pplayer->dying = NO;
+ pplayer->dying = DYING_NOT;
player_level_begin(pplayer);
/* Remove Tux's power ups */
void player_remove_powerups(player_type* pplayer)
{
- pplayer->got_coffee = NO;
+ pplayer->got_coffee = false;
pplayer->size = SMALL;
pplayer->base.height = 32;
}
pplayer->base.x= 0;
else if(pplayer->base.x< scroll_x)
pplayer->base.x= scroll_x;
- else if (pplayer->base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == YES)
+ else if (pplayer->base.x< 160 + scroll_x && scroll_x > 0 && debug_mode == true)
{
scroll_x = pplayer->base.x- 160;
/*pplayer->base.x+= 160;*/
typedef struct player_type
{
- player_input_type input;
- player_keymap_type keymap;
- int score;
- int distros;
- int got_coffee;
- int size;
- int duck;
- int dying;
- int dir;
- int jumping;
- int frame_main;
- int frame;
- int lives;
- base_type base;
- base_type old_base;
- base_type previous_base;
- timer_type invincible_timer;
- timer_type skidding_timer;
- timer_type safe_timer;
- timer_type frame_timer;
- physic_type vphysic;
- physic_type hphysic;
+ player_input_type input;
+ player_keymap_type keymap;
+ int score;
+ int distros;
+ bool got_coffee;
+ int size;
+ bool duck;
+ DyingType dying;
+ int dir;
+ bool jumping;
+ int frame_main;
+ int frame;
+ int lives;
+ base_type base;
+ base_type old_base;
+ base_type previous_base;
+ timer_type invincible_timer;
+ timer_type skidding_timer;
+ timer_type safe_timer;
+ timer_type frame_timer;
+ physic_type vphysic;
+ physic_type hphysic;
}
player_type;
void player_dying(player_type *pplayer);
void player_remove_powerups(player_type *pplayer);
void player_keep_in_bounds(player_type *pplayer);
-int player_on_ground(player_type *pplayer);
-int player_under_solid(player_type *pplayer);
+bool player_on_ground(player_type *pplayer);
+bool player_under_solid(player_type *pplayer);
#endif /*SUPERTUX_PLAYER_H*/
#include <stdlib.h>
#include "scene.h"
-int score, distros, level, next_level, game_pause, quit, score_multiplier, endpos, counting_distros, distro_counter;
+int score;
+int distros;
+int level;
+int next_level;
+int game_pause;
+bool quit;
+int score_multiplier;
+int endpos;
+bool counting_distros;
+int distro_counter;
timer_type super_bkgd_timer;
float scroll_x;
int frame;
scroll_x = 0;
score_multiplier = 1;
- timer_init(&super_bkgd_timer, YES);
+ timer_init(&super_bkgd_timer, true);
- counting_distros = NO;
+ counting_distros = false;
distro_counter = 0;
endpos = 0;
#include "level.h"
#define FRAME_RATE 10 // 100 Frames per second (10ms)
-extern int score, distros, level, next_level, game_pause, quit, score_multiplier, endpos, counting_distros, distro_counter;
+extern int score;
+extern int distros;
+extern int level;
+extern int next_level;
+extern int game_pause;
+extern bool quit;
+extern int score_multiplier;
+extern int endpos;
+extern bool counting_distros;
+extern int distro_counter;
+
extern timer_type super_bkgd_timer;
extern float scroll_x;
extern int frame;
struct stat filestat;
if (stat(filename, &filestat) == -1)
{
- return NO;
+ return false;
}
else
{
if(S_ISREG(filestat.st_mode))
- return YES;
+ return true;
else
- return NO;
+ return false;
}
}
fi = fopen(filename, "wa");
if (fi == NULL)
{
- return NO;
+ return false;
}
- return YES;
+ return true;
}
/* Makes sure a directory is created in either the SuperTux base directory or the SuperTux base directory.*/
snprintf(path, 1024, "%s/%s/", datadir.c_str(), relative_dir);
if(mkdir(path,0755) != 0)
{
- return NO;
+ return false;
}
else
{
- return YES;
+ return true;
}
}
else
{
- return YES;
+ return true;
}
}
menu_additem(&options_menu, MN_LABEL,"Options",0,0);
menu_additem(&options_menu, MN_HL,"",0,0);
menu_additem(&options_menu, MN_TOGGLE,"Fullscreen",use_fullscreen,0);
- if(audio_device == YES)
+ if(audio_device)
{
menu_additem(&options_menu, MN_TOGGLE,"Sound ",use_sound,0);
menu_additem(&options_menu, MN_TOGGLE,"Music ",use_music,0);
default:
if(slot != -1)
{
- if(save == YES)
+ if(save == true)
{
savegame(slot - 1);
}
else
{
- if(game_started == NO)
+ if(game_started == false)
{
gameloop("default",slot - 1,ST_GL_LOAD_GAME);
- show_menu = YES;
+ show_menu = true;
menu_set_current(&main_menu);
}
else
case 4:
if(use_music != options_menu.item[4].toggled)
{
- if(use_music == YES)
+ if(use_music == true)
{
if(playing_music())
{
halt_music();
}
- use_music = NO;
+ use_music = false;
}
else
{
- use_music = YES;
+ use_music = true;
if (!playing_music())
{
play_current_music();
{
SDL_FreeSurface(screen);
- if (use_fullscreen == YES)
+ if (use_fullscreen == true)
{
screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN ) ; /* | SDL_HWSURFACE); */
if (screen == NULL)
"640x480 mode.\n"
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_fullscreen = NO;
+ use_fullscreen = false;
}
}
else
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (use_fullscreen == YES)
+ if (use_fullscreen == true)
{
screen = SDL_SetVideoMode(640, 480, 0, SDL_FULLSCREEN | SDL_OPENGL) ; /* | SDL_HWSURFACE); */
if (screen == NULL)
"640x480 mode.\n"
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_fullscreen = NO;
+ use_fullscreen = false;
}
}
else
/* Init Joystick: */
- use_joystick = YES;
+ use_joystick = true;
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
{
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
- use_joystick = NO;
+ use_joystick = false;
}
else
{
{
fprintf(stderr, "Warning: No joysticks are available.\n");
- use_joystick = NO;
+ use_joystick = false;
}
else
{
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", joystick_num, SDL_GetError());
- use_joystick = NO;
+ use_joystick = false;
}
else
{
fprintf(stderr,
"Warning: Joystick does not have enough axes!\n");
- use_joystick = NO;
+ use_joystick = false;
}
else
{
"Warning: "
"Joystick does not have enough buttons!\n");
- use_joystick = NO;
+ use_joystick = false;
}
}
}
/* Init SDL Audio silently even if --disable-sound : */
- if (audio_device == YES)
+ if (audio_device == true)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if (use_sound == YES || use_music == YES)
+ if (use_sound || use_music)
{
fprintf(stderr,
"\nWarning: I could not initialize audio!\n"
because in this case, use_sound & use_music' values are ignored
when there's no available audio device
*/
- use_sound = NO;
- use_music = NO;
- audio_device = NO;
+ use_sound = false;
+ use_music = false;
+ audio_device = false;
}
}
/* Open sound silently regarless the value of "use_sound": */
- if (audio_device == YES)
+ if (audio_device == true)
{
if (open_audio(44100, AUDIO_S16, 2, 2048) < 0)
{
/* only print out message if sound or music
was not disabled at command-line
*/
- if ((use_sound == YES) || (use_music == YES))
+ if ((use_sound == true) || (use_music == true))
{
fprintf(stderr,
"\nWarning: I could not set up audio for 44100 Hz "
"The Simple DirectMedia error that occured was:\n"
"%s\n\n", SDL_GetError());
}
- use_sound = NO;
- use_music = NO;
- audio_device = NO;
+ use_sound = false;
+ use_music = false;
+ audio_device = false;
}
}
/* Set defaults: */
- debug_mode = NO;
- use_fullscreen = NO;
- show_fps = NO;
- use_gl = NO;
+ debug_mode = false;
+ use_fullscreen = false;
+ show_fps = false;
+ use_gl = false;
- use_sound = YES;
- use_music = YES;
- audio_device = YES;
+ use_sound = true;
+ use_music = true;
+ audio_device = true;
/* Parse arguments: */
{
/* Use full screen: */
- use_fullscreen = YES;
+ use_fullscreen = true;
}
else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0)
{
{
/* Use full screen: */
- show_fps = YES;
+ show_fps = true;
}
else if (strcmp(argv[i], "--opengl") == 0 ||
strcmp(argv[i], "-gl") == 0)
#ifndef NOOPENGL
/* Use OpengGL: */
- use_gl = YES;
+ use_gl = true;
#endif
}
{
/* Disable the compiled in sound feature */
printf("Sounds disabled \n");
- use_sound = NO;
+ use_sound = false;
}
else if (strcmp(argv[i], "--disable-music") == 0)
{
/* Disable the compiled in sound feature */
printf("Music disabled \n");
- use_music = NO;
+ use_music = false;
}
else if (strcmp(argv[i], "--debug-mode") == 0)
{
/* Enable the debug-mode */
- debug_mode = YES;
+ debug_mode = true;
}
else if (strcmp(argv[i], "--help") == 0)
void close_audio( void )
{
- if (audio_device == YES) {
+ if (audio_device) {
Mix_UnregisterAllEffects( SOUND_LEFT_SPEAKER );
Mix_UnregisterAllEffects( SOUND_RIGHT_SPEAKER );
Mix_CloseAudio();
snd = Mix_LoadWAV(file.c_str());
/* printf message and abort if there is an initialized audio device */
- if ((snd == NULL) && (audio_device == YES))
+ if ((snd == NULL) && audio_device)
st_abort("Can't load", file);
return(snd);
sng = Mix_LoadMUS(file.c_str());
/* printf message and abort if there is an initialized audio device */
- if ((sng == NULL) && (audio_device == YES))
+ if ((sng == NULL) && audio_device)
st_abort("Can't load", file);
return (sng);
}
/* this won't call the function if the user has disabled sound
* either via menu or via command-line option
*/
- if ((use_sound == YES) && (audio_device == YES))
+ if ((use_sound == true) && (audio_device == true))
{
Mix_PlayChannel( whichSpeaker, snd, 0);
int playing_music(void)
{
- if (use_music == YES)
+ if (use_music == true)
{
return Mix_PlayingMusic();
}
int halt_music(void)
{
- if ((use_music == YES) && (audio_device == YES))
+ if ((use_music == true) && (audio_device == true))
{
return Mix_HaltMusic();
}
int play_music(Mix_Music *music, int loops)
{
- if ((use_music == YES) && (audio_device == YES))
+ if ((use_music == true) && (audio_device == true))
{
DEBUG_MSG(__PRETTY_FUNCTION__);
return Mix_PlayMusic(music, loops);
{
pplayer->base.height = 32;
pplayer->base.y += 32;
- pplayer->duck = YES;
+ pplayer->duck = true;
}
timer_start(&super_bkgd_timer, 350);
}
else if (pupgrade->kind == UPGRADE_COFFEE)
{
play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
- pplayer->got_coffee = YES;
+ pplayer->got_coffee = true;
timer_start(&super_bkgd_timer, 250);
}
else if (pupgrade->kind == UPGRADE_HERRING)
st_pause_count = 0;
}
-void timer_init(timer_type* ptimer, int st_ticks)
+void timer_init(timer_type* ptimer, bool st_ticks)
{
ptimer->period = 0;
ptimer->time = 0;
- if(st_ticks == YES)
+ if(st_ticks)
ptimer->get_ticks = st_get_ticks;
else
ptimer->get_ticks = SDL_GetTicks;
void timer_stop(timer_type* ptimer)
{
if(ptimer->get_ticks == st_get_ticks)
- timer_init(ptimer,YES);
+ timer_init(ptimer,true);
else
- timer_init(ptimer,NO);
+ timer_init(ptimer,false);
}
int timer_check(timer_type* ptimer)
{
if((ptimer->time != 0) && (ptimer->time + ptimer->period > ptimer->get_ticks()))
- return YES;
+ return true;
else
{
ptimer->time = 0;
- return NO;
+ return false;
}
}
int timer_started(timer_type* ptimer)
{
if(ptimer->time != 0)
- return YES;
+ return true;
else
- return NO;
+ return false;
}
int timer_get_left(timer_type* ptimer)
fwrite(&ptimer->period,sizeof(unsigned int),1,fi);
fwrite(&diff_ticks,sizeof(unsigned int),1,fi);
if(ptimer->get_ticks == st_get_ticks)
- tick_mode = YES;
+ tick_mode = true;
else
- tick_mode = NO;
+ tick_mode = false;
fwrite(&tick_mode,sizeof(unsigned int),1,fi);
}
fread(&ptimer->period,sizeof(unsigned int),1,fi);
fread(&diff_ticks,sizeof(unsigned int),1,fi);
fread(&tick_mode,sizeof(unsigned int),1,fi);
- if(tick_mode == YES)
+ if(tick_mode == true)
ptimer->get_ticks = st_get_ticks;
else
ptimer->get_ticks = SDL_GetTicks;
void st_pause_ticks_init(void);
void st_pause_ticks_start(void);
void st_pause_ticks_stop(void);
-void timer_init(timer_type* ptimer, int st_ticks);
+void timer_init(timer_type* ptimer, bool st_ticks);
void timer_start(timer_type* ptimer, unsigned int period);
void timer_stop(timer_type* ptimer);
/*======================================================================
}
else if(key == SDLK_SPACE || key == SDLK_RETURN)
{
- done = YES;
+ done = true;
quit = gameloop(subset.name.c_str(),1,ST_GL_PLAY);
subset.free();
}
else if(key == SDLK_ESCAPE)
{
- done = YES;
+ done = true;
}
break;
default:
}
break;
case 3:
- update_load_save_game_menu(&load_game_menu, YES);
+ update_load_save_game_menu(&load_game_menu, true);
break;
case 5:
done = 1;
}
else if(current_menu == &load_game_menu)
{
- process_save_load_game_menu(NO);
+ process_save_load_game_menu(false);
}
flipscreen();
pbroken_brick->base.y = y;
pbroken_brick->base.xm = xm;
pbroken_brick->base.ym = ym;
- timer_init(&pbroken_brick->timer,YES);
+ timer_init(&pbroken_brick->timer, true);
timer_start(&pbroken_brick->timer,200);
}
{
pfloating_score->base.x = x;
pfloating_score->base.y = y - 16;
- timer_init(&pfloating_score->timer,YES);
+ timer_init(&pfloating_score->timer,true);
timer_start(&pfloating_score->timer,1000);
pfloating_score->value = s;
}