projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
patch contributed by markos_64:
[supertux.git]
/
src
/
gameloop.cpp
diff --git
a/src/gameloop.cpp
b/src/gameloop.cpp
index
1589565
..
3267063
100644
(file)
--- a/
src/gameloop.cpp
+++ b/
src/gameloop.cpp
@@
-47,20
+47,19
@@
#include "high_scores.h"
#include "gui/menu.h"
#include "sector.h"
#include "high_scores.h"
#include "gui/menu.h"
#include "sector.h"
-#include "player.h"
#include "level.h"
#include "scene.h"
#include "level.h"
#include "scene.h"
-#include "collision.h"
#include "tile.h"
#include "tile.h"
-#include "particlesystem.h"
+#include "object/particlesystem.h"
+#include "object/background.h"
+#include "object/tilemap.h"
+#include "object/camera.h"
+#include "object/player.h"
#include "resources.h"
#include "resources.h"
-#include "background.h"
-#include "tilemap.h"
#include "app/gettext.h"
#include "worldmap.h"
#include "intro.h"
#include "misc.h"
#include "app/gettext.h"
#include "worldmap.h"
#include "intro.h"
#include "misc.h"
-#include "camera.h"
#include "statistics.h"
#include "timer.h"
#include "object/fireworks.h"
#include "statistics.h"
#include "timer.h"
#include "object/fireworks.h"
@@
-80,10
+79,10
@@
bool compare_last(std::string& haystack, std::string needle)
return false;
}
return false;
}
-GameSession::GameSession(const std::string& level
nam
e_, int mode,
-
bool flip_level_,
Statistics* statistics)
+GameSession::GameSession(const std::string& level
fil
e_, int mode,
+ Statistics* statistics)
: level(0), currentsector(0), st_gl_mode(mode),
: level(0), currentsector(0), st_gl_mode(mode),
- end_sequence(NO_ENDSEQUENCE), level
name(levelname_), flip_level(flip_level
_),
+ end_sequence(NO_ENDSEQUENCE), level
file(levelfile
_),
best_level_statistics(statistics)
{
current_ = this;
best_level_statistics(statistics)
{
current_ = this;
@@
-93,9
+92,6
@@
GameSession::GameSession(const std::string& levelname_, int mode,
context = new DrawingContext();
context = new DrawingContext();
- if(flip_levels_mode)
- flip_level = true;
-
last_swap_point = Vector(-1, -1);
last_swap_stats.reset();
last_swap_point = Vector(-1, -1);
last_swap_stats.reset();
@@
-124,9
+120,7
@@
GameSession::restart_level()
currentsector = 0;
level = new Level;
currentsector = 0;
level = new Level;
- level->load(levelname);
- if(flip_level)
- level->do_vertical_flip();
+ level->load(levelfile);
global_stats.reset();
global_stats.set_total_points(COINS_COLLECTED_STAT, level->get_total_coins());
global_stats.reset();
global_stats.set_total_points(COINS_COLLECTED_STAT, level->get_total_coins());
@@
-186,8
+180,13
@@
GameSession::levelintro(void)
char str[60];
DrawingContext context;
char str[60];
DrawingContext context;
- if(currentsector->background)
- currentsector->background->draw(context);
+ for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+ i != currentsector->gameobjects.end(); ++i) {
+ Background* background = dynamic_cast<Background*> (*i);
+ if(background) {
+ background->draw(context);
+ }
+ }
// context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
// CENTER_ALLIGN, LAYER_FOREGROUND1);
// context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
// CENTER_ALLIGN, LAYER_FOREGROUND1);
@@
-205,11
+204,6
@@
GameSession::levelintro(void)
Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
- if(flip_level)
- context.draw_text(white_text,
- _("Level Vertically Flipped!"),
- Vector(screen->w/2, 310), CENTER_ALLIGN, LAYER_FOREGROUND1);
-
if(best_level_statistics != NULL)
best_level_statistics->draw_message_info(context, _("Best Level Statistics"));
if(best_level_statistics != NULL)
best_level_statistics->draw_message_info(context, _("Best Level Statistics"));
@@
-463,6
+457,11
@@
GameSession::process_events()
tux.kill(tux.KILL);
last_keys.clear();
}
tux.kill(tux.KILL);
last_keys.clear();
}
+ if(compare_last(last_keys, "grid"))
+ { // toggle debug grid
+ debug_grid = !debug_grid;
+ last_keys.clear();
+ }
if(compare_last(last_keys, "hover"))
{ // toggle hover ability on/off
tux.enable_hover = !tux.enable_hover;
if(compare_last(last_keys, "hover"))
{ // toggle hover ability on/off
tux.enable_hover = !tux.enable_hover;
@@
-721,8
+720,10
@@
GameSession::run()
while (exit_status == ES_NONE) {
Uint32 ticks = SDL_GetTicks();
float elapsed_time = float(ticks - lastticks) / 1000.;
while (exit_status == ES_NONE) {
Uint32 ticks = SDL_GetTicks();
float elapsed_time = float(ticks - lastticks) / 1000.;
- global_time += elapsed_time;
+ if(!game_pause)
+ global_time += elapsed_time;
lastticks = ticks;
lastticks = ticks;
+
// 40fps is minimum
if(elapsed_time > .025)
elapsed_time = .025;
// 40fps is minimum
if(elapsed_time > .025)
elapsed_time = .025;
@@
-899,12
+900,18
@@
GameSession::drawstatus(DrawingContext& context)
}
void
}
void
-GameSession::drawresultscreen(
void
)
+GameSession::drawresultscreen()
{
char str[80];
DrawingContext context;
{
char str[80];
DrawingContext context;
- currentsector->background->draw(context);
+ for(Sector::GameObjects::iterator i = currentsector->gameobjects.begin();
+ i != currentsector->gameobjects.end(); ++i) {
+ Background* background = dynamic_cast<Background*> (*i);
+ if(background) {
+ background->draw(context);
+ }
+ }
context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
CENTER_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
CENTER_ALLIGN, LAYER_FOREGROUND1);