I hereby claim:
- I am mikepicker on github.
- I am mikepicker (https://keybase.io/mikepicker) on keybase.
- I have a public key ASBV-rCdor5LkYkzuyARoo81AnHDMm-8wLz0ocYzRGSiNQo
To claim this, I am signing this object:
void update() { | |
// Physics | |
survivor.y += world.gravity; | |
// Platform collision | |
if (survivor.y + survivor.h > platform.y && | |
survivor.x + 48 >= platform.x && | |
survivor.x + survivor.w - 48 <= platform.x + platform.w && | |
survivor.y + (survivor.h/2) < platform.y) { |
bool loadMedia() { | |
// Init survivor | |
survivor.texture = loadTexture("assets/survivor.png"); | |
survivor.x = 200; | |
survivor.y = 100; | |
survivor.w = 64; | |
survivor.h = 64; | |
survivor.scaleX = 1; | |
survivor.scaleY = 1; |
struct Survivor { | |
int x, y, w, h; | |
int scaleX, scaleY; | |
int frameX, frameY; | |
int animSpeed = 6; | |
int speed = 3; | |
bool animCompleted = false; | |
bool shot = false; | |
std::string state; | |
SDL_Texture* texture; |
void render() { | |
// Render background | |
SDL_Rect dstBackground = { .x = background.x, .y = background.y, .w = background.w, .h = background.h }; | |
SDL_RenderCopy(gRenderer, background.texture, NULL, &dstBackground); | |
// Render platform | |
SDL_Rect dstPlatf = { .x = platform.x, .y = platform.y, .w = platform.w, .h = platform.h }; | |
SDL_RenderCopy(gRenderer, platform.texture, NULL, &dstPlatf); | |
} |
bool loadMedia() { | |
// Loading success flag | |
bool success = true; | |
// Init background | |
background.texture = loadTexture("assets/background.png"); | |
SDL_QueryTexture(background.texture, NULL, NULL, &background.w, &background.h); | |
background.x = 0; | |
background.y = SCREEN_HEIGHT-background.h; |
// Game objects | |
struct Background { | |
SDL_Texture* texture; | |
}; | |
struct Platform { | |
int x, y, w, h; | |
SDL_Texture* texture; | |
}; |
I hereby claim:
To claim this, I am signing this object: