save_state();
}
load_worldmap("levels/world1/worldmap.stwm");
+fadeout_screen(0.5);
wait_for_screenswitch();
save_state();
wait_for_screenswitch();
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
#ifndef __SOUND_MANAGER_H__
#define __SOUND_MANAGER_H__
#include <AL/al.h>
#include "math/vector.hpp"
-typedef void* SoundHandle;
-
class SoundFile;
class SoundSource;
class StreamSoundSource;
--- /dev/null
+// $Id: screen.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <config.h>
+
+#include "fadeout.hpp"
+#include "main.hpp"
+#include "video/drawing_context.hpp"
+
+FadeOut::FadeOut(float fade_time, Color color)
+ : color(color), fade_time(fade_time), accum_time(0)
+{
+}
+
+FadeOut::~FadeOut()
+{
+}
+
+void
+FadeOut::update(float elapsed_time)
+{
+ accum_time += elapsed_time;
+ if(accum_time > fade_time)
+ accum_time = fade_time;
+}
+
+void
+FadeOut::draw(DrawingContext& context)
+{
+ Color col = color;
+ col.alpha = accum_time / fade_time;
+ context.draw_filled_rect(Vector(0, 0),
+ Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
+ col, LAYER_GUI+1);
+}
+
+bool
+FadeOut::done()
+{
+ return accum_time >= fade_time;
+}
+
--- /dev/null
+// $Id: screen.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#ifndef __FADEOUT_HPP__
+#define __FADEOUT_HPP__
+
+#include "video/color.hpp"
+#include "screen_fade.hpp"
+
+/**
+ * Fades a screen towards a specific color
+ */
+class FadeOut : public ScreenFade
+{
+public:
+ FadeOut(float fade_time, Color dest_color = Color(0, 0, 0));
+ virtual ~FadeOut();
+
+ virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
+
+ /// returns true if the effect is completed
+ virtual bool done();
+
+private:
+ Color color;
+ float fade_time;
+ float accum_time;
+};
+
+#endif
+
#include "log.hpp"
#include "worldmap/worldmap.hpp"
#include "mainloop.hpp"
-#include "video/screen.hpp"
#include "audio/sound_manager.hpp"
#include "gui/menu.hpp"
#include "sector.hpp"
currentsector->activate("main");
}
- levelintro();
+ //levelintro();
currentsector->play_music(LEVEL_MUSIC);
#include "menu.hpp"
#include "mainloop.hpp"
-#include "video/screen.hpp"
#include "video/drawing_context.hpp"
#include "gettext.hpp"
#include "math/vector.hpp"
#include <memory>
#include <stdexcept>
-#include "video/screen.hpp"
#include "log.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "object/tilemap.hpp"
#include "object/coin.hpp"
-// test
-#include "flip_level_transformer.hpp"
-
using namespace std;
Level::Level()
namespace {
inline std::ostream& log_debug_f(const char* file, int line) {
- Console::output << "[DEBUG] " << file << " l." << line << ": ";
+ Console::output << "[DEBUG] " << file << ":" << line << " ";
return Console::output;
}
inline std::ostream& log_info_f(const char* file, int line) {
- Console::output << "[INFO] " << file << " l." << line << ": ";
+ Console::output << "[INFO] " << file << ":" << line << " ";
return Console::output;
}
inline std::ostream& log_warning_f(const char* file, int line) {
- Console::output << "[WARNING] " << file << " l." << line << ": ";
+ Console::output << "[WARNING] " << file << ":" << line << " ";
return Console::output;
}
inline std::ostream& log_fatal_f(const char* file, int line) {
- Console::output << "[FATAL] " << file << " l." << line << ": ";
+ Console::output << "[FATAL] " << file << ":" << line << " ";
return Console::output;
}
#include "resources.hpp"
#include "script_manager.hpp"
#include "screen.hpp"
+#include "screen_fade.hpp"
#include "timer.hpp"
#include "player_status.hpp"
}
void
-MainLoop::push_screen(Screen* screen)
+MainLoop::push_screen(Screen* screen, ScreenFade* screen_fade)
{
this->next_screen.reset(screen);
- nextpush = true;
+ this->screen_fade.reset(screen_fade);
+ nextpop = false;
speed = 1.0;
}
void
-MainLoop::exit_screen()
+MainLoop::exit_screen(ScreenFade* screen_fade)
{
- if (screen_stack.size() < 1) {
- quit();
- return;
- }
- next_screen.reset(screen_stack.back());
- nextpush = false;
- screen_stack.pop_back();
- speed = 1.0;
+ next_screen.reset(NULL);
+ this->screen_fade.reset(screen_fade);
+ nextpop = true;
+}
+
+void
+MainLoop::set_screen_fade(ScreenFade* screen_fade)
+{
+ this->screen_fade.reset(screen_fade);
}
void
-MainLoop::quit()
+MainLoop::quit(ScreenFade* screen_fade)
{
- running = false;
+ for(std::vector<Screen*>::iterator i = screen_stack.begin();
+ i != screen_stack.end(); ++i)
+ delete *i;
+
+ exit_screen(screen_fade);
}
void
running = true;
while(running) {
- if(next_screen.get() != NULL) {
- if(nextpush && current_screen.get() != NULL) {
+ if( (next_screen.get() != NULL || nextpop == true) &&
+ (screen_fade.get() == NULL || screen_fade->done())) {
+ if(current_screen.get() != NULL) {
current_screen->leave();
+ }
+
+ if(nextpop) {
+ if(screen_stack.empty()) {
+ running = false;
+ break;
+ }
+ next_screen.reset(screen_stack.back());
+ screen_stack.pop_back();
+ nextpop = false;
+ speed = 1.0;
+ } else if(current_screen.get() != NULL) {
screen_stack.push_back(current_screen.release());
}
ScriptManager::instance->fire_wakeup_event(ScriptManager::SCREEN_SWITCHED);
current_screen.reset(next_screen.release());
next_screen.reset(NULL);
- nextpush = false;
+ screen_fade.reset(NULL);
}
if(current_screen.get() == NULL)
if(!skipdraw) {
current_screen->draw(context);
if(Menu::current() != NULL)
- Menu::current()->draw(context);
+ Menu::current()->draw(context);
+ if(screen_fade.get() != NULL)
+ screen_fade->draw(context);
Console::instance->draw(context);
if(config->show_fps)
game_time += elapsed_time;
ScriptManager::instance->update();
current_screen->update(elapsed_time);
+ if(screen_fade.get() != NULL)
+ screen_fade->update(elapsed_time);
Console::instance->update(elapsed_time);
main_controller->update();
class Screen;
class Console;
+class ScreenFade;
class DrawingContext;
class MainLoop
~MainLoop();
void run();
- void exit_screen();
- void quit();
+ void exit_screen(ScreenFade* fade = NULL);
+ void quit(ScreenFade* fade = NULL);
void set_speed(float speed);
// push new screen on screen_stack
- void push_screen(Screen* screen);
+ void push_screen(Screen* screen, ScreenFade* fade = NULL);
+ void set_screen_fade(ScreenFade* fade);
private:
void draw_fps(DrawingContext& context, float fps);
bool running;
float speed;
- bool nextpush;
+ bool nextpop;
std::auto_ptr<Screen> next_screen;
std::auto_ptr<Screen> current_screen;
std::auto_ptr<Console> console;
+ std::auto_ptr<ScreenFade> screen_fade;
std::vector<Screen*> screen_stack;
};
pos += Vector(SCREEN_WIDTH * ((float) rand() / RAND_MAX),
SCREEN_HEIGHT/2 * ((float) rand() / RAND_MAX));
- float red = static_cast<float>(rand() % 255) / 255.0;
- float green = static_cast<float>(rand() % ((int) red*255)) / 255.0;
+ int r = rand() % 255;
+ int g = rand() % 255;
+ float red = r / 255.0;
+ float green = g / 255.0;
+ //float red = 0.7;
+ //float green = 0.9;
+ (void) red;
+ (void) green;
sector->add_object(new Particles(pos, 0, 360, Vector(140, 140),
Vector(0, 0), 45, Color(red, green, 0), 3, 1.3,
LAYER_FOREGROUND1+1));
#include "sprite/sprite.hpp"
#include "sector.hpp"
#include "resources.hpp"
-#include "video/screen.hpp"
#include "statistics.hpp"
#include "game_session.hpp"
#include "object/tilemap.hpp"
--- /dev/null
+// $Id: screen.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#ifndef __SCREENFADE_HPP__
+#define __SCREENFADE_HPP__
+
+#include "screen.hpp"
+
+/**
+ * A ScreenFade screen is displayed simultaneously with another screen. This
+ * is intended to be used for transitional effects like fade-out or shrink-fade
+ */
+class ScreenFade : public Screen
+{
+public:
+ virtual ~ScreenFade()
+ {}
+
+ /// returns true if the effect is completed
+ virtual bool done() = 0;
+};
+
+#endif
+
#include "object/player.hpp"
#include "object/tilemap.hpp"
#include "main.hpp"
+#include "fadeout.hpp"
+#include "shrinkfade.hpp"
#include "object/camera.hpp"
#include "flip_level_transformer.hpp"
main_loop->exit_screen();
}
+void fadeout_screen(float seconds)
+{
+ main_loop->set_screen_fade(new FadeOut(seconds));
+}
+
+void shrink_screen(float dest_x, float dest_y, float seconds)
+{
+ main_loop->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds));
+}
+
std::string translate(const std::string& text)
{
return dictionary_manager.get_dictionary().translate(text);
return c;
}
-
void import(HSQUIRRELVM vm, const std::string& filename)
{
IFileStream in(filename);
void save_state()
{
+ using namespace WorldMapNS;
+
if(World::current() == NULL)
throw std::runtime_error("Can't save state without active World");
+ if(WorldMap::current() != NULL)
+ WorldMap::current()->save_state();
World::current()->save_state();
}
void exit_screen();
/**
+ * Does a fadeout for the specified number of seconds before next screenchange
+ */
+void fadeout_screen(float seconds);
+
+/**
+ * Does a shrinking fade towards the destposition for the specified number of
+ * seconds before next screenchange
+ */
+void shrink_screen(float dest_x, float dest_y, float seconds);
+
+/**
* Translate a text into the users language (by looking it up in the .po
* files)
*/
}
+static int fadeout_screen_wrapper(HSQUIRRELVM vm)
+{
+ float arg0;
+ if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a float"));
+ return SQ_ERROR;
+ }
+
+ try {
+ Scripting::fadeout_screen(arg0);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'fadeout_screen'"));
+ return SQ_ERROR;
+ }
+
+}
+
+static int shrink_screen_wrapper(HSQUIRRELVM vm)
+{
+ float arg0;
+ if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a float"));
+ return SQ_ERROR;
+ }
+ float arg1;
+ if(SQ_FAILED(sq_getfloat(vm, 3, &arg1))) {
+ sq_throwerror(vm, _SC("Argument 2 not a float"));
+ return SQ_ERROR;
+ }
+ float arg2;
+ if(SQ_FAILED(sq_getfloat(vm, 4, &arg2))) {
+ sq_throwerror(vm, _SC("Argument 3 not a float"));
+ return SQ_ERROR;
+ }
+
+ try {
+ Scripting::shrink_screen(arg0, arg1, arg2);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'shrink_screen'"));
+ return SQ_ERROR;
+ }
+
+}
+
static int translate_wrapper(HSQUIRRELVM vm)
{
const char* arg0;
throw SquirrelError(v, "Couldn't register function 'exit_screen'");
}
+ sq_pushstring(v, "fadeout_screen", -1);
+ sq_newclosure(v, &fadeout_screen_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'fadeout_screen'");
+ }
+
+ sq_pushstring(v, "shrink_screen", -1);
+ sq_newclosure(v, &shrink_screen_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'shrink_screen'");
+ }
+
sq_pushstring(v, "translate", -1);
sq_newclosure(v, &translate_wrapper, 0);
if(SQ_FAILED(sq_createslot(v, -3))) {
--- /dev/null
+// $Id: screen.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <config.h>
+
+#include "shrinkfade.hpp"
+#include "main.hpp"
+#include "video/drawing_context.hpp"
+
+ShrinkFade::ShrinkFade(const Vector& dest, float fade_time)
+ : dest(dest), fade_time(fade_time), accum_time(0)
+{
+ speedleft = dest.x / fade_time;
+ speedright = (SCREEN_WIDTH - dest.x) / fade_time;
+ speedtop = dest.y / fade_time;
+ speedbottom = (SCREEN_HEIGHT - dest.y) / fade_time;
+}
+
+ShrinkFade::~ShrinkFade()
+{
+}
+
+void
+ShrinkFade::update(float elapsed_time)
+{
+ accum_time += elapsed_time;
+ if(accum_time > fade_time)
+ accum_time = fade_time;
+}
+
+void
+ShrinkFade::draw(DrawingContext& context)
+{
+ Color black(0, 0, 0);
+ float left = speedleft * accum_time;
+ float top = speedtop * accum_time;
+ float right = SCREEN_WIDTH - speedright * accum_time;
+ float bottom = SCREEN_HEIGHT - speedbottom * accum_time;
+
+ context.draw_filled_rect(Vector(0, 0),
+ Vector(left, SCREEN_HEIGHT),
+ black, LAYER_GUI+1);
+ context.draw_filled_rect(Vector(0, 0),
+ Vector(SCREEN_WIDTH, top),
+ black, LAYER_GUI+1);
+ context.draw_filled_rect(Vector(right, 0),
+ Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
+ black, LAYER_GUI+1);
+ context.draw_filled_rect(Vector(0, bottom),
+ Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
+ black, LAYER_GUI+1);
+}
+
+bool
+ShrinkFade::done()
+{
+ return accum_time >= fade_time;
+}
--- /dev/null
+// $Id: screen.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#ifndef __SHRINKFADE_HPP__
+#define __SHRINKFADE_HPP__
+
+#include "screen_fade.hpp"
+#include "math/vector.hpp"
+
+/**
+ * Shrinks a rectangle screen towards a specific position
+ */
+class ShrinkFade : public ScreenFade
+{
+public:
+ ShrinkFade(const Vector& point, float fade_time);
+ virtual ~ShrinkFade();
+
+ virtual void update(float elapsed_time);
+ virtual void draw(DrawingContext& context);
+
+ virtual bool done();
+
+private:
+ Vector dest;
+ float fade_time;
+ float accum_time;
+ float speedleft, speedright, speedtop, speedbottom;
+};
+
+#endif
+
#include "video/font.hpp"
#include "video/drawing_context.hpp"
#include "video/surface.hpp"
-#include "video/screen.hpp"
#include "gui/menu.hpp"
#include "lisp/parser.hpp"
#include "lisp/lisp.hpp"
#include "audio/sound_manager.hpp"
#include "main.hpp"
+#include "fadeout.hpp"
#include "control/joystickkeyboardcontroller.hpp"
static const float DEFAULT_SPEED = 20;
|| main_controller->pressed(Controller::MENU_SELECT))
scroll += SCROLL;
if(main_controller->pressed(Controller::PAUSE_MENU)) {
- fadeout(500);
- main_loop->exit_screen();
+ main_loop->exit_screen(new FadeOut(0.5));
}
scroll += speed * elapsed_time;
}
if(y < 0) {
- fadeout(500);
- main_loop->exit_screen();
+ main_loop->exit_screen(new FadeOut(0.5));
}
}
Tile::Tile()
- : id(0), editor_image(0), attributes(0), data(0), anim_fps(1)
+ : id(0), attributes(0), data(0), anim_fps(1)
{
}
Tile::Tile(unsigned int id_, Uint32 attributes_, const ImageSpec& imagespec)
- : id(id_), editor_image(0), attributes(attributes_), data(0), anim_fps(1)
+ : id(id_), attributes(attributes_), data(0), anim_fps(1)
{
imagespecs.push_back(imagespec);
}
++i) {
delete *i;
}
- delete editor_image;
}
void
const lisp::Lisp* images = reader.get_lisp("images");
if(images)
parse_images(*images);
- reader.get("editor-images", editor_imagefile);
}
void
}
images.push_back(surface);
}
- if(editor_imagefile != "") {
- editor_image = new Surface(tilesetpath + editor_imagefile);
- }
-}
-
-Surface*
-Tile::get_editor_image() const
-{
- if(editor_image)
- return editor_image;
- if(images.size() > 0)
- return images[0];
-
- return 0;
}
void
std::vector<ImageSpec> imagespecs;
std::vector<Surface*> images;
- std::string editor_imagefile;
- Surface* editor_image;
-
/** tile attributes */
uint32_t attributes;
/** Draw a tile on the screen */
void draw(DrawingContext& context, const Vector& pos, int layer) const;
- Surface* get_editor_image() const;
-
unsigned int getID() const
{ return id; }
#include "title.hpp"
#include "mainloop.hpp"
-#include "video/screen.hpp"
#include "video/drawing_context.hpp"
#include "video/surface.hpp"
#include "audio/sound_manager.hpp"
#include "resources.hpp"
#include "gettext.hpp"
#include "textscroller.hpp"
+#include "fadeout.hpp"
#include "file_system.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "control/codecontroller.hpp"
Menu::push_current(contrib_menu.get());
break;
case MNID_CREDITS:
- fadeout(500);
- main_loop->push_screen(new TextScroller("credits.txt"));
+ main_loop->push_screen(new TextScroller("credits.txt"),
+ new FadeOut(0.5));
break;
case MNID_QUITMAINMENU:
- main_loop->quit();
+ main_loop->quit(new FadeOut(0.25));
break;
}
} else if(menu == load_game_menu.get()) {
stream << "save/" << worlddirname << "_" << slot << ".stsg";
std::string slotfile = stream.str();
- fadeout(256);
-
try {
current_world->set_savegame_filename(slotfile);
current_world->run();
reader.get("height", h);
bbox.set_size(w, h);
reader.get("sequence", sequence_name);
+ triggerevent = EVENT_TOUCH;
}
SequenceTrigger::SequenceTrigger(const Vector& pos, const std::string& sequence)
+++ /dev/null
-// $Id$
-//
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#include <config.h>
-
-#include <iostream>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <cerrno>
-#include <assert.h>
-
-#include <unistd.h>
-
-#include <SDL.h>
-
-#include "gameconfig.hpp"
-#include "screen.hpp"
-#include "main.hpp"
-#include "video/drawing_context.hpp"
-#include "audio/sound_manager.hpp"
-#include "math/vector.hpp"
-
-static const float LOOP_DELAY = 20.0;
-
-void fillrect(float x, float y, float w, float h, const Color& col)
-{
- if(w < 0) {
- x += w;
- w = -w;
- }
- if(h < 0) {
- y += h;
- h = -h;
- }
-
- glColor4f(col.red, col.green, col.blue, col.alpha);
-
- glDisable(GL_TEXTURE_2D);
- glBegin(GL_POLYGON);
- glVertex2f(x, y);
- glVertex2f(x+w, y);
- glVertex2f(x+w, y+h);
- glVertex2f(x, y+h);
- glEnd();
- glEnable(GL_TEXTURE_2D);
-
- glColor4f(0, 0, 0, 1);
-}
-
-void fadeout(float fade_time)
-{
- float alpha_inc = LOOP_DELAY / fade_time;
- Color c(0, 0, 0, alpha_inc);
- float alpha = 1.0;
-
- while(alpha >= 0) {
- alpha -= alpha_inc;
- fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, c);
- // left side
-
- SDL_GL_SwapBuffers();
- sound_manager->update();
-
- SDL_Delay(int(LOOP_DELAY));
- alpha -= alpha_inc;
- }
-
- fillrect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, Color());
-}
-
-void shrink_fade(const Vector& point, float fade_time)
-{
- float left_inc = point.x / (fade_time / LOOP_DELAY);
- float right_inc = (SCREEN_WIDTH - point.x) / (fade_time / LOOP_DELAY);
- float up_inc = point.y / (fade_time / LOOP_DELAY);
- float down_inc = (SCREEN_HEIGHT - point.y) / (fade_time / LOOP_DELAY);
-
- float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
- Color c;
-
- while(left_cor < point.x && right_cor < SCREEN_WIDTH - point.x &&
- up_cor < point.y && down_cor < SCREEN_HEIGHT - point.y) {
- left_cor += left_inc;
- right_cor += right_inc;
- up_cor += up_inc;
- down_cor += down_inc;
-
- fillrect(0, 0, left_cor, SCREEN_HEIGHT, c); // left side
- fillrect(SCREEN_WIDTH - right_cor, 0, right_cor, SCREEN_HEIGHT, c); // right side
- fillrect(0, 0, SCREEN_WIDTH, up_cor, c); // up side
- fillrect(0, SCREEN_HEIGHT - down_cor, SCREEN_WIDTH, down_cor+1, c); // down side
-
- SDL_GL_SwapBuffers();
-
- sound_manager->update();
- SDL_Delay(int(LOOP_DELAY));
- }
-}
-
+++ /dev/null
-// $Id$
-//
-// SuperTux
-// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef SUPERTUX_SCREEN_H
-#define SUPERTUX_SCREEN_H
-
-#include <SDL.h>
-#include <GL/gl.h>
-#include <iostream>
-
-#include <vector>
-#include "math/vector.hpp"
-
-void fadeout(float fade_time);
-void shrink_fade(const Vector& point, float fade_time);
-
-#endif
#include "gameconfig.hpp"
#include "physfs/physfs_sdl.hpp"
#include "video/surface.hpp"
-#include "video/screen.hpp"
#include "image_texture.hpp"
#include "texture_manager.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include "mainloop.hpp"
+#include "shrinkfade.hpp"
#include "video/surface.hpp"
-#include "video/screen.hpp"
#include "video/drawing_context.hpp"
#include "sprite/sprite_manager.hpp"
#include "audio/sound_manager.hpp"
}
if (level->pos == tux->get_tile_pos()) {
- // do a shriking fade to the level
- shrink_fade(Vector((level->pos.x*32 + 16 + camera_offset.x),
- (level->pos.y*32 + 16 + camera_offset.y)), 500);
-
try {
- main_loop->push_screen(new GameSession(
- levels_path + level->name, &level->statistics));
+ Vector shrinkpos = Vector(level->pos.x*32 + 16 - camera_offset.x,
+ level->pos.y*32 + 16 - camera_offset.y);
+ std::string levelfile = levels_path + level->name;
+ main_loop->push_screen(new GameSession(levelfile, &level->statistics),
+ new ShrinkFade(shrinkpos, 0.5));
} catch(std::exception& e) {
log_fatal << "Couldn't load level: " << e.what() << std::endl;
}
#include <string>
#include "math/vector.hpp"
-#include "video/screen.hpp"
#include "lisp/lisp.hpp"
#include "control/controller.hpp"
#include "statistics.hpp"