Dumb-ways-to-memorize
2D game
|
Go to the source code of this file.
Data Structures | |
struct | Frame |
struct | sprite_t |
Macros | |
#define | GAME_NAME "Dumb Ways to Memorize" |
#define | SCREEN_STRING "Screen Dimensions" |
#define | SCREEN_RES_W 1280 |
#define | SCREEN_RES_H 720 |
#define | MAX_SPRITES 500 |
#define | MAX_ANIMATIONS 20 |
Functions | |
int | InitGraphics () |
void | ShutdownGraphics () |
Frame * | LoadAnimation (int frame_width, int frame_height, int width, int height) |
sprite_t * | FindSprite (const char *name, int *position) |
sprite_t * | FindFreeSprite (int *position) |
sprite_t * | LoadSprite (const char *name, int flags) |
int | DrawSprite (sprite_t *sprite, int *frame, vec2_t *position, SDL_Renderer *renderer) |
void | FreeSprite (sprite_t *sprite) |
void | IncrementFrame (sprite_t *sprite) |
void | SDL_SetRect (SDL_Rect *rect, int x, int y, int w, int h) |
Variables | |
sprite_t * | gSprites |
int | gLastSprite |
SDL_Window * | gWindow |
SDL_Renderer * | gRenderer |
SDL_Surface * | gRedSurface |
SDL_Texture * | gRedTexture |
SDL_Renderer * | gRedRenderer |
#define GAME_NAME "Dumb Ways to Memorize" |
Definition at line 7 of file graphics.h.
Referenced by InitGraphics().
#define MAX_ANIMATIONS 20 |
Definition at line 12 of file graphics.h.
Referenced by ParseToEntity().
#define MAX_SPRITES 500 |
Definition at line 11 of file graphics.h.
Referenced by FindFreeSprite(), FindSprite(), InitGraphics(), LoadSprite(), and ShutdownGraphics().
#define SCREEN_RES_H 720 |
Definition at line 10 of file graphics.h.
Referenced by InitGraphics(), and ProcessMenuItemsByType().
#define SCREEN_RES_W 1280 |
Definition at line 9 of file graphics.h.
Referenced by InitGraphics(), and ProcessMenuItemsByType().
#define SCREEN_STRING "Screen Dimensions" |
Definition at line 8 of file graphics.h.
Referenced by LoadGameData().
int DrawSprite | ( | sprite_t * | sprite, |
int * | frame, | ||
vec2_t * | position, | ||
SDL_Renderer * | renderer | ||
) |
Draw the sprite. If mCurrentFrame not set, draws the first frame (0,0). If no position given, will draw as if was background.
[in,out] | sprite | If non-null, the sprite. |
[in,out] | frame | If non-null, the frame number to draw. |
[in,out] | position | If non-null, the position. |
[in,out] | renderer | If non-null, the renderer. |
Definition at line 152 of file graphics.c.
References SDL_SetRect(), vec2_t::x, and vec2_t::y.
Referenced by DrawGeneric(), DrawLevel(), DrawMenuByNum(), DrawMenuByState(), and DrawSplash().
sprite_t* FindFreeSprite | ( | int * | position | ) |
Searches for the first free sprite in sprite system memory.
[in,out] | position | If non-null, the position. |
Definition at line 226 of file graphics.c.
References gLastSprite, gSprites, and MAX_SPRITES.
Referenced by LoadSprite().
sprite_t* FindSprite | ( | const char * | name, |
int * | position | ||
) |
Searches for the first sprite.
name | The name of the sprite file. | |
[in,out] | position | If non-null, the position. |
Definition at line 209 of file graphics.c.
References gSprites, and MAX_SPRITES.
Referenced by FreeSprite(), and LoadSprite().
void FreeSprite | ( | sprite_t * | sprite | ) |
Free the sprite memory, if recfcount - 1 > 0 nothing happens.
[in,out] | sprite | If non-null, the sprite. |
Definition at line 246 of file graphics.c.
References FindSprite(), and gSprites.
Referenced by ShutdownGraphics().
void IncrementFrame | ( | sprite_t * | sprite | ) |
int InitGraphics | ( | ) |
Init graphics system. Calls SDL_Init and allocates memory for the sprites.
Definition at line 19 of file graphics.c.
References GAME_NAME, gLastSprite, gRedRenderer, gRedSurface, gRedTexture, gRenderer, gScreenHeight, gScreenWidth, gSprites, gWindow, MAX_SPRITES, SCREEN_RES_H, SCREEN_RES_W, and ShutdownGraphics().
Referenced by Setup().
Frame* LoadAnimation | ( | int | frame_width, |
int | frame_height, | ||
int | width, | ||
int | height | ||
) |
Loads an animation based on frame_width & frame_height.
frame_width | Width of the frame. |
frame_height | Height of the frame. |
width | The width. |
height | The height. |
Definition at line 190 of file graphics.c.
References Frame::Position, vec2_t::x, and vec2_t::y.
Referenced by ParseToEntity().
sprite_t* LoadSprite | ( | const char * | name, |
int | flags | ||
) |
Loads a sprite.
name | The file name of the image to load. |
flags | The flags. |
Definition at line 107 of file graphics.c.
References FindFreeSprite(), FindSprite(), gLastSprite, gRenderer, gSprites, and MAX_SPRITES.
Referenced by AddSpritesToEnt(), LoadLevel(), LoadMenu(), and Update().
void SDL_SetRect | ( | SDL_Rect * | rect, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Sdl set rectangle dimensions.
[in,out] | rect | If non-null, the rectangle to set. |
x | The x coordinate. | |
y | The y coordinate. | |
w | The width. | |
h | The height. |
Definition at line 276 of file graphics.c.
Referenced by DrawSprite(), and ProcessMenuItemsByType().
void ShutdownGraphics | ( | ) |
Shutdown graphics system, which frees all sprite data.
Definition at line 92 of file graphics.c.
References FreeSprite(), gSprites, and MAX_SPRITES.
Referenced by InitGraphics().
int gLastSprite |
Definition at line 15 of file graphics.c.
Referenced by FindFreeSprite(), InitGraphics(), and LoadSprite().
SDL_Renderer* gRedRenderer |
Definition at line 13 of file graphics.c.
Referenced by InitGraphics().
SDL_Surface* gRedSurface |
Definition at line 11 of file graphics.c.
Referenced by InitGraphics().
SDL_Texture* gRedTexture |
Definition at line 12 of file graphics.c.
Referenced by DrawMenuByNum(), DrawMenuByState(), and InitGraphics().
SDL_Renderer* gRenderer |
Definition at line 10 of file graphics.c.
Referenced by Draw(), DrawGeneric(), DrawLevel(), DrawMenuByNum(), DrawMenuByState(), DrawSplash(), InitGraphics(), and LoadSprite().
sprite_t* gSprites |
Definition at line 14 of file graphics.c.
Referenced by FindFreeSprite(), FindSprite(), FreeSprite(), InitGraphics(), LoadSprite(), and ShutdownGraphics().
SDL_Window* gWindow |
Definition at line 9 of file graphics.c.
Referenced by InitGraphics().