[Super-tux-commit] supertux/src sector.h,1.16,1.17 sector.cpp,1.32,1.33 badguy.cpp,1.130,1.131 level
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-10-21 18:03:34
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29460/src Modified Files: sector.h sector.cpp badguy.cpp leveleditor.cpp Log Message: Badguys from the start of the level were not appearing. Fixed. Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.130 retrieving revision 1.131 diff -u -d -r1.130 -r1.131 --- badguy.cpp 19 Oct 2004 17:54:24 -0000 1.130 +++ badguy.cpp 21 Oct 2004 18:03:22 -0000 1.131 @@ -161,8 +161,8 @@ { base.x = 0; base.y = 0; - base.width = 0; - base.height = 0; + base.width = 32; + base.height = 32; mode = NORMAL; dying = DYING_NOT; @@ -188,20 +188,6 @@ while(collision_object_map(base)) --base.y; } - - if(Sector::current()->camera) { - Vector scroll = Sector::current()->camera->get_translation(); - - if(start_position.x > scroll.x - X_OFFSCREEN_DISTANCE && - start_position.x < scroll.x + screen->w + X_OFFSCREEN_DISTANCE && - start_position.y > scroll.y - Y_OFFSCREEN_DISTANCE && - start_position.y < scroll.y + screen->h + Y_OFFSCREEN_DISTANCE) { - activate(LEFT); - } - } } else { - if(start_position.x >= 0 && start_position.x < screen->w - && start_position.y >= 0 && start_position.y < screen->h) - activate(LEFT); } } @@ -229,7 +215,7 @@ dir = activation_dir; float dirsign = activation_dir == LEFT ? -1 : 1; - + set_action("left", "right"); if(kind == BAD_MRBOMB) { physic.set_velocity(dirsign * BADGUY_WALK_SPEED, 0); @@ -772,14 +758,6 @@ check_horizontal_bump(); fall(); -#if 0 - // jump when we're about to fall - if (physic.get_velocity_y() == 0 && - !issolid(base.x+base.width/2, base.y + base.height)) { - physic.enable_gravity(true); - physic.set_velocity_y(2); - } -#endif physic.apply(elapsed_time, base.x, base.y, Sector::current()->gravity); if (dying != DYING_FALLING) @@ -794,6 +772,13 @@ fall(); + // jump when we're about to fall + if (physic.get_velocity_y() == 0 && + !issolid(base.x+base.width/2, base.y + base.height)) { + physic.enable_gravity(true); + physic.set_velocity_y(2); + } + physic.apply(elapsed_time, base.x, base.y, Sector::current()->gravity); if (dying != DYING_FALLING) collision_swept_object_map(&old_base,&base); @@ -876,37 +861,44 @@ kill_me(0); } - if(!seen) { - /* activate badguys if they're just inside the offscreen_distance around the - * screen. Don't activate them inside the screen, since that might have the - * effect of badguys suddenly popping up from nowhere + if(!seen) + { + /* Activate badguys if they're just around the screen to avoid + * the effect of having badguys suddenly popping up from nowhere. */ if (start_position.x > scroll_x - X_OFFSCREEN_DISTANCE && - start_position.x < scroll_x - base.width) + start_position.x < scroll_x - base.width && + start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) activate(RIGHT); - else if(start_position.x > scroll_y - Y_OFFSCREEN_DISTANCE && - start_position.y < scroll_y - base.height) - activate(LEFT); - else if(start_position.x > scroll_x + screen->w && - start_position.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE) + else if (start_position.x > scroll_x + screen->w && + start_position.x < scroll_x + screen->w + X_OFFSCREEN_DISTANCE && + start_position.y > scroll_y - Y_OFFSCREEN_DISTANCE && + start_position.y < scroll_y + Y_OFFSCREEN_DISTANCE) activate(LEFT); - else if(start_position.y > scroll_y + screen->h && - start_position.y < scroll_y + screen->h + Y_OFFSCREEN_DISTANCE) + /* Special case for badguys on start of the level. + * If in the future, it's possible to set Tux start pos, this case + * should contemplate that. */ + else if (start_position.x > 0 && start_position.x < screen->w && + start_position.y > 0 && start_position.y < screen->h) activate(LEFT); - } else { + } + else + { if(base.x + base.width < scroll_x - X_OFFSCREEN_DISTANCE*4 || base.x > scroll_x + screen->w + X_OFFSCREEN_DISTANCE*4 || base.y + base.height < scroll_y - Y_OFFSCREEN_DISTANCE*4 - || base.y > scroll_y + screen->h + Y_OFFSCREEN_DISTANCE*4) { + || base.y > scroll_y + screen->h + Y_OFFSCREEN_DISTANCE*4) + { seen = false; if(dying != DYING_NOT) remove_me(); + } } - } - + if(!seen) return; - + switch (kind) { case BAD_MRICEBLOCK: @@ -1007,7 +999,7 @@ else { // FIXME: Using the image size for the physics and collision is - // a bad idea, since images should always overlap there physical + // a bad idea, since images should always overlap their physical // representation if(left != 0) { if(base.width == 0 && base.height == 0) { @@ -1205,7 +1197,7 @@ void BadGuy::explode(bool right_way) { - BadGuy *badguy = Sector::current()->add_bad_guy(base.x, base.y, BAD_BOMB); + BadGuy *badguy = Sector::current()->add_bad_guy(base.x, base.y, BAD_BOMB, true); if(right_way) { badguy->timer.start(0); Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- sector.h 23 Sep 2004 17:47:46 -0000 1.16 +++ sector.h 21 Oct 2004 18:03:22 -0000 1.17 @@ -107,7 +107,7 @@ const Vector& movement, Tile* tile); void add_bouncy_brick(const Vector& pos); - BadGuy* add_bad_guy(float x, float y, BadGuyKind kind); + BadGuy* add_bad_guy(float x, float y, BadGuyKind kind, bool activate); void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind); bool add_bullet(const Vector& pos, float xm, Direction dir); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- sector.cpp 23 Sep 2004 17:47:49 -0000 1.32 +++ sector.cpp 21 Oct 2004 18:03:22 -0000 1.33 @@ -701,10 +701,12 @@ } BadGuy* -Sector::add_bad_guy(float x, float y, BadGuyKind kind) +Sector::add_bad_guy(float x, float y, BadGuyKind kind, bool activate) { BadGuy* badguy = new BadGuy(kind, x, y); add_object(badguy); + if(activate) + badguy->activate(LEFT); return badguy; } Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.160 retrieving revision 1.161 diff -u -d -r1.160 -r1.161 --- leveleditor.cpp 19 Oct 2004 16:27:50 -0000 1.160 +++ leveleditor.cpp 21 Oct 2004 18:03:23 -0000 1.161 @@ -132,7 +132,7 @@ BadGuyKind kind = BadGuyKind(i); BadGuy badguy(kind, 0,0); -// badguy.activate(LEFT); + badguy.activate(LEFT); Surface *img = badguy.get_image(); tiles_board->add_button(Button(img, "", SDLKey(SDLK_1+i)), -(i+1)); @@ -623,7 +623,7 @@ { BadGuyKind kind = BadGuyKind((-id)-1); BadGuy badguy(kind, 0,0); -// badguy.activate(LEFT); + badguy.activate(LEFT); Surface *img = badguy.get_image(); context.draw_surface(img, Vector(event.button.x - 8, @@ -786,8 +786,8 @@ for(Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); i++) { BadGuy* badguy = dynamic_cast<BadGuy*> (*i); -// if(badguy) -// badguy->activate(LEFT); + if(badguy) + badguy->activate(LEFT); TileMap* tilemap = dynamic_cast<TileMap*> (*i); if(tilemap) @@ -869,7 +869,7 @@ else if(newtile == OBJ_DOOR) sector->add_object(new Door(x, y)); else - sector->add_object(new BadGuy(BadGuyKind((-newtile)-1), x, y)); + sector->add_bad_guy(x, y, BadGuyKind((-newtile)-1), true); sector->update_game_objects(); } |