Skip to content

Commit

Permalink
Comment consistency and touch-ups.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruhmoent committed Jul 19, 2023
1 parent 52b3efd commit 00a42da
Show file tree
Hide file tree
Showing 31 changed files with 179 additions and 178 deletions.
2 changes: 1 addition & 1 deletion src/badguy/igel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Igel::is_freezable() const
/**bool
Igel::collision_squished(GameObject& )
{
// this will hurt
// This will hurt.
return false;
}*/
// Enable this and the igle will no longer be butt-jumpable.
Expand Down
14 changes: 7 additions & 7 deletions src/badguy/jumpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
#include "object/player.hpp"
#include "sprite/sprite.hpp"

static const float JUMPYSPEED=-600;
static const float JUMPY_MID_TOLERANCE=4;
static const float JUMPY_LOW_TOLERANCE=2;
static const float JUMPYSPEED =- 600;
static const float JUMPY_MID_TOLERANCE = 4;
static const float JUMPY_LOW_TOLERANCE = 2;

Jumpy::Jumpy(const ReaderMapping& reader) :
BadGuy(reader, "images/creatures/jumpy/snowjumpy.sprite"),
pos_groundhit(0.0f, 0.0f),
groundhit_pos_set(false)
{
set_action(m_dir, "middle");
// TODO create a nice sound for this...
//SoundManager::current()->preload("sounds/skid.wav");
// TODO: Create a suitable sound for this...
// SoundManager::current()->preload("sounds/skid.wav");
}

void
Expand Down Expand Up @@ -60,8 +60,8 @@ Jumpy::hit(const CollisionHit& chit)
}

