projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed jump behaviour: Tux will now jump even if the button was pressed (up to)...
[supertux.git]
/
src
/
object
/
level_time.cpp
diff --git
a/src/object/level_time.cpp
b/src/object/level_time.cpp
index
bf86db6
..
3244a46
100644
(file)
--- a/
src/object/level_time.cpp
+++ b/
src/object/level_time.cpp
@@
-68,10
+68,18
@@
LevelTime::update(float elapsed_time)
{
if (!running) return;
{
if (!running) return;
- time_left = std::max(time_left - elapsed_time, 0.0f);
+ int prev_time = (int) floor(time_left*5);
+ time_left -= elapsed_time;
if(time_left <= 0) {
if(time_left <= 0) {
- Sector::current()->player->kill(true);
- stop();
+ if(time_left <= -5 || !Sector::current()->player->get_coins())
+ {
+ Sector::current()->player->kill(true);
+ stop();
+ }
+ if(prev_time != (int) floor(time_left*5))
+ {
+ Sector::current()->player->add_coins(-1);
+ }
}
}
}
}
@@
-88,9
+96,9
@@
LevelTime::draw(DrawingContext& context)
Surface* time_surf = time_surface.get();
if (time_surf) {
Surface* time_surf = time_surface.get();
if (time_surf) {
- float all_width = time_surf->get_width() +
white_tex
t->get_text_width(time_text);
+ float all_width = time_surf->get_width() +
normal_fon
t->get_text_width(time_text);
context.draw_surface(time_surf, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1);
context.draw_surface(time_surf, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1);
- context.draw_text(
gold_text, time_text, Vector((SCREEN_WIDTH - all_width)/2 + time_surf->get_width(), BORDER_Y), LEFT_ALLIGN, LAYER_FOREGROUND1
);
+ context.draw_text(
normal_font, time_text, Vector((SCREEN_WIDTH - all_width)/2 + time_surf->get_width(), BORDER_Y), ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color
);
}
}
}
}
@@
-108,8
+116,8
@@
LevelTime::stop()
{
running = false;
}
{
running = false;
}
-
-float
+
+float
LevelTime::get_time()
{
return time_left;
LevelTime::get_time()
{
return time_left;