No constructor.Methods:
virtual void draw(void)
Draws the shape.
virtual void clear(Uint32 color)
Removes the shape by clearing it to a color.
virtual void clear(SDL_Surface *src, Sint16 srcX, Sint16 srcY)
Removes the shape by blitting a part of src over it.
virtual void UpdateRects(void)
Updates (SDL/sge_UpdateRect) areas that have been cleared or drawn.
SDL_Rect get_pos(void)
Returns the current (maybe undrawn) position.
SDL_Rect get_last_pos(void)
Returns the last drawn position.
Sint16 get_xpos(void)
Sint16 get_ypos(void)
Returns the upper left corner of shape.
Sint16 get_w(void)
Sint16 get_h(void)
Returns the width and height of the shape.
SDL_Surface* get_dest(void)
Returns the surface on which this class operates on.
Usefull coords in shape
These methods returns some useful (current) coords in shape.NW N NE W C E SW S SESint16 c_x(void)
Sint16 c_y(void)
Sint16 nw_x(void)
Sint16 nw_y(void)
Sint16 n_x(void)
Sint16 n_y(void)
Sint16 ne_x(void)
Sint16 ne_y(void)
Sint16 e_x(void)
Sint16 e_y(void)
Sint16 se_x(void)
Sint16 se_y(void)
Sint16 s_x(void)
Sint16 s_y(void)
Sint16 sw_x(void)
Sint16 sw_y(void)
Sint16 w_x(void)
Sint16 w_y(void)
sge_surface(SDL_Surface *dest, SDL_Surface *src, Sint16 x=0, Sint16 y=0)Methods:
Dest is the surface you want to blit to, src is the image.
virtual void move_to(Sint16 x, Sint16 y)
Moves the image to a new coord.
virtual void move(Sint16 x_step, Sint16 y_step)
Moves the image x/y steps to the left/down (or right/up if negative step size).
SDL_Surface* get_img(void)
Returns a pointer to the image.
sge_ssprite(SDL_Surface *screen, SDL_Surface *img, Sint16 x=0, Sint16 y=0)Methods:
Img is the first frame to show.
sge_ssprite(SDL_Surface *screen, SDL_Surface *img, sge_cdata *cdata, Sint16 x=0, Sint16 y=0)
As above but with collision data [sge_collision].
void set_vel(Sint16 x, Sint16 y)
void set_xvel(Sint16 x)
void set_yvel(Sint16 y)
Sets the speed (pixels/update).
Sint16 get_xvel(void)
Sint16 get_yvel(void)
Returns the current speed.
virtual bool update(void)
Move the sprite according to the speeds. Returns true if the position changed.
void add_frame(SDL_Surface *img)
void add_frame(SDL_Surface *img, sge_cdata *cdata)
Adds a new frame to the sprite, with or without collision data [sge_collision]. This resets the playing sequence.
void skip_frame(int skips)
void next_frame(void)
void prev_frame(void)
void first_frame(void)
void last_frame(void)
Change the current frame. Calling next_frame()/prev_frame() is the same thing as calling skip_frame(1)/skip_frame(-1). First_frame()/last_frame() sets the first/last frame in the sequence as the current frame (but does not change the sequence).
void set_seq(int start, int stop, playing_mode mode=loop)
void reset_seq(void)
sge_ssprite::playing_mode get_PlayingMode(void)
Changes the frame playing sequence. The default is to loop over all frames (next_frame() returns to the first frame when the last frame has been shown). Use set_seq() to set the start and stop frame (frame 0 is the first frame) and playing mode. You can set the following playing modes:
Use reset_seq() to reset to the default sequence.
- sge_ssprite::loop - loops forever.
- sge_ssprite::play_once - just once then stops on the last frame.
Get_PlayingMode() returns the current mode or sge_ssprite::stop if all frames in the sequence has been shown (only possible if sge_ssprite::play_once was used).
void set_border(SDL_Rect box)
void border_bounce(bool mode)
void border_warp(bool mode)
The sprite will bounce at the border of the screen as default. You can change the allowed rectangle with set_border() or turn this off completely with border_bounce(false). You can also make the sprite warp (pixel for pixel) at the border with border_warp(true).
sge_cdata* get_cdata(void)
Returns the collision map for the current frame (or NULL if no one exist).
sge_frame* get_frame(void)
Returns the frame data for the current frame:struct sge_frame{ //The image SDL_Surface *img; //Collision data sge_cdata *cdata; };std::list<sge_frame*>* get_list(void)
The linked list with frames is stored in a STL list<> container. This method returns a pointer to this list. If you change anything in the list you *MUST* call reset_seq()!
sge_sprite(SDL_Surface *screen, SDL_Surface *img, Sint16 x=0, Sint16 y=0)Methods:
sge_sprite(SDL_Surface *screen, SDL_Surface *img, sge_cdata *cdata, Sint16 x=0, Sint16 y=0)
void set_pps(Sint16 x, Sint16 y)
void set_xpps(Sint16 x)
void set_ypps(Sint16 y)
void set_fps(Sint16 f)
Sets the speed (pixels/second). Set_fps() sets how fast (frames/second) the frames should be changed.
Sint16 get_xpps(void)
Sint16 get_ypps(void)
Sint16 get_fps(void)
Returns the current speeds.
bool update(Uint32 ticks)
bool update(void)
Updates the internal status (calculates the new position and changes the current frame if needed). You can let update() call SDL_GetTicks() itself or provide the information. Returns true if the sprite changed position or frame.
void pause(void)
Halt the sprite until next call to update().
sge_screen(SDL_Surface *screen)Methods:
void add_rect(SDL_Rect rect)
void add_rect(Sint16 x, Sint16 y, Uint32 w, Uint32 h)
Adds an rectangle to be updated (with SDL_UpdateRects()) on update() if needed.
void add_shape(sge_shape *shape)
void add_shape_p(sge_shape *shape)
Adds an sge_shape to be drawn and updated (if needed) on update().
void remove_shape_p(sge_shape *shape)
Removes an sge_shape from the permanent list.
void clear_all(void)
Clears all shapes (even those added with add_shape_p()) and rectangles.
void update(void)
Draws all shapes and updates all rectangles and shapes. All shapes and rectangales are then cleared (beside those added with add_shape_p()) from the class.
Copyright © 1999-2003 Anders Lindström
Last updated 030809