m_physic.set_velocity_y((m_frozen || get_state() != STATE_ACTIVE) ? 0 : JUMPYSPEED);
// TODO create a nice sound for this...
//SoundManager::current()->play("sounds/skid.wav", get_pos());
// TODO: Create a suitable sound for this...
// SoundManager::current()->play("sounds/skid.wav", get_pos());
update_on_ground_flag(chit);
} else if (chit.top) {
m_physic.set_velocity_y(0);
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/kamikazesnowball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ KamikazeSnowball::kill_collision()
HitResponse
KamikazeSnowball::collision_player(Player& player, const CollisionHit& hit)
{
//Hack to tell if we should die
// Methodology to determine necessity of death.
if (!m_frozen)
{
HitResponse response = BadGuy::collision_player(player, hit);
Expand Down Expand Up @@ -141,7 +141,7 @@ LeafShot::collision_squished(GameObject& object)
if (m_frozen)
return BadGuy::collision_squished(object);
set_action("squished", m_dir);
// Spawn death particles
// Spawn death particles.
spawn_explosion_sprites(3, "images/particles/leafshot.sprite");
kill_squished(object);
return true;
Expand Down
18 changes: 9 additions & 9 deletions src/badguy/kugelblitz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void
Kugelblitz::initialize()
{
m_physic.set_velocity_y(300);
m_physic.set_velocity_x(-20); //fall a little to the left
m_physic.set_velocity_x(-20); // Fall a little to the left.
direction = 1;
dying = false;
}
Expand All @@ -78,10 +78,10 @@ Kugelblitz::collision_player(Player& player, const CollisionHit& )
explode();
return ABORT_MOVE;
}
// hit from above?
// Did the collision occur from above?
if (player.get_movement().y - get_movement().y > 0 && player.get_bbox().get_bottom() <
(m_col.m_bbox.get_top() + m_col.m_bbox.get_bottom()) / 2) {
// if it's not is it possible to squish us, then this will hurt
// If not, and if it's possible for the player to squish us, then this collision will hurt.
if (!collision_squished(player))
player.kill(false);
explode();
Expand All @@ -95,16 +95,16 @@ Kugelblitz::collision_player(Player& player, const CollisionHit& )
HitResponse
Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
{
//Let the Kugelblitz explode, too? The problem with that is that
//two Kugelblitzes would cancel each other out on contact...
// Should the Kugelblitz explode as well? The concern is that
// two Kugelblitzes would cancel each other out on contact.
other.kill_fall();
return hit(chit);
}

HitResponse
Kugelblitz::hit(const CollisionHit& hit_)
{
// hit floor?
// Did the collision occur with the floor?
if (hit_.bottom) {
if (!groundhit_pos_set)
{
Expand All @@ -113,7 +113,7 @@ Kugelblitz::hit(const CollisionHit& hit_)
}
set_action("flying");
m_physic.set_velocity_y(0);
//Set random initial speed and direction
// Set random initial speed and direction.
direction = gameRandom.rand(2)? 1: -1;
int speed = (BASE_SPEED + (gameRandom.rand(RAND_SPEED))) * direction;
m_physic.set_velocity_x(static_cast<float>(speed));
Expand Down Expand Up @@ -177,7 +177,7 @@ Kugelblitz::explode()
void
Kugelblitz::try_activate()
{
// Much smaller offscreen distances to pop out of nowhere and surprise Tux
// Define much smaller offscreen distances to appear unexpectedly and surprise Tux.
float X_OFFSCREEN_DISTANCE = 400;
float Y_OFFSCREEN_DISTANCE = 600;

Expand All @@ -188,7 +188,7 @@ Kugelblitz::try_activate()
set_state(STATE_ACTIVE);
if (!m_is_initialized) {

// if starting direction was set to AUTO, this is our chance to re-orient the badguy
// If the starting direction was set to AUTO, this is our chance to re-orient the badguy.
if (m_start_dir == Direction::AUTO) {
Player* player__ = get_nearest_player();
if (player__ && (player__->get_bbox().get_left() > m_col.m_bbox.get_right())) {
Expand Down
18 changes: 9 additions & 9 deletions src/badguy/livefire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ LiveFire::collision_badguy(BadGuy& badguy, const CollisionHit& hit)
void
LiveFire::active_update(float dt_sec) {

// Remove when extinguish animation is done
// Remove when extinguish animation is done.
if ((m_sprite->get_action() == "extinguish-left" || m_sprite->get_action() == "extinguish-right" )
&& m_sprite->animation_done()) remove_me();

Expand All @@ -77,15 +77,15 @@ LiveFire::active_update(float dt_sec) {
bool inReach_bottom = (pb.get_top() <= m_col.m_bbox.get_bottom());

if (inReach_left && inReach_right && inReach_top && inReach_bottom) {
// wake up
// Wake up.
set_action("waking", m_dir, 1);
state = STATE_WAKING;
}
}
}
else if (state == STATE_WAKING) {
if (m_sprite->animation_done()) {
// start walking
// Start walking.
state = STATE_WALKING;
WalkingBadguy::initialize();
}
Expand All @@ -97,7 +97,7 @@ LiveFire::active_update(float dt_sec) {
void
LiveFire::freeze()
{
// attempting to freeze a flame causes it to go out
// Attempting to freeze a flame causes it to go out.
death_sound = "sounds/sizzle.ogg";
kill_fall();
}
Expand All @@ -118,15 +118,15 @@ void
LiveFire::kill_fall()
{
SoundManager::current()->play(death_sound, get_pos());
// throw a puff of smoke
// Emit a puff of smoke.
Vector ppos = m_col.m_bbox.get_middle();
Vector pspeed = Vector(0, -150);
Vector paccel = Vector(0,0);
Sector::get().add<SpriteParticle>("images/particles/smoke.sprite",
"default", ppos, ANCHOR_MIDDLE,
pspeed, paccel,
LAYER_BACKGROUNDTILES+2);
// extinguish the flame
// Extinguish the flame.
set_action("extinguish", m_dir, 1);
m_physic.set_velocity_y(0);
m_physic.set_acceleration_y(0);
Expand All @@ -136,11 +136,11 @@ LiveFire::kill_fall()
set_group(COLGROUP_DISABLED);
state = STATE_DEAD;

// start dead-script
// Start the dead-script.
run_dead_script();
}

/* The following defines a sleeping version */
/* The following defines a sleeping version. */

LiveFireAsleep::LiveFireAsleep(const ReaderMapping& reader) :
LiveFire(reader)
Expand All @@ -166,7 +166,7 @@ LiveFireAsleep::initialize()
set_action("sleeping", m_dir);
}

/* The following defines a dormant version that never wakes */
/* The following defines a dormant version that remains inactive. */
LiveFireDormant::LiveFireDormant(const ReaderMapping& reader) :
LiveFire(reader)
{
Expand Down
8 changes: 4 additions & 4 deletions src/badguy/mole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include "supertux/flip_level_transformer.hpp"
#include "supertux/sector.hpp"

static const float MOLE_WAIT_TIME = 0.2f; /**< time to wait before and after throwing */
static const float THROW_TIME = 4.6f; /**< time to spend throwing */
static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
static const float MOLE_WAIT_TIME = 0.2f; /**< Time to wait before and after throwing. */
static const float THROW_TIME = 4.6f; /**< Time to spend throwing. */
static const float THROW_INTERVAL = 1; /**< Time between two thrown rocks. */
static const float THROW_VELOCITY = 400; /**< Initial velocity of thrown rocks. */

Mole::Mole(const ReaderMapping& reader) :
BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/mole_rock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ MoleRock::collision_solid(const CollisionHit& )
HitResponse
MoleRock::collision_badguy(BadGuy& badguy, const CollisionHit& )
{
// ignore collisions with parent
// Ignore collisions with parent.
if (&badguy == parent) {
return FORCE_MOVE;
}
Expand Down
6 changes: 3 additions & 3 deletions src/badguy/mrbomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ MrBomb::MrBomb(const ReaderMapping& reader) :
walk_speed = 80;
max_drop_height = 16;

//Prevent stutter when Tux jumps on Mr Bomb
// Prevent stutter when Tux jumps on Mr Bomb.
SoundManager::current()->preload("sounds/explosion.wav");

//Check if we need another sprite
// Check if we need another sprite.
if ( !reader.get( "sprite", m_sprite_name ) ){
return;
}
if (m_sprite_name.empty()) {
m_sprite_name = "images/creatures/mr_bomb/mr_bomb.sprite";
return;
}
//Replace sprite
// Replace the sprite.
m_sprite = SpriteManager::current()->create( m_sprite_name );
}

Expand Down
12 changes: 6 additions & 6 deletions src/badguy/mriceblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ MrIceBlock::collision_solid(const CollisionHit& hit)
{
update_on_ground_flag(hit);

if (hit.top || hit.bottom) { // floor or roof
if (hit.top || hit.bottom) { // Floor or roof.
m_physic.set_velocity_y(0);
}

// hit left or right
// Hit left or right.
switch (ice_state) {
case ICESTATE_NORMAL:
WalkingBadguy::collision_solid(hit);
Expand Down Expand Up @@ -125,7 +125,7 @@ MrIceBlock::collision(GameObject& object, const CollisionHit& hit)
HitResponse
MrIceBlock::collision_player(Player& player, const CollisionHit& hit)
{
// handle kicks from left or right side
// Handle kicks from left or right side.
if ((ice_state == ICESTATE_WAKING || ice_state == ICESTATE_FLAT) && get_state() == STATE_ACTIVE) {
if (hit.left) {
m_dir = Direction::RIGHT;
Expand Down Expand Up @@ -244,7 +244,7 @@ MrIceBlock::set_state(IceState state_)

m_physic.set_velocity_x(m_dir == Direction::LEFT ? -KICKSPEED : KICKSPEED);
set_action(m_dir == Direction::LEFT ? "flat-left" : "flat-right", /* loops = */ -1);
// we should slide above 1 block holes now...
// We should slide above 1 block holes now.
m_col.m_bbox.set_size(34, 31.8f);
break;
case ICESTATE_GRABBED:
Expand Down Expand Up @@ -276,7 +276,7 @@ MrIceBlock::ungrab(MovingObject& object, Direction dir_)
auto player = dynamic_cast<Player*> (&object);
if (player && (player->is_swimming() || player->is_water_jumping()))
{
//move icecube a little bit away as to not insta-kill Tux
// Move the ice cube slightly away to avoid instantly killing Tux.
float swimangle = player->get_swimming_angle();
m_col.m_bbox.move(Vector(std::cos(swimangle) * 48.f, std::sin(swimangle) * 48.f));
}
Expand All @@ -287,7 +287,7 @@ MrIceBlock::ungrab(MovingObject& object, Direction dir_)
else if (dir_ == Direction::DOWN) {
Vector mov(0, 32);
if (Sector::get().is_free_of_statics(get_bbox().moved(mov), this)) {
// There is free space, so throw it down
// There is free space, so throw it down.
SoundManager::current()->play("sounds/kick.wav", get_pos());
m_physic.set_velocity_y(KICKSPEED);
}
Expand Down
14 changes: 7 additions & 7 deletions src/badguy/mrtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ MrTree::collision_squished(GameObject& object)
return true;
}

// replace with Stumpy
// Replace with Stumpy.
Vector stumpy_pos = get_pos();
stumpy_pos.x += 8;
stumpy_pos.y += 28;
auto& stumpy = Sector::get().add<Stumpy>(stumpy_pos, m_dir);
remove_me();

// give Feedback
// Give Feedback.
SoundManager::current()->play("sounds/mr_tree.ogg", get_pos());
if (player) player->bounce(*this);

// spawn some particles
// TODO: provide convenience function in MovingSprite or MovingObject?
// Spawn some particles.
// TODO: Provide convenience function in MovingSprite or MovingObject?
for (int px = static_cast<int>(stumpy.get_bbox().get_left()); px < static_cast<int>(stumpy.get_bbox().get_right()); px+=10) {
Vector ppos = Vector(static_cast<float>(px),
static_cast<float>(stumpy.get_bbox().get_top()) - 5.0f);
Expand All @@ -120,16 +120,16 @@ MrTree::collision_squished(GameObject& object)
LAYER_OBJECTS-1);
}

if (!m_frozen) { //Frozen Mr.Trees don't spawn any ViciousIvys.
// spawn ViciousIvy
if (!m_frozen) { // Mr.Trees that are frozen don't spawn any Vicious Ivys.
// Spawn ViciousIvy.
Vector leaf1_pos(stumpy_pos.x - VICIOUSIVY_WIDTH - 1, stumpy_pos.y - VICIOUSIVY_Y_OFFSET);
Rectf leaf1_bbox(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + VICIOUSIVY_WIDTH, leaf1_pos.y + VICIOUSIVY_HEIGHT);
if (Sector::get().is_free_of_movingstatics(leaf1_bbox, this)) {
auto& leaf1 = Sector::get().add<ViciousIvy>(leaf1_bbox.p1(), Direction::LEFT);
leaf1.m_countMe = false;
}

// spawn ViciousIvy
// Spawn ViciousIvy.
Vector leaf2_pos(stumpy_pos.x + m_sprite->get_current_hitbox_width() + 1, stumpy_pos.y - VICIOUSIVY_Y_OFFSET);
Rectf leaf2_bbox(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + VICIOUSIVY_WIDTH, leaf2_pos.y + VICIOUSIVY_HEIGHT);
if (Sector::get().is_free_of_movingstatics(leaf2_bbox, this)) {
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/plant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Plant::Plant(const ReaderMapping& reader) :
void
Plant::initialize()
{
//FIXME: turns plant around for debugging
// FIXME: Turns plant around for debugging.
m_dir = m_dir == Direction::LEFT ? Direction::RIGHT : Direction::LEFT;

state = PLANT_SLEEPING;
Expand Down Expand Up @@ -92,7 +92,7 @@ Plant::active_update(float dt_sec) {

if (state == PLANT_WAKING) {
if (timer.check()) {
// start walking
// Start walking.
set_action(m_dir);
m_physic.set_velocity_x(m_dir == Direction::LEFT ? -PLANT_SPEED : PLANT_SPEED);
state = PLANT_WALKING;
Expand Down
Loading

0 comments on commit 00a42da

Please sign in to comment.