Skip to content

Commit

Permalink
Changed Rectangle class name (portability).
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Nov 4, 2014
1 parent a01fadd commit b9a4278
Show file tree
Hide file tree
Showing 35 changed files with 129 additions and 129 deletions.
4 changes: 2 additions & 2 deletions src/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ void Entity::set_level(Level* level) {
}

void Entity::NotifyCollisions() {
std::vector<Rectangle*> collidables;
std::vector<RectangleShape*> collidables;
level_->CollidablesFor(this, collidables);

for(Rectangle* collidable : collidables) {
for(RectangleShape* collidable : collidables) {
if(collidable->IsEntity() && ((Entity*)collidable)->IsMob()) {
Mob* mob = (Mob*)collidable;

Expand Down
2 changes: 1 addition & 1 deletion src/entity/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Event::Event(Level* level, float x, float y, float width, float height) :
level_(level)
{}

bool Event::CanCollideWith(Rectangle* rectangle) const {
bool Event::CanCollideWith(RectangleShape* rectangle) const {
return rectangle->IsEntity() and ((Entity*)rectangle)->type() == PLAYER;
}
6 changes: 3 additions & 3 deletions src/entity/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include "../math/rectangle.hpp"
#include "../map/level.hpp"

class Event : public Rectangle {
class Event : public RectangleShape {
public:
typedef Rectangle super;
typedef RectangleShape super;
Event(Level* level, float x, float y, float width, float height);

bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;

protected:
Level* level_;
Expand Down
2 changes: 1 addition & 1 deletion src/entity/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Item::Item(Sprite* sprite, float x, float y, const vec2f& offset) :
}


bool Item::CanCollideWith(Rectangle* rectangle) const {
bool Item::CanCollideWith(RectangleShape* rectangle) const {
// Items are only collidable with the Player
return not current_effect_ and rectangle->IsEntity() and ((Entity*) rectangle)->type() == PLAYER;
}
Expand Down
2 changes: 1 addition & 1 deletion src/entity/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Item : public Object {
typedef Object super;
Item(Sprite* sprite, float x, float y, const vec2f& offset);

bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;

void Damage(Entity* from, int damage);
void Dead();
Expand Down
16 changes: 8 additions & 8 deletions src/entity/mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ void Mob::AddAction(const std::string& name, Action* action) {
}

void Mob::MeleeAttack(Hitbox* hitbox) {
std::vector<Rectangle*> candidates;
std::vector<RectangleShape*> candidates;
level_->DynamicCollidablesFor(hitbox, candidates);

for(Rectangle* candidate : candidates) {
for(RectangleShape* candidate : candidates) {
if(candidate->CanCollideWith(this) and candidate->CanReceiveDamageFrom(this) and hitbox->CollidesWith(candidate)) {
if(candidate->IsEntity() && ((Entity*) candidate)->IsVulnerable()) {
Collision c = hitbox->CollisionType(candidate);
Expand Down Expand Up @@ -221,15 +221,15 @@ Entity* Mob::SeekPlayer() const {
}

Entity* Mob::SeekEnemy() const {
Rectangle rectangle(position_.x - 25, position_ .y - 25, 50, 50);
RectangleShape rectangle(position_.x - 25, position_ .y - 25, 50, 50);

std::vector<Rectangle*> candidates;
std::vector<RectangleShape*> candidates;
level_->DynamicCollidablesFor(&rectangle, candidates);

Entity* selected = 0;
float dist = 130;

for(Rectangle* candidate : candidates) {
for(RectangleShape* candidate : candidates) {
if(candidate->IsEntity()) {
Entity* entity = (Entity*) candidate;

Expand Down Expand Up @@ -290,10 +290,10 @@ bool Mob::_UpdatePosition(const vec2f& new_position) {
vec2f old_position = position_;
position_ = new_position;

std::vector<Rectangle*> collidables;
std::vector<RectangleShape*> collidables;
level_->CollidablesFor(this, collidables);

for(Rectangle* collidable : collidables) {
for(RectangleShape* collidable : collidables) {
if(collidable->CanCollideWith(this) && CollidesWith(collidable)) {
if(collidable->HandleCollisionWith(this)) {
position_ = old_position;
Expand All @@ -318,6 +318,6 @@ float Mob::speed() const {
return speed_;
}

bool Mob::CanCollideWith(Rectangle* rectangle) const {
bool Mob::CanCollideWith(RectangleShape* rectangle) const {
return not rectangle->IsEntity() or ((Entity*)rectangle)->type() != type_;
}
2 changes: 1 addition & 1 deletion src/entity/mob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mob : public Entity {
Entity* SeekEnemy() const ;
Path* FindPath(Entity* to);
bool FollowPath(Path* path, double delta);
bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;
float speed() const;

sf::SoundBuffer* attack_sound() const;
Expand Down
4 changes: 2 additions & 2 deletions src/entity/mob/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int Link::boss_keys() const {
return boss_keys_;
}

bool Link::CollidesWith(Rectangle const * rectangle) const {
bool Link::CollidesWith(RectangleShape const * rectangle) const {
return super::CollidesWith(rectangle) and (
(not rectangle->IsEntity()) or
(((Entity*)rectangle)->type() != ENEMY and ((Entity*)rectangle)->type() != BOSS) or
Expand Down Expand Up @@ -129,7 +129,7 @@ void Link::AddBossKey(const std::string& name) {
keys_[name] = true;
}

bool Link::CanCollideWith(Rectangle *rectangle) const{
bool Link::CanCollideWith(RectangleShape*rectangle) const{
return super::CanCollideWith(rectangle) and (
not rectangle->IsEntity() or
((Entity*) rectangle)->type() != FOLLOWER
Expand Down
4 changes: 2 additions & 2 deletions src/entity/mob/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class Link : public Mob {

void Damage(Entity* from, int amount);

bool CollidesWith(Rectangle const * rectangle) const;
bool CollidesWith(RectangleShape const * rectangle) const;
bool HandleCollisionWith(Mob* mob);

bool CanCollideWith(Rectangle *rectangle) const;
bool CanCollideWith(RectangleShape*rectangle) const;

void Die();

Expand Down
4 changes: 2 additions & 2 deletions src/entity/mob/link_follower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ LinkFollower::LinkFollower() :
AddAction("attack", new Attack(this, ATTACK_ANIMATIONS));
}

bool LinkFollower::CollidesWith(Rectangle const * rectangle) const {
bool LinkFollower::CollidesWith(RectangleShape const * rectangle) const {
return super::CollidesWith(rectangle) and (
not rectangle->IsEntity() or
((Entity*)rectangle)->type() != BOSS or
Expand All @@ -81,7 +81,7 @@ bool LinkFollower::HandleCollisionWith(Mob* mob) {
return true;
}

bool LinkFollower::CanCollideWith(Rectangle *rectangle) const{
bool LinkFollower::CanCollideWith(RectangleShape*rectangle) const{
return super::CanCollideWith(rectangle) and (
not rectangle->IsEntity() or
((Entity*) rectangle)->type() != PLAYER
Expand Down
4 changes: 2 additions & 2 deletions src/entity/mob/link_follower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class LinkFollower : public Mob {
LinkFollower();


bool CollidesWith(Rectangle const * rectangle) const;
bool CollidesWith(RectangleShape const * rectangle) const;
bool HandleCollisionWith(Mob* mob);

bool CanCollideWith(Rectangle *rectangle) const;
bool CanCollideWith(RectangleShape*rectangle) const;

private:
};
10 changes: 5 additions & 5 deletions src/entity/mob/moldorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ void Moldorm::Draw() const {
}
}

bool Moldorm::CanCollideWith(Rectangle* rectangle) const {
bool Moldorm::CanCollideWith(RectangleShape* rectangle) const {
return rectangle != hitbox_ and (not rectangle->IsEntity() or ((Entity*)rectangle)->type() == PLAYER);
}

bool Moldorm::CollidesWith(Rectangle const * rectangle) const {
bool Moldorm::CollidesWith(RectangleShape const * rectangle) const {
if(rectangle->IsEntity()) {
for(MoldormNode* node : nodes_) {
if(node->CollidesWith(rectangle))
Expand All @@ -112,7 +112,7 @@ bool Moldorm::CollidesWith(Rectangle const * rectangle) const {
}

Moldorm::MoldormNode::MoldormNode(float x, float y, float width, float height, const vec2f& offset, float max_distance,
Sprite* sprite, Moldorm* head, Rectangle* parent) :
Sprite* sprite, Moldorm* head, RectangleShape* parent) :
super(x, y, width, height),
offset_(offset),
max_distance_(max_distance),
Expand Down Expand Up @@ -142,7 +142,7 @@ Moldorm::MoldormHitbox::MoldormHitbox(Moldorm* moldorm) :
type_ = BOSS;
}

bool Moldorm::MoldormHitbox::CanCollideWith(Rectangle* rectangle) const {
bool Moldorm::MoldormHitbox::CanCollideWith(RectangleShape* rectangle) const {
return moldorm_ != rectangle and moldorm_->CanCollideWith(rectangle);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ Sprite* Moldorm::MoldormHitbox::CurrentSprite() const {
return TAIL;
}

bool Moldorm::MoldormHitbox::CollidesWith(Rectangle const* rectangle) const {
bool Moldorm::MoldormHitbox::CollidesWith(RectangleShape const* rectangle) const {
return moldorm_->CollidesWith(rectangle);
}

Expand Down
18 changes: 9 additions & 9 deletions src/entity/mob/moldorm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#pragma once

class Moldorm : public Mob {
class MoldormNode : public Rectangle {
class MoldormNode : public RectangleShape {
public:
typedef Rectangle super;
typedef RectangleShape super;
MoldormNode(float x, float y, float width, float height, const vec2f& offset, float max_distance,
Sprite* sprite, Moldorm* head, Rectangle* parent);
Sprite* sprite, Moldorm* head, RectangleShape* parent);

void Update(double delta);
void Draw() const;

private:
Sprite* sprite_;
Moldorm* head_;
Rectangle* parent_;
RectangleShape* parent_;
vec2f offset_;
float max_distance_;
};
Expand All @@ -27,9 +27,9 @@ class Moldorm : public Mob {
typedef Entity super;
MoldormHitbox(Moldorm* moldorm);

bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;
bool HandleCollisionWith(Mob* mob);
bool CollidesWith(Rectangle const * rectangle) const;
bool CollidesWith(RectangleShape const * rectangle) const;

Sprite* CurrentSprite(vec2f& position) const;
Sprite* CurrentSprite() const;
Expand All @@ -54,8 +54,8 @@ class Moldorm : public Mob {
Moldorm(float x, float y, Level* level);
~Moldorm();

bool CanCollideWith(Rectangle* rectangle) const;
bool CollidesWith(Rectangle const * rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;
bool CollidesWith(RectangleShape const * rectangle) const;
bool HandleCollisionWith(Mob* mob);
MoldormNode* tail() const;
vec2f direction() const;
Expand All @@ -69,7 +69,7 @@ class Moldorm : public Mob {
void Dead();

private:
Rectangle* hitbox_;
RectangleShape* hitbox_;
std::vector<MoldormNode*> nodes_;
MoldormNode* tail_;
int rotation;
Expand Down
2 changes: 1 addition & 1 deletion src/entity/object/plant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Plant::Plant(Sprite* sprite, float x, float y) :
die_sound_ = CUT_SOUND;
}

bool Plant::CanReceiveDamageFrom(Rectangle const* rectangle) const {
bool Plant::CanReceiveDamageFrom(RectangleShape const* rectangle) const {
return rectangle->IsEntity() and ((Entity*) rectangle)->type() == PLAYER;
}
2 changes: 1 addition & 1 deletion src/entity/object/plant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class Plant : public Object {

Plant(Sprite* sprite, float x, float y);

bool CanReceiveDamageFrom(Rectangle const * rectangle) const;
bool CanReceiveDamageFrom(RectangleShape const * rectangle) const;
};
2 changes: 1 addition & 1 deletion src/entity/object/pole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ void Pole::Draw() const {
}
}

bool Pole::CanCollideWith(Rectangle* rectangle) const {
bool Pole::CanCollideWith(RectangleShape* rectangle) const {
return IN_TRANSITION or type_ != OPEN;
}
2 changes: 1 addition & 1 deletion src/entity/object/pole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Pole : public Entity {

Pole(float x, float y, Type type, Sprite* closed, Sprite* transition);

bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;

void Draw() const;

Expand Down
2 changes: 1 addition & 1 deletion src/entity/object/pole_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ void PoleSwitch::Damage(Entity* from, int amount) {
}));
}

bool PoleSwitch::CanCollideWith(Rectangle* rectangle) const {
bool PoleSwitch::CanCollideWith(RectangleShape* rectangle) const {
return not rectangle->IsEntity() or ((Entity*)rectangle)->type() == PLAYER;
}
2 changes: 1 addition & 1 deletion src/entity/object/pole_switch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PoleSwitch : public Entity {

Sprite* CurrentSprite() const;
Sprite* CurrentSprite(vec2f& position) const;
bool CanCollideWith(Rectangle* rectangle) const;
bool CanCollideWith(RectangleShape* rectangle) const;

void Draw() const;
void Damage(Entity* from, int amount);
Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int Game::WINDOW_HEIGHT = 768;
int Game::WIDTH = Game::WINDOW_WIDTH / Game::SCALE;
int Game::HEIGHT = Game::WINDOW_HEIGHT / Game::SCALE;
bool Game::DIRTY = true;
Rectangle Game::RECTANGLE = Rectangle(0, 0, Game::WINDOW_WIDTH, Game::WINDOW_HEIGHT);
RectangleShape Game::RECTANGLE = RectangleShape(0, 0, Game::WINDOW_WIDTH, Game::WINDOW_HEIGHT);
GLuint Game::FRAMEBUFFER_AUX = 0;
GLuint Game::RENDERBUFFER_AUX = 0;
Game Game::INSTANCE;
Expand Down Expand Up @@ -209,7 +209,7 @@ void Game::Reshape(int width, int height) {
WINDOW_HEIGHT = height;
WIDTH = WINDOW_WIDTH / SCALE;
HEIGHT = WINDOW_HEIGHT / SCALE;
RECTANGLE = Rectangle(0, 0, WIDTH, HEIGHT);
RECTANGLE = RectangleShape(0, 0, WIDTH, HEIGHT);
DIRTY = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Game
static int WIDTH;
static int HEIGHT;
static bool DIRTY;
static Rectangle RECTANGLE;
static RectangleShape RECTANGLE;
static Game INSTANCE;

static GLuint FramebufferAux();
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/hitbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "../graphic/animation.hpp"
#include "../math/rectangle.hpp"

class Hitbox : public Rectangle {
class Hitbox : public RectangleShape {
public:
typedef Rectangle super;
typedef RectangleShape super;
Hitbox(float x, float y, float width, float height);

bool IsHitbox() const;
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/hitbox/animation_hitbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AnimationHitbox::AnimationHitbox(const vec2f& position, Animation* animation) :
position_ = position + animation_->position();
}

Collision AnimationHitbox::CollisionType(Rectangle* rectangle) const {
Collision AnimationHitbox::CollisionType(RectangleShape* rectangle) const {
if(!rectangle->IsHitbox())
return DAMAGE;

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/hitbox/animation_hitbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AnimationHitbox : public Hitbox {

Sprite* CurrentSprite(vec2f& sprite_position) const;
Sprite* CurrentSprite() const;
Collision CollisionType(Rectangle* rectangle) const;
Collision CollisionType(RectangleShape* rectangle) const;

private:
Animation* animation_;
Expand Down
Loading

0 comments on commit b9a4278

Please sign in to comment.