Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7938/src
Modified Files:
badguy.cpp sprite.cpp sprite.h texture.cpp texture.h
Log Message:
Draw enemies upside down when falling.
The drawing code in texture.cpp is just a hack. Not sure how we can flip surfaces in SDL. The OpenGL should be easily done, I will take care of it later.
Index: badguy.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- badguy.cpp 25 May 2004 22:05:05 -0000 1.94
+++ badguy.cpp 27 May 2004 14:18:00 -0000 1.95
@@ -978,7 +978,10 @@
}
Sprite* sprite = (dir == LEFT) ? sprite_left : sprite_right;
- sprite->draw(viewport.world2screen(Vector(base.x, base.y)));
+ if(dying == DYING_FALLING)
+ sprite->draw(viewport.world2screen(Vector(base.x, base.y)), SD_VERTICAL_FLIP);
+ else
+ sprite->draw(viewport.world2screen(Vector(base.x, base.y)));
if (debug_mode)
fillrect(base.x - scroll_x, base.y - scroll_y, base.width, base.height, 75,0,75, 150);
Index: sprite.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/sprite.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- sprite.cpp 20 May 2004 23:07:25 -0000 1.10
+++ sprite.cpp 27 May 2004 14:18:00 -0000 1.11
@@ -73,13 +73,20 @@
}
void
-Sprite::draw(float x, float y)
+Sprite::draw(float x, float y, int special_drawing)
{
time = SDL_GetTicks();
unsigned int frame = get_current_frame();
if (frame < surfaces.size())
- surfaces[frame]->draw(x - x_hotspot, y - y_hotspot);
+ {
+ if(special_drawing == SD_SEMI_TRANSPARENT)
+ surfaces[frame]->draw(x - x_hotspot, y - y_hotspot, 128);
+ if(special_drawing == SD_VERTICAL_FLIP)
+ surfaces[frame]->draw(x - x_hotspot, y - y_hotspot, 255, true);
+ else
+ surfaces[frame]->draw(x - x_hotspot, y - y_hotspot);
+ }
}
void
Index: sprite.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/sprite.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sprite.h 20 May 2004 23:07:25 -0000 1.7
+++ sprite.h 27 May 2004 14:18:00 -0000 1.8
@@ -26,6 +26,8 @@
#include "texture.h"
#include "vector.h"
+enum SpecialDrawing { SD_NONE, SD_VERTICAL_FLIP, SD_SEMI_TRANSPARENT };
+
class Sprite
{
private:
@@ -56,12 +58,12 @@
/** Update the sprite and process to the next frame */
void update(float delta);
- void draw(float x, float y);
+ void draw(float x, float y, int special_drawing = SD_NONE);
void draw_part(float sx, float sy, float x, float y, float w, float h);
int get_current_frame() const;
- void draw(const Vector& pos)
- { draw(pos.x, pos.y); }
+ void draw(const Vector& pos, int special_drawing = SD_NONE)
+ { draw(pos.x, pos.y, special_drawing); }
std::string get_name() const { return name; }
int get_width() const;
Index: texture.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/texture.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- texture.h 20 May 2004 12:12:38 -0000 1.24
+++ texture.h 27 May 2004 14:18:00 -0000 1.25
@@ -88,7 +88,7 @@
/** Reload the surface, which is necesarry in case of a mode swich */
void reload();
- void draw(float x, float y, Uint8 alpha = 255, bool update = false);
+ void draw(float x, float y, Uint8 alpha = 255, bool upside_down = false, bool update = false);
void draw_bg(Uint8 alpha = 255, bool update = false);
void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha = 255, bool update = false);
void draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update = false);
Index: texture.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/texture.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- texture.cpp 9 May 2004 18:08:02 -0000 1.25
+++ texture.cpp 27 May 2004 14:18:00 -0000 1.26
@@ -207,11 +207,15 @@
}
void
-Surface::draw(float x, float y, Uint8 alpha, bool update)
+Surface::draw(float x, float y, Uint8 alpha, bool upside_down, bool update)
{
if (impl)
{
- if (impl->draw(x, y, alpha, update) == -2)
+ if(upside_down) // FIXME: this should be done by the SDL and OpenGL draw()
+ for(float sy = 0; sy < h; sy++)
+ impl->draw_part(0, sy, x, y+(h-sy), w, 1, alpha, update);
+
+ else if (impl->draw(x, y, alpha, update) == -2)
reload();
}
}
|