Sometimes doesn't work, i'll have a look at the fade func later.
SVN-Revision: 1349
void draw_intro()
{
-if(debug_mode)
- fade("/images/background/arctis.jpg", 30, false);
+shrink_fade(Point((screen->w/2),(screen->h/2)), 2000);
display_text_file("intro.txt", "/images/background/arctis.jpg", SCROLL_SPEED_MESSAGE);
}
}
}
+/** This fade shrinks to the given point */
+
+#define LOOP_DELAY 20
+void shrink_fade(Point point, int fade_time)
+{
+float left_inc = (float)point.x / ((float)fade_time / LOOP_DELAY);
+float right_inc = ((float)screen->w - point.x) / ((float)fade_time / LOOP_DELAY);
+float up_inc = (float)point.y / ((float)fade_time / LOOP_DELAY);
+float down_inc = ((float)screen->h - point.y) / ((float)fade_time / LOOP_DELAY);
+
+float left_cor = 0, right_cor = 0, up_cor = 0, down_cor = 0;
+
+while(left_cor < screen->w - point.x && right_cor < screen->w - point.x &&
+ up_cor < screen->h - point.y && down_cor < screen->h - point.y)
+ {
+ left_cor += left_inc;
+ right_cor += right_inc;
+ up_cor += up_inc;
+ down_cor += down_inc;
+
+ fillrect(0, 0, left_cor, screen->h, 0,0,0); // left side
+ fillrect(screen->w - right_cor, 0, right_cor, screen->h, 0,0,0); // right side
+ fillrect(0, 0, screen->w, up_cor, 0,0,0); // up side
+ fillrect(0, screen->h - down_cor, screen->w, down_cor, 0,0,0); // down side
+
+ flipscreen();
+ SDL_Delay(LOOP_DELAY);
+ }
+}
+
/* 'Stolen' from the SDL documentation.
* Set the pixel at (x, y) to the given value
* NOTE: The surface must be locked before calling this!
int red, green, blue;
};
+struct Point
+{
+ Point() : x(0), y(0) {}
+
+ Point(const Point& pos)
+ : x(pos.x), y(pos.y) {}
+
+ Point& operator=(const Point& pos)
+ { x = pos.x;
+ y = pos.y;
+ return *this; }
+
+ Point(int x_, int y_)
+ : x(x_), y(y_) {}
+
+ int x;
+ int y;
+};
+
void drawline(int x1, int y1, int x2, int y2, int r, int g, int b, int a);
void clearscreen(int r, int g, int b);
void drawgradient(Color top_clr, Color bot_clr);
-void fillrect(float x, float y, float w, float h, int r, int g, int b, int a);
+void fillrect(float x, float y, float w, float h, int r, int g, int b, int a = 255);
//void black_fade(Surface* surface, int seconds, bool fade_out);
void fade(const std::string& surface, int seconds, bool fade_out);
+void shrink_fade(Point point, int fade_time);
void updatescreen(void);
void flipscreen(void);
void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
{
PlayerStatus old_player_status = player_status;
- std::cout << "Enter the current level: " << level->name << std::endl;;
+ std::cout << "Enter the current level: " << level->name << std::endl;
+ // do a shriking fade to the level
+ shrink_fade(Point((level->x*32 + 16 + offset.x),(level->y*32 + 16 + offset.y)), 3000);
GameSession session(datadir + "/levels/" + level->name,
1, ST_GL_LOAD_LEVEL_FILE);
#include <string>
#include "musicref.h"
+#include "screen.h"
namespace WorldMapNS {
-struct Point
-{
- Point() : x(0), y(0) {}
-
- Point(const Point& pos)
- : x(pos.x), y(pos.y) {}
-
- Point& operator=(const Point& pos)
- { x = pos.x;
- y = pos.y;
- return *this; }
-
- Point(int x_, int y_)
- : x(x_), y(y_) {}
-
- int x;
- int y;
-};
-
class Tile
{
public: