-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
87 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,37 @@ | ||
#include "key.hpp" | ||
#include "../mob.hpp" | ||
#include "../mob/link.hpp" | ||
#include "../../graphic/effect/bounce.hpp" | ||
#include "../../audio/sound.hpp" | ||
|
||
SpriteSheet* Key::SPRITESHEET; | ||
std::vector<Sprite*> Key::KEYS; | ||
sf::SoundBuffer* Key::GET_SOUND; | ||
|
||
void Key::Load() { | ||
SPRITESHEET = new SpriteSheet("item/keys.png", 32, 16, 16, 16); | ||
KEYS = SPRITESHEET->GetSprites(0, 3); | ||
GET_SOUND = Sound::Buffer("rupee/get.wav"); | ||
} | ||
|
||
Key::Key(Key::Type type, float x, float y) : | ||
super(KEYS[type], x, y, vec2f(0, -10)), | ||
key_type_(type) | ||
{ | ||
die_sound_ = GET_SOUND; | ||
ChangeEffect(new Bounce(12, 0.25)); | ||
} | ||
|
||
bool Key::HandleCollisionWith(Mob* mob) { | ||
if(not IsAlive()) | ||
return false; | ||
|
||
if(key_type_ == SMALL) { | ||
((Link*)mob)->UpdateSmallKeys(1); | ||
} else { | ||
((Link*)mob)->UpdateBossKeys(1); | ||
} | ||
|
||
Kill(); | ||
return false; | ||
} |
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,25 @@ | ||
#pragma once | ||
|
||
#include "../item.hpp" | ||
#include "../../graphic/spritesheet.hpp" | ||
|
||
class Key : public Item { | ||
public: | ||
typedef Item super; | ||
enum Type { | ||
BOSS, SMALL | ||
}; | ||
|
||
static SpriteSheet* SPRITESHEET; | ||
static std::vector<Sprite*> KEYS; | ||
static sf::SoundBuffer* GET_SOUND; | ||
|
||
static void Load(); | ||
|
||
Key(Key::Type type, float x, float y); | ||
|
||
bool HandleCollisionWith(Mob* mob); | ||
|
||
private: | ||
Key::Type key_type_; | ||
}; |
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