bin_PROGRAMS = supertux
supertux_SOURCES = \
-badguy.cpp badguy.h bitmask.cpp bitmask.h button.cpp button.h collision.cpp collision.h configfile.cpp configfile.h defines.h gameloop.cpp gameloop.h globals.cpp globals.h high_scores.cpp high_scores.h intro.cpp intro.h level.cpp level.h leveleditor.cpp leveleditor.h lispreader.cpp lispreader.h menu.cpp menu.h particlesystem.cpp particlesystem.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h screen.cpp screen.h setup.cpp setup.h sound.cpp sound.h special.cpp special.h supertux.cpp supertux.h text.cpp text.h texture.cpp texture.h timer.cpp timer.h title.cpp title.h type.cpp type.h world.cpp world.h worldmap.cpp worldmap.h tile.h tile.cpp mousecursor.cpp mousecursor.h resources.h resources.cpp
+badguy.cpp badguy.h bitmask.cpp bitmask.h button.cpp button.h collision.cpp collision.h configfile.cpp configfile.h defines.h gameloop.cpp gameloop.h globals.cpp globals.h high_scores.cpp high_scores.h intro.cpp intro.h level.cpp level.h leveleditor.cpp leveleditor.h lispreader.cpp lispreader.h menu.cpp menu.h particlesystem.cpp particlesystem.h physic.cpp physic.h player.cpp player.h scene.cpp scene.h screen.cpp screen.h setup.cpp setup.h sound.cpp sound.h special.cpp special.h supertux.cpp supertux.h text.cpp text.h texture.cpp texture.h timer.cpp timer.h title.cpp title.h type.cpp type.h world.cpp world.h worldmap.cpp worldmap.h tile.h tile.cpp mousecursor.cpp mousecursor.h resources.h resources.cpp gameobjs.h gameobjs.cpp
# EOF #
noinst_HEADERS =
#include "badguy.h"
#include "scene.h"
#include "screen.h"
+#include "world.h"
#include "tile.h"
texture_type img_bsod_squished_left[1];
#include "collision.h"
#include "bitmask.h"
#include "scene.h"
+#include "world.h"
#include "tile.h"
bool rectcollision(base_type* one, base_type* two)
Tile* gettile(float x, float y)
{
- return TileManager::instance()->get(GameSession::current()->get_level()->gettileid(x, y));
+ return TileManager::instance()->get(World::current()->get_level()->gettileid(x, y));
}
bool issolid(float x, float y)
/* Init the game: */
world->arrays_free();
- set_defaults();
+ world->set_defaults();
strcpy(level_subset, subset.c_str());
/* Either way, (re-)load the (next) level... */
tux.level_begin();
- set_defaults();
+ world->set_defaults();
world->get_level()->cleanup();
return(quit);
}
-/* Draw a tile on the screen: */
-
-void drawshape(float x, float y, unsigned int c, Uint8 alpha)
-{
- if (c != 0)
- {
- Tile* ptile = TileManager::instance()->get(c);
- if(ptile)
- {
- if(ptile->images.size() > 1)
- {
- texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y, alpha);
- }
- else if (ptile->images.size() == 1)
- {
- texture_draw(&ptile->images[0],x,y, alpha);
- }
- else
- {
- //printf("Tile not dravable %u\n", c);
- }
- }
- }
-}
-
/* Bounce a brick: */
void bumpbrick(float x, float y)
{
level_subset[strlen(level_subset)-1] = '\0';
fread(&level,sizeof(int),1,fi);
- set_defaults();
+ world->set_defaults();
world->get_level()->cleanup();
world->arrays_free();
+ world->get_level()->free_gfx();
+ world->get_level()->free_song();
if(world->get_level()->load(level_subset,level) != 0)
exit(1);
+
world->activate_bad_guys();
world->activate_particle_systems();
-
- world->get_level()->free_gfx();
world->get_level()->load_gfx();
- world->get_level()->free_song();
world->get_level()->load_song();
levelintro();
--- /dev/null
+#include "world.h"
+#include "tile.h"
+#include "gameloop.h"
+#include "gameobjs.h"
+
+void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y)
+{
+ pbouncy_distro->base.x = x;
+ pbouncy_distro->base.y = y;
+ pbouncy_distro->base.ym = -2;
+}
+
+void bouncy_distro_action(bouncy_distro_type* pbouncy_distro)
+{
+ pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio;
+
+ pbouncy_distro->base.ym += 0.1 * frame_ratio;
+
+ if (pbouncy_distro->base.ym >= 0)
+ world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro));
+}
+
+void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro)
+{
+ texture_draw(&img_distro[0],
+ pbouncy_distro->base.x - scroll_x,
+ pbouncy_distro->base.y);
+}
+
+void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile,
+ float x, float y, float xm, float ym)
+{
+ pbroken_brick->tile = tile;
+ pbroken_brick->base.x = x;
+ pbroken_brick->base.y = y;
+ pbroken_brick->base.xm = xm;
+ pbroken_brick->base.ym = ym;
+
+ timer_init(&pbroken_brick->timer, true);
+ timer_start(&pbroken_brick->timer,200);
+}
+
+void broken_brick_action(broken_brick_type* pbroken_brick)
+{
+ pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio;
+ pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio;
+
+ if (!timer_check(&pbroken_brick->timer))
+ world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick));
+}
+
+void broken_brick_draw(broken_brick_type* pbroken_brick)
+{
+ SDL_Rect src, dest;
+ src.x = rand() % 16;
+ src.y = rand() % 16;
+ src.w = 16;
+ src.h = 16;
+
+ dest.x = (int)(pbroken_brick->base.x - scroll_x);
+ dest.y = (int)pbroken_brick->base.y;
+ dest.w = 16;
+ dest.h = 16;
+
+ if (pbroken_brick->tile->images.size() > 0)
+ texture_draw_part(&pbroken_brick->tile->images[0],
+ src.x,src.y,dest.x,dest.y,dest.w,dest.h);
+}
+
+void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y)
+{
+ pbouncy_brick->base.x = x;
+ pbouncy_brick->base.y = y;
+ pbouncy_brick->offset = 0;
+ pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED;
+ pbouncy_brick->shape = GameSession::current()->get_level()->gettileid(x, y);
+}
+
+void bouncy_brick_action(bouncy_brick_type* pbouncy_brick)
+{
+
+ pbouncy_brick->offset = (pbouncy_brick->offset +
+ pbouncy_brick->offset_m * frame_ratio);
+
+ /* Go back down? */
+
+ if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET)
+ pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED;
+
+
+ /* Stop bouncing? */
+
+ if (pbouncy_brick->offset >= 0)
+ world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick));
+}
+
+void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick)
+{
+ int s;
+ SDL_Rect dest;
+
+ if (pbouncy_brick->base.x >= scroll_x - 32 &&
+ pbouncy_brick->base.x <= scroll_x + screen->w)
+ {
+ dest.x = (int)(pbouncy_brick->base.x - scroll_x);
+ dest.y = (int)pbouncy_brick->base.y;
+ dest.w = 32;
+ dest.h = 32;
+
+ Level* plevel = GameSession::current()->get_level();
+
+ // FIXME: overdrawing hack to clean the tile from the screen to
+ // paint it later at on offseted position
+ if(plevel->bkgd_image[0] == '\0')
+ {
+ fillrect(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y,
+ 32,32,
+ plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0);
+ }
+ else
+ {
+ s = (int)scroll_x / 30;
+ texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y,
+ dest.x, dest.y,dest.w,dest.h);
+ }
+
+ Tile::draw(pbouncy_brick->base.x - scroll_x,
+ pbouncy_brick->base.y + pbouncy_brick->offset,
+ pbouncy_brick->shape);
+ }
+}
+
+void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s)
+{
+ pfloating_score->base.x = x;
+ pfloating_score->base.y = y - 16;
+ timer_init(&pfloating_score->timer,true);
+ timer_start(&pfloating_score->timer,1000);
+ pfloating_score->value = s;
+}
+
+void floating_score_action(floating_score_type* pfloating_score)
+{
+ pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio;
+
+ if(!timer_check(&pfloating_score->timer))
+ world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score));
+}
+
+void floating_score_draw(floating_score_type* pfloating_score)
+{
+ char str[10];
+ sprintf(str, "%d", pfloating_score->value);
+ text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1);
+}
+
+/* EOF */
+
--- /dev/null
+
+#ifndef SUPERTUX_GAMEOBJS_H
+#define SUPERTUX_GAMEOBJS_H
+
+#include "type.h"
+#include "texture.h"
+#include "timer.h"
+#include "scene.h"
+
+/* Bounciness of distros: */
+#define NO_BOUNCE 0
+#define BOUNCE 1
+
+class bouncy_distro_type
+{
+ public:
+ base_type base;
+};
+
+extern texture_type img_distro[4];
+
+void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y);
+void bouncy_distro_action(bouncy_distro_type* pbouncy_distro);
+void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro);
+void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object);
+
+#define BOUNCY_BRICK_MAX_OFFSET 8
+#define BOUNCY_BRICK_SPEED 0.9
+
+class Tile;
+
+class broken_brick_type
+{
+ public:
+ base_type base;
+ timer_type timer;
+ Tile* tile;
+};
+
+void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile,
+ float x, float y, float xm, float ym);
+void broken_brick_action(broken_brick_type* pbroken_brick);
+void broken_brick_draw(broken_brick_type* pbroken_brick);
+
+class bouncy_brick_type
+{
+ public:
+ float offset;
+ float offset_m;
+ int shape;
+ base_type base;
+};
+
+void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y);
+void bouncy_brick_action(bouncy_brick_type* pbouncy_brick);
+void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick);
+
+class floating_score_type
+{
+ public:
+ int value;
+ timer_type timer;
+ base_type base;
+};
+
+void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s);
+void floating_score_action(floating_score_type* pfloating_score);
+void floating_score_draw(floating_score_type* pfloating_score);
+
+#endif
+
+/* Local Variables: */
+/* mode:c++ */
+/* End */
void load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha);
};
-
#endif /*SUPERTUX_LEVEL_H*/
#include <SDL_image.h>
#include "leveleditor.h"
+#include "world.h"
#include "screen.h"
#include "defines.h"
#include "globals.h"
#include "setup.h"
#include "menu.h"
#include "level.h"
+#include "gameloop.h"
#include "badguy.h"
#include "scene.h"
#include "button.h"
/* draw button bar */
fillrect(screen->w - 64, 0, 64, screen->h, 50, 50, 50,255);
- drawshape(19 * 32, 14 * 32, le_current_tile);
+ Tile::draw(19 * 32, 14 * 32, le_current_tile);
if(TileManager::instance()->get(le_current_tile)->editor_images.size() > 0)
texture_draw(&TileManager::instance()->get(le_current_tile)->editor_images[0], 19 * 32, 14 * 32);
else
a = 128;
- drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->bg_tiles[y][x + (int)(pos_x / 32)],a);
+ Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->bg_tiles[y][x + (int)(pos_x / 32)],a);
if(active_tm == TM_IA)
a = 255;
else
a = 128;
- drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->ia_tiles[y][x + (int)(pos_x / 32)],a);
+ Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->ia_tiles[y][x + (int)(pos_x / 32)],a);
if(active_tm == TM_FG)
a = 255;
else
a = 128;
- drawshape(32*x - fmodf(pos_x, 32), y * 32, le_current_level->fg_tiles[y][x + (int)(pos_x / 32)],a);
+ Tile::draw(32*x - fmodf(pos_x, 32), y * 32, le_current_level->fg_tiles[y][x + (int)(pos_x / 32)],a);
/* draw whats inside stuff when cursor is selecting those */
/* (draw them all the time - is this the right behaviour?) */
#include "scene.h"
#include "player.h"
#include "badguy.h"
+#include "gameobjs.h"
#include "resources.h"
texture_type img_waves[3];
/* Distros: */
-
texture_load(&img_distro[0], datadir + "/images/shared/distro-0.png",
USE_ALPHA);
timer_type time_left;
double frame_ratio;
-void set_defaults(void)
-{
- // Set defaults:
- scroll_x = 0;
-
- score_multiplier = 1;
- timer_init(&super_bkgd_timer, true);
-
- counting_distros = false;
- distro_counter = 0;
-
- endpos = 0;
-
- /* set current song/music */
- set_current_music(LEVEL_MUSIC);
-}
-
// EOF //
#define SUPERTUX_SCENE_H
#include "defines.h"
-#include "gameloop.h"
#include "player.h"
#include "badguy.h"
-#include "world.h"
#include "special.h"
#include "level.h"
#include "particlesystem.h"
extern timer_type time_left;
extern double frame_ratio;
-void set_defaults(void);
-
#endif /*SUPERTUX_SCENE_H*/
//
//
#include "tile.h"
+#include "scene.h"
#include "assert.h"
TileManager* TileManager::instance_ = 0;
}
}
+void
+Tile::draw(float x, float y, unsigned int c, Uint8 alpha)
+{
+ if (c != 0)
+ {
+ Tile* ptile = TileManager::instance()->get(c);
+ if(ptile)
+ {
+ if(ptile->images.size() > 1)
+ {
+ texture_draw(&ptile->images[( ((global_frame_counter*25) / ptile->anim_speed) % (ptile->images.size()))],x,y, alpha);
+ }
+ else if (ptile->images.size() == 1)
+ {
+ texture_draw(&ptile->images[0],x,y, alpha);
+ }
+ else
+ {
+ //printf("Tile not dravable %u\n", c);
+ }
+ }
+ }
+}
+
// EOF //
int next_tile;
int anim_speed;
+
+ /** Draw a tile on the screen: */
+ static void draw(float x, float y, unsigned int c, Uint8 alpha = 255);
};
struct TileGroup
}
};
-
-
#endif
#include "scene.h"
#include "player.h"
#include "math.h"
+#include "tile.h"
void loadshared(void);
{
for (int x = 0; x < 21; ++x)
{
- drawshape(32*x - fmodf(scroll_x, 32), y * 32,
- plevel->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
+ plevel->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
}
}
texture_type img_distro[4];
+World* World::current_ = 0;
+
World world;
World::World()
{
+ // FIXME: Move this to action and draw and everywhere else where the
+ // world calls child functions
+ current_ = this;
+
level = new Level;
}
delete level;
}
+void
+World::set_defaults()
+{
+ // Set defaults:
+ scroll_x = 0;
+
+ score_multiplier = 1;
+ timer_init(&super_bkgd_timer, true);
+
+ counting_distros = false;
+ distro_counter = 0;
+
+ endpos = 0;
+
+ /* set current song/music */
+ set_current_music(LEVEL_MUSIC);
+}
+
int
World::load(const char* subset, int level_nr)
{
{
for (x = 0; x < 21; ++x)
{
- drawshape(32*x - fmodf(scroll_x, 32), y * 32,
- level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
+ level->bg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
}
}
{
for (x = 0; x < 21; ++x)
{
- drawshape(32*x - fmodf(scroll_x, 32), y * 32,
- level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
+ level->ia_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
}
}
{
for (x = 0; x < 21; ++x)
{
- drawshape(32*x - fmodf(scroll_x, 32), y * 32,
- level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
+ Tile::draw(32*x - fmodf(scroll_x, 32), y * 32,
+ level->fg_tiles[(int)y][(int)x + (int)(scroll_x / 32)]);
}
}
play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
}
-
-
-void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y)
-{
- pbouncy_distro->base.x = x;
- pbouncy_distro->base.y = y;
- pbouncy_distro->base.ym = -2;
-}
-
-void bouncy_distro_action(bouncy_distro_type* pbouncy_distro)
-{
- pbouncy_distro->base.y = pbouncy_distro->base.y + pbouncy_distro->base.ym * frame_ratio;
-
- pbouncy_distro->base.ym += 0.1 * frame_ratio;
-
- if (pbouncy_distro->base.ym >= 0)
- world.bouncy_distros.erase(static_cast<std::vector<bouncy_distro_type>::iterator>(pbouncy_distro));
-}
-
-void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro)
-{
- texture_draw(&img_distro[0],
- pbouncy_distro->base.x - scroll_x,
- pbouncy_distro->base.y);
-}
-
-void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile,
- float x, float y, float xm, float ym)
-{
- pbroken_brick->tile = tile;
- pbroken_brick->base.x = x;
- pbroken_brick->base.y = y;
- pbroken_brick->base.xm = xm;
- pbroken_brick->base.ym = ym;
-
- timer_init(&pbroken_brick->timer, true);
- timer_start(&pbroken_brick->timer,200);
-}
-
-void broken_brick_action(broken_brick_type* pbroken_brick)
-{
- pbroken_brick->base.x = pbroken_brick->base.x + pbroken_brick->base.xm * frame_ratio;
- pbroken_brick->base.y = pbroken_brick->base.y + pbroken_brick->base.ym * frame_ratio;
-
- if (!timer_check(&pbroken_brick->timer))
- world.broken_bricks.erase(static_cast<std::vector<broken_brick_type>::iterator>(pbroken_brick));
-}
-
-void broken_brick_draw(broken_brick_type* pbroken_brick)
-{
- SDL_Rect src, dest;
- src.x = rand() % 16;
- src.y = rand() % 16;
- src.w = 16;
- src.h = 16;
-
- dest.x = (int)(pbroken_brick->base.x - scroll_x);
- dest.y = (int)pbroken_brick->base.y;
- dest.w = 16;
- dest.h = 16;
-
- if (pbroken_brick->tile->images.size() > 0)
- texture_draw_part(&pbroken_brick->tile->images[0],
- src.x,src.y,dest.x,dest.y,dest.w,dest.h);
-}
-
-void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y)
-{
- pbouncy_brick->base.x = x;
- pbouncy_brick->base.y = y;
- pbouncy_brick->offset = 0;
- pbouncy_brick->offset_m = -BOUNCY_BRICK_SPEED;
- pbouncy_brick->shape = GameSession::current()->get_level()->gettileid(x, y);
-}
-
-void bouncy_brick_action(bouncy_brick_type* pbouncy_brick)
-{
-
- pbouncy_brick->offset = (pbouncy_brick->offset +
- pbouncy_brick->offset_m * frame_ratio);
-
- /* Go back down? */
-
- if (pbouncy_brick->offset < -BOUNCY_BRICK_MAX_OFFSET)
- pbouncy_brick->offset_m = BOUNCY_BRICK_SPEED;
-
-
- /* Stop bouncing? */
-
- if (pbouncy_brick->offset >= 0)
- world.bouncy_bricks.erase(static_cast<std::vector<bouncy_brick_type>::iterator>(pbouncy_brick));
-}
-
-void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick)
-{
- int s;
- SDL_Rect dest;
-
- if (pbouncy_brick->base.x >= scroll_x - 32 &&
- pbouncy_brick->base.x <= scroll_x + screen->w)
- {
- dest.x = (int)(pbouncy_brick->base.x - scroll_x);
- dest.y = (int)pbouncy_brick->base.y;
- dest.w = 32;
- dest.h = 32;
-
- Level* plevel = GameSession::current()->get_level();
-
- // FIXME: overdrawing hack to clean the tile from the screen to
- // paint it later at on offseted position
- if(plevel->bkgd_image[0] == '\0')
- {
- fillrect(pbouncy_brick->base.x - scroll_x, pbouncy_brick->base.y,
- 32,32,
- plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_blue, 0);
- }
- else
- {
- s = (int)scroll_x / 30;
- texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y,
- dest.x, dest.y,dest.w,dest.h);
- }
-
- drawshape(pbouncy_brick->base.x - scroll_x,
- pbouncy_brick->base.y + pbouncy_brick->offset,
- pbouncy_brick->shape);
- }
-}
-
-void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s)
-{
- pfloating_score->base.x = x;
- pfloating_score->base.y = y - 16;
- timer_init(&pfloating_score->timer,true);
- timer_start(&pfloating_score->timer,1000);
- pfloating_score->value = s;
-}
-
-void floating_score_action(floating_score_type* pfloating_score)
-{
- pfloating_score->base.y = pfloating_score->base.y - 2 * frame_ratio;
-
- if(!timer_check(&pfloating_score->timer))
- world.floating_scores.erase(static_cast<std::vector<floating_score_type>::iterator>(pfloating_score));
-}
-
-void floating_score_draw(floating_score_type* pfloating_score)
-{
- char str[10];
- sprintf(str, "%d", pfloating_score->value);
- text_draw(&gold_text, str, (int)pfloating_score->base.x + 16 - strlen(str) * 8, (int)pfloating_score->base.y, 1);
-}
-
/* Break a brick: */
void trybreakbrick(float x, float y, bool small)
{
- Level* plevel = GameSession::current()->get_level();
+ Level* plevel = World::current()->get_level();
Tile* tile = gettile(x, y);
if (tile->brick)
/* Empty a box: */
void tryemptybox(float x, float y, int col_side)
{
- Level* plevel = GameSession::current()->get_level();
+ Level* plevel = World::current()->get_level();
Tile* tile = gettile(x,y);
if (!tile->fullbox)
/* Try to grab a distro: */
void trygrabdistro(float x, float y, int bounciness)
{
- Level* plevel = GameSession::current()->get_level();
+ Level* plevel = World::current()->get_level();
Tile* tile = gettile(x, y);
if (tile && tile->distro)
{
#include "scene.h"
#include "special.h"
#include "particlesystem.h"
-
-/* Bounciness of distros: */
-
-#define NO_BOUNCE 0
-#define BOUNCE 1
-
-struct bouncy_distro_type
-{
- base_type base;
-};
-
-extern texture_type img_distro[4];
-
-void bouncy_distro_init(bouncy_distro_type* pbouncy_distro, float x, float y);
-void bouncy_distro_action(bouncy_distro_type* pbouncy_distro);
-void bouncy_distro_draw(bouncy_distro_type* pbouncy_distro);
-void bouncy_distro_collision(bouncy_distro_type* pbouncy_distro, int c_object);
-
-#define BOUNCY_BRICK_MAX_OFFSET 8
-#define BOUNCY_BRICK_SPEED 0.9
-
-struct broken_brick_type
-{
- base_type base;
- timer_type timer;
- Tile* tile;
-};
-
-void broken_brick_init(broken_brick_type* pbroken_brick, Tile* tile,
- float x, float y, float xm, float ym);
-void broken_brick_action(broken_brick_type* pbroken_brick);
-void broken_brick_draw(broken_brick_type* pbroken_brick);
-
-struct bouncy_brick_type
-{
- float offset;
- float offset_m;
- int shape;
- base_type base;
-};
-
-void bouncy_brick_init(bouncy_brick_type* pbouncy_brick, float x, float y);
-void bouncy_brick_action(bouncy_brick_type* pbouncy_brick);
-void bouncy_brick_draw(bouncy_brick_type* pbouncy_brick);
-
-struct floating_score_type
-{
- int value;
- timer_type timer;
- base_type base;
-};
-
-void floating_score_init(floating_score_type* pfloating_score, float x, float y, int s);
-void floating_score_action(floating_score_type* pfloating_score);
-void floating_score_draw(floating_score_type* pfloating_score);
+#include "gameobjs.h"
/** Try to grab the coin at the given coordinates */
void trygrabdistro(float x, float y, int bounciness);
Level* level;
std::vector<bouncy_distro_type> bouncy_distros;
- std::vector<broken_brick_type> broken_bricks;
- std::vector<bouncy_brick_type> bouncy_bricks;
- std::vector<BadGuy> bad_guys;
+ std::vector<broken_brick_type> broken_bricks;
+ std::vector<bouncy_brick_type> bouncy_bricks;
std::vector<floating_score_type> floating_scores;
+
+ std::vector<BadGuy> bad_guys;
std::vector<upgrade_type> upgrades;
std::vector<bullet_type> bullets;
std::vector<ParticleSystem*> particle_systems;
+ static World* current_;
public:
+ static World* current() { return current_; }
+
World();
~World();
Level* get_level() { return level; }
+ void set_defaults();
+
void draw();
void action();
void arrays_free();