<MatzeB> it also removes the code for the bsod badguy, since that was a duplication of the snowball code anyway
SVN-Revision: 814
#include "resources.h"
#include "sprite_manager.h"
-Sprite* img_bsod_squished_left;
-Sprite* img_bsod_squished_right;
-Sprite* img_bsod_falling_left;
-Sprite* img_bsod_falling_right;
Sprite* img_mriceblock_flat_left;
Sprite* img_mriceblock_flat_right;
Sprite* img_mriceblock_falling_left;
Sprite* img_mriceblock_falling_right;
-Sprite* img_bsod_left;
-Sprite* img_bsod_right;
Sprite* img_mriceblock_left;
Sprite* img_mriceblock_right;
Sprite* img_jumpy_left_up;
return BAD_JUMPY;
else if (str == "laptop" || str == "mriceblock") // was laptop in old maps
return BAD_MRICEBLOCK;
- else if (str == "bsod")
- return BAD_BSOD;
else if (str == "mrbomb")
return BAD_MRBOMB;
else if (str == "stalactite")
return BAD_FLYINGSNOWBALL;
else if (str == "spiky")
return BAD_SPIKY;
- else if (str == "snowball")
+ else if (str == "snowball" || str == "bsod") // was bsod in old maps
return BAD_SNOWBALL;
else
{
printf("Couldn't convert badguy: '%s'\n", str.c_str());
- return BAD_BSOD;
+ return BAD_SNOWBALL;
}
}
case BAD_MRICEBLOCK:
return "mriceblock";
break;
- case BAD_BSOD:
- return "bsod";
- break;
case BAD_MRBOMB:
return "mrbomb";
break;
return "snowball";
break;
default:
- return "bsod";
+ return "snowball";
}
}
physic.reset();
timer.init(true);
- if(kind == BAD_BSOD) {
- physic.set_velocity(-BADGUY_WALK_SPEED, 0);
- set_sprite(img_bsod_left, img_bsod_right);
- } else if(kind == BAD_MRBOMB) {
+ if(kind == BAD_MRBOMB) {
physic.set_velocity(-BADGUY_WALK_SPEED, 0);
set_sprite(img_mrbomb_left, img_mrbomb_right);
} else if (kind == BAD_MRICEBLOCK) {
}
void
-BadGuy::action_bsod(float frame_ratio)
-{
- static const float BSODJUMP = 2;
-
- if (dying == DYING_NOT)
- check_horizontal_bump();
-
- 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(physic.get_velocity_x(), BSODJUMP);
- }
-
- // Handle dying timer:
- if (dying == DYING_SQUISHED && !timer.check())
- {
- /* Remove it if time's up: */
- remove_me();
- return;
- }
-
- // move
- physic.apply(frame_ratio, base.x, base.y);
- if(dying != DYING_FALLING)
- collision_swept_object_map(&old_base, &base);
-}
-
-void
BadGuy::action_mriceblock(float frame_ratio)
{
Player& tux = *World::current()->get_tux();
switch (kind)
{
- case BAD_BSOD:
- action_bsod(frame_ratio);
- break;
-
case BAD_MRICEBLOCK:
action_mriceblock(frame_ratio);
break;
remove_me();
return;
- } else if(kind == BAD_BSOD) {
- squish_me(player);
- set_sprite(img_bsod_squished_left, img_bsod_squished_right);
- physic.set_velocity_x(0);
- return;
-
} else if (kind == BAD_MRICEBLOCK) {
if (mode == NORMAL || mode == KICK)
{
Player& tux = *World::current()->get_tux();
tux.holding_something = false;
}
- } else if(kind == BAD_BSOD) {
- set_sprite(img_bsod_falling_left, img_bsod_falling_right);
}
physic.enable_gravity(true);
physic.set_velocity_y(0);
/* Gain some points: */
-// if (kind == BAD_BSOD)
World::current()->add_score(base.x - scroll_x, base.y,
score * player_status.score_multiplier);
-/* else
- World::current()->add_score(base.x - scroll_x, base.y,
- 25 * player_status.score_multiplier);*/
/* Play death sound: */
play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);
void load_badguy_gfx()
{
- img_bsod_squished_left = sprite_manager->load("bsod-squished-left");
- img_bsod_squished_right = sprite_manager->load("bsod-squished-right");
- img_bsod_falling_left = sprite_manager->load("bsod-falling-left");
- img_bsod_falling_right = sprite_manager->load("bsod-falling-right");
img_mriceblock_flat_left = sprite_manager->load("mriceblock-flat-left");
img_mriceblock_flat_right = sprite_manager->load("mriceblock-flat-right");
img_mriceblock_falling_left = sprite_manager->load("mriceblock-falling-left");
img_mriceblock_falling_right = sprite_manager->load("mriceblock-falling-right");
- img_bsod_left = sprite_manager->load("bsod-left");
- img_bsod_right = sprite_manager->load("bsod-right");
img_mriceblock_left = sprite_manager->load("mriceblock-left");
img_mriceblock_right = sprite_manager->load("mriceblock-right");
img_jumpy_left_up = sprite_manager->load("jumpy-left-up");
/* Bad guy kinds: */
enum BadGuyKind {
- BAD_BSOD,
BAD_MRICEBLOCK,
BAD_JUMPY,
BAD_MRBOMB,
: kind(kind_), x(x_), y(y_), stay_on_platform(stay_on_platform_) {}
BadGuyData()
- : kind(BAD_BSOD), x(0), y(0), stay_on_platform(false) {}
+ : kind(BAD_SNOWBALL), x(0), y(0), stay_on_platform(false) {}
};
class Player;
bool is_removable() const { return removable; }
private:
- void action_bsod(float frame_ratio);
void action_mriceblock(float frame_ratio);
void action_jumpy(float frame_ratio);
void action_bomb(float frame_ratio);
using namespace std;
-st_subset::st_subset()
+LevelSubset::LevelSubset()
+ : image(0), levels(0)
{
- levels = 0;
}
-void st_subset::create(const std::string& subset_name)
+LevelSubset::~LevelSubset()
+{
+ delete image;
+}
+
+void LevelSubset::create(const std::string& subset_name)
{
Level new_lev;
- st_subset new_subset;
+ LevelSubset new_subset;
new_subset.name = subset_name;
new_subset.title = "Unknown Title";
new_subset.description = "No description so far.";
new_lev.save(subset_name.c_str(),1);
}
-void st_subset::parse (lisp_object_t* cursor)
+void LevelSubset::parse (lisp_object_t* cursor)
{
while(!lisp_nil_p(cursor))
{
}
}
-void st_subset::load(char *subset)
+void LevelSubset::load(char *subset)
{
FILE* fi;
char filename[1024];
levels = --i;
}
-void st_subset::save()
+void LevelSubset::save()
{
FILE* fi;
string filename;
}
}
-void st_subset::free()
-{
- title.clear();
- description.clear();
- name.clear();
- delete image;
- levels = 0;
-}
-
Level::Level()
: img_bkgd(0)
{
/** This type holds meta-information about a level-subset.
It could be extended to handle manipulation of subsets. */
-class st_subset
+class LevelSubset
{
public:
- st_subset();
+ LevelSubset();
+ ~LevelSubset();
+
static void create(const std::string& subset_name);
void load(char *subset);
void save();
- void free();
std::string name;
std::string title;
static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
static LevelEditorWorld le_world;
-static st_subset le_level_subset;
+static LevelSubset le_level_subset;
static int le_show_grid;
static int le_frame;
static Surface* le_selection;
switch (i = subset_new_menu->check())
{
case 3:
- st_subset::create(subset_new_menu->item[2].input);
+ LevelSubset::create(subset_new_menu->item[2].input);
le_level_subset.load(subset_new_menu->item[2].input);
leveleditor_menu->item[3].kind = MN_GOTO;
le_level = 1;
le_world.bad_guys.erase(le_world.bad_guys.begin() + i);
if(c == '0') /* if it's a bad guy */
- le_world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
+ le_world.add_bad_guy(xx*32, yy*32, BAD_SNOWBALL);
else if(c == '1')
le_world.add_bad_guy(xx*32, yy*32, BAD_MRICEBLOCK);
else if(c == '2')
le_current_level->change(xx*32, yy*32, tm, c);
if(c == '0') // if it's a bad guy
- le_world.add_bad_guy(xx*32, yy*32, BAD_BSOD);
+ le_world.add_bad_guy(xx*32, yy*32, BAD_SNOWBALL);
else if(c == '1')
le_world.add_bad_guy(xx*32, yy*32, BAD_MRICEBLOCK);
else if(c == '2')
static unsigned int last_update_time;
static unsigned int update_time;
-std::vector<st_subset> contrib_subsets;
+std::vector<LevelSubset*> contrib_subsets;
std::string current_contrib_subset;
+void free_contrib_menu()
+{
+ for(std::vector<LevelSubset*>::iterator i = contrib_subsets.begin();
+ i != contrib_subsets.end(); ++i)
+ delete *i;
+
+ contrib_subsets.clear();
+ contrib_menu->clear();
+}
+
void generate_contrib_menu()
{
string_list_type level_subsets = dsubdirs("/levels", "info");
- contrib_menu->clear();
+ free_contrib_menu();
+
contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0);
contrib_menu->additem(MN_HL,"",0,0);
for (int i = 0; i < level_subsets.num_items; ++i)
{
- st_subset subset;
- subset.load(level_subsets.item[i]);
- contrib_menu->additem(MN_GOTO, subset.title.c_str(), i,
+ LevelSubset* subset = new LevelSubset();
+ subset->load(level_subsets.item[i]);
+ contrib_menu->additem(MN_GOTO, subset->title.c_str(), i,
contrib_subset_menu, i+1);
contrib_subsets.push_back(subset);
}
{
current_subset = index;
// FIXME: This shouln't be busy looping
- st_subset& subset = contrib_subsets[index];
+ LevelSubset& subset = * (contrib_subsets[index]);
current_contrib_subset = subset.name;
/* --- TITLE SCREEN --- */
void title(void)
{
- st_subset subset;
random_timer.init(true);
walking = true;
}
/* Free surfaces: */
+ free_contrib_menu();
delete bkg_title;
delete logo;
delete img_choose_subset;