Skip to content

Commit

Permalink
Get rid of some pointless getter/setters.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit-n committed Oct 28, 2015
1 parent b1495ba commit a23450a
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 427 deletions.
24 changes: 12 additions & 12 deletions draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ void Renderer::drawSprite(float x, float y, float z, float rotation, SpriteSheet

void Renderer::drawFieldOfView(Scene* scene, FieldOfView* fov, GLuint program)
{
if (!fov->isActive())
if (!fov->_active)
{
return;
}
Expand Down Expand Up @@ -884,7 +884,7 @@ void Renderer::drawEntities(Scene* scene)
vol.x -= scene->getCamera().x;
vol.y -= scene->getCamera().y;

if (ent->isHighlighted())
if (ent->_highlighted)
{
drawRect2(vol, 1, 1, 1, 1);
}
Expand Down Expand Up @@ -954,7 +954,7 @@ void Renderer::drawEntities(Scene* scene)

for (i = 0; i < map->getNumberOfShafts(); i++)
{
if (map->getShaftAt(i)->isMoving())
if (map->getShaftAt(i)->_moving)
{
vol = map->getShaftAt(i)->getRect();
vol.x -= scene->getCamera().x;
Expand Down Expand Up @@ -988,7 +988,7 @@ void Renderer::drawEntities(Scene* scene)
vol = particle->getCollisionRect();
vol.x -= scene->getCamera().x;
vol.y -= scene->getCamera().y;
if (particle->isAlive())
if (particle->_alive)
{
drawSprite( position.x - cam.x,
position.y - cam.y,
Expand Down Expand Up @@ -1435,7 +1435,7 @@ void Renderer::drawScene(Scene* scene)
drawTileLayer(scene, 0);
if (!scene->inCrosslinkMode())
{
if ((!player->isInElevator() || !player->getElevatorDoor()->getShaft()->isMoving()) && !player->isPinning())
if ((!player->isInElevator() || !player->getElevatorDoor()->_shaft->_moving) && !player->isPinning())
{
glBindTexture(GL_TEXTURE_2D, player->getDirection() == Right ? resPlayer->getTexId() : resPlayerLeft->getTexId());
drawSprite( scene->getPlayerPosition().x - cam.x,
Expand All @@ -1451,7 +1451,7 @@ void Renderer::drawScene(Scene* scene)
drawSprite( scene->getPlayerPosition().x - cam.x,
scene->getPlayerPosition().y - cam.y - 4,
2.8f,
player->getArmRotation(),
player->_armRotation,
player->getDirection() == Right ? resPlayer : resPlayerLeft,
spr,
SDM_Normal, 0, 0, 0);
Expand Down Expand Up @@ -1486,7 +1486,7 @@ void Renderer::drawScene(Scene* scene)
if (scene->inCrosslinkMode())
{
//if in crosslink mode, draw black sprites of enemies and player last so that color is not affected by lights.
if ((!player->isInElevator() || !player->getElevatorDoor()->getShaft()->isMoving()) && !player->isPinning())
if ((!player->isInElevator() || !player->getElevatorDoor()->_shaft->_moving) && !player->isPinning())
{
drawSpriteBind( scene->getPlayerPosition().x - cam.x,
scene->getPlayerPosition().y - cam.y,
Expand All @@ -1497,7 +1497,7 @@ void Renderer::drawScene(Scene* scene)
SDM_LinkableCross, 0, 0, 0);
}
drawEnemies(scene, true);
sprintf(print, "Energy: %i", scene->getPlayerEnergy());
sprintf(print, "Energy: %i", scene->_playerEnergy);
drawText(32, 160, print, RGB_WHITE, 1.0f, font1);
}

Expand Down Expand Up @@ -1533,7 +1533,7 @@ void Renderer::drawScene(Scene* scene)

if (scene->hasPlayerFiredShot() || player->isAimingGun())
{
sprintf(print, "%i", scene->getTimeToSniper());
sprintf(print, "%i", (scene->_timeToSniper / 1000));
if (scene->hasPlayerFiredShot())
{
drawText(winX - 64, winY - 32, print, RGB_RED, 1.0f, font1);
Expand All @@ -1544,7 +1544,7 @@ void Renderer::drawScene(Scene* scene)
}
if (player->isAimingGun())
{
sprintf(print, "Ammo: %i", scene->getNumPlayerBullets());
sprintf(print, "Ammo: %i", scene->_numPlayerBullets);
drawText(32, 128, print, RGB_WHITE, 1.0f, font1);
}
}
Expand Down Expand Up @@ -1590,14 +1590,14 @@ void Renderer::drawDebugSceneText(Scene* scene)
py = scene->getPlayerPosition().y;
drawText(px - scene->getCamera().x, py - scene->getCamera().y, print, RGB_WHITE, 1.0f, font1);
drawText(32, 32, (char*)"On Ground: ", RGB_WHITE, 1.0f, font1);
if (scene->getPlayer()->isOnGround())
if (scene->getPlayer()->_onGround)
drawText(192, 32, (char*)"Yes", 0.0f, 1.0f, 0.0f, 1.0f, font1);
else
drawText(192, 32, (char*)"No", RGB_RED, 1.0f, font1);

sprintf(print, "Attach Type: %i", scene->getPlayer()->getAttachType());
drawText(32, 64, print, RGB_WHITE, 1.0f, font1);
sprintf(print, "Light: %i", scene->getPlayer()->getLightVisibility());
sprintf(print, "Light: %i", scene->getPlayer()->_lightVisibility);
drawText(32, 96, print, RGB_WHITE, 1.0f, font1);
}

Expand Down
44 changes: 2 additions & 42 deletions elevators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,6 @@ bool ElevatorDoor::isOpen()
return _open;
}

void ElevatorDoor::registerShaft(ElevatorShaft* shaft)
{
_shaft = shaft;
}

void ElevatorDoor::registerSwitch(ElevatorSwitch* eSwitch)
{
_switch = eSwitch;
}

ElevatorShaft* ElevatorDoor::getShaft()
{
return _shaft;
}

void ElevatorDoor::update(unsigned int dT)
{
Entity::update(dT);
Expand All @@ -109,11 +94,6 @@ bool ElevatorDoor::isClosing()
return _activeSequence == Locator::getAnimationManager()->getSequence(ANIM_ELEVATOR_CLOSE);
}

ElevatorSwitch* ElevatorDoor::getSwitch()
{
return _switch;
}

ElevatorShaft::ElevatorShaft(int x)
{
_moving = false;
Expand Down Expand Up @@ -179,17 +159,12 @@ void ElevatorShaft::update()
_yVel /= fabs(_yVel);
_yVel *= 0.1f;
setAccel(&_acceleration, true, _yVel < 0.0f ? -0.01f : 0.01f, _yVel < 0.0f ? -1.5f : 1.5f);
setMoving(true);
_moving = true;
_waitingForClose = false;
Locator::getAudio()->playSound("elevator_leave");
}
}

int ElevatorShaft::getX()
{
return _x;
}

void ElevatorShaft::setOpenDoor(ElevatorDoor* door, bool animate)
{
int index = containsDoor(door);
Expand Down Expand Up @@ -232,19 +207,14 @@ void ElevatorShaft::setTarget(ElevatorDoor* target)
_openDoor->close(true);
_waitingForClose = true;
_target = target;
_target->getSwitch()->changeSprite(Locator::getSpriteManager()->getIndex("./data/sprites/linkable.sprites", "elev_switch_wait"));
_target->_switch->changeSprite(Locator::getSpriteManager()->getIndex("./data/sprites/linkable.sprites", "elev_switch_wait"));
}

void ElevatorShaft::addDoor(ElevatorDoor* ed)
{
_doors.push_back(ed);
}

bool ElevatorShaft::isMoving()
{
return _moving;
}

int ElevatorShaft::containsDoor(ElevatorDoor* door)
{
unsigned int i;
Expand All @@ -258,11 +228,6 @@ int ElevatorShaft::containsDoor(ElevatorDoor* door)
return -1;
}

void ElevatorShaft::setMoving(bool b)
{
_moving = b;
}

ElevatorDoor* ElevatorShaft::getOpenDoor()
{
return _openDoor;
Expand Down Expand Up @@ -339,9 +304,4 @@ int ElevatorShaft::getDoorIndexOrdered(int index)
}
}
return -1;
}

float ElevatorShaft::getVelocity()
{
return _yVel;
}
14 changes: 2 additions & 12 deletions enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void Enemy::update(unsigned int dT)
{
_targetSwitch->activate(NULL);
_numSwitchAttempts++;
if ((_lightToActivate != NULL && _lightToActivate->isActive()) || _numSwitchAttempts == 3) //activate the light, or give up.
if ((_lightToActivate != NULL && _lightToActivate->_active) || _numSwitchAttempts == 3) //activate the light, or give up.
{
_targetSwitch = NULL;
_targetType = TARGET_NONE;
Expand Down Expand Up @@ -621,7 +621,7 @@ void Enemy::setStrongestLight(FieldOfView* light)
changeState(PATROLLING);
}

if ((light == _lightToActivate && light != NULL) || (light != NULL && _lightToActivate != NULL && light->getLightFixture() == _lightToActivate->getLightFixture()))
if ((light == _lightToActivate && light != NULL) || (light != NULL && _lightToActivate != NULL && light->_fixture == _lightToActivate->_fixture))
{
//Nothing to activate, since it's now on.
_lightToActivate = NULL;
Expand Down Expand Up @@ -778,16 +778,6 @@ void Enemy::_fireWeapon(GunShotTraceType gstt)
setResolve(1, gstt);
}

void Enemy::setGun(EnemyGun* gun)
{
_gun = gun;
}

EnemyGun* Enemy::getGun()
{
return _gun;
}

void Enemy::setResolve(int timeToReact, GunShotTraceType gstt)
{
_resolve.timeSinceShot = timeToReact;
Expand Down
24 changes: 0 additions & 24 deletions entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ void Entity::changeAnimationSequence(AnimationSequence* sequence)
}
}

bool Entity::isHighlighted()
{
return _highlighted;
}

void Entity::setHighlighted(bool b)
{
_highlighted = b;
}

Particle::Particle(float x, float y, unsigned int sprite) : Entity(x, y, sprite)
{
setCollisionRectDims(8, 8, 8);
Expand All @@ -232,27 +222,13 @@ void Particle::update(unsigned int dT)
updateCollisionRectPosition();
}

bool Particle::isAlive()
{
return _alive;
}
void Particle::setAlive(bool b)
{
_alive = b;
}

TutorialMark::TutorialMark(float x, float y, StringMessage ts) : Entity(x, y)
{
setCollisionRectDims(32, 48, ENTDIM);
_ts = ts;
_sprite = Locator::getSpriteManager()->getIndex("./data/sprites/objects.sprites", "tutorial");
}

StringMessage TutorialMark::getTutorialString()
{
return _ts;
}

MainComputer::MainComputer(float x, float y, bool active) : Entity(x, y)
{
setCollisionRectDims(64, 32, ENTDIM);
Expand Down
Loading

0 comments on commit a23450a

Please sign in to comment.