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.
SVN-Revision: 1338
}
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);
}
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
#include "texture.h"
#include "vector.h"
+enum SpecialDrawing { SD_NONE, SD_VERTICAL_FLIP, SD_SEMI_TRANSPARENT };
+
class Sprite
{
private:
/** 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;
}
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();
}
}
/** 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);