-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Created by engin on 24.04.2019. | ||
// | ||
|
||
#include "Flag.h" | ||
#include "../Utils.h" | ||
|
||
|
||
Flag::Flag(SDL_Renderer *ren, int x, int y) { | ||
collisionBox = new AABB( | ||
x * TILE_SIZE - TILE_SIZE, // 2 tiles width | ||
x * TILE_SIZE + TILE_SIZE -1, | ||
y * TILE_SIZE, | ||
y * TILE_SIZE + TILE_SIZE -1); //-1 because 32 is not part of box. pixels 0 - TILE_SIZE, TILE_SIZE excluded | ||
|
||
|
||
std::string flagImage = Utils::getResourcePath("flag") + "flag.bmp"; | ||
texture = Utils::loadTexture(ren, flagImage); | ||
|
||
} | ||
|
||
Flag::~Flag() { | ||
SDL_DestroyTexture(texture); | ||
delete(collisionBox); | ||
} | ||
void Flag::render(SDL_Renderer *renderer, int x, int y, long time) { | ||
SDL_Rect screenPos; | ||
screenPos.x = collisionBox->getLeftBorder() - x; | ||
screenPos.y = collisionBox->getUpBorder() - y; | ||
screenPos.w = TILE_SIZE * 2; | ||
screenPos.h = TILE_SIZE; | ||
SDL_RendererFlip flip = SDL_FLIP_NONE; | ||
SDL_RenderCopyEx(renderer, getTexture(time), nullptr, &screenPos, 0, nullptr, flip); | ||
} | ||
|
||
TileTypes Flag::interactWithSide(std::shared_ptr<Context> context, std::shared_ptr<InteractiveObject> otherObject, | ||
CollisionSide interactionSide, long time) { | ||
return EMPTY; | ||
} | ||
|
||
void Flag::step(std::shared_ptr<Context> context, long time) { | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Created by engin on 24.04.2019. | ||
// | ||
|
||
#ifndef MARIO_FLAG_H | ||
#define MARIO_FLAG_H | ||
|
||
|
||
#include "InteractiveObject.h" | ||
|
||
class Flag : public InteractiveObject { | ||
AABB* collisionBox; | ||
SDL_Texture * texture; | ||
|
||
public: | ||
|
||
Flag(SDL_Renderer *ren, int x, int y); | ||
|
||
~Flag(); | ||
|
||
AABB *getPosition() const override { | ||
return collisionBox; | ||
} | ||
|
||
SDL_Texture *getTexture(long time) const override { | ||
return texture; | ||
} | ||
|
||
TileTypes getTileType() const override { | ||
return TileTypes::FLAG; | ||
} | ||
|
||
void render(SDL_Renderer *renderer, int x, int y, long time) override; | ||
|
||
TileTypes interactWithSide(std::shared_ptr<Context> context, std::shared_ptr<InteractiveObject> otherObject, | ||
CollisionSide interactionSide, long time) override; | ||
|
||
void step(std::shared_ptr<Context> context, long time) override; | ||
|
||
bool waitingForDestroy() const override { | ||
return false; | ||
} | ||
}; | ||
|
||
|
||
#endif //MARIO_FLAG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters