void le_activate_bad_guys(void);
void le_highlight_selection();
+void apply_level_settings_menu();
/* leveleditor internals */
static char **level_subsets;
static button_type le_test_level_bt;
static button_type le_next_level_bt;
static button_type le_previous_level_bt;
+static button_type le_move_right_bt;
+static button_type le_move_left_bt;
static button_type le_rubber_bt;
static button_type le_select_mode_one_bt;
static button_type le_select_mode_two_bt;
break;
case 4:
break;
- case 11:
- strcpy(le_current_level->name,level_settings_menu.item[1].input);
+ case 13:
+ apply_level_settings_menu();
break;
}
}
le_level = 1;
arrays_init();
loadshared();
- le_current_level = (st_level*) malloc(sizeof(st_level));
+ le_current_level = (st_level*) malloc(sizeof(st_level));
if(level_load(le_current_level, le_level_subset.name, le_level) != 0)
{
le_quit();
break;
}
}
+ else if(current_menu == &subset_new_menu)
+ {
+ if(subset_new_menu.item[2].input[0] == '\0')
+ subset_new_menu.item[3].kind = MN_DEACTIVE;
+ else
+ subset_new_menu.item[3].kind = MN_ACTION;
+
+ /*switch (i = menu_check(&subset_load_menu))
+ {
+ case 0:
+ break;
+ default:
+ if(i != -1)
+ {
+ subset_load(&le_level_subset,level_subsets[i-2]);
+ leveleditor_menu.item[3].kind = MN_GOTO;
+ le_level = 1;
+ arrays_init();
+ loadshared();
+ le_current_level = (st_level*) malloc(sizeof(st_level));
+ if(level_load(le_current_level, le_level_subset.name, le_level) != 0)
+ {
+ le_quit();
+ return 1;
+ }
+ le_set_defaults();
+ level_load_gfx(le_current_level);
+ le_activate_bad_guys();
+ show_menu = YES;
+ }
+ break;
+ }*/
+ }
}
if(done)
level_subsets = dsubdirs("/levels", "info", &subsets_num);
le_show_grid = YES;
-
+
/* 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;
-
+
/*
subset_load(&le_level_subset,"default");
arrays_init();
button_load(&le_select_mode_two_bt,"/images/icons/select-mode2.png","Select Tiles",SDLK_F3,screen->w-32,16);
button_load(&le_test_level_bt,"/images/icons/test-level.png","Test Level",SDLK_F4,screen->w-64,screen->h - 64);
button_load(&le_settings_bt,"/images/icons/settings.png","Level settings",SDLK_0,screen->w-32,screen->h - 64);
+ button_load(&le_move_left_bt,"/images/icons/left.png","Test Level",SDLK_F4,screen->w-64,screen->h - 32);
+ button_load(&le_move_right_bt,"/images/icons/right.png","Level settings",SDLK_0,screen->w-48,screen->h - 32);
button_panel_init(&le_bt_panel, screen->w - 64,64, 64, 380);
menu_init(&leveleditor_menu);
menu_reset();
menu_set_current(&leveleditor_menu);
show_menu = YES;
-
+
menu_init(&subset_load_menu);
menu_additem(&subset_load_menu,menu_item_create(MN_LABEL,"Load Level Subset",0,0));
menu_additem(&subset_load_menu,menu_item_create(MN_HL,"",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_LABEL,"Level Settings",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_HL,"",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Name:",0,0));
- menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Theme:",0,0));
- menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Song:",0,0));
- menu_additem(&level_settings_menu,menu_item_create(MN_TEXTFIELD,"Background:",0,0));
+ menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Theme:",0,0));
+ menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Song:",0,0));
+ menu_additem(&level_settings_menu,menu_item_create(MN_STRINGSELECT,"Background:",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Length: ",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Time: ",0,0));
menu_additem(&level_settings_menu,menu_item_create(MN_NUMFIELD,"Gravity:",0,0));
return 0;
}
-void update_level_settings()
+void update_level_settings_menu()
{
char str[80];
- menu_item_change_input(&level_settings_menu.item[1], le_current_level->name);
+ menu_item_change_input(&level_settings_menu.item[2], le_current_level->name);
sprintf(str,"%d",le_current_level->width);
- menu_item_change_input(&level_settings_menu.item[5], str);
- sprintf(str,"%d",le_current_level->time_left);
menu_item_change_input(&level_settings_menu.item[6], str);
- sprintf(str,"%2.0f",le_current_level->gravity);
+ sprintf(str,"%d",le_current_level->time_left);
menu_item_change_input(&level_settings_menu.item[7], str);
- sprintf(str,"%d",le_current_level->bkgd_red);
+ sprintf(str,"%2.0f",le_current_level->gravity);
menu_item_change_input(&level_settings_menu.item[8], str);
- sprintf(str,"%d",le_current_level->bkgd_green);
+ sprintf(str,"%d",le_current_level->bkgd_red);
menu_item_change_input(&level_settings_menu.item[9], str);
- sprintf(str,"%d",le_current_level->bkgd_blue);
+ sprintf(str,"%d",le_current_level->bkgd_green);
menu_item_change_input(&level_settings_menu.item[10], str);
+ sprintf(str,"%d",le_current_level->bkgd_blue);
+ menu_item_change_input(&level_settings_menu.item[11], str);
+}
+
+void apply_level_settings_menu()
+{
+ int i,y,j;
+ strcpy(le_current_level->name,level_settings_menu.item[2].input);
+
+ i = le_current_level->width;
+ le_current_level->width = atoi(level_settings_menu.item[6].input);
+ if(le_current_level->width < i)
+ {
+ if(le_current_level->width < 21)
+ le_current_level->width = 21;
+ for(y = 0; y < 15; ++y)
+ {
+ le_current_level->tiles[y] = (unsigned char*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned char));
+ le_current_level->tiles[y][le_current_level->width] = (unsigned char) '\0';
+ }
+ }
+ else if(le_current_level->width > i)
+ {
+ for(y = 0; y < 15; ++y)
+ {
+ le_current_level->tiles[y] = (unsigned char*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned char));
+ for(j = 0; j < le_current_level->width - i; ++j)
+ le_current_level->tiles[y][i+j] = (unsigned char) '.';
+ le_current_level->tiles[y][le_current_level->width] = (unsigned char) '\0';
+ }
+ }
+ le_current_level->time_left = atoi(level_settings_menu.item[7].input);
+ le_current_level->gravity = atof(level_settings_menu.item[8].input);
+ le_current_level->bkgd_red = atoi(level_settings_menu.item[9].input);
+ le_current_level->bkgd_green = atoi(level_settings_menu.item[10].input);
+ le_current_level->bkgd_blue = atoi(level_settings_menu.item[11].input);
}
void le_goto_level(int levelnb)
{
+ arrays_free();
+ arrays_init();
level_free(le_current_level);
if(level_load(le_current_level, le_level_subset.name, levelnb) != 0)
button_draw(&le_select_mode_two_bt);
button_draw(&le_bad_bsod_bt);
button_draw(&le_settings_bt);
+ button_draw(&le_move_right_bt);
+ button_draw(&le_move_left_bt);
button_panel_draw(&le_bt_panel);
sprintf(str, "%d/%d", le_level,le_level_subset.levels);
if(le_level > 1)
le_goto_level(--le_level);
}
+ button_event(&le_move_left_bt,&event);
+ if(button_get_state(&le_move_left_bt) == BN_PRESSED)
+ pos_x -= 180;
+ button_event(&le_move_right_bt,&event);
+ if(button_get_state(&le_move_right_bt) == BN_PRESSED)
+ pos_x += 180;
button_event(&le_rubber_bt,&event);
if(button_get_state(&le_rubber_bt) == BN_CLICKED)
le_current_tile = '.';
{
if(show_menu == NO)
{
+ update_level_settings_menu();
menu_set_current(&level_settings_menu);
show_menu = YES;
}
int menuaction;
int show_menu;
int menu_change;
-texture_type checkbox, checkbox_checked, back;
+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;
menu_type* current_menu, * last_menu;
else
pmenu->active_item = 0;
break;
+ case MN_LEFT:
+ if(pmenu->item[pmenu->active_item].kind == MN_STRINGSELECT)
+ {}
+ case MN_RIGHT:
+ if(pmenu->item[pmenu->active_item].kind == MN_STRINGSELECT)
+ {}
case MN_HIT:
if(pmenu->item[pmenu->active_item].kind == MN_GOTO && pmenu->item[pmenu->active_item].target_menu != NULL)
menu_set_current((menu_type*)pmenu->item[pmenu->active_item].target_menu);
fillrect(screen->w/2 - menu_width/2,screen->h/2-(((pmenu->num_items)*24)/2),menu_width,menu_height,150,150,150,100);
if(timer_check(&pmenu->effect))
- {
- e = timer_get_left(&pmenu->effect) / 4;
- }
+ {
+ e = timer_get_left(&pmenu->effect) / 4;
+ }
else
- {
- e = 0;
- }
-
+ {
+ e = 0;
+ }
+
for(i = 0; i < pmenu->num_items; ++i)
{
if(pmenu->arrange_left == YES)
b = (a - ((strlen(pmenu->item[i].text)+strlen(pmenu->item[i].input)) * 16)) / 2;
else
b = 0;
-
- if(e != 0)
- {
- if(i % 2)
- f = e;
- else
- f = -e;
- }
- else
- f = 0;
-
+
+ if(e != 0)
+ {
+ if(i % 2)
+ f = e;
+ else
+ f = -e;
+ }
+ else
+ f = 0;
+
if(pmenu->item[i].kind == MN_DEACTIVE)
{
text_drawf(&black_text,pmenu->item[i].text, - b,(i)*24 - menu_height/2 + 10 + f,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
}
else if(pmenu->item[i].kind == MN_LABEL)
{
- text_drawf(&gold_text,pmenu->item[i].text, - b,(i)*24 - menu_height/2 + 10,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
+ text_drawf(&white_big_text,pmenu->item[i].text, - b,(i)*24 - menu_height/2 + 10,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
}
else if(pmenu->item[i].kind == MN_TEXTFIELD || pmenu->item[i].kind == MN_NUMFIELD)
{
+ fillrect(-b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2 - 1,(i)*24 - menu_height/2 + 10 + screen->h /2 - 10 + f,(strlen(pmenu->item[i].input)+1)*16 + 2,20,255,255,255,255);
+ fillrect(- b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2,(i)*24 - menu_height/2 + 10 + screen->h /2 - 9 + f,(strlen(pmenu->item[i].input)+1)*16,18,0,0,0,128);
+ text_drawf(&gold_text,pmenu->item[i].input, - b + ((strlen(pmenu->item[i].text)+1) * 16)/2,(i)*24 - menu_height/2 + 10 + f,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
+ if(i == pmenu->active_item)
+ {
+ text_drawf(&blue_text,pmenu->item[i].text, - b -(((strlen(pmenu->item[i].input)+1) * 16)/2),(i)*24 - menu_height/2 + 10 + f,A_HMIDDLE, A_VMIDDLE,3,NO_UPDATE);
+ }
+ else
+ {
+ text_drawf(&white_text,pmenu->item[i].text, - b -(((strlen(pmenu->item[i].input)+1) * 16)/2),(i)*24 - menu_height/2 +10 + f,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
+ }
+ }
+ else if(pmenu->item[i].kind == MN_STRINGSELECT)
+ {
+ /* Draw arrows */
+ texture_draw(&arrow_left,-b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2 - 17,(i)*24 - menu_height/2 + 10 + screen->h / 2 -8 + f,NO_UPDATE);
+ texture_draw(&arrow_right,-b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2 - 1 + (strlen(pmenu->item[i].input)+1)*16,(i)*24 - menu_height/2 + 10 + screen->h / 2 -8 + f,NO_UPDATE);
+ /* Draw input background */
+ fillrect(-b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2 - 1,(i)*24 - menu_height/2 + 10 + screen->h /2 - 10 + f,(strlen(pmenu->item[i].input)+1)*16 + 2,20,255,255,255,255);
+ fillrect(- b +screen->w/2 - ((strlen(pmenu->item[i].input)*16)/2) + ((strlen(pmenu->item[i].text) + 1)*16)/2,(i)*24 - menu_height/2 + 10 + screen->h /2 - 9 + f,(strlen(pmenu->item[i].input)+1)*16,18,0,0,0,128);
+
text_drawf(&gold_text,pmenu->item[i].input, - b + ((strlen(pmenu->item[i].text)+1) * 16)/2,(i)*24 - menu_height/2 + 10 + f,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
if(i == pmenu->active_item)
{
menuaction = MN_DOWN;
menu_change = YES;
break;
+ case SDLK_LEFT: /* Menu Up */
+ menuaction = MN_LEFT;
+ menu_change = YES;
+ break;
+ case SDLK_RIGHT: /* Menu Down */
+ menuaction = MN_RIGHT;
+ menu_change = YES;
+ break;
case SDLK_RETURN: /* Menu Hit */
menuaction = MN_HIT;
menu_change = YES;
timer_init(&pplayer->invincible_timer,YES);
timer_init(&pplayer->skidding_timer,YES);
timer_init(&pplayer->safe_timer,YES);
+ timer_init(&pplayer->frame_timer,YES);
physic_init(&pplayer->hphysic);
physic_init(&pplayer->vphysic);
}
}
else
{
- /* Land: */
+ /* Land: */
if (pplayer->base.ym > 0)
{
physic_init(&pplayer->vphysic);
}
- while(issolid( pplayer->base.x + 16, pplayer->base.y + pplayer->base.height) && !issolid( pplayer->base.x + 16, pplayer->base.y))
+ while(issolid( pplayer->base.x + 16, pplayer->base.y + pplayer->base.height) && !issolid( pplayer->base.x + 16, pplayer->base.y + 1))
{
--pplayer->base.y;
}
--pplayer->base.x;
}
- if(pplayer->base.ym <= 0)
+ if(pplayer->base.ym < 0)
{
if (isbrick(pplayer->base.x, pplayer->base.y) ||
distros++;
}
}
- }
+ }
- player_grabdistros(pplayer);
+ player_grabdistros(pplayer);
- /* FIXME: this code is COMPLETLY broken!!! */
- /* if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
- !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y + 31))
+ /* FIXME: this code is COMPLETLY broken!!! */
+ /* if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
+ !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y + 31))
+ {
+ while (issolid(pplayer->base.x, pplayer->base.y + 31))
{
- while (issolid(pplayer->base.x, pplayer->base.y + 31))
- {
- if (pplayer->base.xm < 0)
- pplayer->base.x++;
- else if (pplayer->base.xm > 0)
- pplayer->base.x--;
- }
-
- pplayer->base.xm = 0;
- }*/
-
- /*if (issolid(pplayer->base.x, pplayer->base.y) &&
- !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y))
- {
- while (issolid(pplayer->base.x, (pplayer->base.y)))
- {
- if (pplayer->base.xm < 0)
- pplayer->base.x++;
- else if (pplayer->base.xm > 0)
- pplayer->base.x--;
- }
+ if (pplayer->base.xm < 0)
+ pplayer->base.x++;
+ else if (pplayer->base.xm > 0)
+ pplayer->base.x--;
+ }
- pplayer->base.xm = 0;
- }*/
+ pplayer->base.xm = 0;
+ }*/
- /*if (issolid(pplayer->base.x, pplayer->base.y + 31))
+ /*if (issolid(pplayer->base.x, pplayer->base.y) &&
+ !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y))
+ {
+ while (issolid(pplayer->base.x, (pplayer->base.y)))
{
- /* Set down properly: * /
+ if (pplayer->base.xm < 0)
+ pplayer->base.x++;
+ else if (pplayer->base.xm > 0)
+ pplayer->base.x--;
+ }
+
+ pplayer->base.xm = 0;
+ }*/
- int debug_int = 0;
- while (issolid(pplayer->base.x, pplayer->base.y + 31))
+ /*if (issolid(pplayer->base.x, pplayer->base.y + 31))
+ {
+ /* Set down properly: * /
+
+ int debug_int = 0;
+ while (issolid(pplayer->base.x, pplayer->base.y + 31))
+ {
+ ++debug_int;
+ if(debug_int > 32)
{
- ++debug_int;
- if(debug_int > 32)
- {
- DEBUG_MSG("FIXME - UNDER certain circumstances I'm hanging in a loop here!");
- /*the circumstances are:
- issolid() is true and base.ym == 0
- use of floating point varibles for base stuff* /
- break;
- }
- if (pplayer->base.ym < 0)
- pplayer->base.y++;
- else if (pplayer->base.ym > 0)
- pplayer->base.y--;
+ DEBUG_MSG("FIXME - UNDER certain circumstances I'm hanging in a loop here!");
+ /*the circumstances are:
+ issolid() is true and base.ym == 0
+ use of floating point varibles for base stuff* /
+ break;
}
+ if (pplayer->base.ym < 0)
+ pplayer->base.y++;
+ else if (pplayer->base.ym > 0)
+ pplayer->base.y--;
+ }
- /* Reset score multiplier (for multi-hits): */
+ /* Reset score multiplier (for multi-hits): */
- if (pplayer->base.ym > 0)
- score_multiplier = 1;
+ if (pplayer->base.ym > 2)
+ score_multiplier = 1;
- /* Stop jumping! * /
+ /* Stop jumping! * /
+ pplayer->base.ym = 0;
+ pplayer->jumping = NO;
+ pplayer->input.up = UP;
+ }
+ /* FIXME: this code is COMPLETLY broken!!! */
+ /*if (issolid(pplayer->base.x, pplayer->base.y) ||
+ (pplayer->size == BIG && !pplayer->duck &&
+ (issolid(pplayer->base.x, pplayer->base.y - 32))))
+ {*/
+ /*if (!issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y) &&
+ (pplayer->size == SMALL || pplayer->duck ||
+ !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32)))* /
+
+ if (((!issolid(pplayer->base.x, pplayer->base.y- pplayer->base.ym * frame_ratio) && (issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x, pplayer->base.y+31))))
+ ||((!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y) && (issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y)))))
+ /*(pplayer->size == SMALL || pplayer->duck ||
+ !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))* /
+ {
+ pplayer->base.y = pplayer->base.y- pplayer->base.ym * frame_ratio;
pplayer->base.ym = 0;
- pplayer->jumping = NO;
- pplayer->input.up = UP;
- }
- /* FIXME: this code is COMPLETLY broken!!! */
- /*if (issolid(pplayer->base.x, pplayer->base.y) ||
- (pplayer->size == BIG && !pplayer->duck &&
- (issolid(pplayer->base.x, pplayer->base.y - 32))))
- {*/
- /*if (!issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y) &&
- (pplayer->size == SMALL || pplayer->duck ||
- !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32)))* /
+ }
+
+ if (((issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y)) && (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y))
+ /*(pplayer->size == SMALL || pplayer->duck ||
+ !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))* /) ||
+ (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y+pplayer->base.height) && (issolid(pplayer->base.x, pplayer->base.y+pplayer->base.height) || issolid(pplayer->base.x +32, pplayer->base.y+pplayer->base.height))))
+ {
+ pplayer->base.x = pplayer->base.x- pplayer->base.xm * frame_ratio;
+ pplayer->base.xm = 0;
+ }
- if (((!issolid(pplayer->base.x, pplayer->base.y- pplayer->base.ym * frame_ratio) && (issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x, pplayer->base.y+31))))
- ||((!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y) && (issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y)))))
- /*(pplayer->size == SMALL || pplayer->duck ||
- !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))* /
+ if (pplayer->base.ym <= 0)
{
- pplayer->base.y = pplayer->base.y- pplayer->base.ym * frame_ratio;
- pplayer->base.ym = 0;
+ if (isbrick(pplayer->base.x, pplayer->base.y) ||
+ isfullbox(pplayer->base.x, pplayer->base.y))
+ {
+ trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
+ trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
+ bumpbrick(pplayer->base.x, pplayer->base.y);
+ tryemptybox(pplayer->base.x, pplayer->base.y);
+ }
+
+ if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
+ isfullbox(pplayer->base.x+ 31, pplayer->base.y))
+ {
+ trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32,BOUNCE);
+ trybumpbadguy(pplayer->base.x+ 31, pplayer->base.y - 64);
+ bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
+ tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
+ }
+ /* Get a distro from a brick? * /
+
+ if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
+ shape(pplayer->base.x, pplayer->base.y) == 'y')
+ {
+ add_bouncy_distro(((pplayer->base.x+ 1)
+ / 32) * 32,
+ (int)(pplayer->base.y / 32) * 32);
+
+ if (counting_distros == NO)
+ {
+ counting_distros = YES;
+ distro_counter = 100;
}
- if (((issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y)) && (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y))
- /*(pplayer->size == SMALL || pplayer->duck ||
- !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))* /) ||
- (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y+pplayer->base.height) && (issolid(pplayer->base.x, pplayer->base.y+pplayer->base.height) || issolid(pplayer->base.x +32, pplayer->base.y+pplayer->base.height))))
+ if (distro_counter <= 0)
+ level_change(¤t_level,pplayer->base.x,pplayer->base.y, 'a');
+
+ play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
+ score = score + SCORE_DISTRO;
+ distros++;
+ }
+ else if (shape(pplayer->base.x+ 31, pplayer->base.y) == 'x' ||
+ shape(pplayer->base.x+ 31, pplayer->base.y) == 'y')
+ {
+ add_bouncy_distro(((pplayer->base.x+ 1 + 31)
+ / 32) * 32,
+ (int)(pplayer->base.y / 32) * 32);
+
+ if (counting_distros == NO)
{
- pplayer->base.x = pplayer->base.x- pplayer->base.xm * frame_ratio;
- pplayer->base.xm = 0;
+ counting_distros = YES;
+ distro_counter = 100;
}
+ if (distro_counter <= 0)
+ level_change(¤t_level,pplayer->base.x+ 31, pplayer->base.y, 'a');
+
+ play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
+ score = score + SCORE_DISTRO;
+ distros++;
+ }
+
+ }
+ else
+ {
+ pplayer->base.ym = 0;
+ pplayer->jumping = NO;
+ timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
+ }
+ /*}*/
+ /* Bump into things: * /
+
+ if (issolid(pplayer->base.x, pplayer->base.y) ||
+ (pplayer->size == BIG && !pplayer->duck &&
+ (issolid(pplayer->base.x, pplayer->base.y - 32))))
+ {
+
+ if (!issolid(pplayer->base.x, pplayer->base.y - pplayer->base.ym) &&
+ (pplayer->size == SMALL || pplayer->duck ||
+ !issolid(pplayer->base.x, pplayer->base.y - 32 - pplayer->base.ym)))
+ {
if (pplayer->base.ym <= 0)
{
+ /* Jumping up? */
+ /* FIXME: this code is COMPLETLY broken!!! */
+ if (pplayer->size == BIG)
+ {
+ /* Break bricks and empty boxes: * /
+
+ if (!pplayer->duck)
+ {
+ if (isbrick(pplayer->base.x, pplayer->base.y - 32) ||
+ isfullbox(pplayer->base.x, pplayer->base.y - 32))
+ {
+ trygrabdistro(pplayer->base.x, pplayer->base.y - 64, BOUNCE);
+ trybumpbadguy(pplayer->base.x, pplayer->base.y - 96);
+
+ if (isfullbox(pplayer->base.x, pplayer->base.y - 32))
+ {
+ bumpbrick(pplayer->base.x, pplayer->base.y - 32);
+ }
+
+ trybreakbrick(pplayer->base.x, pplayer->base.y - 32);
+ tryemptybox(pplayer->base.x, pplayer->base.y - 32);
+ }
+
+ if (isbrick(pplayer->base.x+ 31, pplayer->base.y - 32) ||
+ isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
+ {
+ trygrabdistro(pplayer->base.x+ 31,
+ pplayer->base.y - 64,
+ BOUNCE);
+ trybumpbadguy(pplayer->base.x+ 31,
+ pplayer->base.y - 96);
+
+ if (isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
+ {
+ bumpbrick(pplayer->base.x+ 31, pplayer->base.y - 32);
+ }
+
+ trybreakbrick(pplayer->base.x+ 31,
+ pplayer->base.y - 32);
+ tryemptybox(pplayer->base.x+ 31,
+ pplayer->base.y - 32);
+ }
+ }
+ else /* ducking * /
+ {
+ if (isbrick(pplayer->base.x, pplayer->base.y) ||
+ isfullbox(pplayer->base.x, pplayer->base.y))
+ {
+ trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
+ trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
+ if (isfullbox(pplayer->base.x, pplayer->base.y))
+ bumpbrick(pplayer->base.x, pplayer->base.y);
+ trybreakbrick(pplayer->base.x, pplayer->base.y);
+ tryemptybox(pplayer->base.x, pplayer->base.y);
+ }
+
+ if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
+ isfullbox(pplayer->base.x+ 31, pplayer->base.y))
+ {
+ trygrabdistro(pplayer->base.x+ 31,
+ pplayer->base.y - 32,
+ BOUNCE);
+ trybumpbadguy(pplayer->base.x+ 31,
+ pplayer->base.y - 64);
+ if (isfullbox(pplayer->base.x+ 31, pplayer->base.y))
+ bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
+ trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
+ tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
+ }
+ }
+ }
+ else
+ {
+ /* It's a brick and we're small, make the brick
+ bounce, and grab any distros above it: * /
+
if (isbrick(pplayer->base.x, pplayer->base.y) ||
isfullbox(pplayer->base.x, pplayer->base.y))
{
bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
}
+
+
/* Get a distro from a brick? * /
if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
score = score + SCORE_DISTRO;
distros++;
}
+ }
+
+ /* Bump head: * /
+
+ pplayer->base.y = (int)(pplayer->base.y / 32) * 32 + 30;
}
else
{
+ /* Land on feet: * /
+
+ pplayer->base.y = (int)(pplayer->base.y / 32) * 32 - 32;
+ }
+
pplayer->base.ym = 0;
pplayer->jumping = NO;
timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
- }
- /*}*/
- /* Bump into things: * /
-
- if (issolid(pplayer->base.x, pplayer->base.y) ||
- (pplayer->size == BIG && !pplayer->duck &&
- (issolid(pplayer->base.x, pplayer->base.y - 32))))
- {
-
- if (!issolid(pplayer->base.x, pplayer->base.y - pplayer->base.ym) &&
- (pplayer->size == SMALL || pplayer->duck ||
- !issolid(pplayer->base.x, pplayer->base.y - 32 - pplayer->base.ym)))
- {
- if (pplayer->base.ym <= 0)
- {
- /* Jumping up? */
- /* FIXME: this code is COMPLETLY broken!!! */
- if (pplayer->size == BIG)
- {
- /* Break bricks and empty boxes: * /
-
- if (!pplayer->duck)
- {
- if (isbrick(pplayer->base.x, pplayer->base.y - 32) ||
- isfullbox(pplayer->base.x, pplayer->base.y - 32))
- {
- trygrabdistro(pplayer->base.x, pplayer->base.y - 64, BOUNCE);
- trybumpbadguy(pplayer->base.x, pplayer->base.y - 96);
-
- if (isfullbox(pplayer->base.x, pplayer->base.y - 32))
- {
- bumpbrick(pplayer->base.x, pplayer->base.y - 32);
- }
-
- trybreakbrick(pplayer->base.x, pplayer->base.y - 32);
- tryemptybox(pplayer->base.x, pplayer->base.y - 32);
- }
-
- if (isbrick(pplayer->base.x+ 31, pplayer->base.y - 32) ||
- isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
- {
- trygrabdistro(pplayer->base.x+ 31,
- pplayer->base.y - 64,
- BOUNCE);
- trybumpbadguy(pplayer->base.x+ 31,
- pplayer->base.y - 96);
-
- if (isfullbox(pplayer->base.x+ 31, pplayer->base.y - 32))
- {
- bumpbrick(pplayer->base.x+ 31, pplayer->base.y - 32);
- }
-
- trybreakbrick(pplayer->base.x+ 31,
- pplayer->base.y - 32);
- tryemptybox(pplayer->base.x+ 31,
- pplayer->base.y - 32);
- }
- }
- else /* ducking * /
- {
- if (isbrick(pplayer->base.x, pplayer->base.y) ||
- isfullbox(pplayer->base.x, pplayer->base.y))
- {
- trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
- trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
- if (isfullbox(pplayer->base.x, pplayer->base.y))
- bumpbrick(pplayer->base.x, pplayer->base.y);
- trybreakbrick(pplayer->base.x, pplayer->base.y);
- tryemptybox(pplayer->base.x, pplayer->base.y);
- }
-
- if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
- isfullbox(pplayer->base.x+ 31, pplayer->base.y))
- {
- trygrabdistro(pplayer->base.x+ 31,
- pplayer->base.y - 32,
- BOUNCE);
- trybumpbadguy(pplayer->base.x+ 31,
- pplayer->base.y - 64);
- if (isfullbox(pplayer->base.x+ 31, pplayer->base.y))
- bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
- trybreakbrick(pplayer->base.x+ 31, pplayer->base.y);
- tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
- }
- }
- }
- else
- {
- /* It's a brick and we're small, make the brick
- bounce, and grab any distros above it: * /
-
- if (isbrick(pplayer->base.x, pplayer->base.y) ||
- isfullbox(pplayer->base.x, pplayer->base.y))
- {
- trygrabdistro(pplayer->base.x, pplayer->base.y - 32,BOUNCE);
- trybumpbadguy(pplayer->base.x, pplayer->base.y - 64);
- bumpbrick(pplayer->base.x, pplayer->base.y);
- tryemptybox(pplayer->base.x, pplayer->base.y);
- }
-
- if (isbrick(pplayer->base.x+ 31, pplayer->base.y) ||
- isfullbox(pplayer->base.x+ 31, pplayer->base.y))
- {
- trygrabdistro(pplayer->base.x+ 31, pplayer->base.y - 32,BOUNCE);
- trybumpbadguy(pplayer->base.x+ 31, pplayer->base.y - 64);
- bumpbrick(pplayer->base.x+ 31, pplayer->base.y);
- tryemptybox(pplayer->base.x+ 31, pplayer->base.y);
- }
-
-
- /* Get a distro from a brick? * /
-
- if (shape(pplayer->base.x, pplayer->base.y) == 'x' ||
- shape(pplayer->base.x, pplayer->base.y) == 'y')
- {
- add_bouncy_distro(((pplayer->base.x+ 1)
- / 32) * 32,
- (int)(pplayer->base.y / 32) * 32);
-
- if (counting_distros == NO)
- {
- counting_distros = YES;
- distro_counter = 100;
- }
-
- if (distro_counter <= 0)
- level_change(¤t_level,pplayer->base.x,pplayer->base.y, 'a');
-
- play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
- score = score + SCORE_DISTRO;
- distros++;
- }
- else if (shape(pplayer->base.x+ 31, pplayer->base.y) == 'x' ||
- shape(pplayer->base.x+ 31, pplayer->base.y) == 'y')
- {
- add_bouncy_distro(((pplayer->base.x+ 1 + 31)
- / 32) * 32,
- (int)(pplayer->base.y / 32) * 32);
-
- if (counting_distros == NO)
- {
- counting_distros = YES;
- distro_counter = 100;
- }
-
- if (distro_counter <= 0)
- level_change(¤t_level,pplayer->base.x+ 31, pplayer->base.y, 'a');
-
- play_sound(sounds[SND_DISTRO], SOUND_CENTER_SPEAKER);
- score = score + SCORE_DISTRO;
- distros++;
- }
- }
-
-
- /* Bump head: * /
-
- pplayer->base.y = (int)(pplayer->base.y / 32) * 32 + 30;
- }
- else
- {
- /* Land on feet: * /
-
- pplayer->base.y = (int)(pplayer->base.y / 32) * 32 - 32;
- }
-
- pplayer->base.ym = 0;
- pplayer->jumping = NO;
- timer_start(&pplayer->jump_timer,MAX_JUMP_TIME);
- }*/
- }
+ }*/
+ }
}
}
else if(pplayer->input.up == UP && pplayer->jumping == YES)
{
- /* Land: * /
- DEBUG_MSG("Stop Jump");
- pplayer->jumping = NO;
-
- if (pplayer->base.ym > 0)
- {
- pplayer->base.y = (int)(pplayer->base.y / 32) * 32;
- pplayer->base.ym = 0;
- }
- physic_init(&pplayer->vphysic);
- }
- else if(pplayer->input.up == UP)
- {*/
if (issolid(pplayer->base.x + 16, pplayer->base.y + pplayer->base.height + 1))
{
physic_init(&pplayer->vphysic);
else
{
pplayer->jumping = NO;
- printf("%f",physic_get_velocity(&pplayer->vphysic));
if(physic_is_set(&pplayer->vphysic))
{
- if(physic_get_velocity(&pplayer->vphysic) < 0.)
- {
- physic_set_state(&pplayer->vphysic,PH_VT);
- physic_set_start_vy(&pplayer->vphysic,0);
- }
+ if(physic_get_velocity(&pplayer->vphysic) < 0.)
+ {
+ physic_set_state(&pplayer->vphysic,PH_VT);
+ physic_set_start_vy(&pplayer->vphysic,0);
+ }
}
else
{
/* (Tux): */
- if (pplayer->input.right == UP && pplayer->input.left == UP)
- {
- pplayer->frame_main = 1;
- pplayer->frame = 1;
- }
- else
+ if(!timer_check(&pplayer->frame_timer))
{
- if ((pplayer->input.fire == DOWN && (frame % 2) == 0) ||
- (frame % 4) == 0)
- pplayer->frame_main = (pplayer->frame_main + 1) % 4;
+ timer_start(&pplayer->frame_timer,25);
+ if (pplayer->input.right == UP && pplayer->input.left == UP)
+ {
+ pplayer->frame_main = 1;
+ pplayer->frame = 1;
+ }
+ else
+ {
+ if ((pplayer->input.fire == DOWN && (frame % 2) == 0) ||
+ (frame % 4) == 0)
+ pplayer->frame_main = (pplayer->frame_main + 1) % 4;
- pplayer->frame = pplayer->frame_main;
+ pplayer->frame = pplayer->frame_main;
- if (pplayer->frame == 3)
- pplayer->frame = 1;
+ if (pplayer->frame == 3)
+ pplayer->frame = 1;
+ }
}
}
else
{
pbad_c->dying = FALLING;
- pbad_c->base.ym = -8;
+ physic_set_state(&pplayer->vphysic,PH_VT);
+ physic_set_start_vy(&pplayer->vphysic,-2.);
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
}
}
else
{
pbad_c->dying = FALLING;
- pbad_c->base.ym = -8;
+ physic_set_state(&pplayer->vphysic,PH_VT);
+ physic_set_start_vy(&pplayer->vphysic,-2.);
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
}
}