diff --git a/src/addon/addon.cpp b/src/addon/addon.cpp index ecaed01d6d4..76e70cba572 100644 --- a/src/addon/addon.cpp +++ b/src/addon/addon.cpp @@ -59,7 +59,7 @@ Addon::Type addon_type_from_string(const std::string& type) } else { - throw std::runtime_error("not a valid Addon::Type: " + type); + throw std::runtime_error("Not a valid Addon::Type: " + type); } } @@ -102,7 +102,7 @@ std::string generate_menu_item_text(const Addon& addon) } else { - // Only addon type and name, no need for translation. + // Only add-on type and name, no need for translation. text = fmt::format("{} \"{}\"", type, addon.get_title()); } @@ -130,12 +130,12 @@ Addon::parse(const ReaderMapping& mapping) if (addon->m_id.empty()) { - throw std::runtime_error("addon id is empty"); + throw std::runtime_error("Add-on id is empty"); } if (addon->m_id.find_first_not_of(s_allowed_characters) != std::string::npos) { - throw std::runtime_error("addon id contains illegal characters: " + addon->m_id); + throw std::runtime_error("Add-on id contains illegal characters: " + addon->m_id); } mapping.get("version", addon->m_version); @@ -194,7 +194,7 @@ Addon::parse(const std::string& fname) auto root = doc.get_root(); if (root.get_name() != "supertux-addoninfo") { - throw std::runtime_error("file is not a supertux-addoninfo file."); + throw std::runtime_error("File is not a supertux-addoninfo file."); } else { diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index 81ed9a6beed..214442e5f86 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -43,7 +43,7 @@ static const char* ADDON_INFO_PATH = "/addons/repository.nfo"; MD5 md5_from_file(const std::string& filename) { - // TODO: this does not work as expected for some files -- IFileStream seems to not always behave like an ifstream. + // TODO: This does not work as expected for some files -- IFileStream seems to not always behave like an ifstream. //IFileStream ifs(installed_physfs_filename); //std::string md5 = MD5(ifs).hex_digest(); @@ -98,7 +98,7 @@ static Addon& get_addon(const AddonManager::AddonMap& list, const AddonId& id, static std::vector get_addons(const AddonManager::AddonMap& list) { - // Use a map for storing sorted addon titles with their respective IDs. + // Use a map for storing sorted add-on titles with their respective IDs. std::map sorted_titles; for (const auto& [id, addon] : list) { @@ -121,7 +121,7 @@ static PHYSFS_EnumerateCallbackResult add_to_dictionary_path(void *data, const c if (physfsutil::is_directory(full_path)) { log_debug << "Adding \"" << full_path << "\" to dictionary search path" << std::endl; - // We want translations from addons to have precedence + // We want translations from add-ons to have precedence. g_dictionary_manager->add_directory(full_path, true); } return PHYSFS_ENUM_OK; @@ -163,7 +163,7 @@ AddonManager::AddonManager(const std::string& addon_directory, add_installed_addons(); - // FIXME: We should also restore the order here + // FIXME: We should also restore the order here. for (auto& addon : m_addon_config) { if (addon.enabled) @@ -216,7 +216,7 @@ AddonManager::AddonManager(const std::string& addon_directory, AddonManager::~AddonManager() { - // sync enabled/disabled add-ons into the config for saving + // Sync enabled/disabled add-ons into the config for saving. m_addon_config.clear(); for (const auto& [id, addon] : m_installed_addons) { @@ -301,11 +301,11 @@ AddonManager::check_online() TransferStatusListPtr AddonManager::request_install_addon(const AddonId& addon_id) { - // remove addon if it already exists + // Remove add-on if it already exists. auto it = m_installed_addons.find(addon_id); if (it != m_installed_addons.end()) { - log_debug << "reinstalling addon " << addon_id << std::endl; + log_debug << "Reinstalling add-on " << addon_id << std::endl; if (it->second->is_enabled()) { disable_addon(it->first); @@ -314,7 +314,7 @@ AddonManager::request_install_addon(const AddonId& addon_id) } else { - log_debug << "installing addon " << addon_id << std::endl; + log_debug << "Installing add-on " << addon_id << std::endl; } auto& addon = get_repository_addon(addon_id); @@ -331,7 +331,7 @@ AddonManager::request_install_addon(const AddonId& addon_id) { if (success) { - // complete the addon install + // Complete the add-on installation. Addon& repository_addon = get_repository_addon(addon_id); MD5 md5 = md5_from_file(install_filename); @@ -403,11 +403,11 @@ AddonManager::request_install_addon_dependencies(const AddonId& addon_id) void AddonManager::install_addon(const AddonId& addon_id) { - { // remove addon if it already exists + { // remove addon if it already exists. auto it = m_installed_addons.find(addon_id); if (it != m_installed_addons.end()) { - log_debug << "reinstalling addon " << addon_id << std::endl; + log_debug << "Reinstalling add-on " << addon_id << std::endl; if (it->second->is_enabled()) { disable_addon(it->first); @@ -416,7 +416,7 @@ AddonManager::install_addon(const AddonId& addon_id) } else { - log_debug << "installing addon " << addon_id << std::endl; + log_debug << "Installing add-on " << addon_id << std::endl; } } @@ -469,13 +469,13 @@ AddonManager::install_addon_from_local_file(const std::string& filename) void AddonManager::uninstall_addon(const AddonId& addon_id) { - log_debug << "uninstalling addon " << addon_id << std::endl; + log_debug << "Uninstalling add-on " << addon_id << std::endl; auto& addon = get_installed_addon(addon_id); if (addon.is_enabled()) { disable_addon(addon_id); } - log_debug << "deleting file \"" << addon.get_install_filename() << "\"" << std::endl; + log_debug << "Deleting file \"" << addon.get_install_filename() << "\"" << std::endl; const auto it = m_installed_addons.find(addon.get_id()); if (it != m_installed_addons.end()) { @@ -487,7 +487,7 @@ AddonManager::uninstall_addon(const AddonId& addon_id) } else { - throw std::runtime_error(_("Error uninstalling addon: Addon with id ") + addon_id + _(" not found.")); + throw std::runtime_error(_("Error uninstalling add-on: Addon with id ") + addon_id + _(" not found.")); } } @@ -733,12 +733,12 @@ AddonManager::scan_for_archives() const { std::vector archives; - // Search for archives and add them to the search path + // Search for archives and add them to the search path. physfsutil::enumerate_files(m_addon_directory, [this, &archives](const std::string& filename) { const std::string fullpath = FileSystem::join(m_addon_directory, filename); if (physfsutil::is_directory(fullpath)) { - // ignore dot files (e.g. '.git/'), as well as the addon cache directory + // ignore dot files (e.g. '.git/'), as well as the addon cache directory. if (filename[0] != '.' && fullpath != m_cache_directory) { archives.push_back(fullpath); } @@ -765,7 +765,7 @@ AddonManager::scan_for_info(const std::string& archive_os_path) const { std::string nfo_filename = FileSystem::join("/", file); - // make sure it's in the current archive_os_path + // Make sure it's in the current archive_os_path. const char* realdir = PHYSFS_getRealDir(nfo_filename.c_str()); if (!realdir) { @@ -826,7 +826,7 @@ AddonManager::add_installed_archive(const std::string& archive, const std::strin } catch(...) { - // save addon title and author on stack before std::move + // Save add-on title and author on stack before std::move. const std::string addon_title = addon->get_title(); const std::string addon_author = addon->get_author(); m_installed_addons[addon_id] = std::move(addon); @@ -842,7 +842,7 @@ AddonManager::add_installed_archive(const std::string& archive, const std::strin } Dialog::show_message(fmt::format(_("Add-on {} by {} successfully installed."), addon_title, addon_author)); - // if currently opened menu is addons menu refresh it + // If currently opened menu is add-ons menu refresh it. AddonMenu* addon_menu = dynamic_cast(MenuManager::instance().current_menu()); if (addon_menu) addon_menu->refresh(); @@ -942,7 +942,7 @@ AddonManager::check_for_langpack_updates() try { const std::string& addon_id = "language-pack"; - log_debug << "Looking for language addon with ID " << addon_id << "..." << std::endl; + log_debug << "Looking for language add-on with ID " << addon_id << "..." << std::endl; Addon& langpack = get_repository_addon(addon_id); try @@ -951,7 +951,7 @@ AddonManager::check_for_langpack_updates() if (installed_langpack.get_md5() == langpack.get_md5() || installed_langpack.get_version() > langpack.get_version()) { - log_debug << "Language addon " << addon_id << " is already the latest version." << std::endl; + log_debug << "Language add-on " << addon_id << " is already the latest version." << std::endl; return; } @@ -982,7 +982,7 @@ AddonManager::check_for_langpack_updates() } catch(std::exception&) { - log_debug << "Language addon for current locale not found." << std::endl; + log_debug << "Language add-on for current locale not found." << std::endl; } } catch(...) diff --git a/src/addon/downloader.cpp b/src/addon/downloader.cpp index 9e71d606264..5d09ae64c9f 100644 --- a/src/addon/downloader.cpp +++ b/src/addon/downloader.cpp @@ -39,7 +39,7 @@ namespace { -// This one is necessary for a download function +// This one is necessary for a download function. size_t my_curl_string_append(void* ptr, size_t size, size_t nmemb, void* userdata) { std::string& s = *static_cast(userdata); @@ -296,7 +296,8 @@ class Transfer final curl_easy_setopt(m_handle, CURLOPT_PROGRESSFUNCTION, &Transfer::on_progress_wrap); } #else - // Avoid code injection from funny callers + // Sanitize input to prevent code injection from malicious callers. + // Escape backslashes and single quotes in the URL and file path to ensure safe usage. auto url_clean = StringUtil::replace_all(StringUtil::replace_all(url, "\\", "\\\\"), "'", "\\'"); auto path_clean = StringUtil::replace_all(StringUtil::replace_all(FileSystem::join(std::string(PHYSFS_getWriteDir()), outfile), "\\", "\\\\"), "'", "\\'"); emscripten_run_script(("supertux_xhr_download(" + std::to_string(m_id) + ", '" + url_clean + "', '" + path_clean + "');").c_str()); @@ -442,7 +443,7 @@ Downloader::download(const std::string& url, throw std::runtime_error(url + ": download failed: " + why); } #else - log_warning << "Direct download not yet implemented for Emscripten" << std::endl; + log_warning << "Direct download not yet implemented for Emscripten." << std::endl; // FUTURE MAINTAINERS: If this needs to be implemented, take a look at // emscripten_wget(), emscripten_async_wget(), emscripten_wget_data() and // emscripten_async_wget_data(): @@ -467,7 +468,7 @@ Downloader::download(const std::string& url, const std::string& filename) PHYSFS_close); download(url, my_curl_physfs_write, fout.get()); #else - log_warning << "Direct download not yet implemented for Emscripten" << std::endl; + log_warning << "Direct download not yet implemented for Emscripten." << std::endl; // FUTURE MAINTAINERS: If this needs to be implemented, take a look at // emscripten_wget(), emscripten_async_wget(), emscripten_wget_data() and // emscripten_async_wget_data(): @@ -514,7 +515,7 @@ Downloader::update() if (m_last_update_time == g_real_time) return; m_last_update_time = g_real_time; - // read data from the network + // Read data from the network. CURLMcode ret; int running_handles; while ((ret = curl_multi_perform(m_multi_handle, &running_handles)) == CURLM_CALL_MULTI_PERFORM) @@ -522,7 +523,7 @@ Downloader::update() log_debug << "updating" << std::endl; } - // check if any downloads got finished + // Check if any downloads got finished. int msgs_in_queue; CURLMsg* msg; while ((msg = curl_multi_info_read(m_multi_handle, &msgs_in_queue))) @@ -584,7 +585,7 @@ Downloader::update() break; default: - log_warning << "unhandled cURL message: " << msg->msg << std::endl; + log_warning << "Unhandled cURL message: " << msg->msg << std::endl; break; } } @@ -594,7 +595,7 @@ Downloader::update() TransferStatusPtr Downloader::request_download(const std::string& url, const std::string& outfile) { - log_info << "request_download: " << url << std::endl; + log_info << "Requesting download for: " << url << std::endl; auto transfer = std::make_unique(*this, m_next_transfer_id++, url, outfile); #ifndef EMSCRIPTEN curl_multi_add_handle(m_multi_handle, transfer->get_curl_handle()); @@ -611,7 +612,7 @@ Downloader::onDownloadProgress(int id, int loaded, int total) auto it = m_transfers.find(id); if (it == m_transfers.end()) { - log_warning << "transfer not found: " << id << std::endl; + log_warning << "Transfer not found: " << id << std::endl; } else { @@ -625,7 +626,7 @@ Downloader::onDownloadFinished(int id) auto it = m_transfers.find(id); if (it == m_transfers.end()) { - log_warning << "transfer not found: " << id << std::endl; + log_warning << "Transfer not found: " << id << std::endl; } else { @@ -649,7 +650,7 @@ Downloader::onDownloadError(int id) auto it = m_transfers.find(id); if (it == m_transfers.end()) { - log_warning << "transfer not found: " << id << std::endl; + log_warning << "Transfer not found: " << id << std::endl; } else { @@ -673,7 +674,7 @@ Downloader::onDownloadAborted(int id) auto it = m_transfers.find(id); if (it == m_transfers.end()) { - log_warning << "transfer not found: " << id << std::endl; + log_warning << "Transfer not found: " << id << std::endl; } else { diff --git a/src/badguy/angrystone.cpp b/src/badguy/angrystone.cpp index b81c1c9c98e..c6ad36c4d96 100644 --- a/src/badguy/angrystone.cpp +++ b/src/badguy/angrystone.cpp @@ -20,17 +20,16 @@ #include "sprite/sprite.hpp" static const float CHARGE_SPEED = 240; - static const float CHARGE_TIME = .5; static const float ATTACK_TIME = 1; static const float RECOVER_TIME = .5; AngryStone::AngryStone(const ReaderMapping& reader) : BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"), - attackDirection(0.0f, 0.0f), - oldWallDirection(0.0f, 0.0f), - timer(), - state(IDLE) + m_attack_direction(0.0f, 0.0f), + m_old_wall_direction(0.0f, 0.0f), + m_timer(), + m_state(IDLE) { m_countMe = false; m_physic.set_velocity_x(0); @@ -46,15 +45,16 @@ AngryStone::collision_solid(const CollisionHit& hit) BadGuy::collision_solid(hit); // TODO #if 0 - if ((state == ATTACKING) && - (hit.normal.x == -attackDirection.x) && (hit.normal.y == attackDirection.y)) { - state = IDLE; + if ((m_state == ATTACKING) && + (hit.normal.x == -m_attack_direction.x) && (hit.normal.y == m_attack_direction.y)) + { + m_state = IDLE; sprite->set_action("idle"); physic.set_velocity_x(0); physic.set_velocity_y(0); physic.enable_gravity(true); - oldWallDirection.x = attackDirection.x; - oldWallDirection.y = attackDirection.y; + m_old_wall_direction.x = m_attack_direction.x; + m_old_wall_direction.y = m_attack_direction.y; } #endif } @@ -65,13 +65,14 @@ AngryStone::kill_fall() if (!m_frozen) return; BadGuy::kill_fall(); - //prevents AngryStone from getting killed by other enemies or the player + // Prevents AngryStone from getting killed by other enemies or the player. } HitResponse AngryStone::collision_badguy(BadGuy& badguy, const CollisionHit& ) { - if (state == ATTACKING) { + if (m_state == ATTACKING) + { badguy.kill_fall(); return FORCE_MOVE; } @@ -80,18 +81,20 @@ AngryStone::collision_badguy(BadGuy& badguy, const CollisionHit& ) } void -AngryStone::active_update(float dt_sec) { +AngryStone::active_update(float dt_sec) +{ BadGuy::active_update(dt_sec); if (m_frozen) return; - switch (state) { - - - case IDLE: { + switch (m_state) + { + case IDLE: + { auto player = get_nearest_player(); - if (player) { + if (player) + { auto badguy = this; const Vector& playerPos = player->get_pos(); const Vector& badguyPos = badguy->get_pos(); @@ -104,53 +107,65 @@ AngryStone::active_update(float dt_sec) { float playerWidth = player->get_bbox().get_width(); float badguyWidth = badguy->get_bbox().get_width(); - if ((dx > -playerWidth) && (dx < badguyWidth)) { - if (dy > 0) { - attackDirection.x = 0; - attackDirection.y = 1; - } else { - attackDirection.x = 0; - attackDirection.y = -1; + if ((dx > -playerWidth) && (dx < badguyWidth)) + { + if (dy > 0) + { + m_attack_direction.x = 0; + m_attack_direction.y = 1; + } else + { + m_attack_direction.x = 0; + m_attack_direction.y = -1; } - if ((attackDirection.x != oldWallDirection.x) || (attackDirection.y != oldWallDirection.y)) { + if ((m_attack_direction.x != m_old_wall_direction.x) || (m_attack_direction.y != m_old_wall_direction.y)) + { set_action("charging"); - timer.start(CHARGE_TIME); - state = CHARGING; + m_timer.start(CHARGE_TIME); + m_state = CHARGING; } - } else if ((dy > -playerHeight) && (dy < badguyHeight)) { - if (dx > 0) { - attackDirection.x = 1; - attackDirection.y = 0; - } else { - attackDirection.x = -1; - attackDirection.y = 0; + } else if ((dy > -playerHeight) && (dy < badguyHeight)) + { + if (dx > 0) + { + m_attack_direction.x = 1; + m_attack_direction.y = 0; + } else + { + m_attack_direction.x = -1; + m_attack_direction.y = 0; } - if ((attackDirection.x != oldWallDirection.x) || (attackDirection.y != oldWallDirection.y)) { + if ((m_attack_direction.x != m_old_wall_direction.x) || (m_attack_direction.y != m_old_wall_direction.y)) + { set_action("charging"); - timer.start(CHARGE_TIME); - state = CHARGING; + m_timer.start(CHARGE_TIME); + m_state = CHARGING; } } } } break; - case CHARGING: { - if (timer.check()) { + case CHARGING: + { + if (m_timer.check()) + { set_action("attacking"); - timer.start(ATTACK_TIME); - state = ATTACKING; + m_timer.start(ATTACK_TIME); + m_state = ATTACKING; m_physic.enable_gravity(false); - m_physic.set_velocity_x(CHARGE_SPEED * attackDirection.x); - m_physic.set_velocity_y(CHARGE_SPEED * attackDirection.y); - oldWallDirection.x = 0; - oldWallDirection.y = 0; + m_physic.set_velocity_x(CHARGE_SPEED * m_attack_direction.x); + m_physic.set_velocity_y(CHARGE_SPEED * m_attack_direction.y); + m_old_wall_direction.x = 0; + m_old_wall_direction.y = 0; } } break; - case ATTACKING: { - if (timer.check()) { - timer.start(RECOVER_TIME); - state = RECOVERING; + case ATTACKING: + { + if (m_timer.check()) + { + m_timer.start(RECOVER_TIME); + m_state = RECOVERING; set_action("idle"); m_physic.enable_gravity(true); m_physic.set_velocity_x(0); @@ -158,9 +173,11 @@ AngryStone::active_update(float dt_sec) { } } break; - case RECOVERING: { - if (timer.check()) { - state = IDLE; + case RECOVERING: + { + if (m_timer.check()) + { + m_state = IDLE; set_action("idle"); m_physic.enable_gravity(true); m_physic.set_velocity_x(0); @@ -168,14 +185,13 @@ AngryStone::active_update(float dt_sec) { } } break; } - } void AngryStone::freeze() { BadGuy::freeze(); - state = IDLE; + m_state = IDLE; m_physic.enable_gravity(true); } diff --git a/src/badguy/angrystone.hpp b/src/badguy/angrystone.hpp index d11c69259dc..d9a2b5d535a 100644 --- a/src/badguy/angrystone.hpp +++ b/src/badguy/angrystone.hpp @@ -40,7 +40,8 @@ class AngryStone final : public BadGuy virtual std::string get_display_name() const override { return display_name(); } protected: - enum AngryStoneState { + enum AngryStoneState + { IDLE, CHARGING, ATTACKING, @@ -48,10 +49,10 @@ class AngryStone final : public BadGuy }; private: - Vector attackDirection; /**< 1-normalized vector of current attack direction */ - Vector oldWallDirection; /**< if wall was hit during last attack: 1-normalized vector of last attack direction, (0,0) otherwise */ - Timer timer; - AngryStoneState state; + Vector m_attack_direction; /**< A normalized vector representing the current attack direction. */ + Vector m_old_wall_direction; /**< If a wall was hit during the last attack, a normalized vector representing the direction of the last attack, (0,0) otherwise. */ + Timer m_timer; + AngryStoneState m_state; private: AngryStone(const AngryStone&) = delete; diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 2f56b9b4b9c..10620d035ce 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -322,7 +322,7 @@ BadGuy::inactive_update(float ) void BadGuy::collision_tile(uint32_t tile_attributes) { - // Don't kill badguys that have already been killed + // Don't kill badguys that have already been killed. if (!is_active()) return; if (tile_attributes & Tile::WATER && !is_in_water()) @@ -378,7 +378,7 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit) /* Badguys don't let badguys squish other badguys. It's bad. */ #if 0 - // hit from above? + // Hit from above? if (badguy->get_bbox().get_bottom() < (bbox.get_top() + (player->is_sliding() ? 8.f : 16.f))) { if (collision_squished(*badguy)) { return ABORT_MOVE; @@ -392,7 +392,7 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit) auto player = dynamic_cast (&other); if (player) { - // hit from above? + // Hit from above? if (player->get_bbox().get_bottom() < (m_col.m_bbox.get_top() + 16)) { if (player->is_stone()) { kill_fall(); @@ -487,7 +487,7 @@ BadGuy::collision_player(Player& player, const CollisionHit& hit) return ABORT_MOVE; } } - //TODO: unfreeze timer + //TODO: Unfreeze timer. if (m_frozen) { player.collision_solid(hit); @@ -508,7 +508,7 @@ BadGuy::collision_badguy(BadGuy& badguy, const CollisionHit& hit) bool BadGuy::collision_squished(GameObject& object) { - // frozen badguys can be killed with butt-jump + // Frozen badguys can be killed with butt-jump. if (m_frozen) { auto player = dynamic_cast(&object); @@ -526,42 +526,42 @@ BadGuy::collision_bullet(Bullet& bullet, const CollisionHit& hit) { if (is_frozen()) { if (bullet.get_type() == FIRE_BONUS) { - // fire bullet thaws frozen badguys + // Fire bullet thaws frozen badguys. unfreeze(); bullet.remove_me(); return ABORT_MOVE; } else { - // other bullets ricochet + // Other bullets ricochet. bullet.ricochet(*this, hit); return FORCE_MOVE; } } else if (is_ignited()) { if (bullet.get_type() == ICE_BONUS) { - // ice bullets extinguish ignited badguys + // Ice bullets extinguish ignited badguys. extinguish(); bullet.remove_me(); return ABORT_MOVE; } else { - // other bullets are absorbed by ignited badguys + // Other bullets are absorbed by ignited badguys. bullet.remove_me(); return FORCE_MOVE; } } else if (bullet.get_type() == FIRE_BONUS && is_flammable()) { - // fire bullets ignite flammable badguys + // Fire bullets ignite flammable badguys. ignite(); bullet.remove_me(); return ABORT_MOVE; } else if (bullet.get_type() == ICE_BONUS && is_freezable()) { - // ice bullets freeze freezable badguys + // Ice bullets freeze freezable badguys. freeze(); bullet.remove_me(); return ABORT_MOVE; } else { - // in all other cases, bullets ricochet + // In all other cases, bullets ricochet. bullet.ricochet(*this, hit); return FORCE_MOVE; } @@ -583,7 +583,7 @@ BadGuy::kill_squished(GameObject& object) player->bounce(*this); } - // start dead-script + // Start the dead-script. run_dead_script(); } @@ -603,14 +603,14 @@ BadGuy::kill_fall() Sector::get().add( "images/particles/ice_piece"+std::to_string(graphicsRandom.rand(1, 3))+".sprite", "default", m_col.m_bbox.p1() + pr_pos, ANCHOR_MIDDLE, - //SPEED: add current enemy speed but do not add downwards velocity because it looks bad + //SPEED: Add current enemy speed, but do not add downwards velocity because it looks bad. Vector(m_physic.get_velocity_x(), m_physic.get_velocity_y() > 0.f ? 0.f : m_physic.get_velocity_y()) - //SPEED: add specified speed and randomization + //SPEED: Add specified speed and randomization. + speed + Vector(graphicsRandom.randf(-30.f, 30.f), graphicsRandom.randf(-30.f, 30.f)), Vector(0, Sector::get().get_gravity() * graphicsRandom.randf(100.f, 120.f)), LAYER_OBJECTS - 1, true); } } - // start dead-script + // Start the dead-script. run_dead_script(); remove_me(); } else { @@ -623,7 +623,7 @@ BadGuy::kill_fall() // Set the badguy layer to be the foremost, so that // this does not reveal secret tilemaps: m_layer = Sector::get().get_foremost_layer() + 1; - // start dead-script + // Start the dead-script. run_dead_script(); } @@ -642,7 +642,7 @@ BadGuy::run_dead_script() m_parent_dispenser->notify_dead(); } - // start dead-script + // Start the dead-script. if (!m_dead_script.empty()) { Sector::get().run_script(m_dead_script, "dead-script"); } @@ -671,7 +671,7 @@ BadGuy::set_state(State state_) //bbox.set_pos(start_position); break; case STATE_INACTIVE: - // was the badguy dead anyway? + // Was the badguy dead anyway? if (laststate == STATE_SQUISHED || laststate == STATE_FALLING) { remove_me(); } @@ -703,8 +703,8 @@ BadGuy::is_offscreen() const if (!Editor::is_active()) { player_dist = player->get_bbox().get_middle() - m_col.m_bbox.get_middle(); } - // In SuperTux 0.1.x, Badguys were activated when Tux<->Badguy center distance was approx. <= ~668px - // This doesn't work for wide-screen monitors which give us a virt. res. of approx. 1066px x 600px + // In SuperTux 0.1.x, Badguys were activated when Tux<->Badguy center distance was approx. <= ~668px. + // This doesn't work for wide-screen monitors which give us a virt. res. of approx. 1066px x 600px. if (((fabsf(player_dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(player_dist.y) <= Y_OFFSCREEN_DISTANCE)) ||((fabsf(cam_dist.x) <= X_OFFSCREEN_DISTANCE) && (fabsf(cam_dist.y) <= Y_OFFSCREEN_DISTANCE))) { return false; @@ -715,7 +715,7 @@ BadGuy::is_offscreen() const void BadGuy::try_activate() { - // Don't activate if player is dying + // Don't activate if player is dying. auto player = get_nearest_player(); if (!player) return; @@ -723,7 +723,7 @@ BadGuy::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 starting direction was set to AUTO, this is our chance to re-orient the badguy. if (m_start_dir == Direction::AUTO) { auto player_ = get_nearest_player(); if (player_ && (player_->get_bbox().get_left() > m_col.m_bbox.get_right())) { @@ -743,7 +743,7 @@ BadGuy::try_activate() bool BadGuy::might_fall(int height) const { - // make sure we check for at least a 1-pixel fall + // Make sure we check for at least a 1-pixel fall. assert(height > 0); float x1; @@ -805,7 +805,7 @@ BadGuy::grab(MovingObject& object, const Vector& pos, Direction dir_) if (m_sprite->has_action("iced-left")) { set_action("iced", m_dir, 1); - // when the sprite doesn't have sepaigrate actions for left and right, it tries to use an universal one. + // When the sprite doesn't have sepaigrate actions for left and right, it tries to use an universal one. } else { @@ -813,7 +813,7 @@ BadGuy::grab(MovingObject& object, const Vector& pos, Direction dir_) { set_action("iced", 1); } - // when no iced action exists, default to shading badguy blue + // When no iced action exists, default to shading badguy blue. else { m_sprite->set_color(Color(0.60f, 0.72f, 0.88f)); @@ -850,7 +850,7 @@ BadGuy::ungrab(MovingObject& object, Direction dir_) 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. m_physic.set_velocity_y(500.f); } } @@ -893,12 +893,12 @@ BadGuy::freeze() if (m_sprite->has_action("iced-left")) set_action("iced", m_dir, 1); - // when the sprite doesn't have separate actions for left and right, it tries to use an universal one. + // When the sprite doesn't have separate actions for left and right, it tries to use an universal one. else { if (m_sprite->has_action("iced")) set_action("iced", 1); - // when no iced action exists, default to shading badguy blue + // When no iced action exists, default to shading badguy blue. else { m_sprite->set_color(Color(0.60f, 0.72f, 0.88f)); @@ -931,9 +931,9 @@ BadGuy::unfreeze(bool melt) Sector::get().add( particle_sprite_name + std::to_string(graphicsRandom.rand(1, 3)) + ".sprite", "default", m_col.m_bbox.p1() + pr_pos, ANCHOR_MIDDLE, - //SPEED: add current enemy speed but do not add downwards velocity because it looks bad + //SPEED: add current enemy speed but do not add downwards velocity because it looks bad. Vector(m_physic.get_velocity_x(), m_physic.get_velocity_y() > 0.f ? 0.f : m_physic.get_velocity_y()) - //SPEED: add specified speed and randomization + //SPEED: add specified speed and randomization. + speed + Vector(graphicsRandom.randf(-30.f, 30.f), 0.f), Vector(0.f, Sector::get().get_gravity() * graphicsRandom.randf(100.f, 120.f)), LAYER_OBJECTS + 1, true); } @@ -977,7 +977,7 @@ BadGuy::ignite() if (m_sprite->has_action("melting-left")) { - // melt it! + // Melt it! if (m_sprite->has_action("ground-melting-left") && on_ground()) { set_action("ground-melting", m_dir, 1); SoundManager::current()->play("sounds/splash.ogg", get_pos()); @@ -991,7 +991,7 @@ BadGuy::ignite() run_dead_script(); } else if (m_sprite->has_action("burning-left")) { - // burn it! + // Burn it! m_glowing = true; SoundManager::current()->play("sounds/fire.ogg", get_pos()); set_action("burning", m_dir, 1); @@ -1117,7 +1117,7 @@ BadGuy::can_be_affected_by_wind() const void BadGuy::add_wind_velocity(const Vector& velocity, const Vector& end_speed) { - // only add velocity in the same direction as the wind + // Only add velocity in the same direction as the wind. if (end_speed.x > 0 && m_physic.get_velocity_x() < end_speed.x) m_physic.set_velocity_x(std::min(m_physic.get_velocity_x() + velocity.x, end_speed.x)); if (end_speed.x < 0 && m_physic.get_velocity_x() > end_speed.x) diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index 88c64160b45..19942870e95 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -144,7 +144,7 @@ Bomb::grab(MovingObject& object, const Vector& pos, Direction dir_) m_dir = dir_; // We actually face the opposite direction of Tux here to make the fuse more - // visible instead of hiding it behind Tux + // visible instead of hiding it behind Tux. set_action("ticking", m_dir, Sprite::LOOPS_CONTINUED); set_colgroup_active(COLGROUP_DISABLED); } @@ -153,19 +153,19 @@ void Bomb::ungrab(MovingObject& object, Direction dir_) { auto player = dynamic_cast (&object); - //handle swimming + // Handle swimming state of the player. if (player && (player->is_swimming() || player->is_water_jumping())) { float swimangle = player->get_swimming_angle(); m_physic.set_velocity(Vector(std::cos(swimangle) * 40.f, std::sin(swimangle) * 40.f) + player->get_physic().get_velocity()); } - //handle non-swimming + // Handle non-swimming. else { if (player) { - //handle x-movement + // Handle x-movement based on the player's direction and velocity. if (fabsf(player->get_physic().get_velocity_x()) < 1.0f) m_physic.set_velocity_x(0.f); else if ((player->m_dir == Direction::LEFT && player->get_physic().get_velocity_x() <= -1.0f) @@ -175,7 +175,7 @@ Bomb::ungrab(MovingObject& object, Direction dir_) else m_physic.set_velocity_x(player->get_physic().get_velocity_x() + (player->m_dir == Direction::LEFT ? -330.f : 330.f)); - //handle y-movement + // Handle y-movement based on the player's direction and velocity. m_physic.set_velocity_y(dir_ == Direction::UP ? -500.f : dir_ == Direction::DOWN ? 500.f : player->get_physic().get_velocity_x() != 0.f ? -200.f : 0.f); diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index 43b6416c714..4c3c5ba1638 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -86,8 +86,8 @@ BouncingSnowball::collision_solid(const CollisionHit& hit) m_physic.set_velocity_y(0); } - // left or right collision - // The direction must correspond, else we got fake bounces on slopes. + // Left or right collision. + // The direction must correspond, otherwise, we would experience fake bounces on slopes. if ((hit.left && m_dir == Direction::LEFT) || (hit.right && m_dir == Direction::RIGHT)) { m_dir = m_dir == Direction::LEFT ? Direction::RIGHT : Direction::LEFT; set_action(m_dir); diff --git a/src/badguy/captainsnowball.cpp b/src/badguy/captainsnowball.cpp index 8f28152766d..250324ad55c 100644 --- a/src/badguy/captainsnowball.cpp +++ b/src/badguy/captainsnowball.cpp @@ -36,7 +36,7 @@ CaptainSnowball::CaptainSnowball(const ReaderMapping& reader) : bool CaptainSnowball::might_climb(int width, int height) const { - // make sure we check for at least a 1-pixel climb + // Make sure we check for at least a 1-pixel climb. assert(height > 0); float x1; diff --git a/src/badguy/crusher.cpp b/src/badguy/crusher.cpp index 7193dd7b8be..a702d98e689 100644 --- a/src/badguy/crusher.cpp +++ b/src/badguy/crusher.cpp @@ -36,7 +36,7 @@ #include "util/reader_mapping.hpp" namespace { - /* Maximum movement speed in pixels per LOGICAL_FPS */ + /* Maximum movement speed in pixels per LOGICAL_FPS. */ const float RECOVER_SPEED_NORMAL = -3.125f; const float RECOVER_SPEED_LARGE = -2.0f; const float DROP_ACTIVATION_DISTANCE = 4.0f; @@ -62,8 +62,7 @@ Crusher::Crusher(const ReaderMapping& reader) : on_type_change(-1); reader.get("sideways", m_sideways); - // TODO: crusher hitting deserves its own sounds- - // one for hitting the ground, one for hitting Tux + // TODO: Add distinct sounds for crusher hitting the ground and hitting Tux. SoundManager::current()->preload(not_ice() ? "sounds/thud.ogg" : "sounds/brick.wav"); set_state(m_state, true); after_sprite_set(); @@ -155,7 +154,7 @@ Crusher::collision_solid(const CollisionHit& hit) m_cooldown_timer = m_ic_size == LARGE ? PAUSE_TIME_LARGE : PAUSE_TIME_NORMAL; set_state(RECOVERING); - // throw some particles + // Throw some particles. for (int j = 0; j < 5; j++) { if (!m_sideways) @@ -216,7 +215,7 @@ Crusher::update(float dt_sec) m_cooldown_timer = 0.0; } - //because this game's physics are so broken, we have to create faux collisions with bricks + // Because this game's physics are so broken, we have to create faux collisions with bricks. for (auto& brick : Sector::get().get_objects_by_type()) { @@ -245,7 +244,7 @@ Crusher::update(float dt_sec) } } - //determine whether side-crushers will go left or right + // Determine whether side-crushers will go left or right. if (auto* player = Sector::get().get_nearest_player(m_col.m_bbox)) { @@ -255,7 +254,7 @@ Crusher::update(float dt_sec) } } - // handle blockage + // Handle blockage. Rectf recover_box = get_bbox().grown(-1); if (!m_sideways) { @@ -277,7 +276,7 @@ Crusher::update(float dt_sec) } bool blocked = !Sector::get().is_free_of_statics(recover_box); - //velocity for recovery speed + // Velocity for recovery speed. float recover_x; float recover_y; @@ -297,7 +296,7 @@ Crusher::update(float dt_sec) bool returned_left = m_sideways && m_side_dir == Direction::LEFT && get_bbox().get_left() >= m_start_position.x - 2.f; bool returned_right = m_sideways && m_side_dir == Direction::RIGHT && get_bbox().get_left() <= m_start_position.x + 2.f; - //handle crusher states + // Handle crusher states. switch (m_state) { case IDLE: @@ -418,10 +417,10 @@ Crusher::draw(DrawingContext& context) m_sprite->draw(context.color(), get_pos(), m_layer + 2, m_flip); if (m_sprite->has_action("whites")) { - // draw crusher's eyes slightly behind + // Draw crusher's eyes slightly behind. m_lefteye->draw(context.color(), get_pos() + eye_position(false), m_layer + 1, m_flip); m_righteye->draw(context.color(), get_pos() + eye_position(true), m_layer + 1, m_flip); - // draw the whites of crusher's eyes even further behind + // Draw the whites of crusher's eyes even further behind. m_whites->draw(context.color(), get_pos(), m_layer, m_flip); } } @@ -554,17 +553,17 @@ Crusher::eye_position(bool right) const case IDLE: if (auto* player = Sector::get().get_nearest_player(m_col.m_bbox)) { - // Crusher focuses on approximate position of player's head + // Crusher focuses on approximate position of player's head. const float player_focus_x = (player->get_bbox().get_right() + player->get_bbox().get_left()) * 0.5f; const float player_focus_y = player->get_bbox().get_bottom() * 0.25f + player->get_bbox().get_top() * 0.75f; - // Crusher's approximate origin of line-of-sight + // Crusher's approximate origin of line-of-sight. const float crusher_origin_x = get_bbox().get_middle().x; const float crusher_origin_y = get_bbox().get_middle().y; - // Line-of-sight displacement from crusher to player + // Line-of-sight displacement from crusher to player. const float displacement_x = player_focus_x - crusher_origin_x; const float displacement_y = player_focus_y - crusher_origin_y; const float displacement_mag = powf(powf(displacement_x, 2.0f) + powf(displacement_y, 2.0f), 0.5f); - // Determine weighting for eye displacement along x given crusher eye shape + // Determine weighting for eye displacement along x given crusher eye shape. int weight_x = m_sprite->get_width() / 64 * (((displacement_x > 0) == right) ? 1 : 4); int weight_y = m_sprite->get_width() / 64 * 2; @@ -584,18 +583,18 @@ Crusher::eye_position(bool right) const } break; case RECOVERING: - // Eyes spin while crusher is recovering, giving a dazed impression - return Vector(sinf((right ? 1 : -1) * // X motion of each eye is opposite of the other - ((!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position - (m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f)) * //Phase factor due to cooldown timer - static_cast(m_sprite->get_width()) / 64.0f * 2.0f - (right ? 1 : -1) * // Amplitude dependent on size - static_cast(m_sprite->get_width()) / 64.0f * 2.0f, // Offset to keep eyes visible - - cosf((right ? 3.1415f : 0.0f) + // Eyes spin out of phase of eachother - (!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position - (m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f) * //Phase factor due to cooldown timer - static_cast(m_sprite->get_width()) / 64.0f * 2.0f - // Amplitude dependent on size - static_cast(m_sprite->get_width()) / 64.0f * 2.0f); // Offset to keep eyes visible + // Eyes spin while crusher is recovering, giving a dazed impression. + return Vector(sinf((right ? 1 : -1) * // X motion of each eye is opposite of the other. + ((!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position. + (m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f)) * //Phase factor due to cooldown timer. + static_cast(m_sprite->get_width()) / 64.0f * 2.0f - (right ? 1 : -1) * // Amplitude dependent on size. + static_cast(m_sprite->get_width()) / 64.0f * 2.0f, // Offset to keep eyes visible. + + cosf((right ? 3.1415f : 0.0f) + // Eyes spin out of phase of eachother. + (!m_sideways ? get_pos().y / 13 : get_pos().x / 13) - // Phase factor due to y position. + (m_ic_size == NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + m_cooldown_timer * 13.0f) * //Phase factor due to cooldown timer. + static_cast(m_sprite->get_width()) / 64.0f * 2.0f - // Amplitude dependent on size. + static_cast(m_sprite->get_width()) / 64.0f * 2.0f); // Offset to keep eyes visible. default: log_debug << "Crusher in invalid state" << std::endl; break; diff --git a/src/badguy/crystallo.cpp b/src/badguy/crystallo.cpp index 8baa7926dc3..4520a3cab4f 100644 --- a/src/badguy/crystallo.cpp +++ b/src/badguy/crystallo.cpp @@ -42,7 +42,7 @@ Crystallo::get_settings() void Crystallo::active_update(float dt_sec) { - //walking and turning properly + // Walking and turning properly. float targetwalk = m_dir == Direction::LEFT ? -80.f : 80.f; if (m_dir != Direction::LEFT && get_pos().x > (m_start_position.x + m_radius - 20.f)) targetwalk = -80.f; diff --git a/src/badguy/dart.cpp b/src/badguy/dart.cpp index 0cb9d8e2552..e77c589fff4 100644 --- a/src/badguy/dart.cpp +++ b/src/badguy/dart.cpp @@ -107,7 +107,7 @@ Dart::collision_solid(const CollisionHit& ) HitResponse Dart::collision_badguy(BadGuy& badguy, const CollisionHit& ) { - // ignore collisions with parent + // Ignore collisions with parent. if (&badguy == parent) { return FORCE_MOVE; } diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index d6d1241c442..b8af7b20e30 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -51,7 +51,7 @@ Dispenser::Dispenser(const ReaderMapping& reader) : reader.get("random", m_random, false); std::vector badguys; - if (reader.get("badguy", badguys)) // Backward compatibility + if (reader.get("badguy", badguys)) // Backward compatibility. { for (auto& badguy : badguys) add_object(GameObjectFactory::instance().create(badguy)); @@ -86,7 +86,7 @@ Dispenser::add_object(std::unique_ptr object) { auto moving_object = dynamic_cast(object.get()); if (!GameObjectFactory::instance().has_params(object->get_class_name(), ObjectFactory::RegisteredObjectParam::OBJ_PARAM_DISPENSABLE) || - !moving_object) // Object is not MovingObject, or is not dispensable + !moving_object) // Object is not MovingObject, or is not dispensable. { log_warning << object->get_class_name() << " is not dispensable. Removing from dispenser object list." << std::endl; return; @@ -141,7 +141,7 @@ Dispenser::active_update(float dt_sec) } if (m_dispense_timer.check()) { - // auto always shoots in Tux's direction + // Auto always shoots in Tux's direction. if (m_autotarget) { auto player = get_nearest_player(); @@ -165,7 +165,7 @@ Dispenser::launch_object() if (m_objects.empty()) return; if (m_frozen) return; - //FIXME: Does is_offscreen() work right here? + // FIXME: Does is_offscreen() work right here? if (!is_offscreen() && !Editor::is_active()) { Direction launch_dir = m_dir; @@ -230,7 +230,7 @@ Dispenser::launch_object() break; case DispenserType::CANNON: - spawnpoint = get_pos(); /* top-left corner of the cannon */ + spawnpoint = get_pos(); /* Top-left corner of the cannon. */ if (launch_dir == Direction::LEFT) spawnpoint.x -= object_bbox.get_width() + 1; else @@ -247,17 +247,17 @@ Dispenser::launch_object() break; } - /* Now we set the real spawn position */ + /* Now we set the real spawn position. */ moving_object->set_pos(spawnpoint); - /* Set reference to dispenser in the object itself */ + /* Set reference to dispenser in the object itself. */ moving_object->set_parent_dispenser(this); - if (obj_badguy) // The object is a badguy + if (obj_badguy) // The object is a badguy. { auto badguy = static_cast(moving_object); - /* We don't want to count dispensed badguys in level stats */ + /* We don't want to count dispensed badguys in level stats. */ badguy->m_countMe = false; if (m_limit_dispensed_badguys) diff --git a/src/badguy/dive_mine.cpp b/src/badguy/dive_mine.cpp index 8b99adcb5c7..207e569090f 100644 --- a/src/badguy/dive_mine.cpp +++ b/src/badguy/dive_mine.cpp @@ -127,7 +127,7 @@ DiveMine::active_update(float dt_sec) } m_physic.enable_gravity(false); - // Update float cycles + // Update float cycles. if (!m_chasing) { if (std::abs(m_physic.get_acceleration_y()) > s_max_float_acceleration * 3) @@ -136,11 +136,11 @@ DiveMine::active_update(float dt_sec) m_physic.set_acceleration_y(m_physic.get_acceleration_y() + (s_max_float_acceleration / 25) * (m_physic.get_velocity_y() < 0.f ? 1 : -1)); } - // Detect if player is near + // Detect if player is near. auto player = get_nearest_player(); if (player) { - // Face the player + // Face the player. m_dir = (player->get_pos().x > get_pos().x) ? Direction::RIGHT : Direction::LEFT; } @@ -153,7 +153,7 @@ DiveMine::active_update(float dt_sec) Vector dist = player->get_bbox().get_middle() - m_col.m_bbox.get_middle(); if (m_chasing) { - if (glm::length(dist) > s_trigger_radius) // Player is out of trigger radius + if (glm::length(dist) > s_trigger_radius) // Player is out of trigger radius. { stop_chasing(); return; @@ -191,7 +191,7 @@ DiveMine::unfreeze(bool melt) { BadGuy::unfreeze(); - m_chasing = true; // Ensure stop_chasing() will be executed + m_chasing = true; // Ensure stop_chasing() will be executed. stop_chasing(); } diff --git a/src/badguy/fish_chasing.cpp b/src/badguy/fish_chasing.cpp index a9adef05c2a..4bbcb11ce59 100644 --- a/src/badguy/fish_chasing.cpp +++ b/src/badguy/fish_chasing.cpp @@ -41,12 +41,12 @@ FishChasing::FishChasing(const ReaderMapping& reader) : void FishChasing::active_update(float dt_sec) { - //basic stuff + // Perform basic updates. BadGuy::active_update(dt_sec); m_in_water = !Sector::get().is_free_of_tiles(get_bbox(), true, Tile::WATER); m_physic.enable_gravity((!m_frozen && m_in_water) ? false : true); - //beached stuff + // Handle beached state when the fish is in water and beached_timer is active. if (m_in_water && m_beached_timer.started()) m_beached_timer.stop(); @@ -57,7 +57,7 @@ FishChasing::active_update(float dt_sec) { m_beached_timer.stop(); } - //behavior + // Behavior - chase the nearest player. auto player = get_nearest_player(); if (!player) return; Vector p1 = m_col.m_bbox.get_middle(); diff --git a/src/badguy/fish_jumping.cpp b/src/badguy/fish_jumping.cpp index 58f08ca764b..5bfa3d80c70 100644 --- a/src/badguy/fish_jumping.cpp +++ b/src/badguy/fish_jumping.cpp @@ -73,10 +73,10 @@ FishJumping::collision_tile(uint32_t tile_attributes) if ((tile_attributes & Tile::WATER) && (m_physic.get_velocity_y() >= 0)) { if (m_beached_timer.started()) m_beached_timer.stop(); - // initialize stop position if uninitialized + // Initialize stop position if uninitialized. if (m_stop_y == 0) m_stop_y = get_pos().y + m_col.m_bbox.get_height(); - // stop when we have reached the stop position + // Stop when we have reached the stop position. if (get_pos().y >= m_stop_y && m_physic.get_velocity_y() > 0.f) { if (!m_frozen) start_waiting(); @@ -103,17 +103,17 @@ FishJumping::active_update(float dt_sec) m_beached_timer.stop(); } - // waited long enough? + // Waited long enough? if (m_wait_timer.check()) jump(); - // set sprite + // Set sprite. if (!m_frozen && !is_ignited()) set_action((m_physic.get_velocity_y() == 0.f && m_in_water) ? "wait" : m_physic.get_velocity_y() < 0.f ? "normal" : "down"); - // we can't afford flying out of the tilemap, 'cause the engine would remove us. - if ((get_pos().y - 31.8f) < 0) // too high, let us fall + // We can't afford flying out of the tilemap, 'cause the engine would remove us. + if ((get_pos().y - 31.8f) < 0) // Too high, let us fall. { m_physic.set_velocity_y(0); m_physic.enable_gravity(true); diff --git a/src/badguy/fish_swimming.cpp b/src/badguy/fish_swimming.cpp index 0ad9d320c46..897db96abd3 100644 --- a/src/badguy/fish_swimming.cpp +++ b/src/badguy/fish_swimming.cpp @@ -108,12 +108,12 @@ FishSwimming::collision_badguy(BadGuy& badguy, const CollisionHit& hit) void FishSwimming::active_update(float dt_sec) { - //basic stuff + // Perform basic updates. BadGuy::active_update(dt_sec); m_in_water = !Sector::get().is_free_of_tiles(get_bbox(), true, Tile::WATER); m_physic.enable_gravity((!m_frozen && m_in_water) ? false : true); - //beached stuff + // Handle beached state when the fish is in water and beached_timer is active. if (m_in_water && m_beached_timer.started()) m_beached_timer.stop(); @@ -124,7 +124,7 @@ FishSwimming::active_update(float dt_sec) { m_beached_timer.stop(); } - //y-velocity stuff + // Handle y-velocity related functionality. if (!m_float_timer.started()) m_float_timer.start(FISH_FLOAT_TIME); @@ -158,7 +158,7 @@ FishSwimming::active_update(float dt_sec) { if (!m_beached_timer.started()) { - //x-velocity stuff + // Handle x-velocity related functionality. float goal_x_velocity = m_dir == Direction::LEFT ? -128.f : 128.f; if (m_dir != Direction::LEFT && get_pos().x > (m_start_position.x + m_radius - 20.f)) goal_x_velocity = -128.f; @@ -208,19 +208,19 @@ FishSwimming::maintain_velocity(float goal_x_velocity) return; float current_x_velocity = m_physic.get_velocity_x(); - /* We're very close to our target speed. Just set it to avoid oscillation */ + /* We're very close to our target speed. Just set it to avoid oscillation. */ if ((current_x_velocity > (goal_x_velocity - 5.0f)) && (current_x_velocity < (goal_x_velocity + 5.0f))) { m_physic.set_velocity_x(goal_x_velocity); m_physic.set_acceleration_x(0.0); } - /* Check if we're going too slow or even in the wrong direction */ + /* Check if we're going too slow or even in the wrong direction. */ else if (((goal_x_velocity <= 0.0f) && (current_x_velocity > goal_x_velocity)) || ((goal_x_velocity > 0.0f) && (current_x_velocity < goal_x_velocity))) { m_physic.set_acceleration_x(goal_x_velocity); } - /* Check if we're going too fast */ + /* Check if we're going too fast. */ else if (((goal_x_velocity <= 0.0f) && (current_x_velocity < goal_x_velocity)) || ((goal_x_velocity > 0.0f) && (current_x_velocity > goal_x_velocity))) { m_physic.set_acceleration_x((-1.f) * goal_x_velocity); diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 69b3527ecda..36a076627e7 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -114,7 +114,7 @@ Flame::freeze() Vector(0, -150), Vector(0,0), LAYER_BACKGROUNDTILES+2); set_group(COLGROUP_DISABLED); - // start dead-script + // Start the dead-script. run_dead_script(); } diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index 66dc7110f74..d508b5ee735 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -24,9 +24,9 @@ #include "supertux/sector.hpp" namespace { -const float PUFF_INTERVAL_MIN = 4.0f; /**< spawn new puff of smoke at most that often */ -const float PUFF_INTERVAL_MAX = 8.0f; /**< spawn new puff of smoke at least that often */ -const float GLOBAL_SPEED_MULT = 0.8f; /**< the overall movement speed/rate */ +const float PUFF_INTERVAL_MIN = 4.0f; /**< Spawn new puff of smoke at most that often. */ +const float PUFF_INTERVAL_MAX = 8.0f; /**< Spawn new puff of smoke at least that often. */ +const float GLOBAL_SPEED_MULT = 0.8f; /**< The overall movement speed/rate. */ } FlyingSnowBall::FlyingSnowBall(const ReaderMapping& reader) : @@ -92,7 +92,7 @@ FlyingSnowBall::active_update(float dt_sec) set_action(m_dir); } - // spawn smoke puffs + // Spawn smoke puffs. if (puff_timer.check()) { Vector ppos = m_col.m_bbox.get_middle(); Vector pspeed = Vector(graphicsRandom.randf(-10, 10), 150); diff --git a/src/badguy/ghosttree.cpp b/src/badguy/ghosttree.cpp index 506f16aa919..282ddc14ae7 100644 --- a/src/badguy/ghosttree.cpp +++ b/src/badguy/ghosttree.cpp @@ -155,14 +155,14 @@ GhostTree::active_update(float /*dt_sec*/) } if (root_timer.check()) { - /* TODO indicate root with an animation */ + /* TODO: indicate root with an animation. */ auto player = get_nearest_player(); if (player) Sector::get().add(Vector(player->get_bbox().get_left(), (m_flip == NO_FLIP ? (m_col.m_bbox.get_bottom() + ROOT_TOP_OFFSET) : (m_col.m_bbox.get_top() - ROOT_TOP_OFFSET - ROOT_HEIGHT))), m_flip); } } else if (mystate == STATE_SWALLOWING) { if (suck_lantern) { - // suck in lantern + // Suck in the lantern. assert (suck_lantern); Vector pos = suck_lantern->get_pos(); Vector delta = m_col.m_bbox.get_middle() + SUCK_TARGET_OFFSET - pos; @@ -176,7 +176,7 @@ GhostTree::active_update(float /*dt_sec*/) suck_lantern->grab(*this, pos, Direction::RIGHT); } } else { - // wait until lantern is swallowed + // Wait until the lantern is swallowed completely. if (m_sprite->animation_done()) { if (is_color_deadly(suck_lantern_color)) { die(); diff --git a/src/badguy/ghoul.cpp b/src/badguy/ghoul.cpp index 9b7df79ea6f..8f577224077 100644 --- a/src/badguy/ghoul.cpp +++ b/src/badguy/ghoul.cpp @@ -23,8 +23,8 @@ #include "util/reader_mapping.hpp" #include "util/writer.hpp" -static const float FLYSPEED = 80.0f; /**< speed in px per second */ -static const float TRACK_RANGE = 2500.0f; /**< at what distance to start tracking the player */ +static const float FLYSPEED = 80.0f; /**< Speed in px per second. */ +static const float TRACK_RANGE = 2500.0f; /**< At what distance to start tracking the player. */ Ghoul::Ghoul(const ReaderMapping& reader) : BadGuy(reader, "images/creatures/ghoul/ghoul.sprite"), diff --git a/src/badguy/goldbomb.cpp b/src/badguy/goldbomb.cpp index 72866d516c2..ae34bbb744b 100644 --- a/src/badguy/goldbomb.cpp +++ b/src/badguy/goldbomb.cpp @@ -38,7 +38,6 @@ GoldBomb::GoldBomb(const ReaderMapping& reader) : walk_speed = 80; max_drop_height = 16; - //Prevent stutter when Tux jumps on Gold Bomb SoundManager::current()->preload("sounds/explosion.wav"); m_exploding_sprite->set_action("default", 1); @@ -203,7 +202,7 @@ GoldBomb::grab(MovingObject& object, const Vector& pos, Direction dir_) Portable::grab(object,pos,dir_); if (tstate == STATE_TICKING){ // We actually face the opposite direction of Tux here to make the fuse more - // visible instead of hiding it behind Tux + // visible instead of hiding it behind Tux. set_action("ticking", m_dir, Sprite::LOOPS_CONTINUED); set_colgroup_active(COLGROUP_DISABLED); } @@ -225,19 +224,19 @@ GoldBomb::ungrab(MovingObject& object, Direction dir_) BadGuy::ungrab(object, dir_); else { - //handle swimming + // Handle swimming state of the player. if (player && (player->is_swimming() || player->is_water_jumping())) { float swimangle = player->get_swimming_angle(); m_physic.set_velocity(Vector(std::cos(swimangle) * 40.f, std::sin(swimangle) * 40.f) + player->get_physic().get_velocity()); } - //handle non-swimming + // Handle non-swimming. else { if (player) { - //handle x-movement + // Handle x-movement based on the player's direction and velocity. if (fabsf(player->get_physic().get_velocity_x()) < 1.0f) m_physic.set_velocity_x(0.f); else if ((player->m_dir == Direction::LEFT && player->get_physic().get_velocity_x() <= -1.0f) @@ -247,7 +246,7 @@ GoldBomb::ungrab(MovingObject& object, Direction dir_) else m_physic.set_velocity_x(player->get_physic().get_velocity_x() + (player->m_dir == Direction::LEFT ? -330.f : 330.f)); - //handle y-movement + // Handle y-movement based on the player's direction and velocity. m_physic.set_velocity_y(dir_ == Direction::UP ? -500.f : dir_ == Direction::DOWN ? 500.f : player->get_physic().get_velocity_x() != 0.f ? -200.f : 0.f); diff --git a/src/badguy/haywire.cpp b/src/badguy/haywire.cpp index cdcfaa954b5..2f270010a46 100644 --- a/src/badguy/haywire.cpp +++ b/src/badguy/haywire.cpp @@ -54,7 +54,6 @@ Haywire::Haywire(const ReaderMapping& reader) : walk_speed = NORMAL_WALK_SPEED; max_drop_height = 16; - //Prevent stutter when Tux jumps on Mr Bomb SoundManager::current()->preload("sounds/explosion.wav"); } @@ -152,7 +151,7 @@ Haywire::active_update(float dt_sec) } else { - //jump over gaps if Tux isnt below + // Jump over gaps if Tux isn't below. Rectf gap_box = get_bbox(); gap_box.set_left(m_col.m_bbox.get_left() + (m_dir == Direction::LEFT ? -38.f : 26.f)); gap_box.set_right(m_col.m_bbox.get_right() + (m_dir == Direction::LEFT ? -26.f : 38.f)); @@ -168,7 +167,7 @@ Haywire::active_update(float dt_sec) } } - //end of pathfinding + // End of pathfinding. if (stomped_timer.get_timeleft() < 0.05f) { if (m_jumping) @@ -205,7 +204,7 @@ Haywire::active_update(float dt_sec) } else if (player && time_stunned == 0.0f) { - /* Player is on the right or left*/ + /* Player is on the right or left. */ Direction player_dir = get_player_direction(player); if (player_dir != m_last_player_direction) { @@ -230,8 +229,8 @@ Haywire::active_update(float dt_sec) void Haywire::deactivate() { - // stop ticking/grunting sounds, in case we are deactivated before actually - // exploding (see https://github.com/SuperTux/supertux/issues/1260) + // Stop ticking/grunting sounds, in case we are deactivated before actually + // exploding (see https://github.com/SuperTux/supertux/issues/1260). stop_looping_sounds(); } diff --git a/src/badguy/igel.cpp b/src/badguy/igel.cpp index b56cc1cff85..6e76f76e46d 100644 --- a/src/badguy/igel.cpp +++ b/src/badguy/igel.cpp @@ -21,9 +21,9 @@ namespace { -const float IGEL_SPEED = 80; /**< speed at which we walk around */ -const float TURN_RECOVER_TIME = 0.5; /**< seconds before we will again turn around when shot at */ -const float RANGE_OF_VISION = 256; /**< range in px at which we can see bullets */ +const float IGEL_SPEED = 80; /**< Speed at which we walk around. */ +const float TURN_RECOVER_TIME = 0.5; /**< Seconds before we will again turn around when shot at. */ +const float RANGE_OF_VISION = 256; /**< Sange in px at which we can see bullets. */ } // namespace @@ -66,33 +66,34 @@ Igel::active_update(float dt_sec) { bool wants_to_flee = false; - // check if we see a fire bullet + // Check if we see a fire bullet. for (const auto& bullet : Sector::get().get_objects_by_type()) { if (bullet.get_type() != FIRE_BONUS) continue; if (can_see(bullet)) wants_to_flee = true; } - // if we flee, handle this ourselves + // If the Igel wants to flee and the turn recovery timer is not started, + // turn around and handle the fleeing behavior. if (wants_to_flee && (!turn_recover_timer.started())) { turn_around(); BadGuy::active_update(dt_sec); return; } - // else adhere to default behaviour + // Otherwise, adhere to the default behavior for WalkingBadguy. WalkingBadguy::active_update(dt_sec); } HitResponse Igel::collision_bullet(Bullet& bullet, const CollisionHit& hit) { - // default reaction if hit on front side or for freeze and unfreeze + // Default reaction if hit on the front side or for freeze and unfreeze conditions. if (((m_dir == Direction::LEFT) && hit.left) || ((m_dir == Direction::RIGHT) && hit.right) || (bullet.get_type() == ICE_BONUS) || ((bullet.get_type() == FIRE_BONUS) && (m_frozen))) { return BadGuy::collision_bullet(bullet, hit); } - // else make bullet ricochet and ignore the hit + // Otherwise, make the bullet ricochet and ignore the hit for this case. bullet.ricochet(*this, hit); return FORCE_MOVE; } @@ -106,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. diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index f2276cd9aed..603aec4cd65 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -21,9 +21,9 @@ #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"), @@ -31,8 +31,8 @@ Jumpy::Jumpy(const ReaderMapping& reader) : 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 @@ -57,8 +57,8 @@ Jumpy::hit(const CollisionHit& chit) groundhit_pos_set = true; 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); diff --git a/src/badguy/kamikazesnowball.cpp b/src/badguy/kamikazesnowball.cpp index ab3bb98f36d..dbd410541ae 100644 --- a/src/badguy/kamikazesnowball.cpp +++ b/src/badguy/kamikazesnowball.cpp @@ -81,7 +81,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); @@ -137,7 +137,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; diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 50bc6c1daf8..4400896369e 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -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; } @@ -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(); @@ -95,8 +95,8 @@ 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); } @@ -104,7 +104,7 @@ Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit) HitResponse Kugelblitz::hit(const CollisionHit& hit_) { - // hit floor? + // Did the collision occur with the floor? if (hit_.bottom) { if (!groundhit_pos_set) { @@ -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(speed)); @@ -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; @@ -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())) { diff --git a/src/badguy/livefire.cpp b/src/badguy/livefire.cpp index ccb612486e9..9d0a7d46974 100644 --- a/src/badguy/livefire.cpp +++ b/src/badguy/livefire.cpp @@ -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(); @@ -77,7 +77,7 @@ 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; } @@ -85,7 +85,7 @@ LiveFire::active_update(float dt_sec) { } else if (state == STATE_WAKING) { if (m_sprite->animation_done()) { - // start walking + // Start walking. state = STATE_WALKING; WalkingBadguy::initialize(); } @@ -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(); } @@ -118,7 +118,7 @@ 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); @@ -126,7 +126,7 @@ LiveFire::kill_fall() "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); @@ -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) @@ -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) { diff --git a/src/badguy/mole.cpp b/src/badguy/mole.cpp index 610d5d6b7c3..68723607fd5 100644 --- a/src/badguy/mole.cpp +++ b/src/badguy/mole.cpp @@ -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), diff --git a/src/badguy/mole_rock.cpp b/src/badguy/mole_rock.cpp index 17bb09be8f1..57cf27d567f 100644 --- a/src/badguy/mole_rock.cpp +++ b/src/badguy/mole_rock.cpp @@ -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; } diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index 03e309456ae..55fae1bfa17 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -34,7 +34,7 @@ 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"); } diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index d8792fb6c5e..2480a7e92af 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -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); @@ -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; @@ -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: @@ -276,7 +276,7 @@ MrIceBlock::ungrab(MovingObject& object, Direction dir_) auto player = dynamic_cast (&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)); } @@ -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); } diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index b84b01158b0..ab0717146fd 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -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_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(stumpy.get_bbox().get_left()); px < static_cast(stumpy.get_bbox().get_right()); px+=10) { Vector ppos = Vector(static_cast(px), static_cast(stumpy.get_bbox().get_top()) - 5.0f); @@ -120,8 +120,8 @@ 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)) { @@ -129,7 +129,7 @@ MrTree::collision_squished(GameObject& object) 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)) { diff --git a/src/badguy/owl.cpp b/src/badguy/owl.cpp index 2eeb3de7320..4ab91454440 100644 --- a/src/badguy/owl.cpp +++ b/src/badguy/owl.cpp @@ -115,7 +115,7 @@ Owl::active_update (float dt_sec) obj_pos.x -= verticalOffset; obj_pos.y += 3.f; /* Move a little away from the hitbox (the body). Looks nicer. */ - //To drop enemie before leave the screen + // Drop carried object before leaving the screen if (obj_pos.x<=16 || obj_pos.x+16>=Sector::get().get_width()){ carried_object->ungrab (*this, m_dir); carried_object = nullptr; @@ -169,7 +169,7 @@ Owl::kill_fall() carried_object = nullptr; } - // start dead-script + // Start the dead-script. run_dead_script(); } diff --git a/src/badguy/plant.cpp b/src/badguy/plant.cpp index 9dde7a072a6..e52ac123fd3 100644 --- a/src/badguy/plant.cpp +++ b/src/badguy/plant.cpp @@ -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; @@ -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; diff --git a/src/badguy/rcrystallo.cpp b/src/badguy/rcrystallo.cpp index c100cc271ed..74fcdd97dd3 100644 --- a/src/badguy/rcrystallo.cpp +++ b/src/badguy/rcrystallo.cpp @@ -55,7 +55,7 @@ RCrystallo::get_settings() void RCrystallo::active_update(float dt_sec) { - //initialization of certain events prior to going into cases + // Initialization of certain events prior to going into cases. auto player = get_nearest_player(); float targetwalk = m_dir == Direction::LEFT ? -80.f : 80.f; Rectf reversefallbox = get_bbox(); @@ -64,7 +64,7 @@ RCrystallo::active_update(float dt_sec) { case RCRYSTALLO_ROOF: m_physic.set_gravity_modifier(-1.f); - //walking and turning properly + // Walking and turning properly. if (m_dir != Direction::LEFT && get_pos().x > (m_start_position.x + m_radius - 20.f)) targetwalk = -80.f; if (m_dir != Direction::RIGHT && get_pos().x < (m_start_position.x - m_radius + 20.f)) @@ -72,20 +72,20 @@ RCrystallo::active_update(float dt_sec) set_action(std::abs(m_physic.get_velocity_x()) < 80.f ? m_dir == Direction::LEFT ? "slowdown-left" : "slowdown-right" : m_dir == Direction::LEFT ? "left" : "right", -1); - //turn at holes + // Turn at holes. reversefallbox.set_top(m_col.m_bbox.get_top() - 33.f); reversefallbox.set_left(m_col.m_bbox.get_left() + (m_dir == Direction::LEFT ? -5.f : 34.f)); reversefallbox.set_right(m_col.m_bbox.get_right() + (m_dir == Direction::LEFT ? -34.f : 5.f)); if (Sector::get().is_free_of_statics(reversefallbox)) turn_around(); - //detect player and fall when it is time + // Detect player and fall when it is time. if (player && player->get_bbox().get_right() > m_col.m_bbox.get_left() - 192.f && player->get_bbox().get_left() < m_col.m_bbox.get_right() + 192.f && player->get_bbox().get_bottom() > m_col.m_bbox.get_top() && Sector::get().free_line_of_sight(m_col.m_bbox.get_middle() + Vector(0, 20), player->get_bbox().get_middle() - Vector(0, 40), false, player)) { - //center enemy, begin falling + // Center enemy, begin falling. m_col.m_bbox.move(Vector(3.f, 0.f)); set_action(m_dir == Direction::LEFT ? "detected-left" : "detected-right", 1, ANCHOR_TOP); state = RCRYSTALLO_DETECT; @@ -161,7 +161,7 @@ RCrystallo::kill_fall() if (is_valid()) { remove_me(); - //create 4 shards that the enemy splits into, which serve as an additional threat + // Create 4 shards that the enemy splits into, which serve as an additional threat. Sector::get().add(m_col.m_bbox.get_middle(), Vector(100.f, -500.f)); Sector::get().add(m_col.m_bbox.get_middle(), Vector(270.f, -350.f)); Sector::get().add(m_col.m_bbox.get_middle(), Vector(-100.f, -500.f)); diff --git a/src/badguy/root.cpp b/src/badguy/root.cpp index 7be4c5d32a5..51511057d3f 100644 --- a/src/badguy/root.cpp +++ b/src/badguy/root.cpp @@ -31,7 +31,7 @@ Root::Root(const Vector& pos, Flip flip) : hatch_timer() { base_sprite->set_action("appearing", 1); - base_sprite->set_animation_loops(1); // TODO: necessary because set_action ignores loops for default action + base_sprite->set_animation_loops(1); // TODO: Necessary because set_action ignores loops for default actions. m_physic.enable_gravity(false); set_colgroup_active(COLGROUP_TOUCHABLE); m_flip = flip; @@ -45,7 +45,7 @@ void Root::deactivate() { remove_me(); - //no dead script + // No dead-script required for deactivation. } void @@ -74,7 +74,7 @@ Root::active_update(float dt_sec) offset_y = 0; mystate = STATE_VANISHING; base_sprite->set_action("vanishing", 2); - base_sprite->set_animation_loops(2); // TODO: doesn't seem to work for loops=1 + base_sprite->set_animation_loops(2); // TODO: Verify if setting loops to 1 works as intended. } set_pos(m_start_position + Vector(0, (m_flip == NO_FLIP ? offset_y : -offset_y))); } diff --git a/src/badguy/scrystallo.cpp b/src/badguy/scrystallo.cpp index d3394164d9a..2f4e01f7d78 100644 --- a/src/badguy/scrystallo.cpp +++ b/src/badguy/scrystallo.cpp @@ -88,7 +88,7 @@ SCrystallo::active_update(float dt_sec) case SCRYSTALLO_SLEEPING: m_physic.set_velocity(0.f, 0.f); m_physic.set_acceleration(0.f, 0.f); - // is sleeping peacefully + // The entity is sleeping peacefully. if (player) { Vector p1 = m_col.m_bbox.get_middle(); @@ -105,7 +105,7 @@ SCrystallo::active_update(float dt_sec) case SCRYSTALLO_WAKING: m_physic.set_velocity(0.f, 0.f); m_physic.set_acceleration(0.f, 0.f); - //wake up, acknowledge surroundings + // Wake up and acknowledge surroundings once the animation is done. if (m_sprite->animation_done()) { SoundManager::current()->play("sounds/crystallo-pop.ogg", get_pos()); @@ -118,7 +118,7 @@ SCrystallo::active_update(float dt_sec) BadGuy::active_update(dt_sec); break; case SCRYSTALLO_JUMPING: - //popping out of the hole, ends when near ground + // Popping out of the hole, ends when near the ground. downbox.set_bottom(get_bbox().get_bottom() + 10.f); if (!Sector::get().is_free_of_statics(downbox)) { @@ -128,7 +128,7 @@ SCrystallo::active_update(float dt_sec) WalkingBadguy::active_update(dt_sec); break; case SCRYSTALLO_WALKING: - //walking and turning properly + // Walking and turning properly. float targetwalk = m_dir == Direction::LEFT ? -80.f : 80.f; if (m_dir != Direction::LEFT && get_pos().x > (m_radius_anchor.x + m_radius - 20.f)) targetwalk = -80.f; diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index 7dce7df8c1f..cfa7667c81d 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -20,7 +20,9 @@ #include "sprite/sprite.hpp" namespace { -static const std::string SKULLYHOP_SOUND = "sounds/hop.ogg"; +const std::string SKULLYHOP_SOUND = "sounds/hop.ogg"; +const float HORIZONTAL_SPEED = 220; /**< X-speed when jumping. */ +const float VERTICAL_SPEED = -450; /**< Y-speed when jumping. */ } SkullyHop::SkullyHop(const ReaderMapping& reader) : @@ -34,7 +36,7 @@ SkullyHop::SkullyHop(const ReaderMapping& reader) : void SkullyHop::initialize() { - // initial state is JUMPING, because we might start airborne + // The initial state is JUMPING, because we might start airborne. state = JUMPING; set_action("jumping", m_dir); } @@ -54,9 +56,7 @@ SkullyHop::set_state(SkullyHopState newState) } else if (newState == JUMPING) { set_action("jumping", m_dir); -const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ m_physic.set_velocity_x(m_dir == Direction::LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED); -const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ m_physic.set_velocity_y(VERTICAL_SPEED); SoundManager::current()->play( SKULLYHOP_SOUND, get_pos()); } @@ -84,25 +84,25 @@ SkullyHop::collision_solid(const CollisionHit& hit) return; } - // just default behaviour (i.e. stop at floor/walls) when squished + // Default behaviour (i.e. stop at floor/walls) when squished. if (BadGuy::get_state() == STATE_SQUISHED) { BadGuy::collision_solid(hit); } - // ignore collisions while standing still + // Ignore collisions while standing still. if (state != JUMPING) return; - // check if we hit the floor while falling + // Check if we hit the floor while falling. if (hit.bottom && m_physic.get_velocity_y() > 0 ) { set_state(STANDING); } - // check if we hit the roof while climbing + // Check if we hit the roof while climbing. if (hit.top) { m_physic.set_velocity_y(0); } - // check if we hit left or right while moving in either direction + // Check if we hit left or right while moving in either direction. if (hit.left || hit.right) { m_dir = m_dir == Direction::LEFT ? Direction::RIGHT : Direction::LEFT; set_action("jumping", m_dir); @@ -113,7 +113,7 @@ SkullyHop::collision_solid(const CollisionHit& hit) HitResponse SkullyHop::collision_badguy(BadGuy& , const CollisionHit& hit) { - // behaviour for badguy collisions is the same as for collisions with solids + // Behaviour for badguy collisions is the same as for collisions with solids. collision_solid(hit); return CONTINUE; @@ -124,17 +124,17 @@ SkullyHop::active_update(float dt_sec) { BadGuy::active_update(dt_sec); - // no change if frozen + // No change if frozen. if (m_frozen) return; - // charge when fully recovered + // Charge when fully recovered. if ((state == STANDING) && (recover_timer.check())) { set_state(CHARGING); return; } - // jump as soon as charging animation completed + // Jump as soon as charging animation completed. if ((state == CHARGING) && (m_sprite->animation_done())) { set_state(JUMPING); return; diff --git a/src/badguy/skydive.cpp b/src/badguy/skydive.cpp index efd9e8973e1..d5b5e95903f 100644 --- a/src/badguy/skydive.cpp +++ b/src/badguy/skydive.cpp @@ -84,7 +84,7 @@ void SkyDive::ungrab(MovingObject& object, Direction dir_) { auto player = dynamic_cast (&object); - //handle swimming + // Handle swimming state of the player. if (player) { if (player->is_swimming() || player->is_water_jumping()) @@ -93,10 +93,10 @@ SkyDive::ungrab(MovingObject& object, Direction dir_) m_physic.set_velocity(Vector(std::cos(swimangle) * 40.f, std::sin(swimangle) * 40.f) + player->get_physic().get_velocity()); } - //handle non-swimming + // Handle non-swimming. else { - //handle x-movement + // Handle x-movement based on the player's direction and velocity. if (fabsf(player->get_physic().get_velocity_x()) < 1.0f) m_physic.set_velocity_x(0.f); else if ((player->m_dir == Direction::LEFT && player->get_physic().get_velocity_x() <= -1.0f) @@ -106,7 +106,7 @@ SkyDive::ungrab(MovingObject& object, Direction dir_) else m_physic.set_velocity_x(player->get_physic().get_velocity_x() + (player->m_dir == Direction::LEFT ? -330.f : 330.f)); - //handle y-movement + // Handle y-movement based on the player's direction and velocity. m_physic.set_velocity_y(dir_ == Direction::UP ? -500.f : dir_ == Direction::DOWN ? 500.f : player->get_physic().get_velocity_x() != 0.f ? -200.f : 0.f); diff --git a/src/badguy/snail.cpp b/src/badguy/snail.cpp index 02eb5b56b31..107e0fe7289 100644 --- a/src/badguy/snail.cpp +++ b/src/badguy/snail.cpp @@ -29,10 +29,10 @@ namespace { const float SNAIL_KICK_SPEED = 500; const int MAX_SNAIL_SQUISHES = 10; -const float SNAIL_KICK_SPEED_Y = -500; /**< y-velocity gained when kicked */ +const float SNAIL_KICK_SPEED_Y = -500; /**< Y-velocity gained when kicked. */ -const float SNAIL_GUARD_DELAY = 5.f; /**< Time in-between corrupted snail guard states (seconds) */ -const float SNAIL_GUARD_TIME = 3.f; /**< Duration of corrupted snail guard states (seconds) */ +const float SNAIL_GUARD_DELAY = 5.f; /**< Time in-between corrupted snail guard states (seconds). */ +const float SNAIL_GUARD_TIME = 3.f; /**< Duration of corrupted snail guard states (seconds). */ } // namespace @@ -53,7 +53,7 @@ Snail::Snail(const ReaderMapping& reader) : SoundManager::current()->preload("sounds/iceblock_bump.wav"); SoundManager::current()->preload("sounds/stomp.wav"); SoundManager::current()->preload("sounds/kick.wav"); - SoundManager::current()->preload("sounds/dartfire.wav"); // TODO: Specific sounds for snail guard state + SoundManager::current()->preload("sounds/dartfire.wav"); // TODO: Specific sounds for snail guard state. } void @@ -132,7 +132,7 @@ Snail::be_kicked(bool upwards) m_physic.set_velocity_x(m_dir == Direction::LEFT ? -SNAIL_KICK_SPEED : SNAIL_KICK_SPEED); m_physic.set_velocity_y(0); - // start a timer to delay addition of upward movement until we are (hopefully) out from under the player + // Start a timer to delay addition of upward movement until we are (hopefully) out from under the player. if (upwards) kicked_delay_timer.start(0.05f); } @@ -176,7 +176,7 @@ Snail::active_update(float dt_sec) { state = STATE_GUARD; set_action("guard", m_dir); - SoundManager::current()->play("sounds/dartfire.wav", get_pos()); // TODO: Specific sounds for snail guard state + SoundManager::current()->play("sounds/dartfire.wav", get_pos()); // TODO: Specific sounds for snail guard state. m_guard_end_timer.start(SNAIL_GUARD_TIME); } break; @@ -186,7 +186,7 @@ Snail::active_update(float dt_sec) { state = STATE_GUARD_RETRACT; set_action("retract", m_dir, /* loops = */ 1); - SoundManager::current()->play("sounds/dartfire.wav", get_pos()); // TODO: Specific sounds for snail guard state + SoundManager::current()->play("sounds/dartfire.wav", get_pos()); // TODO: Specific sounds for snail guard state. } break; @@ -316,9 +316,9 @@ Snail::collision_player(Player& player, const CollisionHit& hit) return BadGuy::collision_player(player, hit); if (state == STATE_GUARD) - return WalkingBadguy::collision_player(player, hit); // Hurt player on collision + return WalkingBadguy::collision_player(player, hit); // Hurt player on collision. - // handle kicks from left or right side + // Handle kicks from left or right side. if ((state == STATE_WAKING || state == STATE_FLAT) && (hit.left || hit.right)) { if (hit.left) { m_dir = Direction::RIGHT; diff --git a/src/badguy/snowman.cpp b/src/badguy/snowman.cpp index b20b6e82dda..b1cff7bca64 100644 --- a/src/badguy/snowman.cpp +++ b/src/badguy/snowman.cpp @@ -32,22 +32,22 @@ Snowman::Snowman(const ReaderMapping& reader) : void Snowman::loose_head() { - // replace with Snowball + // Replace with Snowball. Vector snowball_pos = get_pos(); - // Hard-coded values from sprites + // Hard-coded values from sprites. snowball_pos.x += 5; snowball_pos.y += 1; - /* Create death animation for the (now headless) snowman. */ + /* Create a death animation for the (now headless) snowman. */ set_action (m_dir == Direction::LEFT ? "headless-left" : "headless-right", /* loops = */ -1); - set_pos (get_pos () + Vector (-4.0, 19.0)); /* difference in the sprite offsets */ + set_pos (get_pos () + Vector (-4.0, 19.0)); /* Difference in the sprite offsets. */ m_physic.set_velocity_y(0); m_physic.set_acceleration_y(0); m_physic.enable_gravity(true); set_state (STATE_FALLING); m_countMe = false; - /* Create a new snowball where the snowman's head was */ + /* Create a new snowball where the snowman's head was. */ Sector::get().add(snowball_pos, m_dir, m_dead_script); } @@ -55,24 +55,24 @@ HitResponse Snowman::collision_bullet(Bullet& bullet, const CollisionHit& hit) { if (bullet.get_type() == FIRE_BONUS) { - // fire bullets destroy snowman's body + // Fire bullets destroy snowman's body. Vector snowball_pos = get_pos(); - // Hard-coded values from sprites + // Hard-coded values from sprites. snowball_pos.x += 5; snowball_pos.y += 1; - /* Create a new snowball where the snowman's head was */ + /* Create a new snowball where the snowman's head was. */ Sector::get().add(snowball_pos, m_dir, m_dead_script); m_countMe = false; - SoundManager::current()->play("sounds/pop.ogg", get_pos()); // this could be a different sound + SoundManager::current()->play("sounds/pop.ogg", get_pos()); // This could be a different sound. bullet.remove_me(); ignite(); return ABORT_MOVE; } else { - // in all other cases, bullets ricochet + // In all other cases, bullets ricochet. bullet.ricochet(*this, hit); return FORCE_MOVE; } @@ -88,7 +88,6 @@ Snowman::collision_squished(GameObject& object) return true; } - // bounce if (player) player->bounce(*this); diff --git a/src/badguy/spidermite.cpp b/src/badguy/spidermite.cpp index f6099a955db..d53a3f01c3f 100644 --- a/src/badguy/spidermite.cpp +++ b/src/badguy/spidermite.cpp @@ -53,7 +53,7 @@ SpiderMite::collision_squished(GameObject& object) void SpiderMite::collision_solid(const CollisionHit& hit) { - if (hit.top || hit.bottom) { // hit floor or roof? + if (hit.top || hit.bottom) { // Hit floor or roof? m_physic.set_velocity_y(0); } if (m_frozen) diff --git a/src/badguy/sspiky.cpp b/src/badguy/sspiky.cpp index 01476b74b2c..bca6a086acf 100644 --- a/src/badguy/sspiky.cpp +++ b/src/badguy/sspiky.cpp @@ -73,7 +73,7 @@ SSpiky::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 = SSPIKY_WAKING; } @@ -84,7 +84,7 @@ SSpiky::active_update(float dt_sec) { if (state == SSPIKY_WAKING) { if (m_sprite->animation_done()) { - // start walking + // Start walking. state = SSPIKY_WALKING; WalkingBadguy::initialize(); } @@ -97,7 +97,7 @@ void SSpiky::freeze() { WalkingBadguy::freeze(); - state = SSPIKY_WALKING; // if we get hit while sleeping, wake up :) + state = SSPIKY_WALKING; // If we get hit while sleeping, wake up. } bool diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index aa66150cd8b..18278ff5379 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -116,7 +116,7 @@ Stalactite::collision_badguy(BadGuy& other, const CollisionHit& hit) { if (state == STALACTITE_SQUISHED) return FORCE_MOVE; - // ignore other Stalactites + // Ignore other Stalactites. if (dynamic_cast(&other)) return FORCE_MOVE; if (state != STALACTITE_FALLING) return BadGuy::collision_badguy(other, hit); diff --git a/src/badguy/stumpy.cpp b/src/badguy/stumpy.cpp index ffe4c6ce851..25bdf156ada 100644 --- a/src/badguy/stumpy.cpp +++ b/src/badguy/stumpy.cpp @@ -89,7 +89,7 @@ Stumpy::collision_squished(GameObject& object) if (m_frozen) return WalkingBadguy::collision_squished(object); - // if we're still invincible, we ignore the hit + // If we're still invincible, we ignore the hit. if (mystate == STATE_INVINCIBLE) { SoundManager::current()->play("sounds/mr_treehit.ogg", get_pos()); auto player = dynamic_cast(&object); @@ -97,13 +97,13 @@ Stumpy::collision_squished(GameObject& object) return true; } - // if we can die, we do + // If we can die, we do. if (mystate == STATE_NORMAL) { set_action("squished", m_dir); m_col.set_size(m_sprite->get_current_hitbox_width(), m_sprite->get_current_hitbox_height()); kill_squished(object); - // spawn some particles - // TODO: provide convenience function in MovingSprite or MovingObject? + // Spawn some particles. + // TODO: Provide convenience function in MovingSprite or MovingObject? for (int i = 0; i < 25; i++) { Vector ppos = m_col.m_bbox.get_middle(); float angle = graphicsRandom.randf(-math::PI_2, math::PI_2); @@ -123,7 +123,7 @@ Stumpy::collision_squished(GameObject& object) } - //TODO: exception? + // TODO: Handle exception or add relevant logic here. return true; } diff --git a/src/badguy/toad.cpp b/src/badguy/toad.cpp index 81136b23f4f..4fa6ac3ce64 100644 --- a/src/badguy/toad.cpp +++ b/src/badguy/toad.cpp @@ -21,9 +21,9 @@ #include "sprite/sprite.hpp" namespace { -const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ -const float HORIZONTAL_SPEED = 320; /**< x-speed when jumping */ -const float TOAD_RECOVER_TIME = 0.5; /**< time to stand still before starting a (new) jump */ +const float VERTICAL_SPEED = -450; /**< Vertical speed when jumping. */ +const float HORIZONTAL_SPEED = 320; /**< Horizontal speed when jumping. */ +const float TOAD_RECOVER_TIME = 0.5; /**< Time to stand still before starting a (new) jump. */ static const std::string HOP_SOUND = "sounds/hop.ogg"; } @@ -38,7 +38,7 @@ Toad::Toad(const ReaderMapping& reader) : void Toad::initialize() { - // initial state is JUMPING, because we might start airborne + // The initial state is JUMPING, because we might start airborne. state = JUMPING; set_action("jumping", m_dir); } @@ -62,7 +62,7 @@ Toad::set_state(ToadState newState) } else if (newState == FALLING) { Player* player = get_nearest_player(); - // face player + // Face the player. if (player && (player->get_bbox().get_right() < m_col.m_bbox.get_left()) && (m_dir == Direction::RIGHT)) m_dir = Direction::LEFT; if (player && (player->get_bbox().get_left() > m_col.m_bbox.get_right()) && (m_dir == Direction::LEFT)) m_dir = Direction::RIGHT; set_action("idle", m_dir); @@ -84,25 +84,25 @@ Toad::collision_squished(GameObject& object) void Toad::collision_solid(const CollisionHit& hit) { - // default behavior when frozen + // Default behavior when frozen. if (m_frozen || BadGuy::get_state() == STATE_BURNING) { BadGuy::collision_solid(hit); return; } - // just default behaviour (i.e. stop at floor/walls) when squished + // Default behaviour (i.e. stop at floor/walls) when squished. if (BadGuy::get_state() == STATE_SQUISHED) { BadGuy::collision_solid(hit); return; } - // ignore collisions while standing still + // Ignore collisions while standing still. if (state == IDLE) { return; } - // check if we hit left or right while moving in either direction + // Check if we hit left or right while moving in either direction. if (((m_physic.get_velocity_x() < 0) && hit.left) || ((m_physic.get_velocity_x() > 0) && hit.right)) { /* dir = dir == LEFT ? RIGHT : LEFT; @@ -115,13 +115,13 @@ Toad::collision_solid(const CollisionHit& hit) m_physic.set_velocity_x(-0.25f*m_physic.get_velocity_x()); } - // check if we hit the floor while falling + // Check if we hit the floor while falling. if ((state == FALLING) && hit.bottom) { set_state(IDLE); return; } - // check if we hit the roof while climbing + // Check if we hit the roof while climbing. if ((state == JUMPING) && hit.top) { m_physic.set_velocity_y(0); } @@ -131,7 +131,7 @@ Toad::collision_solid(const CollisionHit& hit) HitResponse Toad::collision_badguy(BadGuy& , const CollisionHit& hit) { - // behaviour for badguy collisions is the same as for collisions with solids + // Behaviour for badguy collisions is the same as for collisions with solids. collision_solid(hit); return CONTINUE; @@ -143,13 +143,13 @@ Toad::active_update(float dt_sec) BadGuy::active_update(dt_sec); - // change sprite when we are falling and not frozen + // Change sprite when we are falling and not frozen. if ((state == JUMPING) && (m_physic.get_velocity_y() > 0) && !m_frozen) { set_state(FALLING); return; } - // jump when fully recovered and if not frozen + // Jump when fully recovered and if not frozen. if ((state == IDLE) && (recover_timer.check() && !m_frozen)) { set_state(JUMPING); return; diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index c3b5e42696e..2787adb9ef0 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -82,22 +82,22 @@ Totem::active_update(float dt_sec) initialize(); } - // jump a bit if we find a suitable totem + // Jump slightly if we encounter a suitable totem. for (auto& obj : Sector::get().get_objects_by_type()) { auto t = dynamic_cast(&obj); if (!t) continue; - // skip if we are not approaching each other + // Skip if we are not approaching each other. if (!((m_dir == Direction::LEFT) && (t->m_dir == Direction::RIGHT))) continue; Vector p1 = m_col.m_bbox.p1(); Vector p2 = t->get_pos(); - // skip if not on same height + // Skip if we are not on the same height. float dy = (p1.y - p2.y); if (fabsf(dy - 0) > 2) continue; - // skip if too far away + // Skip if the totem is too far away. float dx = (p1.x - p2.x); if (fabsf(dx - 128) > 2) continue; @@ -145,18 +145,18 @@ Totem::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); - // if we are being carried around, pass event to bottom of stack and ignore it + // If we are being carried around: pass event to bottom of stack and ignore it. if (carried_by) { carried_by->collision_solid(hit); return; } - // If we hit something from above or below: stop moving in this direction + // If we hit something from above or below: stop moving in this direction. if (hit.top || hit.bottom) { m_physic.set_velocity_y(0); } - // If we are hit from the direction we are facing: turn around + // If we are hit from the direction we are facing: turn around. if (hit.left && (m_dir == Direction::LEFT)) { m_dir = Direction::RIGHT; initialize(); @@ -170,13 +170,13 @@ Totem::collision_solid(const CollisionHit& hit) HitResponse Totem::collision_badguy(BadGuy& badguy, const CollisionHit& hit) { - // if we are being carried around, pass event to bottom of stack and ignore it + // If we are being carried around: pass event to bottom of stack and ignore it. if (carried_by) { carried_by->collision_badguy(badguy, hit); return CONTINUE; } - // if we hit a Totem that is not from our stack: have our base jump on its top + // If we hit a Totem that is not from our stack: have our base jump on its top. auto totem = dynamic_cast(&badguy); if (totem) { auto thisBase = this; while (thisBase->carried_by) thisBase=thisBase->carried_by; @@ -187,7 +187,7 @@ Totem::collision_badguy(BadGuy& badguy, const CollisionHit& hit) } } - // If we are hit from the direction we are facing: turn around + // If we are hit from the direction we are facing: turn around. if (hit.left && (m_dir == Direction::LEFT)) { m_dir = Direction::RIGHT; initialize(); @@ -213,7 +213,7 @@ void Totem::jump_on(Totem* target) { if (target->carrying) { - log_warning << "target is already carrying someone" << std::endl; + log_warning << "Target is already carrying someone." << std::endl; return; } @@ -231,7 +231,7 @@ Totem::jump_on(Totem* target) void Totem::jump_off() { if (!carried_by) { - log_warning << "not carried by anyone" << std::endl; + log_warning << "Not carried by anyone." << std::endl; return; } diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index 6541e31cd48..b147d881f2c 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -86,7 +86,7 @@ TreeWillOWisp::start_sucking(const Vector& suck_target_) HitResponse TreeWillOWisp::collision_player(Player& player, const CollisionHit& hit) { - //TODO: basically a no-op. Remove if this doesn't change. + // TODO: This function is essentially a no-op. Remove if it doesn't change the behavior. return BadGuy::collision_player(player, hit); } @@ -112,7 +112,7 @@ TreeWillOWisp::draw(DrawingContext& context) void TreeWillOWisp::active_update(float dt_sec) { - // remove TreeWillOWisp if it has completely vanished + // Remove the TreeWillOWisp if it has completely vanished. if (mystate == STATE_VANISHING) { if (m_sprite->animation_done()) { remove_me(); @@ -136,7 +136,7 @@ TreeWillOWisp::active_update(float dt_sec) Vector newpos(m_start_position + Vector(sinf(angle) * radius, 0)); m_col.set_movement(newpos - get_pos()); float sizemod = cosf(angle) * 0.8f; - /* TODO: modify sprite size */ + /* TODO: Modify sprite size using the 'sizeMod' value. */ sound_source->set_position(get_pos()); diff --git a/src/badguy/viciousivy.cpp b/src/badguy/viciousivy.cpp index 644fc97fcf1..15ddff13fc6 100644 --- a/src/badguy/viciousivy.cpp +++ b/src/badguy/viciousivy.cpp @@ -104,7 +104,7 @@ ViciousIvy::collision_squished(GameObject& object) return WalkingBadguy::collision_squished(object); set_action("squished", m_dir); - // Spawn death particles + // Spawn death particles. spawn_explosion_sprites(3, "images/particles/viciousivy.sprite"); kill_squished(object); return true; diff --git a/src/badguy/walkingleaf.cpp b/src/badguy/walkingleaf.cpp index ab2e60e76ca..b34144fa8d1 100644 --- a/src/badguy/walkingleaf.cpp +++ b/src/badguy/walkingleaf.cpp @@ -89,7 +89,7 @@ WalkingLeaf::collision_squished(GameObject& object) return WalkingBadguy::collision_squished(object); set_action("squished", m_dir); - // Spawn death particles + // Spawn death particles. spawn_explosion_sprites(3, "images/particles/walkingleaf.sprite"); kill_squished(object); return true; diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 83a36c40544..9c0debd76c4 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -28,9 +28,9 @@ #include "util/reader_mapping.hpp" #include "util/writer.hpp" -static const float FLYSPEED = 64.0f; /**< speed in px per second */ -static const float TRACK_RANGE = 384.0f; /**< at what distance to start tracking the player */ -static const float VANISH_RANGE = 512.0f; /**< at what distance to stop tracking and vanish */ +static const float FLYSPEED = 64.0f; /**< Speed in pixels per second. */ +static const float TRACK_RANGE = 384.0f; /**< Distance at which to start tracking the player. */ +static const float VANISH_RANGE = 512.0f; /**< Distance at which to stop tracking and vanish. */ static const std::string SOUNDFILE = "sounds/willowisp.wav"; WillOWisp::WillOWisp(const ReaderMapping& reader) : diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 319ef588e42..f3a6b553c85 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -29,29 +29,30 @@ #include "util/reader_mapping.hpp" #include "video/surface.hpp" -namespace { -const float JUMP_DOWN_VX = 250; /**< horizontal speed while jumping off the dais */ -const float JUMP_DOWN_VY = -250; /**< vertical speed while jumping off the dais */ +namespace +{ +const float JUMP_DOWN_VX = 250; /**< Horizontal speed while jumping off the dais. */ +const float JUMP_DOWN_VY = -250; /**< Vertical speed while jumping off the dais. */ -const float RUN_VX = 350; /**< horizontal speed while running */ +const float RUN_VX = 350; /**< Horizontal speed while running. */ -const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */ -const float JUMP_UP_VY = -700; /**< vertical speed while jumping on the dais */ +const float JUMP_UP_VX = 350; /**< Horizontal speed while jumping on the dais. */ +const float JUMP_UP_VY = -700; /**< Vertical speed while jumping on the dais. */ -const float STOMP_VY = -300; /** vertical speed while stomping on the dais */ +const float STOMP_VY = -300; /**< Vertical speed while stomping on the dais. */ -const float RUN_DISTANCE = 1060; /** Distance between the x-coordinates of left and right end positions */ -const float JUMP_SPACE = 448; /** Distance between jump position and stand position */ -const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again */ -const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */ -const int INITIAL_HITPOINTS = 5; /**< number of hits we can take */ +const float RUN_DISTANCE = 1060; /**< Distance between the x-coordinates of left and right end positions. */ +const float JUMP_SPACE = 448; /**< Distance between the jump position and the stand position. */ +const float STOMP_WAIT = 0.5; /**< Time we stay on the dais before jumping again. */ +const float SAFE_TIME = 0.5; /**< The time we are safe when Tux just hit us. */ +const int INITIAL_HITPOINTS = 5; /**< Number of hits we can take. */ const float YETI_SQUISH_TIME = 3; -const float SNOW_EXPLOSIONS_FREQUENCY = 8; /**< number of snowball explosions per second */ -const int SNOW_EXPLOSIONS_COUNT = 5; /**< number of snowballs per explosion */ -const float SNOW_EXPLOSIONS_VX = 150; /**< Speed of snowballs */ -const float SNOW_EXPLOSIONS_VY = -200; /**< Speed of snowballs */ +const float SNOW_EXPLOSIONS_FREQUENCY = 8; /**< Number of snowball explosions per second. */ +const int SNOW_EXPLOSIONS_COUNT = 5; /**< Number of snowballs per explosion. */ +const float SNOW_EXPLOSIONS_VX = 150; /**< Speed of snowballs. */ +const float SNOW_EXPLOSIONS_VY = -200; /**< Speed of snowballs. */ } Yeti::Yeti(const ReaderMapping& reader) : @@ -115,7 +116,7 @@ Yeti::recalculate_pos() void Yeti::draw(DrawingContext& context) { - // we blink when we are safe + // We blink when we are safe. if (safe_timer.started() && size_t(g_game_time * 40) % 2) return; @@ -178,8 +179,8 @@ Yeti::active_update(float dt_sec) if (state_timer.check()) { BadGuy::kill_fall(); state = FALLING; - m_physic.set_velocity_y(JUMP_UP_VY / 2); // Move up a bit before falling - // Add some extra explosions + m_physic.set_velocity_y(JUMP_UP_VY / 2); // Move up a bit before falling. + // Add some extra explosions. for (int i = 0; i < 10; i++) { add_snow_explosions(); } @@ -223,7 +224,7 @@ Yeti::jump_up() void Yeti::be_angry() { - //turn around + // Turn around. m_dir = (m_dir==Direction::RIGHT) ? Direction::LEFT : Direction::RIGHT; set_action("stand", m_dir); @@ -260,7 +261,7 @@ void Yeti::take_hit(Player& ) hit_points--; if (hit_points <= 0) { - // We're dead + // We're dead. m_physic.set_velocity_x(((m_dir==Direction::RIGHT)?+RUN_VX:-RUN_VX)/5); m_physic.set_velocity_y(0); @@ -270,7 +271,7 @@ void Yeti::take_hit(Player& ) state = SQUISHED; state_timer.start(YETI_SQUISH_TIME); set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC); - //sprite->set_action("dead"); // This sprite does not look very good + // sprite->setAction("dead"); } else { safe_timer.start(SAFE_TIME); @@ -280,13 +281,13 @@ void Yeti::take_hit(Player& ) void Yeti::kill_fall() { - // shooting bullets or being invincible won't work :) + // Shooting bullets or being invincible won't prevent this action. } void Yeti::drop_stalactite() { - // make a stalactite falling down and shake camera a bit + // Make a stalactite fall down and shake the camera a bit. Sector::get().get_camera().shake(.1f, 0, 20.f); auto player = get_nearest_player(); @@ -296,14 +297,14 @@ Yeti::drop_stalactite() { if (stalactite.is_hanging()) { if (hit_points >= 3) { - // drop stalactites within 3 of player, going out with each jump + // Drop stalactites within 3 units of player, going out with each jump. float distancex = fabsf(stalactite.get_bbox().get_middle().x - player->get_bbox().get_middle().x); if (distancex < static_cast(stomp_count) * 32.0f) { stalactite.start_shaking(); } } else { /* if (hitpoints < 3) */ - // drop every 3rd pair of stalactites + // Drop every 3rd pair of stalactites. if ((((static_cast(stalactite.get_pos().x) + 16) / 64) % 3) == (stomp_count % 3)) { stalactite.start_shaking(); } @@ -317,7 +318,7 @@ Yeti::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if (hit.top || hit.bottom) { - // hit floor or roof + // Hit floor or roof. m_physic.set_velocity_y(0); switch (state) { case JUMP_DOWN: @@ -328,17 +329,17 @@ Yeti::collision_solid(const CollisionHit& hit) case JUMP_UP: break; case BE_ANGRY: - // we just landed + // We just landed. if (!state_timer.started()) { set_action("stand", m_dir); stomp_count++; drop_stalactite(); - // go to other side after 3 jumps + // Go to the other side after 3 jumps. if (stomp_count == 3) { jump_down(); } else { - // jump again + // Jump again. state_timer.start(STOMP_WAIT); } } @@ -349,7 +350,7 @@ Yeti::collision_solid(const CollisionHit& hit) break; } } else if (hit.left || hit.right) { - // hit wall + // Hit wall. if(state != SQUISHED && state != FALLING) jump_up(); } diff --git a/src/badguy/yeti_stalactite.cpp b/src/badguy/yeti_stalactite.cpp index c09a003faa6..54788cbc320 100644 --- a/src/badguy/yeti_stalactite.cpp +++ b/src/badguy/yeti_stalactite.cpp @@ -54,17 +54,17 @@ YetiStalactite::active_update(float dt_sec) void YetiStalactite::update(float dt_sec) { - // Respawn instead of removing once squished + // Respawn instead of removing once squished. if (get_state() == STATE_SQUISHED && check_state_timer()) { set_state(STATE_ACTIVE); state = STALACTITE_HANGING; - // Hopefully we shouldn't come into contact with anything... + // Attempt to minimize any potential collisions during this process. set_action("normal"); set_pos(m_start_position); set_colgroup_active(COLGROUP_TOUCHABLE); } - // Call back to badguy to do normal stuff + // Invoke the badguy's update function to handle regular tasks. BadGuy::update(dt_sec); } diff --git a/src/badguy/zeekling.cpp b/src/badguy/zeekling.cpp index f392b44b735..52b6e90b1db 100644 --- a/src/badguy/zeekling.cpp +++ b/src/badguy/zeekling.cpp @@ -122,7 +122,7 @@ Zeekling::collision_solid(const CollisionHit& hit) } } -/** linear prediction of player and badguy positions to decide if we should enter the DIVING state */ +/** Linear prediction of player and badguy positions to decide if we should enter the DIVING state. */ bool Zeekling::should_we_dive() { @@ -132,40 +132,40 @@ Zeekling::should_we_dive() const auto player = get_nearest_player(); if (player && last_player && (player == last_player)) { - // get positions, calculate movement + // Get positions and calculate movement. const Vector& player_pos = player->get_pos(); const Vector player_mov = (player_pos - last_player_pos); const Vector self_pos = m_col.m_bbox.p1(); const Vector self_mov = (self_pos - last_self_pos); - // new vertical speed to test with + // New vertical speed to test with. float vy = 2*fabsf(self_mov.x); - // do not dive if we are not above the player + // Do not dive if we are not above the player. float height = player_pos.y - self_pos.y; if (height <= 0) return false; - // do not dive if we are too far above the player + // Do not dive if we are too far above the player. if (height > 512) return false; - // do not dive if we would not descend faster than the player + // Do not dive if we would not descend faster than the player. float relSpeed = vy - player_mov.y; if (relSpeed <= 0) return false; - // guess number of frames to descend to same height as player + // Guess number of frames to descend to same height as player. float estFrames = height / relSpeed; - // guess where the player would be at this time + // Guess where the player would be at this time. float estPx = (player_pos.x + (estFrames * player_mov.x)); - // guess where we would be at this time + // Guess where we would be at this time. float estBx = (self_pos.x + (estFrames * self_mov.x)); - // near misses are OK, too + // Allow for slight inaccuracies. if (fabsf(estPx - estBx) < 8) return true; } - // update last player tracked, as well as our positions + // Update the last player tracked, as well as our positions. last_player = player; if (player) { last_player_pos = player->get_pos(); @@ -189,7 +189,7 @@ Zeekling::active_update(float dt_sec) { BadGuy::active_update(dt_sec); return; } else if (state == CLIMBING) { - // stop climbing when we're back at initial height + // Stop climbing when we're back at initial height. if (get_pos().y <= m_start_position.y) { state = FLYING; m_physic.set_velocity_y(0); diff --git a/src/badguy/zeekling.hpp b/src/badguy/zeekling.hpp index ca4d2583d81..73577595821 100644 --- a/src/badguy/zeekling.hpp +++ b/src/badguy/zeekling.hpp @@ -58,9 +58,9 @@ class Zeekling final : public BadGuy float speed; Timer diveRecoverTimer; ZeeklingState state; - const MovingObject* last_player; /**< last player we tracked */ - Vector last_player_pos; /**< position we last spotted the player at */ - Vector last_self_pos; /**< position we last were at */ + const MovingObject* last_player; /**< Last player we tracked. */ + Vector last_player_pos; /**< Position we last spotted the player at. */ + Vector last_self_pos; /**< Position we last were at. */ private: Zeekling(const Zeekling&) = delete; diff --git a/src/collision/collision.cpp b/src/collision/collision.cpp index 2cd8d4a3045..30bab7ffec3 100644 --- a/src/collision/collision.cpp +++ b/src/collision/collision.cpp @@ -205,14 +205,14 @@ bool line_intersects_line(const Vector& line1_start, const Vector& line1_end, co float den1 = (d2-b2)*(c1-c2) + (a2-c2)*(d1-d2); float den2 = (d2-b2)*(a1-a2) + (a2-c2)*(b1-b2); - // normalize to positive numerator + // Normalize to positive numerator. if (num < 0) { num = -num; den1 = -den1; den2 = -den2; } - // numerator is zero -> Check for parallel or coinciding lines + // Numerator is zero -> Check for parallel or coinciding lines. if (num == 0) { if ((b1-b2)*(c1-a2) != (a1-a2)*(d1-b2)) return false; if (a1 == a2) { @@ -226,7 +226,7 @@ bool line_intersects_line(const Vector& line1_start, const Vector& line1_end, co return ((a1 <= c2) && (a2 >= c1)); } - // Standard check + // Standard check. return (den1>=0) && (den1<=num) && (den2>=0) && (den2<=num); } diff --git a/src/collision/collision_movement_manager.cpp b/src/collision/collision_movement_manager.cpp index 6a3544c82d9..379965e3f23 100644 --- a/src/collision/collision_movement_manager.cpp +++ b/src/collision/collision_movement_manager.cpp @@ -46,7 +46,7 @@ CollisionGroundMovementManager::apply_all_ground_movement() const auto& tilemaps_map = movements.get_tilemaps_map(); // Find the lowest "y" position (i.e. the highest point since - // (0,0) is the top-left corner) and the associated object + // (0,0) is the top-left corner) and the associated object. Vector lowest_y_vector(0.0f, 0.0f); bool first_to_do = true; diff --git a/src/collision/collision_system.cpp b/src/collision/collision_system.cpp index b95f05aa5b2..35afbbf74cf 100644 --- a/src/collision/collision_system.cpp +++ b/src/collision/collision_system.cpp @@ -57,7 +57,7 @@ CollisionSystem::remove(CollisionObject* object) std::find(m_objects.begin(), m_objects.end(), object)); - // FIXME: this is a patch. A better way of fixing this is coming. + // FIXME: This is a patch. A better way of fixing this is coming. for (auto* collision_object : m_objects) { collision_object->notify_object_removal(object); } @@ -123,7 +123,7 @@ collision::Constraints check_collisions(const Vector& obj_movement, const Rectf& if (moving_object != nullptr && other_object != nullptr && !moving_object->collides(*other_object, dummy)) return constraints; - // calculate intersection + // Calculate intersection. const float itop = moving_obj_rect.get_bottom() - grown_other_obj_rect.get_top(); const float ibottom = grown_other_obj_rect.get_bottom() - moving_obj_rect.get_top(); const float ileft = moving_obj_rect.get_right() - grown_other_obj_rect.get_left(); @@ -140,7 +140,7 @@ collision::Constraints check_collisions(const Vector& obj_movement, const Rectf& shiftout = true; } } else { - // shiftout bottom/top + // Shiftout bottom/top. if (itop < SHIFT_DELTA) { constraints.constrain_bottom(grown_other_obj_rect.get_top()); shiftout = true; @@ -198,7 +198,7 @@ CollisionSystem::collision_tilemap(collision::Constraints* constraints, for (auto* solids : m_sector.get_solid_tilemaps()) { - // test with all tiles in this rectangle + // Test with all tiles in this rectangle. const Rect test_tiles = solids->get_tiles_overlapping(Rectf(x1, y1, x2, y2)); bool hits_bottom = false; @@ -209,7 +209,7 @@ CollisionSystem::collision_tilemap(collision::Constraints* constraints, { const Tile& tile = solids->get_tile(x, y); - // skip non-solid tiles + // Skip non-solid tiles. if (tile.is_solid()) { Rectf tile_bbox = solids->get_tile_bbox(x, y); @@ -230,7 +230,7 @@ CollisionSystem::collision_tilemap(collision::Constraints* constraints, if (is_relatively_solid) { - if (tile.is_slope ()) { // slope tile + if (tile.is_slope ()) { // Slope tile. AATriangle triangle; int slope_data = tile.get_data(); if (solids->get_flip() & VERTICAL_FLIP) @@ -240,7 +240,7 @@ CollisionSystem::collision_tilemap(collision::Constraints* constraints, bool triangle_hits_bottom = false; collision::rectangle_aatriangle(constraints, dest, triangle, triangle_hits_bottom); hits_bottom |= triangle_hits_bottom; - } else { // normal rectangular tile + } else { // Normal rectangular tile. collision::Constraints new_constraints = check_collisions(movement, dest, tile_bbox, nullptr, nullptr); hits_bottom |= new_constraints.hit.bottom; constraints->merge_constraints(new_constraints); @@ -266,7 +266,7 @@ CollisionSystem::collision_tile_attributes(const Rectf& dest, const Vector& mov) uint32_t result = 0; for (auto& solids: m_sector.get_solid_tilemaps()) { - // test with all tiles in this rectangle + // Test with all tiles in this rectangle. const Rect test_tiles = solids->get_tiles_overlapping(Rectf(x1, y1, x2, y2)); // For ice (only), add a little fudge to recognize tiles Tux is standing on. @@ -293,7 +293,7 @@ CollisionSystem::collision_tile_attributes(const Rectf& dest, const Vector& mov) return result; } -/** fills in CollisionHit and Normal vector of 2 intersecting rectangle */ +/** Fills the CollisionHit and Normal vector between two intersecting rectangles. */ static void get_hit_normal(const Rectf& r1, const Rectf& r2, CollisionHit& hit, Vector& normal) { @@ -371,7 +371,7 @@ CollisionSystem::collision_static(collision::Constraints* constraints, { collision_tilemap(constraints, movement, dest, object); - // collision with other (static) objects + // Collision with other (static) objects. for (auto* static_object : m_objects) { if (( @@ -411,13 +411,13 @@ CollisionSystem::collision_static_constrains(CollisionObject& object) if (!constraints.has_constraints()) break; - // apply calculated horizontal constraints + // Apply calculated horizontal constraints. if (constraints.get_position_bottom() < infinity) { float height = constraints.get_height(); if (height < object.get_bbox().get_height()) { - // we're crushed, but ignore this for now, we'll get this again + // We're crushed, but ignore this for now, we'll get this again // later if we're really crushed or things will solve itself when - // looking at the vertical constraints + // looking at the vertical constraints. pressure.y += object.get_bbox().get_height() - height; } else { dest.set_bottom(constraints.get_position_bottom() - EPSILON); @@ -443,14 +443,14 @@ CollisionSystem::collision_static_constrains(CollisionObject& object) if (!constraints.has_constraints()) break; - // apply calculated vertical constraints + // Apply calculated vertical constraints. const float width = constraints.get_width(); if (width < infinity) { if (width + SHIFT_DELTA < object.get_bbox().get_width()) { - // we're crushed, but ignore this for now, we'll get this again + // We're crushed, but ignore this for now, we'll get this again // later if we're really crushed or things will solve itself when - // looking at the horizontal constraints + // looking at the horizontal constraints. pressure.x += object.get_bbox().get_width() - width; } else { float xmid = constraints.get_x_midpoint (); @@ -473,7 +473,7 @@ CollisionSystem::collision_static_constrains(CollisionObject& object) object.collision_solid(constraints.hit); } - // an extra pass to make sure we're not crushed vertically + // An extra pass to make sure we're not crushed vertically. if (pressure.y > 0) { constraints = Constraints(); collision_static(&constraints, movement, dest, object); @@ -490,7 +490,7 @@ CollisionSystem::collision_static_constrains(CollisionObject& object) } } - // an extra pass to make sure we're not crushed horizontally + // An extra pass to make sure we're not crushed horizontally. if (pressure.x > 0) { constraints = Constraints(); collision_static(&constraints, movement, dest, object); @@ -514,14 +514,14 @@ CollisionSystem::update() { if (Editor::is_active()) { return; - //Objects in editor shouldn't collide. + // Objects in editor shouldn't collide. } using namespace collision; m_ground_movement_manager->apply_all_ground_movement(); - // calculate destination positions of the objects + // Calculate destination positions of the objects. for (const auto& object : m_objects) { const Vector& mov = object->get_movement(); @@ -536,7 +536,7 @@ CollisionSystem::update() object->clear_bottom_collision_list(); } - // part1: COLGROUP_MOVING vs COLGROUP_STATIC and tilemap + // Part 1: COLGROUP_MOVING vs COLGROUP_STATIC and tilemap. for (const auto& object : m_objects) { if ((object->get_group() != COLGROUP_MOVING && object->get_group() != COLGROUP_MOVING_STATIC @@ -547,7 +547,7 @@ CollisionSystem::update() collision_static_constrains(*object); } - // part2: COLGROUP_MOVING vs tile attributes + // Part 2: COLGROUP_MOVING vs tile attributes. for (const auto& object : m_objects) { if ((object->get_group() != COLGROUP_MOVING && object->get_group() != COLGROUP_MOVING_STATIC @@ -561,7 +561,7 @@ CollisionSystem::update() } } - // part2.5: COLGROUP_MOVING vs COLGROUP_TOUCHABLE + // Part 2.5: COLGROUP_MOVING vs COLGROUP_TOUCHABLE. for (const auto& object : m_objects) { if ((object->get_group() != COLGROUP_MOVING @@ -590,7 +590,7 @@ CollisionSystem::update() } } - // part3: COLGROUP_MOVING vs COLGROUP_MOVING + // Part 3: COLGROUP_MOVING vs COLGROUP_MOVING. for (auto i = m_objects.begin(); i != m_objects.end(); ++i) { auto object = *i; @@ -611,7 +611,7 @@ CollisionSystem::update() } } - // apply object movement + // Apply object movement. for (auto* object : m_objects) { object->m_bbox = object->m_dest; object->m_movement = Vector(0, 0); @@ -624,7 +624,7 @@ CollisionSystem::is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid, using namespace collision; for (const auto& solids : m_sector.get_solid_tilemaps()) { - // test with all tiles in this rectangle + // Test with all tiles in this rectangle. const Rect test_tiles = solids->get_tiles_overlapping(rect); for (int x = test_tiles.left; x < test_tiles.right; ++x) { @@ -695,14 +695,14 @@ CollisionSystem::free_line_of_sight(const Vector& line_start, const Vector& line { using namespace collision; - // check if no tile is in the way + // Check if no tile is in the way. const float lsx = std::min(line_start.x, line_end.x); const float lex = std::max(line_start.x, line_end.x); const float lsy = std::min(line_start.y, line_end.y); const float ley = std::max(line_start.y, line_end.y); - for (float test_x = lsx; test_x <= lex; test_x += 16) { // NOLINT - for (float test_y = lsy; test_y <= ley; test_y += 16) { // NOLINT + for (float test_x = lsx; test_x <= lex; test_x += 16) { // NOLINT. + for (float test_y = lsy; test_y <= ley; test_y += 16) { // NOLINT. for (const auto& solids : m_sector.get_solid_tilemaps()) { const auto& test_vector = Vector(test_x, test_y); if(solids->is_outside_bounds(test_vector)) @@ -720,7 +720,7 @@ CollisionSystem::free_line_of_sight(const Vector& line_start, const Vector& line if (ignore_objects) return true; - // check if no object is in the way + // Check if no object is in the way. for (const auto& object : m_objects) { if (object == ignore_object) continue; if (!object->is_valid()) continue; diff --git a/src/control/controller.cpp b/src/control/controller.cpp index 2fd89844fcb..f96bbfc1524 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -99,7 +99,7 @@ Controller::set_control(Control control, bool value) void Controller::set_jump_key_with_up(bool value) { - // Do not release the jump key if the jump key is still pressed + // Do not release the jump key if the jump key is still pressed. if (!m_jump_key_pressed) { m_controls[static_cast(Control::JUMP)] = value; } diff --git a/src/control/game_controller_manager.cpp b/src/control/game_controller_manager.cpp index 79e4b4d1dcf..682ea18300e 100644 --- a/src/control/game_controller_manager.cpp +++ b/src/control/game_controller_manager.cpp @@ -144,8 +144,7 @@ GameControllerManager::process_axis_event(const SDL_ControllerAxisEvent& ev) player_id = it->second; } - // FIXME: buttons and axis are fighting for control ownership, need - // to OR the values together + // FIXME: Buttons and axis are fighting for control ownership, need jump slightly if we encounter a suitable totem. //log_info << "axis event: " << static_cast(ev.axis) << " " << ev.value << std::endl; Controller& controller = m_parent->get_controller(player_id); @@ -277,7 +276,7 @@ GameControllerManager::on_controller_removed(int instance_id) if (m_parent->m_use_game_controller && g_config->multiplayer_auto_manage_players && deleted_player_id != 0 && !m_parent->m_uses_keyboard[deleted_player_id]) { - // Sectors in worldmaps have no Player's of that class + // Sectors in worldmaps have no Player's of that class. if (Sector::current() && Sector::current()->get_object_count() > 0) { auto players = Sector::current()->get_objects_by_type(); @@ -310,8 +309,8 @@ GameControllerManager::on_player_removed(int player_id) if (it2 != m_game_controllers.end()) { it2->second = -1; - // Try again, in case multiple controllers were bount to a player - // Recursive call shouldn't go too deep except in hardcore scenarios + // Try again, in case multiple controllers were bount to a player. + // Recursive call shouldn't go too deep except in hardcore scenarios. on_player_removed(player_id); } } @@ -334,7 +333,7 @@ GameControllerManager::rumble(SDL_GameController* controller) const if (SDL_GameControllerHasRumble(controller)) { #endif - // TODO: Rumble intensity setting (like volume) + // TODO: Rumble intensity setting (like volume). SDL_GameControllerRumble(controller, 0xFFFF, 0xFFFF, 300); #if SDL_VERSION_ATLEAST(2, 0, 18) } diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index 9e3c4a746c9..bb51ca2258e 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -144,8 +144,8 @@ Editor::draw(Compositor& compositor) widget->draw(context); } - // Don't draw the sector if we're about to test - there's a dangling pointer - // with the PlayerStatus and I'm not experienced enough to fix it + // Avoid drawing the sector if we're about to test it, as there is a dangling pointer + // issue with the PlayerStatus. if (!m_leveltested) m_sector->draw(context); @@ -164,7 +164,7 @@ Editor::draw(Compositor& compositor) void Editor::update(float dt_sec, const Controller& controller) { - // Auto-save (interval) + // Auto-save (interval). if (m_level) { m_time_since_last_save += dt_sec; if (m_time_since_last_save >= static_cast(std::max( @@ -175,7 +175,7 @@ Editor::update(float dt_sec, const Controller& controller) // Set the test level file even though we're not testing, so that // if the user quits the editor without ever testing, it'll delete - // the autosave file anyways + // the autosave file anyways. m_autosave_levelfile = FileSystem::join(directory, backup_filename); try { @@ -190,7 +190,7 @@ Editor::update(float dt_sec, const Controller& controller) m_time_since_last_save = 0.f; } - // Pass all requests + // Pass all requests. if (m_reload_request) { reload_level(); } @@ -200,7 +200,7 @@ Editor::update(float dt_sec, const Controller& controller) } if (m_newlevel_request) { - //Create new level + // Create new level. } if (m_reactivate_request) { @@ -238,7 +238,7 @@ Editor::update(float dt_sec, const Controller& controller) return; } - // update other stuff + // Update other components. if (m_levelloaded && !m_leveltested) { BIND_SECTOR(*m_sector); @@ -261,7 +261,7 @@ Editor::update(float dt_sec, const Controller& controller) void Editor::remove_autosave_file() { - // Clear the auto-save file + // Clear the auto-save file. if (!m_autosave_levelfile.empty()) { // Try to remove the test level using the PhysFS file system @@ -457,7 +457,7 @@ Editor::set_sector(Sector* sector) m_sector = sector; m_sector->activate("main"); - { // initialize badguy sprites and other GameObject stuff + { // Initialize badguy sprites and perform other GameObject related tasks. BIND_SECTOR(*m_sector); for(auto& object : m_sector->get_objects()) { object->after_editor_set(); @@ -471,7 +471,7 @@ void Editor::delete_current_sector() { if (m_level->m_sectors.size() <= 1) { - log_fatal << "deleting the last sector is not allowed" << std::endl; + log_fatal << "Deleting the last sector is not allowed." << std::endl; } for (auto i = m_level->m_sectors.begin(); i != m_level->m_sectors.end(); ++i) { @@ -503,7 +503,7 @@ Editor::set_level(std::unique_ptr level, bool reset) m_toolbox_widget->set_input_type(EditorToolboxWidget::InputType::NONE); } - // Re/load level + // Reload level. m_level = nullptr; m_levelloaded = true; @@ -544,7 +544,7 @@ Editor::reload_level() undo_stack_cleanup(); // Autosave files : Once the level is loaded, make sure - // to use the regular file + // to use the regular file. m_levelfile = get_levelname_from_autosave(m_levelfile); m_autosave_levelfile = FileSystem::join(get_level_directory(), get_autosave_from_levelname(m_levelfile)); @@ -559,7 +559,7 @@ Editor::quit_editor() { remove_autosave_file(); - //Quit level editor + // Quit level editor. m_world = nullptr; m_levelfile = ""; m_levelloaded = false; @@ -569,7 +569,7 @@ Editor::quit_editor() #ifdef __EMSCRIPTEN__ int persistent = EM_ASM_INT({ return supertux2_ispersistent(); - }, 0); // EM_ASM_INT is a variadic macro and Clang requires at least 1 value for the variadic argument + }, 0); // EM_ASM_INT is a variadic macro and Clang requires at least 1 value for the variadic argument. if (!persistent) Dialog::show_message(_("Don't forget that your levels and assets\naren't saved between sessions!\nIf you want to keep your levels, download them\nfrom the \"Manage Assets\" menu.")); #endif @@ -676,7 +676,7 @@ Editor::setup() m_layers_widget->setup(); m_savegame = Savegame::from_file("levels/misc"); - // Reactivate the editor after level test + // Reactivate the editor after level test. if (m_leveltested) { m_leveltested = false; Tile::draw_editor_images = true; diff --git a/src/gui/dialog.cpp b/src/gui/dialog.cpp index 59d954206bd..f8940eb7b1b 100644 --- a/src/gui/dialog.cpp +++ b/src/gui/dialog.cpp @@ -112,7 +112,7 @@ Dialog::get_button_at(const Vector& mouse_pos) const void Dialog::event(const SDL_Event& ev) { - if (m_passive) // Passive dialogs don't accept events + if (m_passive) // Passive dialogs don't accept events. return; switch (ev.type) { @@ -155,7 +155,7 @@ Dialog::event(const SDL_Event& ev) void Dialog::process_input(const Controller& controller) { - if (m_passive) // Passive dialogs don't accept events + if (m_passive) // Passive dialogs don't accept events. return; if (controller.pressed(Control::LEFT)) @@ -196,7 +196,7 @@ Dialog::draw(DrawingContext& context) (static_cast(context.get_height()) / 2.0f - m_text_size.height / 2.0f))), m_size); - // draw background rect + // Draw background rect. context.color().draw_filled_rect(bg_rect.grown(12.0f), Color(g_config->menubackcolor.red, g_config->menubackcolor.green, g_config->menubackcolor.blue, (std::max(0.f, g_config->menubackcolor.alpha - (m_passive ? 0.5f : 0.0f)))), @@ -209,7 +209,7 @@ Dialog::draw(DrawingContext& context) g_config->menuroundness, LAYER_GUI-10); - // draw text + // Draw text. context.color().draw_text(Resources::normal_font, m_text, Vector(bg_rect.get_left() + bg_rect.get_width()/2.0f, bg_rect.get_top()), @@ -217,7 +217,7 @@ Dialog::draw(DrawingContext& context) if (m_passive) return; - // draw HL line + // Draw horizontal line. context.color().draw_filled_rect(Rectf(Vector(bg_rect.get_left(), bg_rect.get_bottom() - 35), Sizef(bg_rect.get_width(), 4)), g_config->hlcolor, LAYER_GUI); @@ -225,7 +225,7 @@ Dialog::draw(DrawingContext& context) Sizef(bg_rect.get_width(), 2)), Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI); - // draw buttons + // Draw buttons. for (int i = 0; i < static_cast(m_buttons.size()); ++i) { float segment_width = bg_rect.get_width() / static_cast(m_buttons.size()); diff --git a/src/interface/control.cpp b/src/interface/control.cpp index 2437d57447f..6207c9b21e9 100644 --- a/src/interface/control.cpp +++ b/src/interface/control.cpp @@ -25,3 +25,4 @@ InterfaceControl::InterfaceControl() : { } +/* EOF */ diff --git a/src/interface/control_button.cpp b/src/interface/control_button.cpp index 0eec9149b5c..f6e28d0fae2 100644 --- a/src/interface/control_button.cpp +++ b/src/interface/control_button.cpp @@ -113,3 +113,4 @@ ControlButton::on_key_down(const SDL_KeyboardEvent& key) return false; } +/* EOF */ diff --git a/src/interface/control_checkbox.cpp b/src/interface/control_checkbox.cpp index ff267cbecf5..ee3a2a3799e 100644 --- a/src/interface/control_checkbox.cpp +++ b/src/interface/control_checkbox.cpp @@ -90,3 +90,4 @@ ControlCheckbox::on_key_up(const SDL_KeyboardEvent& key) return true; } +/* EOF */ diff --git a/src/interface/control_enum.cpp b/src/interface/control_enum.cpp index 0f7cb9f0c56..a6c41f9a7dd 100644 --- a/src/interface/control_enum.cpp +++ b/src/interface/control_enum.cpp @@ -21,3 +21,4 @@ // https://stackoverflow.com/questions/56041900 +/* EOF */ diff --git a/src/interface/control_textbox.cpp b/src/interface/control_textbox.cpp index 194093f75bf..4a5a0a02546 100644 --- a/src/interface/control_textbox.cpp +++ b/src/interface/control_textbox.cpp @@ -27,7 +27,7 @@ #include "video/video_system.hpp" #include "video/viewport.hpp" -// The time for the caret to change visibility (when it flashes) +// The time for the caret to change visibility (when it flashes). static const float CONTROL_CURSOR_TIMER = 0.5f; ControlTextbox::ControlTextbox() : @@ -53,7 +53,7 @@ ControlTextbox::update(float dt_sec) m_cursor_timer = CONTROL_CURSOR_TIMER; } - // Apparently the stuff bugs from time to time + // Apparently the stuff bugs from time to time. recenter_offset(); } diff --git a/src/interface/control_textbox_float.cpp b/src/interface/control_textbox_float.cpp index e3b8fb78209..a331a4b678b 100644 --- a/src/interface/control_textbox_float.cpp +++ b/src/interface/control_textbox_float.cpp @@ -67,7 +67,7 @@ ControlTextboxFloat::parse_value(bool call_on_change /* = true (see header */) if (*m_value != temp) { *m_value = temp; - // Do it anyways + // Revert the value regardless. revert_value(); if (call_on_change && m_on_change) @@ -89,7 +89,7 @@ ControlTextboxFloat::revert_value() while (m_internal_string_backup.at(m_internal_string_backup.size() - 1) == '0') m_internal_string_backup.pop_back(); - // ...but keep at least one number after the point + // ...but keep at least one number after the point. if (m_internal_string_backup.at(m_internal_string_backup.size() - 1) == '.') m_internal_string_backup += "0"; diff --git a/src/interface/control_textbox_int.cpp b/src/interface/control_textbox_int.cpp index 6f3acdb4b48..bd4aa907b51 100644 --- a/src/interface/control_textbox_int.cpp +++ b/src/interface/control_textbox_int.cpp @@ -67,7 +67,7 @@ ControlTextboxInt::parse_value(bool call_on_change /* = true (see header */) if (*m_value != temp) { *m_value = temp; - // Do it anyways + // Revert the value regardless. revert_value(); if (call_on_change && m_on_change) diff --git a/src/math/aatriangle.cpp b/src/math/aatriangle.cpp index 687c31a2a23..76a50513927 100644 --- a/src/math/aatriangle.cpp +++ b/src/math/aatriangle.cpp @@ -31,7 +31,7 @@ int AATriangle::vertical_flip(int dir) { deform = AATriangle::DEFORM_BOTTOM; break; default: - // unchanged + // Unchanged. break; } return (direction | deform); diff --git a/src/math/anchor_point.cpp b/src/math/anchor_point.cpp index ac33803e101..8430cc7dfb5 100644 --- a/src/math/anchor_point.cpp +++ b/src/math/anchor_point.cpp @@ -27,8 +27,8 @@ std::vector get_anchor_names() { - // Must be dynamic because language can change at runtime (+ tinygettext must - // be init'ed) + // The language setting must be dynamic because it can change at runtime, + // and it requires initialization of the TinyGetText library (tinygettext). return { _("Top Left"), _("Top"), @@ -70,13 +70,13 @@ Vector get_anchor_pos(const Rectf& rect, AnchorPoint point) Vector result(0.0f, 0.0f); switch (point % 3) { - case 0: // left + case 0: // Left. result.x = rect.get_left(); break; - case 1: // middle + case 1: // Middle. result.x = rect.get_left() + (rect.get_right() - rect.get_left()) / 2.0f; break; - case 2: // right + case 2: // Right. result.x = rect.get_right(); break; default: @@ -86,13 +86,13 @@ Vector get_anchor_pos(const Rectf& rect, AnchorPoint point) } switch (point / 3) { - case 0: // top + case 0: // Top. result.y = rect.get_top(); break; - case 1: // middle + case 1: // Middle. result.y = rect.get_top() + (rect.get_bottom() - rect.get_top()) / 2.0f; break; - case 2: // bottom + case 2: // Bottom. result.y = rect.get_bottom(); break; default: @@ -110,13 +110,13 @@ Vector get_anchor_pos(const Rectf& destrect, float width, float height, Vector result(0.0f, 0.0f); switch (point % 3) { - case 0: // left + case 0: // Left. result.x = destrect.get_left(); break; - case 1: // middle + case 1: // Middle. result.x = destrect.get_middle().x - width / 2.0f; break; - case 2: // right + case 2: // Right. result.x = destrect.get_right() - width; break; default: @@ -126,13 +126,13 @@ Vector get_anchor_pos(const Rectf& destrect, float width, float height, } switch (point / 3) { - case 0: // top + case 0: // Top. result.y = destrect.get_top(); break; - case 1: // middle + case 1: // Middle. result.y = destrect.get_middle().y - height / 2.0f; break; - case 2: // bottom + case 2: // Bottom. result.y = destrect.get_bottom() - height; break; default: diff --git a/src/math/bezier.cpp b/src/math/bezier.cpp index ceff5d26b2d..68a427ca766 100644 --- a/src/math/bezier.cpp +++ b/src/math/bezier.cpp @@ -23,7 +23,7 @@ Vector Bezier::get_point(const Vector& p1, const Vector& p2, const Vector& p3, const Vector& p4, float t) { - // SPECIAL CASE + // SPECIAL CASE: // If Beziers aren't used, treat it linearly. That is because Beziers will // automatically add some "easing"-like effect when unused, which might be // undesired. @@ -85,7 +85,7 @@ Bezier::get_point_at_length(const Vector& p1, const Vector& p2, const Vector& p3 // The length might be equal to something like 4.86e-05 if the original length // was equal or close to the total length, due to float's limited precision. - // We'll consider it a problem if the difference is greater than 0.001 + // We'll consider it a problem if the difference is greater than 0.001. if (length > 0.001f) log_warning << "Attempt to get point on Bezier curve further than the end: " << length << std::endl; @@ -104,7 +104,7 @@ Bezier::draw_curve(DrawingContext& context, const Vector& p1, const Vector& p2, const Vector& p3, const Vector& p4, int steps, Color color, int layer) { - // Save ourselves some processing time in common special cases + // Save ourselves some processing time in common special cases. if (p1 == p2 && p3 == p4) { context.color().draw_line(p1, p4, color, layer); diff --git a/src/math/easing.cpp b/src/math/easing.cpp index 161db6b03ce..1781a3ad1a4 100644 --- a/src/math/easing.cpp +++ b/src/math/easing.cpp @@ -24,25 +24,25 @@ #include #include -// Modeled after the line y = x +// Modeled after the line y = x. double LinearInterpolation(double p) { return p; } -// Modeled after the parabola y = x^2 +// Modeled after the parabola y = x^2. double QuadraticEaseIn(double p) { return p * p; } -// Modeled after the parabola y = -x^2 + 2x +// Modeled after the parabola y = -x^2 + 2x. double QuadraticEaseOut(double p) { return -(p * (p - 2)); } -// Modeled after the piecewise quadratic +// Modeled after the piecewise quadratic: // y = (1/2)((2x)^2) ; [0, 0.5) // y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1] double QuadraticEaseInOut(double p) @@ -57,20 +57,20 @@ double QuadraticEaseInOut(double p) } } -// Modeled after the cubic y = x^3 +// Modeled after the cubic y = x^3. double CubicEaseIn(double p) { return p * p * p; } -// Modeled after the cubic y = (x - 1)^3 + 1 +// Modeled after the cubic y = (x - 1)^3 + 1. double CubicEaseOut(double p) { double f = (p - 1); return f * f * f + 1; } -// Modeled after the piecewise cubic +// Modeled after the piecewise cubic: // y = (1/2)((2x)^3) ; [0, 0.5) // y = (1/2)((2x-2)^3 + 2) ; [0.5, 1] double CubicEaseInOut(double p) @@ -86,20 +86,20 @@ double CubicEaseInOut(double p) } } -// Modeled after the quartic x^4 +// Modeled after the quartic x^4. double QuarticEaseIn(double p) { return p * p * p * p; } -// Modeled after the quartic y = 1 - (x - 1)^4 +// Modeled after the quartic y = 1 - (x - 1)^4. double QuarticEaseOut(double p) { double f = (p - 1); return f * f * f * (1 - p) + 1; } -// Modeled after the piecewise quartic +// Modeled after the piecewise quartic. // y = (1/2)((2x)^4) ; [0, 0.5) // y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1] double QuarticEaseInOut(double p) @@ -115,20 +115,20 @@ double QuarticEaseInOut(double p) } } -// Modeled after the quintic y = x^5 +// Modeled after the quintic y = x^5. double QuinticEaseIn(double p) { return p * p * p * p * p; } -// Modeled after the quintic y = (x - 1)^5 + 1 +// Modeled after the quintic y = (x - 1)^5 + 1. double QuinticEaseOut(double p) { double f = (p - 1); return f * f * f * f * f + 1; } -// Modeled after the piecewise quintic +// Modeled after the piecewise quintic: // y = (1/2)((2x)^5) ; [0, 0.5) // y = (1/2)((2x-2)^5 + 2) ; [0.5, 1] double QuinticEaseInOut(double p) @@ -144,37 +144,37 @@ double QuinticEaseInOut(double p) } } -// Modeled after quarter-cycle of sine wave +// Modeled after quarter-cycle of sine wave. double SineEaseIn(double p) { return sin((p - 1) * M_PI_2) + 1; } -// Modeled after quarter-cycle of sine wave (different phase) +// Modeled after quarter-cycle of sine wave (different phase). double SineEaseOut(double p) { return sin(p * M_PI_2); } -// Modeled after half sine wave +// Modeled after half sine wave. double SineEaseInOut(double p) { return 0.5 * (1 - cos(p * M_PI)); } -// Modeled after shifted quadrant IV of unit circle +// Modeled after shifted quadrant IV of unit circle. double CircularEaseIn(double p) { return 1 - sqrt(1 - (p * p)); } -// Modeled after shifted quadrant II of unit circle +// Modeled after shifted quadrant II of unit circle. double CircularEaseOut(double p) { return sqrt((2 - p) * p); } -// Modeled after the piecewise circular function +// Modeled after the piecewise circular function: // y = (1/2)(1 - sqrt(1 - 4x^2)) ; [0, 0.5) // y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1] double CircularEaseInOut(double p) @@ -189,19 +189,19 @@ double CircularEaseInOut(double p) } } -// Modeled after the exponential function y = 2^(10(x - 1)) +// Modeled after the exponential function y = 2^(10(x - 1)). double ExponentialEaseIn(double p) { return (p == 0.0) ? p : pow(2, 10 * (p - 1)); } -// Modeled after the exponential function y = -2^(-10x) + 1 +// Modeled after the exponential function y = -2^(-10x) + 1. double ExponentialEaseOut(double p) { return (p == 1.0) ? p : 1 - pow(2, -10 * p); } -// Modeled after the piecewise exponential +// Modeled after the piecewise exponential: // y = (1/2)2^(10(2x - 1)) ; [0,0.5) // y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1] double ExponentialEaseInOut(double p) @@ -218,13 +218,13 @@ double ExponentialEaseInOut(double p) } } -// Modeled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1)) +// Modeled after the damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1)). double ElasticEaseIn(double p) { return sin(13 * M_PI_2 * p) * pow(2, 10 * (p - 1)); } -// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1 +// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1. double ElasticEaseOut(double p) { return sin(-13 * M_PI_2 * (p + 1)) * pow(2, -10 * p) + 1; @@ -245,13 +245,13 @@ double ElasticEaseInOut(double p) } } -// Modeled after the overshooting cubic y = x^3-x*sin(x*pi) +// Modeled after the overshooting cubic y = x^3-x*sin(x*pi). double BackEaseIn(double p) { return p * p * p - p * sin(p * M_PI); } -// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi)) +// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi)). double BackEaseOut(double p) { double f = (1 - p); @@ -382,7 +382,6 @@ easing getEasingByName(const EasingMode& ease_type) } } - EasingMode EasingMode_from_string(const std::string& ease_name) { const char* name = ease_name.c_str(); @@ -616,7 +615,7 @@ std::string get_reverse_easing_str(const std::string& ease_name) return e + "In"; } - throw std::runtime_error("Trying to find opposite easing of non-easing string"); + throw std::runtime_error("Trying to find opposite easing of non-easing string."); } /* EOF */ diff --git a/src/object/ambient_light.cpp b/src/object/ambient_light.cpp index 19f15d73f99..04040f74c46 100644 --- a/src/object/ambient_light.cpp +++ b/src/object/ambient_light.cpp @@ -47,7 +47,7 @@ AmbientLight::AmbientLight(const ReaderMapping& mapping) : if (mapping.get("color", color_vec)) { if (color_vec.size() < 3) { - log_warning << "ambient-light requires three float arguments" << std::endl; + log_warning << "'ambient-light' requires three float arguments" << std::endl; } else { m_ambient_light = Color(color_vec); } diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index 863980891a3..dc40c9533e3 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -53,14 +53,14 @@ AmbientSound::AmbientSound(const ReaderMapping& mapping) : mapping.get("sample" ,sample , ""); mapping.get("volume" ,maximumvolume , 1.0f); - // square all distances (saves us a sqrt later) + // Square all distances (saves us a sqrt later). if (!Editor::is_active()) { distance_bias*=distance_bias; distance_factor*=distance_factor; } - // set default silence_distance + // Set default silence_distance. if (distance_factor == 0) silence_distance = std::numeric_limits::max(); @@ -70,7 +70,7 @@ AmbientSound::AmbientSound(const ReaderMapping& mapping) : mapping.get("silence_distance",silence_distance); if (!Editor::is_active()) { - sound_source.reset(); // not playing at the beginning + sound_source.reset(); // Resetting the sound source to stop playing at the beginning. SoundManager::current()->preload(sample); } latency=0; @@ -93,7 +93,7 @@ AmbientSound::AmbientSound(const Vector& pos, float factor, float bias, float vo m_col.m_bbox.set_pos(pos); m_col.m_bbox.set_size(32, 32); - // set default silence_distance + // Set default silence_distance. if (distance_factor == 0) silence_distance = std::numeric_limits::max(); @@ -101,7 +101,7 @@ AmbientSound::AmbientSound(const Vector& pos, float factor, float bias, float vo silence_distance = 1/distance_factor; if (!Editor::is_active()) { - sound_source.reset(); // not playing at the beginning + sound_source.reset(); // Resetting the sound source to stop playing at the beginning. SoundManager::current()->preload(sample); } } @@ -166,35 +166,35 @@ AmbientSound::update(float dt_sec) float px,py; float rx,ry; - // Camera position + // Get the central position of the camera. px=Sector::get().get_camera().get_center().x; py=Sector::get().get_camera().get_center().y; - // Relate to which point in the area + // Determine the nearest point within the area bounds. rx=pxset_gain(currentvolume*maximumvolume); if (sqrdistance>=silence_distance && currentvolume < 1e-3f) @@ -205,16 +205,16 @@ AmbientSound::update(float dt_sec) start_playing(); latency=0; } - else // set a reasonable latency + else // Set a reasonable latency. latency = static_cast(0.001f / distance_factor); //(int)(10*((sqrdistance-silence_distance)/silence_distance)); } } - // heuristically measured "good" latency maximum + // Heuristically measured "good" maximum latency. - // if (latency>0.001/distance_factor) - // latency= + // if (latency > 0.001 / distance_factor) + // latency = } #ifndef SCRIPTING_API diff --git a/src/object/background.cpp b/src/object/background.cpp index 7692f109ce2..e72bdeba14f 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -114,7 +114,7 @@ Background::Background(const ReaderMapping& reader) : reader.get("scroll-offset-x", m_scroll_offset.x, 0.0f); reader.get("scroll-offset-y", m_scroll_offset.y, 0.0f); - // for backwards compatibility, add position to scroll offset + // For backward compatibility, add position to scroll offset. float px; float py; if (reader.get("x", px)) @@ -132,7 +132,7 @@ Background::Background(const ReaderMapping& reader) : if(!reader.get("speed-x", m_parallax_speed.x)) { - // for backward compatibilty + // For backward compatibility. reader.get("speed", m_parallax_speed.x, 0.5f); } @@ -225,7 +225,7 @@ Background::update(float dt_sec) if (m_timer_color.check()) { m_color = m_dst_color; - m_timer_color.stop(); // to reset the "check()" value + m_timer_color.stop(); // To reset the "check()" value. } else if (m_timer_color.started()) { @@ -466,10 +466,10 @@ Background::load_background(const std::string& image_path) return nullptr; if (PHYSFS_exists(image_path.c_str())) - // No need to search fallback paths + // No need to search fallback paths. return Surface::from_file(image_path); - // Search for a fallback image in fallback_paths + // Search for a fallback image in fallback_paths. const std::string& default_dir = "images/background/"; const std::string& default_dir2 = "/images/background/"; std::string new_path = image_path; @@ -479,7 +479,7 @@ Background::load_background(const std::string& image_path) new_path.erase(0, default_dir2.length()); auto it = fallback_paths.find(new_path); if (it == fallback_paths.end()) - // Unknown image, let the texture manager select the dummy texture + // Unknown image, let the texture manager select the dummy texture. return Surface::from_file(image_path); new_path = default_dir + it->second; @@ -500,5 +500,4 @@ Background::on_flip(float height) FlipLevelTransformer::transform_flip(m_flip); } - /* EOF */ diff --git a/src/object/bicycle_platform.cpp b/src/object/bicycle_platform.cpp index 75ddb4dd531..553532ac0b2 100644 --- a/src/object/bicycle_platform.cpp +++ b/src/object/bicycle_platform.cpp @@ -54,7 +54,7 @@ BicyclePlatformChild::collision(GameObject& other, const CollisionHit& ) { const float gravity = Sector::get().get_gravity(); - // somehow the hit parameter does not get filled in, so to determine (hit.top == true) we do this: + // Somehow the hit parameter does not get filled in, so to determine (hit.top == true) we do this: auto mo = dynamic_cast(&other); if (!mo) return FORCE_MOVE; if ((mo->get_bbox().get_bottom()) > (m_col.m_bbox.get_top() + 2)) return FORCE_MOVE; @@ -78,7 +78,7 @@ BicyclePlatformChild::collision(GameObject& other, const CollisionHit& ) void BicyclePlatformChild::editor_delete() { - // removing a child removes the whole platform + // Removing a child removes the whole platform. m_parent.editor_delete(); } @@ -179,13 +179,13 @@ BicyclePlatform::on_flip(float height) void BicyclePlatform::editor_delete() { - // remove children + // Remove children. for (auto& child : m_children) { child->remove_me(); } - // remove self + // Remove self. remove_me(); } diff --git a/src/object/block.cpp b/src/object/block.cpp index cff5261efe8..b43cbd3a242 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -92,10 +92,10 @@ Block::collision(GameObject& other, const CollisionHit& ) } } - // only interact with other objects if... + // Only interact with other objects if: // 1) we are bouncing // 2) the object is not portable (either never or not currently) - // 3) the object is being hit from below (baguys don't get killed for activating boxes) + // 3) the object is being hit from below (baguys don't get killed for activating boxes). auto badguy = dynamic_cast (&other); auto portable = dynamic_cast (&other); auto moving_object = dynamic_cast (&other); @@ -105,18 +105,18 @@ Block::collision(GameObject& other, const CollisionHit& ) bool hit_mo_from_below = ((moving_object == nullptr) || (moving_object->get_bbox().get_bottom() < (m_col.m_bbox.get_top() + SHIFT_DELTA))); if (m_bouncing && (!is_portable || badguy || is_bomb) && hit_mo_from_below) { - // Badguys get killed + // Badguys get killed. if (badguy) { badguy->kill_fall(); } - // Coins get collected + // Coins get collected. auto coin = dynamic_cast (&other); if (coin) { coin->collect(); } - //Eggs get jumped + // Eggs get jumped. auto growup = dynamic_cast (&other); if (growup) { growup->do_jump(); diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 3ca508c22b3..8deee2738da 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -90,7 +90,7 @@ BonusBlock::BonusBlock(const ReaderMapping& mapping) : while (iter.next()) { const std::string& token = iter.get_key(); if (token == "x" || token == "y" || token == "sprite") { - // already initialized in Block::Block + // Already initialized in Block::Block. } else if (token == "count") { iter.get(m_hit_counter); } else if (token == "script") { @@ -137,12 +137,12 @@ BonusBlock::BonusBlock(const ReaderMapping& mapping) : } else if (token == "coin-sprite") { iter.get(m_coin_sprite); } else if (token == "custom-contents") { - // handled elsewhere + // Handled elsewhere. } else { if (m_contents == Content::CUSTOM && !m_object) { // FIXME: This an ugly mess, could probably be removed as of // 16. Aug 2018 no level in either the supertux or the - // addon-src repository is using this anymore + // addon-src repository is using this anymore. ReaderMapping object_mapping = iter.as_mapping(); auto game_object = GameObjectFactory::instance().create(token, object_mapping); @@ -175,7 +175,7 @@ BonusBlock::Content BonusBlock::get_content_by_data(int tile_data) const { // Warning: 'tile_data' can't be cast to 'Content', this manual - // conversion is necessary + // conversion is necessary. switch (tile_data) { case 1: return Content::COIN; case 2: return Content::FIREGROW; @@ -184,11 +184,11 @@ BonusBlock::get_content_by_data(int tile_data) const case 5: return Content::ICEGROW; case 6: return Content::LIGHT; case 7: return Content::TRAMPOLINE; - case 8: return Content::PORTABLE_TRAMPOLINE; // Trampoline - case 9: return Content::ROCK; // Rock + case 8: return Content::PORTABLE_TRAMPOLINE; // Trampoline. + case 9: return Content::ROCK; // Rock. case 10: return Content::RAIN; case 11: return Content::EXPLODE; - case 12: return Content::POTION; // Red potion + case 12: return Content::POTION; // Red potion. case 13: return Content::AIRGROW; case 14: return Content::EARTHGROW; case 15: return Content::LIGHT_ON; @@ -245,7 +245,7 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit_) auto badguy = dynamic_cast (&other); if (badguy) { - // hit contains no information for collisions with blocks. + // Hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the block // SHIFT_DELTA is required to slide over one tile gaps. if ( badguy->can_break() && ( badguy->get_bbox().get_bottom() > m_col.m_bbox.get_top() + SHIFT_DELTA ) ) { @@ -342,7 +342,7 @@ BonusBlock::try_open(Player* player) } case Content::SCRIPT: - { break; } // because scripts always run, this prevents default contents from being assumed + { break; } // This prevents default contents from being assumed because scripts always run. case Content::LIGHT: case Content::LIGHT_ON: @@ -393,12 +393,12 @@ BonusBlock::try_open(Player* player) if (play_upgrade_sound) SoundManager::current()->play("sounds/upgrade.wav", get_pos(), upgrade_sound_gain); - if (!m_script.empty()) { // scripts always run if defined + if (!m_script.empty()) { // Scripts always run if defined. Sector::get().run_script(m_script, "BonusBlockScript"); } start_bounce(player); - if (m_hit_counter <= 0 || m_contents == Content::LIGHT || m_contents == Content::LIGHT_ON) { //use 0 to allow infinite hits + if (m_hit_counter <= 0 || m_contents == Content::LIGHT || m_contents == Content::LIGHT_ON) { // Use 0 to allow infinite hits. } else if (m_hit_counter == 1) { set_action("empty"); } else { @@ -413,7 +413,7 @@ BonusBlock::try_drop(Player *player) if (m_sprite->get_action() == "empty") return; - // First what's below the bonus block, if solid send it up anyway (excepting doll) + // Determine the area below the bonus block. If it's solid, send it up regardless (except for dolls). Rectf dest_; dest_.set_left(m_col.m_bbox.get_left() + 1); dest_.set_top(m_col.m_bbox.get_bottom() + 1); @@ -486,7 +486,7 @@ BonusBlock::try_drop(Player *player) case Content::CUSTOM: { - //NOTE: non-portable trampolines could be moved to Content::CUSTOM, but they should not drop + // NOTE: Non-portable trampolines could be moved to Content::CUSTOM, but they should not drop. m_object->set_pos(get_pos() + Vector(0, 32)); Sector::get().add_object(std::move(m_object)); play_upgrade_sound = true; @@ -498,7 +498,7 @@ BonusBlock::try_drop(Player *player) { countdown = true; break; - } // because scripts always run, this prevents default contents from being assumed + } // This prevents default contents from being assumed because scripts always run. case Content::LIGHT: case Content::LIGHT_ON: @@ -538,11 +538,11 @@ BonusBlock::try_drop(Player *player) if (play_upgrade_sound) SoundManager::current()->play("sounds/upgrade.wav", get_pos(), upgrade_sound_gain); - if (!m_script.empty()) { // scripts always run if defined + if (!m_script.empty()) { // Scripts always run if defined. Sector::get().run_script(m_script, "powerup-script"); } - if (countdown) { // only decrease hit counter if try_open was not called + if (countdown) { // Only decrease the hit counter if try_open was not called. if (m_hit_counter == 1) { set_action("empty"); } else { @@ -586,9 +586,9 @@ BonusBlock::drop_growup_bonus(Player* player, const std::string& bonus_sprite_na void BonusBlock::draw(DrawingContext& context) { - // do the regular drawing first + // Perform the regular drawing first. Block::draw(context); - // then Draw the light if on. + // Draw the light if the bonus block is in the "on" state. if (m_sprite->get_action() == "on") { Vector pos = get_pos() + (m_col.m_bbox.get_size().as_vector() - Vector(static_cast(m_lightsprite->get_width()), static_cast(m_lightsprite->get_height()))) / 2.0f; @@ -615,7 +615,7 @@ BonusBlock::get_content_from_string(const std::string& contentstring) const return Content::ONEUP; } else if (contentstring == "custom") { return Content::CUSTOM; - } else if (contentstring == "script") { // use when bonusblock is to contain ONLY a script + } else if (contentstring == "script") { // Use this when the bonus block is intended to contain ONLY a script. return Content::SCRIPT; } else if (contentstring == "light") { return Content::LIGHT; @@ -670,25 +670,26 @@ BonusBlock::preload_contents(int d) { switch (d) { - case 6: // Light - case 15: // Light (On) + case 6: // Light. + case 15: // Light (On). SoundManager::current()->preload("sounds/switch.ogg"); m_lightsprite=Surface::from_file("/images/objects/lightmap_light/bonusblock_light.png"); break; case 7: - //object = new Trampoline(get_pos(), false); //needed if this is to be moved to custom + // Uncomment the following line if this is to be moved to the "custom" case. + // object = new Trampoline(get_pos(), false); break; - case 8: // Trampoline + case 8: // Trampoline. m_object = std::make_unique(get_pos(), true); break; - case 9: // Rock + case 9: // Rock. m_object = std::make_unique(get_pos(), "images/objects/rock/rock.sprite"); break; - case 12: // Red potion + case 12: // Red potion. m_object = std::make_unique(get_pos(), "images/powerups/potions/red-potion.sprite"); break; diff --git a/src/object/bouncy_coin.cpp b/src/object/bouncy_coin.cpp index c2cc371fbbd..ab665f9b944 100644 --- a/src/object/bouncy_coin.cpp +++ b/src/object/bouncy_coin.cpp @@ -19,9 +19,9 @@ #include "sprite/sprite.hpp" #include "sprite/sprite_manager.hpp" -/** this controls the time over which a bouncy coin fades */ +/** Controls the duration over which a bouncy coin fades. */ static const float FADE_TIME = .2f; -/** this is the total life time of a bouncy coin */ +/** Represents the total lifetime of a bouncy coin. */ static const float LIFE_TIME = .5f; BouncyCoin::BouncyCoin(const Vector& pos, bool emerge, const std::string& sprite_path) : diff --git a/src/object/brick.cpp b/src/object/brick.cpp index fc9b3829968..8980f67c379 100644 --- a/src/object/brick.cpp +++ b/src/object/brick.cpp @@ -68,7 +68,7 @@ Brick::collision(GameObject& other, const CollisionHit& hit) auto badguy = dynamic_cast (&other); if (badguy) { - // hit contains no information for collisions with blocks. + // Hit contains no information for collisions with blocks. // Badguy's bottom has to be below the top of the brick // SHIFT_DELTA is required to slide over one tile gaps. if ( badguy->can_break() && ( badguy->get_bbox().get_bottom() > m_col.m_bbox.get_top() + SHIFT_DELTA ) ) { @@ -101,7 +101,7 @@ Brick::try_break(Player* player, bool slider) if (m_sprite->get_action() == "empty") return; - //takes too long for sliding tux to barrel through crates and ends up stopping him otherwise + // Takes too long for sliding tux to barrel through crates and ends up stopping him otherwise. if (slider && m_breakable && m_coin_counter <= 0) break_me(); diff --git a/src/object/bullet.cpp b/src/object/bullet.cpp index e000bd45f69..c9af24a1c99 100644 --- a/src/object/bullet.cpp +++ b/src/object/bullet.cpp @@ -60,7 +60,7 @@ Bullet::Bullet(const Vector& pos, const Vector& xm, Direction dir, BonusType typ void Bullet::update(float dt_sec) { - // cause fireball color to flicker randomly + // Cause fireball color to flicker randomly. if (graphicsRandom.rand(5) != 0) { lightsprite->set_color(Color(0.3f + graphicsRandom.randf(10) / 100.0f, 0.1f + graphicsRandom.randf(20.0f) / 100.0f, diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 41bd69be4fc..036c741b24f 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -30,9 +30,9 @@ #include "video/video_system.hpp" #include "video/viewport.hpp" -/* this is the fractional distance toward the peek +/* This is the fractional distance toward the peek position to move each frame; lower is slower, - 0 is never get there, 1 is instant */ + 0 is never get there, 1 is instant. */ static const float PEEK_ARRIVE_RATIO = 0.03f; /** @@ -40,39 +40,39 @@ static const float PEEK_ARRIVE_RATIO = 0.03f; * These variables allow establishing a minimum zone around them that will also * be always visible. */ -static const float HORIZONTAL_MARGIN = 196.f; // 6 tiles -static const float VERTICAL_MARGIN = 196.f; // 6 tiles -static const float PEEK_ADD_HORIZONTAL_MARGIN = 320.f; // 10 tiles -static const float PEEK_ADD_VERTICAL_MARGIN = 320.f; // 10 tiles +static const float HORIZONTAL_MARGIN = 196.f; // 6 tiles. +static const float VERTICAL_MARGIN = 196.f; // 6 tiles. +static const float PEEK_ADD_HORIZONTAL_MARGIN = 320.f; // 10 tiles. +static const float PEEK_ADD_VERTICAL_MARGIN = 320.f; // 10 tiles. -/* 0 = no movement, 1 = no smooth adaptation */ +/* 0 = no movement, 1 = no smooth adaptation. */ static const float MULTIPLAYER_CAM_WEIGHT = 0.1f; class CameraConfig final { public: - // 0 = No, 1 = Fix, 2 = Mario/Yoshi, 3 = Kirby, 4 = Super Metroid-like + // 0 = No, 1 = Fix, 2 = Mario/Yoshi, 3 = Kirby, 4 = Super Metroid-like. int xmode; - // as above + // As above. int ymode; float kirby_rectsize_x; float kirby_rectsize_y; - // where to fix the player (used for Yoshi and Fix camera) + // Where to fix the player (used for Yoshi and Fix camera). float target_x; float target_y; - // maximum scrolling speed in Y direction + // Maximum scrolling speed in Y direction. float max_speed_x; float max_speed_y; - // factor to dynamically increase max_speed_x based on player speed + // Factor to dynamically increase max_speed_x based on player speed. float dynamic_max_speed_x; - // time the player has to face into the other direction before we assume a - // changed direction + // Time the player has to face into the other direction before we assume a + // changed direction. float dirchange_time; - // edge_x + // edge_x. float edge_x; - // when too change from noscroll mode back to lookahead left/right mode - // set to <= 0 to disable noscroll mode + // When too change from noscroll mode back to lookahead left/right mode + // set to <= 0 to disable noscroll mode. float sensitive_x; float clamp_x; @@ -335,7 +335,7 @@ Camera::draw(DrawingContext& context) void Camera::update(float dt_sec) { - // Minimum scale should be set during the update sequence; else, reset it + // Minimum scale should be set during the update sequence; else, reset it. m_enfore_minimum_scale = false; switch (m_mode) { @@ -383,7 +383,7 @@ Camera::keep_in_bounds(Vector& translation_) float width = d_sector->get_width(); float height = d_sector->get_height(); - // don't scroll before the start or after the level's end + // Don't scroll before the start or after the level's end. translation_.x = math::clamp(translation_.x, 0.0f, width - static_cast(m_screen_size.width)); translation_.y = math::clamp(translation_.y, 0.0f, height - static_cast(m_screen_size.height)); @@ -398,12 +398,12 @@ Camera::shake() { if (m_shaketimer.started()) { - // old method + // Old method: // m_translation.x -= sinf(m_shaketimer.get_timegone() * m_shakespeed) * m_shakedepth_x; // m_translation.y -= sinf(m_shaketimer.get_timegone() * m_shakespeed) * m_shakedepth_y; - // elastic easing + // Elastic easing: m_translation.x -= m_shakedepth_x * ((std::pow(2.f, -0.8f * (m_shakespeed * m_shaketimer.get_timegone()))) * std::sin(((0.8f * m_shakespeed * m_shaketimer.get_timegone()) - 0.75f) * (2.f * math::PI) / 3.f)); @@ -417,18 +417,18 @@ Camera::update_scroll_normal(float dt_sec) { const auto& config_ = *(m_config); Player& player = *d_sector->get_players()[0]; - // TODO: co-op mode needs a good camera + // TODO: Co-op mode needs a good camera. Vector player_pos(player.get_bbox().get_left(), player.get_bbox().get_bottom()); static Vector last_player_pos = player_pos; Vector player_delta = player_pos - last_player_pos; last_player_pos = player_pos; - // check that we don't have division by zero later + // Check that we don't have division by zero later. if (dt_sec < CAMERA_EPSILON) return; - /****** Vertical Scrolling part ******/ + /****** Vertical Scrolling part. ******/ int ymode = config_.ymode; if (player.is_dying() || d_sector->get_height() == 19*32) { @@ -441,7 +441,7 @@ Camera::update_scroll_normal(float dt_sec) // target_y is the height we target our scrolling at. This is not always the // height of the player: while jumping upwards, we should use the // position where they last touched the ground. (this probably needs - // exceptions for trampolines and similar things in the future) + // exceptions for trampolines and similar things in the future). float target_y; if (player.m_fall_mode == Player::JUMPING) target_y = player.m_last_ground_y + player.get_bbox().get_height(); @@ -449,18 +449,18 @@ Camera::update_scroll_normal(float dt_sec) target_y = player.get_bbox().get_bottom(); target_y -= static_cast(static_cast(m_screen_size.height)) * config_.target_y; - // delta_y is the distance we'd have to travel to directly reach target_y + // delta_y is the distance we'd have to travel to directly reach target_y. float delta_y = m_cached_translation.y - target_y; - // speed is the speed the camera would need to reach target_y in this frame + // speed is the speed the camera would need to reach target_y in this frame. float speed_y = delta_y / dt_sec; - // limit the camera speed when jumping upwards + // Limit the camera speed when jumping upwards. if (player.m_fall_mode != Player::FALLING && player.m_fall_mode != Player::TRAMPOLINE_JUMP) { speed_y = math::clamp(speed_y, -config_.max_speed_y, config_.max_speed_y); } - // scroll with calculated speed + // Scroll with calculated speed. m_cached_translation.y -= speed_y * dt_sec; } if (ymode == 3) { @@ -474,21 +474,21 @@ Camera::update_scroll_normal(float dt_sec) float lowerend = static_cast(m_screen_size.height) * (1 - config_.edge_x); if (player_delta.y < -CAMERA_EPSILON) { - // walking left + // Walking left. m_lookahead_pos.y -= player_delta.y * config_.dynamic_speed_sm; if (m_lookahead_pos.y > lowerend) { m_lookahead_pos.y = lowerend; } } else if (player_delta.y > CAMERA_EPSILON) { - // walking right + // Walking right. m_lookahead_pos.y -= player_delta.y * config_.dynamic_speed_sm; if (m_lookahead_pos.y < upperend) { m_lookahead_pos.y = upperend; } } - // adjust for level ends + // Adjust for level ends. if (player_pos.y < upperend) { m_lookahead_pos.y = upperend; } @@ -549,14 +549,14 @@ Camera::update_scroll_normal(float dt_sec) m_cached_translation.x = player_pos.x - static_cast(m_screen_size.width) * config_.target_x; } if (xmode == 2) { - // our camera is either in leftscrolling, rightscrolling or + // Our camera is either in leftscrolling, rightscrolling or // nonscrollingmode. // - // when suddenly changing directions while scrolling into the other - // direction abort scrolling, since tux might be going left/right at a - // relatively small part of the map (like when jumping upwards) + // When suddenly changing directions while scrolling into the other + // direction abort scrolling, since Tux might be going left/right at a + // relatively small part of the map (like when jumping upwards). - // Find out direction in which the player moves + // Find out direction in which the player moves. LookaheadMode walkDirection; if (player_delta.x < -CAMERA_EPSILON) walkDirection = LookaheadMode::LEFT; else if (player_delta.x > CAMERA_EPSILON) walkDirection = LookaheadMode::RIGHT; @@ -612,7 +612,7 @@ Camera::update_scroll_normal(float dt_sec) LEFTEND = static_cast(m_screen_size.width) * config_.edge_x; RIGHTEND = static_cast(m_screen_size.width) * (1-config_.edge_x); - // calculate our scroll target depending on scroll mode + // Calculate our scroll target depending on scroll mode. float target_x; if (m_lookahead_mode == LookaheadMode::LEFT) target_x = player_pos.x - RIGHTEND; @@ -621,17 +621,17 @@ Camera::update_scroll_normal(float dt_sec) else target_x = m_cached_translation.x; - // that's the distance we would have to travel to reach target_x + // That's the distance we would have to travel to reach target_x. float delta_x = m_cached_translation.x - target_x; - // the speed we'd need to travel to reach target_x in this frame + // The speed we'd need to travel to reach target_x in this frame. float speed_x = delta_x / dt_sec; - // limit our speed + // Limit our speed. float player_speed_x = player_delta.x / dt_sec; float maxv = config_.max_speed_x + (fabsf(player_speed_x * config_.dynamic_max_speed_x)); speed_x = math::clamp(speed_x, -maxv, maxv); - // apply scrolling + // Apply scrolling. m_cached_translation.x -= speed_x * dt_sec; } if (xmode == 3) { @@ -645,14 +645,14 @@ Camera::update_scroll_normal(float dt_sec) float RIGHTEND = static_cast(m_screen_size.width) * (1 - config_.edge_x); if (player_delta.x < -CAMERA_EPSILON) { - // walking left + // Walking left. m_lookahead_pos.x -= player_delta.x * config_.dynamic_speed_sm; if (m_lookahead_pos.x > RIGHTEND) { m_lookahead_pos.x = RIGHTEND; } } else if (player_delta.x > CAMERA_EPSILON) { - // walking right + // Walking right. m_lookahead_pos.x -= player_delta.x * config_.dynamic_speed_sm; if (m_lookahead_pos.x < LEFTEND) { m_lookahead_pos.x = LEFTEND; @@ -666,7 +666,7 @@ Camera::update_scroll_normal(float dt_sec) m_lookahead_pos.x = LEFTEND; } - // adjust for level ends + // Adjust for level ends. if (player_pos.x < LEFTEND) { m_lookahead_pos.x = LEFTEND; } @@ -758,7 +758,7 @@ Camera::update_scroll_normal_multiplayer(float dt_sec) y2 = std::max(y2, btm); } - // Might happens if all players are dead + // Might happen if all players are dead. if (x2 < x1 || y2 < y1) return; @@ -843,11 +843,11 @@ Camera::update_scale(float dt_sec) (m_scale_target - m_scale_origin) * true_progress; } - // Re-center camera when zooming + // Re-center camera when zooming. m_lookahead_pos /= 1.01f; } - // FIXME: Poor design: This shouldn't pose a problem to multiplayer + // FIXME: Poor design: This shouldn't pose a problem to multiplayer. if (m_mode == Mode::NORMAL && Sector::current()->get_object_count() > 1) return; diff --git a/src/object/candle.cpp b/src/object/candle.cpp index f415920016c..105ef022a7b 100644 --- a/src/object/candle.cpp +++ b/src/object/candle.cpp @@ -39,14 +39,14 @@ Candle::Candle(const ReaderMapping& mapping) : if (!mapping.get("color", vColor)) vColor = {1.0f, 1.0f, 1.0f}; mapping.get("layer", m_layer, 0); - //change the light color if defined + // Change the light color if defined. if (vColor.size() >= 3) { lightcolor = Color(vColor); candle_light_1->set_blend(Blend::ADD); candle_light_2->set_blend(Blend::ADD); candle_light_1->set_color(lightcolor); candle_light_2->set_color(lightcolor); - //the following allows the original candle appearance to be preserved + // The following allows the original candle appearance to be preserved. candle_light_1->set_action("white"); candle_light_2->set_action("white"); } @@ -88,18 +88,18 @@ Candle::get_settings() void Candle::draw(DrawingContext& context) { - // draw regular sprite + // Draw regular sprite. MovingSprite::draw(context); - // draw on lightmap + // Draw on lightmap. if (burning) { - //Vector pos = get_pos() + (bbox.get_size() - candle_light_1->get_size()) / 2; - // draw approx. 1 in 10 frames darker. Makes the candle flicker + // Vector pos = get_pos() + (bbox.get_size() - candle_light_1->get_size()) / 2; + // draw approx. 1 in 10 frames darker. Makes the candle flicker. if (graphicsRandom.rand(10) != 0 || !flicker) { - //context.color().draw_surface(candle_light_1, pos, layer); + // context.color().draw_surface(candle_light_1, pos, layer); candle_light_1->draw(context.light(), m_col.m_bbox.get_middle(), m_layer); } else { - //context.color().draw_surface(candle_light_2, pos, layer); + // context.color().draw_surface(candle_light_2, pos, layer); candle_light_2->draw(context.light(), m_col.m_bbox.get_middle(), m_layer); } } @@ -140,7 +140,7 @@ Candle::set_burning(bool burning_) } else { set_action("off"); } - //puff smoke for flickering light sources only + // Puff smoke for flickering light sources only. if (flicker) puff_smoke(); } diff --git a/src/object/cloud_particle_system.cpp b/src/object/cloud_particle_system.cpp index 0079baf89e9..0b9ed19263a 100644 --- a/src/object/cloud_particle_system.cpp +++ b/src/object/cloud_particle_system.cpp @@ -66,7 +66,7 @@ void CloudParticleSystem::init() { virtual_width = 2000.0; - // create some random clouds + // Create some random clouds. add_clouds(m_current_amount, 0.f); } @@ -87,7 +87,7 @@ void CloudParticleSystem::update(float dt_sec) if (!enabled) return; - // Update speed + // Update speed. if (m_speed_fade_time_remaining > 0.f) { if (dt_sec >= m_speed_fade_time_remaining) { m_current_speed = m_target_speed; @@ -118,14 +118,14 @@ void CloudParticleSystem::update(float dt_sec) while (cloudParticle->pos.y > cam.get_translation().y + screen_height) cloudParticle->pos.y -= screen_height + static_cast(cloudParticle->texture->get_height()) * 2.f; - // Update alpha + // Update alpha. if (cloudParticle->target_time_remaining > 0.f) { if (dt_sec >= cloudParticle->target_time_remaining) { cloudParticle->alpha = cloudParticle->target_alpha; cloudParticle->target_time_remaining = 0.f; if (cloudParticle->alpha == 0.f) { - // Remove this particle - // But not right here, else it'd mess with the iterator + // Remove this particle, but not at this point + // as it would interfere with the iterator. } } else { float amount = dt_sec / cloudParticle->target_time_remaining; @@ -135,9 +135,9 @@ void CloudParticleSystem::update(float dt_sec) } } - // Clear dead clouds - // Scroll through the vector backwards, because removing an element affects - // the index of all elements after it (prevents buggy behavior) + // Clear dead clouds. + // Iterate through the vector backwards to avoid affecting the index of elements + // after removal, preventing buggy behavior. for (int i = static_cast(particles.size()) - 1; i >= 0; --i) { auto particle = dynamic_cast(particles.at(i).get()); @@ -158,7 +158,7 @@ int CloudParticleSystem::add_clouds(int amount, float fade_time) for (int i = 0; i < amount_to_add; ++i) { auto particle = std::make_unique(); // Don't consider the camera, because the Sector might not exist yet - // Instead, rely on update() to correct this when it will be called + // Instead, rely on update() to correct this when it will be called. particle->pos.x = graphicsRandom.randf(virtual_width); particle->pos.y = graphicsRandom.randf(virtual_height); particle->texture = cloudimage; @@ -188,7 +188,7 @@ int CloudParticleSystem::remove_clouds(int amount, float fade_time) auto particle = dynamic_cast(particles.at(i).get()); if (particle->target_alpha != 1.f || particle->target_time_remaining != 0.f) { - // Skip that one, it doesn't count + // Skip that one, it doesn't count. --i; } else { particle->target_alpha = 0.f; @@ -201,9 +201,9 @@ int CloudParticleSystem::remove_clouds(int amount, float fade_time) void CloudParticleSystem::fade_speed(float new_speed, float fade_time) { - // No check to enabled; change the fading even if it's disabled + // No check for enabled; change the fading even if it's disabled. - // If time is 0 (or smaller?), then update() will never change m_current_speed + // If fade_time is 0 or smaller, update() will never change m_current_speed. if (fade_time <= 0.f) { m_current_speed = new_speed; @@ -215,7 +215,7 @@ void CloudParticleSystem::fade_speed(float new_speed, float fade_time) void CloudParticleSystem::fade_amount(int new_amount, float fade_time, float time_between) { - // No check to enabled; change the fading even if it's disabled + // No check for enabled; change the fading even if it's disabled. int delta = new_amount - m_current_real_amount; @@ -226,7 +226,7 @@ void CloudParticleSystem::fade_amount(int new_amount, float fade_time, float tim else if (delta > 0) { add_clouds(delta, fade_time); - } // Else delta == 0, in which case there is nothing to do + } // If delta is zero, there is nothing to do. } @@ -269,7 +269,7 @@ void CloudParticleSystem::draw(DrawingContext& context) auto& surface = it.first; auto& batch = it.second; // FIXME: What is the colour used for? - // RESOLVED : That's the tint and the alpha + // RESOLVED : That's the tint and the alpha. context.color().draw_surface_batch(surface, batch.move_srcrects(), batch.move_dstrects(), batch.move_angles(), batch.get_color(), z_pos); } diff --git a/src/object/coin.cpp b/src/object/coin.cpp index 62a5cf97f14..ee18a0a5a39 100644 --- a/src/object/coin.cpp +++ b/src/object/coin.cpp @@ -80,7 +80,7 @@ Coin::finish_construction() void Coin::update(float dt_sec) { - // if we have a path to follow, follow it + // If we have a path to follow, follow it. if (get_walker()) { Vector v(0.0f, 0.0f); if (m_from_tilemap) @@ -138,43 +138,43 @@ Coin::collect() } else { switch ((pitch_one - tile) % 7) { case -6: - pitch = 1.f/2; // C + pitch = 1.f/2; // C. break; case -5: - pitch = 5.f/8; // E + pitch = 5.f/8; // E. break; case -4: - pitch = 4.f/6; // F + pitch = 4.f/6; // F. break; case -3: - pitch = 3.f/4; // G + pitch = 3.f/4; // G. break; case -2: - pitch = 5.f/6; // A + pitch = 5.f/6; // A. break; case -1: - pitch = 9.f/10; // Bb + pitch = 9.f/10; // Bb. break; case 0: - pitch = 1.f; // c + pitch = 1.f; // c. break; case 1: - pitch = 9.f/8; // d + pitch = 9.f/8; // d. break; case 2: - pitch = 5.f/4; // e + pitch = 5.f/4; // e. break; case 3: - pitch = 4.f/3; // f + pitch = 4.f/3; // f. break; case 4: - pitch = 3.f/2; // g + pitch = 3.f/2; // g. break; case 5: - pitch = 5.f/3; // a + pitch = 5.f/3; // a. break; case 6: - pitch = 9.f/5; // bb + pitch = 9.f/5; // bb. break; } last_pitch = pitch; @@ -209,7 +209,7 @@ Coin::collision(GameObject& other, const CollisionHit& ) return ABORT_MOVE; } -/* The following defines a coin subject to gravity */ +/* The following defines a coin subject to gravity. */ HeavyCoin::HeavyCoin(const Vector& pos, const Vector& init_velocity, bool count_stats, const std::string& sprite_path) : Coin(pos, count_stats, sprite_path), m_physic(), @@ -234,15 +234,15 @@ HeavyCoin::HeavyCoin(const ReaderMapping& reader, bool count_stats) : void HeavyCoin::update(float dt_sec) { - // enable physics + // Enable physics. m_col.set_movement(m_physic.get_movement(dt_sec)); } void HeavyCoin::collision_solid(const CollisionHit& hit) { - float clink_threshold = 100.0f; // sets the minimum speed needed to result in collision noise - //TODO: colliding HeavyCoins should have their own unique sound + float clink_threshold = 100.0f; // Sets the minimum speed needed to result in collision noise. + // TODO: Colliding with HeavyCoins should have their own unique sound. if (hit.bottom) { if (m_physic.get_velocity_y() > clink_threshold && !m_last_hit.bottom) @@ -268,7 +268,7 @@ HeavyCoin::collision_solid(const CollisionHit& hit) } // Only make a sound if the coin wasn't hittin anything last frame (A coin - // stuck in solid matter would flood the sound manager - see #1555 on GitHub) + // stuck in solid matter would flood the sound manager - see #1555 on GitHub). m_last_hit = hit; } @@ -351,7 +351,7 @@ void HeavyCoin::on_flip(float height) { // Call on_flip from grandparent class MovingSprite to - // avoid flipping of gravity-affected object HeavyCoin + // avoid flipping of gravity-affected object HeavyCoin. MovingSprite::on_flip(height); } diff --git a/src/object/coin_explode.cpp b/src/object/coin_explode.cpp index c465f549590..72b29249425 100644 --- a/src/object/coin_explode.cpp +++ b/src/object/coin_explode.cpp @@ -30,8 +30,8 @@ CoinExplode::CoinExplode(const Vector& pos, bool count_stats, const std::string& void CoinExplode::update(float ) { - float mag = 100.0f; // madnitude that coins are to be thrown - float rand = 30.0f; // max variation to be subtracted from magnitide + float mag = 100.0f; // Magnitude at which coins are thrown. + float rand = 30.0f; // Max variation to be subtracted from the magnitude. Sector::get().add(position, Vector(2.5, -4.5) * (mag - gameRandom.randf(rand)), m_count_stats, m_sprite); Sector::get().add(position, Vector(2, -5) * (mag - gameRandom.randf(rand)), m_count_stats, m_sprite); diff --git a/src/object/coin_rain.cpp b/src/object/coin_rain.cpp index 92c3f81aab7..b296f6a6e55 100644 --- a/src/object/coin_rain.cpp +++ b/src/object/coin_rain.cpp @@ -22,7 +22,7 @@ #include "sprite/sprite_manager.hpp" #include "supertux/sector.hpp" -static const float DROP_TIME = .1f; // time duration between "drops" of coin rain +static const float DROP_TIME = .1f; // Time duration between "drops" of coin rain. CoinRain::CoinRain(const Vector& pos, bool emerge, bool count_stats, const std::string& sprite_path) : sprite(SpriteManager::current()->create(sprite_path)), @@ -42,19 +42,19 @@ CoinRain::CoinRain(const Vector& pos, bool emerge, bool count_stats, const std:: void CoinRain::update(float dt_sec) { - // first a single (untouchable) coin flies up above the sector + // First a single (untouchable) coin flies up above the sector. if (position.y > -32){ float dist = -500 * dt_sec; position.y += dist; emerge_distance += dist; - } // then the first collectable coin drops from one of ten random positions + } // Then the first collectable coin drops from one of ten random positions. else if (counter==0){ drop = gameRandom.rand(10); Sector::get().add(Vector(position.x + 32.0f * static_cast((drop < 5) ? -drop - 1 : drop - 4), -32.0f), Vector(0, 0), m_count_stats, m_sprite_path); counter++; timer.start(DROP_TIME); - } // finally the remainder of the coins drop in a determined but appears to be a random order + } // Finally, the remaining coins drop in a determined but seemingly random order. else if (timer.check()){ if (counter<10){ drop += 7; diff --git a/src/object/custom_particle_system.cpp b/src/object/custom_particle_system.cpp index feb6cb204bd..fdee4c63fca 100644 --- a/src/object/custom_particle_system.cpp +++ b/src/object/custom_particle_system.cpp @@ -538,10 +538,10 @@ CustomParticleSystem::get_settings() void CustomParticleSystem::update(float dt_sec) { - // "enabled" being false only means new particles shouldn't spawn; - // update the already existing particles regardless, if any + // The "enabled" flag being false only indicates that new particles shouldn't spawn. + // However, we still need to update the existing particles, if any. - // Handle easings + // Handle script-based easings. for (auto& req : script_easings) { req.time_remain -= dt_sec; @@ -558,7 +558,7 @@ CustomParticleSystem::update(float dt_sec) } } - // Update existing particles + // Update existing particles. for (auto& it : custom_particles) { auto particle = dynamic_cast(it.get()); assert(particle); @@ -696,12 +696,12 @@ CustomParticleSystem::update(float dt_sec) is_in_life_zone = true; break; - // Nothing to do; there's a warning if I don't put that here + // This case is intentionally empty; it serves as a placeholder to prevent a warning. case ParticleZone::ParticleZoneType::Spawn: break; } } - } // For each ParticleZone object + } // For each ParticleZone object. if (!is_in_life_zone && particle->has_been_in_life_zone) { if (particle->last_life_zone_required_instakill) { @@ -750,7 +750,7 @@ CustomParticleSystem::update(float dt_sec) particle->speedY *= -1; } else { float face_angle = atanf(c.slope_normal.y / c.slope_normal.x); - float dest_angle = face_angle * 2.f - speed_angle; // Reflect the angle around face_angle + float dest_angle = face_angle * 2.f - speed_angle; // Reflect the angle around face_angle. float dX = cosf(dest_angle), dY = sinf(dest_angle); @@ -806,12 +806,12 @@ CustomParticleSystem::update(float dt_sec) } } - } // For each particle + } // For each particle. // Clear dead particles - // Scroll through the vector backwards, because removing an element affects - // the index of all elements after it (prevents buggy behavior) + // We iterate through the vector backwards because removing an element affects + // the index of all elements after it, which can lead to buggy behavior. for (int i = static_cast(custom_particles.size()) - 1; i >= 0; --i) { auto particle = dynamic_cast(custom_particles.at(i).get()); @@ -820,7 +820,7 @@ CustomParticleSystem::update(float dt_sec) } } - // Add necessary particles + // Add necessary particles. float remaining = dt_sec + time_last_remaining; if (enabled) { @@ -845,7 +845,7 @@ CustomParticleSystem::update(float dt_sec) // it won't store all the time waiting for some particles to go and then // spawn a bazillion particles instantly. (Bacisally it means : This will // help guarantee there will be at least m_delay between each particle - // spawn as long as m_delay >= dt_sec) + // spawn as long as m_delay >= dt_sec). time_last_remaining = (remaining > m_delay) ? m_delay : remaining; } @@ -853,8 +853,8 @@ CustomParticleSystem::update(float dt_sec) void CustomParticleSystem::draw(DrawingContext& context) { - // "enabled" being false only means new particles shouldn't spawn; - // draw the already existing particles regardless, if any + // The "enabled" flag being false only indicates that new particles shouldn't spawn. + // However, we still need to update the existing particles, if any. context.push_transform(); @@ -912,7 +912,7 @@ CustomParticleSystem::draw(DrawingContext& context) } // Duplicated from ParticleSystem_Interactive because I intend to bring edits -// sometime in the future, for even more flexibility with particles. (Semphris) +// sometime in the future, for even more flexibility with particles. (Semphris). int CustomParticleSystem::collision(Particle* object, const Vector& movement) { @@ -921,7 +921,7 @@ CustomParticleSystem::collision(Particle* object, const Vector& movement) CustomParticle* particle = dynamic_cast(object); assert(particle); - // calculate rectangle where the object will move + // Calculate rectangle where the object will move. float x1, x2; float y1, y2; @@ -944,7 +944,7 @@ CustomParticleSystem::collision(Particle* object, const Vector& movement) } bool water = false; - // test with all tiles in this rectangle + // Test with all tiles in this rectangle. int starttilex = int(x1-1) / 32; int starttiley = int(y1-1) / 32; int max_x = int(x2+1); @@ -955,25 +955,25 @@ CustomParticleSystem::collision(Particle* object, const Vector& movement) Constraints constraints; for (const auto& solids : Sector::get().get_solid_tilemaps()) { - // FIXME Handle a nonzero tilemap offset - // Check if it gets fixed in particlesystem_interactive.cpp + // FIXME: Handle a nonzero tilemap offset. + // Check if it gets fixed in particlesystem_interactive.cpp. for (int x = starttilex; x*32 < max_x; ++x) { for (int y = starttiley; y*32 < max_y; ++y) { const Tile& tile = solids->get_tile(x, y); - // skip non-solid tiles, except water + // Skip non-solid tiles, except water. if (! (tile.get_attributes() & (Tile::WATER | Tile::SOLID))) continue; Rectf rect = solids->get_tile_bbox(x, y); - if (tile.is_slope ()) { // slope tile + if (tile.is_slope ()) { // Slope tile. AATriangle triangle = AATriangle(rect, tile.get_data()); if (rectangle_aatriangle(&constraints, dest, triangle)) { if (tile.get_attributes() & Tile::WATER) water = true; } - } else { // normal rectangular tile + } else { // Normal rectangular tile. if (intersects(dest, rect)) { if (tile.get_attributes() & Tile::WATER) water = true; @@ -984,20 +984,20 @@ CustomParticleSystem::collision(Particle* object, const Vector& movement) } } - // TODO don't use magic numbers here... + // TODO: Avoid using magic numbers in this section. - // did we collide at all? + // Check if any constraints exist for collision. if (!constraints.has_constraints()) return -1; const CollisionHit& hit = constraints.hit; if (water) { - return 0; //collision with water tile - don't draw splash + return 0; // Collision with water tile - no need to draw splash. } else { if (hit.right || hit.left) { - return 2; //collision from right + return 2; // Collision from the right. } else { - return 1; //collision from above + return 1; // Collision from above. } } } @@ -1010,7 +1010,7 @@ CustomParticleSystem::get_collision(Particle* object, const Vector& movement) CustomParticle* particle = dynamic_cast(object); assert(particle); - // calculate rectangle where the object will move + // Calculate rectangle where the object will move. float x1, x2; float y1, y2; @@ -1030,7 +1030,7 @@ CustomParticleSystem::get_collision(Particle* object, const Vector& movement) y2 = temp_y; } - // test with all tiles in this rectangle + // Test with all tiles in this rectangle. int starttilex = int(x1-1) / 32; int starttiley = int(y1-1) / 32; int max_x = int(x2+1); @@ -1041,21 +1041,21 @@ CustomParticleSystem::get_collision(Particle* object, const Vector& movement) Constraints constraints; for (const auto& solids : Sector::get().get_solid_tilemaps()) { - // FIXME Handle a nonzero tilemap offset - // Check if it gets fixed in particlesystem_interactive.cpp + // FIXME: Handle a nonzero tilemap offset. + // Check if it gets fixed in particlesystem_interactive.cpp. for (int x = starttilex; x*32 < max_x; ++x) { for (int y = starttiley; y*32 < max_y; ++y) { const Tile& tile = solids->get_tile(x, y); - // skip non-solid tiles + // Skip non-solid tiles. if (! (tile.get_attributes() & (/*Tile::WATER |*/ Tile::SOLID))) continue; Rectf rect = solids->get_tile_bbox(x, y); - if (tile.is_slope ()) { // slope tile + if (tile.is_slope ()) { // Slope tile. AATriangle triangle = AATriangle(rect, tile.get_data()); rectangle_aatriangle(&constraints, dest, triangle); - } else { // normal rectangular tile + } else { // Normal rectangular tile. if (intersects(dest, rect)) { set_rectangle_rectangle_constraints(&constraints, dest, rect); } @@ -1094,14 +1094,14 @@ CustomParticleSystem::get_zones() //if (!!GameSession::current() && Sector::current()) { if (!ParticleEditor::current()) { - // In game or in level editor + // In game or in level editor. for (auto& zone : GameSession::current()->get_current_sector().get_objects_by_type()) { list.push_back(zone.get_details()); } } else { - // In particle editor + // In particle editor. list.push_back(ParticleZone::ZoneDetails(m_name, ParticleZone::ParticleZoneType::Spawn, Rectf(virtual_width / 2 - 16.f, @@ -1129,7 +1129,7 @@ CustomParticleSystem::get_abs_y() /** Initializes and adds a single particle to the stack. Performs * no check regarding the maximum amount of total particles. - * @param lifetime The time elapsed since the moment the particle should have been born + * @param lifetime The time elapsed since the moment the particle should have been born. */ void CustomParticleSystem::add_particle(float lifetime, float x, float y) diff --git a/src/object/custom_particle_system_file.cpp b/src/object/custom_particle_system_file.cpp index 12964431ba0..18ec3ed07f3 100644 --- a/src/object/custom_particle_system_file.cpp +++ b/src/object/custom_particle_system_file.cpp @@ -53,7 +53,7 @@ CustomParticleSystemFile::get_settings() result.add_file(_("File"), &m_filename, "file", {}, {".stcp"}, "/particles"); result.add_particle_editor(); - // It is assumed get_settings() is called whenever the menu is opened + // It is assumed get_settings() is called whenever the menu is opened. Editor::current()->m_particle_editor_filename = &m_filename; result.add_remove(); diff --git a/src/object/display_effect.cpp b/src/object/display_effect.cpp index 958c84ea770..48935408b33 100644 --- a/src/object/display_effect.cpp +++ b/src/object/display_effect.cpp @@ -110,7 +110,7 @@ DisplayEffect::draw(DrawingContext& context) assert(false); } - // Same as in fadetoblack.cpp + // Same as in fadetoblack.cpp. alpha = Color::remove_gamma(alpha); } context.color().draw_filled_rect(Rectf(0, 0, diff --git a/src/object/explosion.cpp b/src/object/explosion.cpp index 73d1c9582bd..63e85432829 100644 --- a/src/object/explosion.cpp +++ b/src/object/explosion.cpp @@ -73,15 +73,15 @@ Explosion::explode() Sector::get().get_camera().shake(.1f, 0.f, 10.f); set_action(hurt ? "default" : "pop", 1); - m_sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action - m_sprite->set_angle(graphicsRandom.randf(0, 360)); // a random rotation on the sprite to make explosions appear more random + m_sprite->set_animation_loops(1); //TODO: This is necessary because set_action will not set "loops" when "action" is the default action. + m_sprite->set_angle(graphicsRandom.randf(0, 360)); // A random rotation on the sprite to make explosions appear more random. if (hurt) SoundManager::current()->play("sounds/explosion.wav", get_pos(), 0.98f); else SoundManager::current()->play("sounds/firecracker.ogg", get_pos(), 0.7f); bool does_push = push_strength > 0; - // spawn some particles + // Spawn some particles. Vector accel = Vector(0, Sector::get().get_gravity()*100); Sector::get().add( m_col.m_bbox.get_middle(), -360, 360, 450.0f, 900.0f, accel, num_particles, diff --git a/src/object/firefly.cpp b/src/object/firefly.cpp index b579e8bc9bb..37b473d7a66 100644 --- a/src/object/firefly.cpp +++ b/src/object/firefly.cpp @@ -30,8 +30,8 @@ #include "supertux/sector.hpp" #include "util/reader_mapping.hpp" -static const Color TORCH_LIGHT_COLOR = Color(0.87f, 0.64f, 0.12f); /** Color of the light specific to the torch firefly sprite */ -static const Vector TORCH_LIGHT_OFFSET = Vector(0, 12); /** Offset of the light specific to the torch firefly sprite */ +static const Color TORCH_LIGHT_COLOR = Color(0.87f, 0.64f, 0.12f); /** Color of the light specific to the torch firefly sprite. */ +static const Vector TORCH_LIGHT_OFFSET = Vector(0, 12); /** Offset of the light specific to the torch firefly sprite. */ Firefly::Firefly(const ReaderMapping& mapping) : MovingSprite(mapping, "images/objects/resetpoints/default-resetpoint.sprite", LAYER_TILES, COLGROUP_TOUCHABLE), @@ -47,7 +47,7 @@ Firefly::Firefly(const ReaderMapping& mapping) : update_state(); - //Load sound + // Load sound. if ( m_sprite_name.find("vbell", 0) != std::string::npos ) { SoundManager::current()->preload("sounds/savebell_low.wav"); } @@ -106,7 +106,7 @@ Firefly::collision(GameObject& other, const CollisionHit& ) auto player = dynamic_cast (&other); if (player) { activated = true; - // spawn some particles + // Spawn some particles. // TODO: provide convenience function in MovingSprite or MovingObject? for (int i = 0; i < 5; i++) { Vector ppos = m_col.m_bbox.get_middle(); diff --git a/src/object/floating_text.cpp b/src/object/floating_text.cpp index bf32d041186..94489130f41 100644 --- a/src/object/floating_text.cpp +++ b/src/object/floating_text.cpp @@ -32,16 +32,11 @@ FloatingText::FloatingText(const Vector& pos, const std::string& text_) : FloatingText::FloatingText(const Vector& pos, int score) : position(pos), - text(), + text(std::to_string(score)), timer() { timer.start(.1f); - // turn int into a string - char str[10]; - snprintf(str, 10, "%d", score); - text = str; - position.x -= static_cast(text.size()) * 8.0f; } @@ -59,7 +54,7 @@ const float FADING_TIME = .350f; void FloatingText::draw(DrawingContext& context) { - // make an alpha animation when disappearing + // Make an alpha animation when disappearing. float alpha; if (timer.get_timeleft() < FADING_TIME) alpha = timer.get_timeleft() * 255.0f / FADING_TIME; diff --git a/src/object/ghost_particle_system.cpp b/src/object/ghost_particle_system.cpp index da136a09605..40916c7cf97 100644 --- a/src/object/ghost_particle_system.cpp +++ b/src/object/ghost_particle_system.cpp @@ -26,7 +26,7 @@ #include "video/viewport.hpp" //FIXME: Sometimes both ghosts have the same image -// Ghosts don't change their movement pattern - not random +// Ghosts don't change their movement pattern - not random. GhostParticleSystem::GhostParticleSystem() { init(); @@ -50,7 +50,7 @@ GhostParticleSystem::init() virtual_width = static_cast(SCREEN_WIDTH) * 2.0f; - // create two ghosts + // Create two ghosts. size_t ghostcount = 2; for (size_t i=0; i(); diff --git a/src/object/gradient.cpp b/src/object/gradient.cpp index 911905a3c04..c6040d1352a 100644 --- a/src/object/gradient.cpp +++ b/src/object/gradient.cpp @@ -207,7 +207,7 @@ Gradient::set_gradient(const Color& top, const Color& bottom) m_gradient_top.blue > 1.0f || m_gradient_top.alpha > 1.0f) { - log_warning << "top gradient color has values above 1.0" << std::endl; + log_warning << "Top gradient color has values above 1.0." << std::endl; } if (m_gradient_bottom.red > 1.0f || @@ -215,7 +215,7 @@ Gradient::set_gradient(const Color& top, const Color& bottom) m_gradient_bottom.blue > 1.0f || m_gradient_bottom.alpha > 1.0f) { - log_warning << "bottom gradient color has values above 1.0" << std::endl; + log_warning << "Bottom gradient color has values above 1.0." << std::endl; } } diff --git a/src/object/growup.cpp b/src/object/growup.cpp index 51e751b76b0..bb9960f5fff 100644 --- a/src/object/growup.cpp +++ b/src/object/growup.cpp @@ -33,9 +33,9 @@ GrowUp::GrowUp(const Vector& pos, Direction direction) : physic.enable_gravity(true); physic.set_velocity_x((direction == Direction::LEFT) ? -100.0f : 100.0f); SoundManager::current()->preload("sounds/grow.ogg"); - //shadow to remain in place as egg rolls + // Set the shadow action for the egg sprite, so it remains in place as the egg rolls. shadesprite->set_action("shadow"); - //set light for glow effect + // Configure the light sprite for the glow effect. lightsprite->set_blend(Blend::ADD); lightsprite->set_color(Color(0.2f, 0.2f, 0.0f)); } diff --git a/src/physfs/ifile_streambuf.cpp b/src/physfs/ifile_streambuf.cpp index 4ada56204a6..e3aa9067c31 100644 --- a/src/physfs/ifile_streambuf.cpp +++ b/src/physfs/ifile_streambuf.cpp @@ -25,8 +25,8 @@ IFileStreambuf::IFileStreambuf(const std::string& filename) : file(), buf() { - // check this as PHYSFS seems to be buggy and still returns a - // valid pointer in this case + // Check this as PHYSFS seems to be buggy and still returns a + // valid pointer in this case. if (filename.empty()) { throw std::runtime_error("Couldn't open file: empty filename"); } @@ -67,7 +67,7 @@ IFileStreambuf::seekpos(pos_type pos, std::ios_base::openmode) return pos_type(off_type(-1)); } - // the seek invalidated the buffer + // The seek invalidated the buffer. setg(buf, buf, buf); return pos; } diff --git a/src/scripting/custom_particles.cpp b/src/scripting/custom_particles.cpp index 67140dd7dca..5507c02b411 100644 --- a/src/scripting/custom_particles.cpp +++ b/src/scripting/custom_particles.cpp @@ -49,20 +49,15 @@ void CustomParticles::spawn_particles(int amount, bool instantly) } else { - // TODO - log_warning << "Delayed spawn mode not yet implemented for scripting" << std::endl; + // TODO: Implement delayed spawn mode for scripting. + log_warning << "Delayed spawn mode is not yet implemented for scripting." << std::endl; } } - - // ============================================================================= // ============================ ATTRIBUTES ================================= // ============================================================================= - - - int CustomParticles::get_max_amount() { SCRIPT_GUARD_DEFAULT; @@ -87,9 +82,6 @@ void CustomParticles::set_cover_screen(bool cover) object.m_cover_screen = cover; } - - - std::string CustomParticles::get_birth_mode() { SCRIPT_GUARD_DEFAULT; @@ -126,11 +118,10 @@ void CustomParticles::set_birth_mode(std::string mode) } else { - log_warning << "Invalid option " + mode + "; valid options are: None, Fade, Shrink" << std::endl; + log_warning << "Invalid option " + mode + "; valid options are: None, Fade, Shrink." << std::endl; } } - std::string CustomParticles::get_death_mode() { SCRIPT_GUARD_DEFAULT; @@ -167,11 +158,10 @@ void CustomParticles::set_death_mode(std::string mode) } else { - log_warning << "Invalid option " + mode + "; valid options are: None, Fade, Shrink" << std::endl; + log_warning << "Invalid option " + mode + "; valid options are: None, Fade, Shrink." << std::endl; } } - std::string CustomParticles::get_rotation_mode() { SCRIPT_GUARD_DEFAULT; @@ -208,11 +198,10 @@ void CustomParticles::set_rotation_mode(std::string mode) } else { - log_warning << "Invalid option " + mode + "; valid options are: Fixed, Facing, Wiggling" << std::endl; + log_warning << "Invalid option " + mode + "; valid options are: Fixed, Facing, Wiggling." << std::endl; } } - std::string CustomParticles::get_collision_mode() { SCRIPT_GUARD_DEFAULT; @@ -270,11 +259,10 @@ void CustomParticles::set_collision_mode(std::string mode) } else { - log_warning << "Invalid option " + mode + "; valid options are: Ignore, Stick, StickForever, BounceHeavy, BounceLight, Destroy" << std::endl; + log_warning << "Invalid option " + mode + "; valid options are: Ignore, Stick, StickForever, BounceHeavy, BounceLight, Destroy." << std::endl; } } - std::string CustomParticles::get_offscreen_mode() { SCRIPT_GUARD_DEFAULT; @@ -311,18 +299,14 @@ void CustomParticles::set_offscreen_mode(std::string mode) } else { - log_warning << "Invalid option " + mode + "; valid options are: Never, OnlyOnExit, Always" << std::endl; + log_warning << "Invalid option " + mode + "; valid options are: Never, OnlyOnExit, Always." << std::endl; } } - - - - - // ============================================================================= -// delay +// Delay // ----------------------------------------------------------------------------- + float CustomParticles::get_delay() { SCRIPT_GUARD_DEFAULT; @@ -347,11 +331,10 @@ void CustomParticles::ease_delay(float delay, float time, std::string easing) object.ease_value(&object.m_delay, delay, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// lifetime +// Lifetime // ----------------------------------------------------------------------------- + float CustomParticles::get_lifetime() { SCRIPT_GUARD_DEFAULT; @@ -376,11 +359,10 @@ void CustomParticles::ease_lifetime(float lifetime, float time, std::string easi object.ease_value(&object.m_particle_lifetime, lifetime, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// lifetime_variation +// Lifetime variation // ----------------------------------------------------------------------------- + float CustomParticles::get_lifetime_variation() { SCRIPT_GUARD_DEFAULT; @@ -405,11 +387,10 @@ void CustomParticles::ease_lifetime_variation(float lifetime_variation, float ti object.ease_value(&object.m_particle_lifetime_variation, lifetime_variation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// birth_time +// Birth time // ----------------------------------------------------------------------------- + float CustomParticles::get_birth_time() { SCRIPT_GUARD_DEFAULT; @@ -434,11 +415,10 @@ void CustomParticles::ease_birth_time(float birth_time, float time, std::string object.ease_value(&object.m_particle_birth_time, birth_time, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// birth_time_variation +// Birth time variation // ----------------------------------------------------------------------------- + float CustomParticles::get_birth_time_variation() { SCRIPT_GUARD_DEFAULT; @@ -463,11 +443,10 @@ void CustomParticles::ease_birth_time_variation(float birth_time_variation, floa object.ease_value(&object.m_particle_birth_time_variation, birth_time_variation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// death_time +// Death time // ----------------------------------------------------------------------------- + float CustomParticles::get_death_time() { SCRIPT_GUARD_DEFAULT; @@ -495,7 +474,7 @@ void CustomParticles::ease_death_time(float death_time, float time, std::string // ============================================================================= -// death_time_variation +// Death time variation // ----------------------------------------------------------------------------- float CustomParticles::get_death_time_variation() { @@ -521,11 +500,10 @@ void CustomParticles::ease_death_time_variation(float death_time_variation, floa object.ease_value(&object.m_particle_death_time_variation, death_time_variation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// speed_x +// X speed // ----------------------------------------------------------------------------- + float CustomParticles::get_speed_x() { SCRIPT_GUARD_DEFAULT; @@ -550,11 +528,10 @@ void CustomParticles::ease_speed_x(float speed_x, float time, std::string easing object.ease_value(&object.m_particle_speed_x, speed_x, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// speed_y +// Y speed // ----------------------------------------------------------------------------- + float CustomParticles::get_speed_y() { SCRIPT_GUARD_DEFAULT; @@ -579,11 +556,10 @@ void CustomParticles::ease_speed_y(float speed_y, float time, std::string easing object.ease_value(&object.m_particle_speed_y, speed_y, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// speed_variation_x +// X speed variation // ----------------------------------------------------------------------------- + float CustomParticles::get_speed_variation_x() { SCRIPT_GUARD_DEFAULT; @@ -608,11 +584,10 @@ void CustomParticles::ease_speed_variation_x(float speed_variation_x, float time object.ease_value(&object.m_particle_speed_variation_x, speed_variation_x, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// speed_variation_y +// Y speed variation // ----------------------------------------------------------------------------- + float CustomParticles::get_speed_variation_y() { SCRIPT_GUARD_DEFAULT; @@ -637,11 +612,10 @@ void CustomParticles::ease_speed_variation_y(float speed_variation_y, float time object.ease_value(&object.m_particle_speed_variation_y, speed_variation_y, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// acceleration_x +// X acceleration // ----------------------------------------------------------------------------- + float CustomParticles::get_acceleration_x() { SCRIPT_GUARD_DEFAULT; @@ -666,11 +640,10 @@ void CustomParticles::ease_acceleration_x(float acceleration_x, float time, std: object.ease_value(&object.m_particle_acceleration_x, acceleration_x, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// acceleration_y +// Y acceleration // ----------------------------------------------------------------------------- + float CustomParticles::get_acceleration_y() { SCRIPT_GUARD_DEFAULT; @@ -695,11 +668,10 @@ void CustomParticles::ease_acceleration_y(float acceleration_y, float time, std: object.ease_value(&object.m_particle_acceleration_y, acceleration_y, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// friction_x +// X friction // ----------------------------------------------------------------------------- + float CustomParticles::get_friction_x() { SCRIPT_GUARD_DEFAULT; @@ -724,11 +696,10 @@ void CustomParticles::ease_friction_x(float friction_x, float time, std::string object.ease_value(&object.m_particle_friction_x, friction_x, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// friction_y +// Y friction // ----------------------------------------------------------------------------- + float CustomParticles::get_friction_y() { SCRIPT_GUARD_DEFAULT; @@ -753,11 +724,10 @@ void CustomParticles::ease_friction_y(float friction_y, float time, std::string object.ease_value(&object.m_particle_friction_y, friction_y, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// feather_factor +// Feather factor // ----------------------------------------------------------------------------- + float CustomParticles::get_feather_factor() { SCRIPT_GUARD_DEFAULT; @@ -782,11 +752,10 @@ void CustomParticles::ease_feather_factor(float feather_factor, float time, std: object.ease_value(&object.m_particle_feather_factor, feather_factor, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation +// Rotation // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation() { SCRIPT_GUARD_DEFAULT; @@ -811,11 +780,10 @@ void CustomParticles::ease_rotation(float rotation, float time, std::string easi object.ease_value(&object.m_particle_rotation, rotation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation_variation +// Rotation variation // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation_variation() { SCRIPT_GUARD_DEFAULT; @@ -840,11 +808,10 @@ void CustomParticles::ease_rotation_variation(float rotation_variation, float ti object.ease_value(&object.m_particle_rotation_variation, rotation_variation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation_speed +// Rotation speed // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation_speed() { SCRIPT_GUARD_DEFAULT; @@ -869,11 +836,10 @@ void CustomParticles::ease_rotation_speed(float rotation_speed, float time, std: object.ease_value(&object.m_particle_rotation_speed, rotation_speed, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation_speed_variation +// Rotation speed variation // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation_speed_variation() { SCRIPT_GUARD_DEFAULT; @@ -898,11 +864,10 @@ void CustomParticles::ease_rotation_speed_variation(float rotation_speed_variati object.ease_value(&object.m_particle_rotation_speed_variation, rotation_speed_variation, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation_acceleration +// Rotation acceleration // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation_acceleration() { SCRIPT_GUARD_DEFAULT; @@ -927,11 +892,10 @@ void CustomParticles::ease_rotation_acceleration(float rotation_acceleration, fl object.ease_value(&object.m_particle_rotation_acceleration, rotation_acceleration, time, getEasingByName(EasingMode_from_string(easing))); } - - // ============================================================================= -// rotation_decceleration +// Rotation decceleration // ----------------------------------------------------------------------------- + float CustomParticles::get_rotation_decceleration() { SCRIPT_GUARD_DEFAULT; diff --git a/src/scripting/floating_image.cpp b/src/scripting/floating_image.cpp index 1ce30c23fc0..6eedf572489 100644 --- a/src/scripting/floating_image.cpp +++ b/src/scripting/floating_image.cpp @@ -119,6 +119,6 @@ FloatingImage::fade_out(float time) object.fade_out(time); } -} // scripting +} // namespace scripting /* EOF */ diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 5735882f15a..a3dd0becc24 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -41,8 +41,8 @@ namespace { -// not added to header, function to only be used by others -// in this file +// Not added to header, function to only be used by others +// in this file. bool validate_sector_player() { if (::Sector::current() == nullptr) @@ -93,7 +93,7 @@ void start_cutscene() { log_warning << "start_cutscene(): starting a new cutscene above another one, ending preceding cutscene (use end_cutscene() in scripts!)" << std::endl; - // Remove all sounds that started playing while skipping + // Remove all sounds that started playing while skipping. if (session->get_current_level().m_skip_cutscene) SoundManager::current()->stop_sounds(); } @@ -107,16 +107,16 @@ void end_cutscene() auto session = GameSession::current(); if (session == nullptr) { - log_info << "No game session" << std::endl; + log_info << "No game session." << std::endl; return; } if (!session->get_current_level().m_is_in_cutscene) { - log_warning << "end_cutscene(): no cutscene to end, resetting status anyways" << std::endl; + log_warning << "end_cutscene(): no cutscene to end, resetting status anyways." << std::endl; } - // Remove all sounds that started playing while skipping + // Remove all sounds that started playing while skipping. if (session->get_current_level().m_skip_cutscene) SoundManager::current()->stop_sounds(); @@ -142,7 +142,7 @@ void wait(HSQUIRRELVM vm, float seconds) { if (auto squirrelenv = static_cast(sq_getforeignptr(vm))) { - // wait anyways, to prevent scripts like `while (true) {wait(0.1); ...}` + // Wait anyways, to prevent scripts like `while (true) {wait(0.1); ...}`. squirrelenv->wait_for_seconds(vm, 0); } else if (auto squirrelvm = static_cast(sq_getsharedforeignptr(vm))) @@ -158,7 +158,7 @@ void wait(HSQUIRRELVM vm, float seconds) { if (auto squirrelenv = static_cast(sq_getforeignptr(vm))) { - // wait anyways, to prevent scripts like `while (true) {wait(0.1); ...}` from freezing the game + // Wait anyways, to prevent scripts like `while (true) {wait(0.1); ...}` from freezing the game. squirrelenv->skippable_wait_for_seconds(vm, seconds); //GameSession::current()->set_scheduler(squirrelenv->get_scheduler()); } @@ -289,7 +289,7 @@ void debug_worldmap_ghost(bool enable) auto worldmap_sector = worldmap::WorldMapSector::current(); if (worldmap_sector == nullptr) - throw std::runtime_error("Can't change ghost mode without active WorldMapSector"); + throw std::runtime_error("Can't change ghost mode without active WorldMapSector."); auto& tux = worldmap_sector->get_singleton_by_type(); tux.set_ghost_mode(enable); @@ -301,7 +301,7 @@ void save_state() if (!worldmap) { - throw std::runtime_error("Can't save state without active Worldmap"); + throw std::runtime_error("Can't save state without active Worldmap."); } else { @@ -315,7 +315,7 @@ void load_state() if (!worldmap) { - throw std::runtime_error("Can't save state without active Worldmap"); + throw std::runtime_error("Can't save state without active Worldmap."); } else { @@ -356,7 +356,7 @@ void play_sound(const std::string& filename) void grease() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); // scripting::Player != ::Player tux.get_physic().set_velocity_x(tux.get_physic().get_velocity_x()*3); } @@ -364,7 +364,7 @@ void grease() void invincible() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); tux.m_invincible_timer.start(10000); } @@ -372,7 +372,7 @@ void invincible() void ghost() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); tux.set_ghost_mode(true); } @@ -380,7 +380,7 @@ void ghost() void mortal() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); tux.m_invincible_timer.stop(); tux.set_ghost_mode(false); @@ -391,7 +391,7 @@ void restart() auto session = GameSession::current(); if (session == nullptr) { - log_info << "No game session" << std::endl; + log_info << "No game session." << std::endl; return; } session->restart_level(); @@ -400,7 +400,7 @@ void restart() void whereami() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); log_info << "You are at x " << (static_cast(tux.get_pos().x)) << ", y " << (static_cast(tux.get_pos().y)) << std::endl; } @@ -408,7 +408,7 @@ void whereami() void gotoend() { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); tux.move(Vector( (::Sector::get().get_width()) - (static_cast(SCREEN_WIDTH) * 2.0f), 0)); @@ -419,7 +419,7 @@ void gotoend() void warp(float offset_x, float offset_y) { if (!validate_sector_player()) return; - // FIXME: This only has effect on the first player + // FIXME: This only has effect on the first player. ::Player& tux = *(::Sector::get().get_players()[0]); tux.move(Vector( tux.get_pos().x + (offset_x*32), tux.get_pos().y - (offset_y*32))); @@ -450,7 +450,7 @@ void set_game_speed(float speed) { // Always put a minimum speed above 0 - if the user enabled transitions, // executing transitions would take an unreaonably long time if we allow - // game speeds like 0.00001 + // game speeds like 0.00001. log_warning << "Cannot set game speed to less than 0.05" << std::endl; throw std::runtime_error("Cannot set game speed to less than 0.05"); } @@ -462,7 +462,7 @@ void record_demo(const std::string& filename) { if (GameSession::current() == nullptr) { - log_info << "No game session" << std::endl; + log_info << "No game session." << std::endl; return; } GameSession::current()->restart_level(); @@ -474,10 +474,10 @@ void play_demo(const std::string& filename) auto session = GameSession::current(); if (session == nullptr) { - log_info << "No game session" << std::endl; + log_info << "No game session." << std::endl; return; } - // Reset random seed + // Reset random seed. g_config->random_seed = session->get_demo_random_seed(filename); gameRandom.seed(g_config->random_seed); session->restart_level(); diff --git a/src/sdk/discord.cpp b/src/sdk/discord.cpp index bf2127c1d6e..c0904b48b56 100644 --- a/src/sdk/discord.cpp +++ b/src/sdk/discord.cpp @@ -91,7 +91,7 @@ DiscordIntegration::DiscordIntegration() : DiscordIntegration::~DiscordIntegration() { - // It shouldn't get here, but just in case + // It shouldn't get here, but just in case. close(); } @@ -188,7 +188,7 @@ DiscordIntegration::update_status(IntegrationStatus status) } } - // TODO: Manage parties and all + // TODO: Manage parties and all. discordPresence.largeImageKey = "supertux_logo"; Discord_UpdatePresence(&discordPresence); diff --git a/src/supertux/autotile.cpp b/src/supertux/autotile.cpp index 41e4fddeb47..be546aea1d5 100644 --- a/src/supertux/autotile.cpp +++ b/src/supertux/autotile.cpp @@ -20,7 +20,7 @@ //#include "supertux/autotile_parser.hpp" -// AutotileMask +// AutotileMask. AutotileMask::AutotileMask(uint8_t mask, bool center) : m_mask(mask), @@ -40,7 +40,7 @@ AutotileMask::get_mask() const return m_mask; } -// Autotile +// Autotile. Autotile::Autotile(uint32_t tile_id, std::vector> alt_tiles, std::vector masks, bool solid) : m_tile_id(tile_id), @@ -73,13 +73,13 @@ uint32_t Autotile::pick_tile(int x, int y) const { // Needed? Not needed? - // Could avoid pointless computation + // Could avoid pointless computation. if (m_alt_tiles.size() == 0) return m_tile_id; // srand() and rand() are inconsistent across platforms (Windows) - //srand(x * 32768 + y); - //float rnd_val = static_cast(rand()) / static_cast(RAND_MAX); + // srand(x * 32768 + y); + // float rnd_val = static_cast(rand()) / static_cast(RAND_MAX); float rnd_val = static_cast( ( @@ -133,7 +133,7 @@ Autotile::is_solid() const } -// AutotileSet +// AutotileSet. std::vector* AutotileSet::m_autotilesets = new std::vector(); @@ -221,8 +221,6 @@ AutotileSet::get_autotile(uint32_t tile_id, return center ? get_default_tile() : 0; } - - uint32_t AutotileSet::get_default_tile() const { @@ -250,7 +248,7 @@ AutotileSet::is_member(uint32_t tile_id) const } } // m_default should *never* be 0 (always a valid solid tile, - // even if said tile isn't part of the tileset) + // even if said tile isn't part of the tileset). return tile_id == m_default && m_default != 0; } @@ -281,7 +279,7 @@ AutotileSet::is_solid(uint32_t tile_id) const //log_warning << "Called AutotileSet::is_solid() with a tile_id that isn't in the Autotileset, yet that returns is_member() = true." << std::endl; // m_default should *never* be 0 (always a valid solid tile, - // even if said tile isn't part of the tileset) + // even if said tile isn't part of the tileset). return tile_id == m_default && m_default != 0; } @@ -301,13 +299,13 @@ void AutotileSet::validate() const { // Corner autotiles are always empty if all 4 corners are, but regular - // autotiles should have a valid tile ID that can be surrounded by emptiness + // autotiles should have a valid tile ID that can be surrounded by emptiness. for (int mask = (m_corner ? 1 : 0); mask <= (m_corner ? 15 : 255); mask++) { uint8_t num_mask = static_cast(mask); bool tile_exists = false; - uint32_t tile_nonsolid = 0; // Relevant only for non-corner autotiles - uint32_t tile_with_that_mask = 0; // Used to help users debug + uint32_t tile_nonsolid = 0; // Relevant only for non-corner autotiles. + uint32_t tile_with_that_mask = 0; // Used to help users debug. for (auto& autotile : m_autotiles) { diff --git a/src/supertux/autotile_parser.cpp b/src/supertux/autotile_parser.cpp index 91c76eeaf97..fae7495b3dc 100644 --- a/src/supertux/autotile_parser.cpp +++ b/src/supertux/autotile_parser.cpp @@ -45,7 +45,7 @@ AutotileParser::parse() auto root = doc.get_root(); if (root.get_name() != "supertux-autotiles") { - throw std::runtime_error("file is not a supertux autotile configuration file."); + throw std::runtime_error("File is not a supertux autotile configuration file (Root list doesn't start with 'supertux-autotiles')."); } auto iter = root.get_mapping().get_iter(); diff --git a/src/supertux/command_line_arguments.cpp b/src/supertux/command_line_arguments.cpp index b8eb7f62838..8e71c17f5d2 100644 --- a/src/supertux/command_line_arguments.cpp +++ b/src/supertux/command_line_arguments.cpp @@ -217,7 +217,7 @@ CommandLineArguments::parse_args(int argc, char** argv) window_size = Size(1280, 800); fullscreen_size = Size(1280, 800); fullscreen_refresh_rate = 0; - aspect_size = Size(0, 0); // auto detect + aspect_size = Size(0, 0); // Auto detect. } else if (arg == "--window" || arg == "-w") { @@ -262,7 +262,7 @@ CommandLineArguments::parse_args(int argc, char** argv) } else { - // use aspect ratio to calculate logical resolution + // Use aspect ratio to calculate logical resolution. if (aspect_width / aspect_height > 1) { aspect_size = Size(600 * aspect_width / aspect_height, 600); } else { diff --git a/src/supertux/console.cpp b/src/supertux/console.cpp index d1bc38d1d97..9546f64ef02 100644 --- a/src/supertux/console.cpp +++ b/src/supertux/console.cpp @@ -61,10 +61,10 @@ ConsoleBuffer::addLine(const std::string& s_) { std::string s = s_; - // output line to stderr + // Output line to stderr. get_logging_instance(false) << s << std::endl; - // wrap long lines + // Wrap long lines. std::string overflow; int line_count = 0; do { @@ -73,7 +73,7 @@ ConsoleBuffer::addLine(const std::string& s_) s = overflow; } while (s.length() > 0); - // trim scrollback buffer + // Trim scrollback buffer. while (m_lines.size() >= 1000) { m_lines.pop_back(); @@ -136,7 +136,7 @@ Console::~Console() void Console::on_buffer_change(int line_count) { - // increase console height if necessary + // Increase console height if necessary. if (m_stayOpen > 0 && m_height < 64) { if (m_height < 4) @@ -146,7 +146,7 @@ Console::on_buffer_change(int line_count) m_height += m_font->get_height() * static_cast(line_count); } - // reset console to full opacity + // Reset console to full opacity. m_alpha = 1.0; } @@ -159,14 +159,14 @@ Console::ready_vm() if (new_vm == nullptr) throw SquirrelError(m_vm, "Couldn't create new VM thread for console"); - // store reference to thread + // Store reference to thread. sq_resetobject(&m_vm_object); if (SQ_FAILED(sq_getstackobj(m_vm, -1, &m_vm_object))) throw SquirrelError(m_vm, "Couldn't get vm object for console"); sq_addref(m_vm, &m_vm_object); sq_pop(m_vm, 1); - // create new roottable for thread + // Create new roottable for thread. sq_newtable(new_vm); sq_pushroottable(new_vm); if (SQ_FAILED(sq_setdelegate(new_vm, -2))) @@ -284,8 +284,8 @@ Console::move_cursor(int offset_) if (m_inputBufferPosition > static_cast(m_inputBuffer.length())) m_inputBufferPosition = static_cast(m_inputBuffer.length()); } -// Helper functions for Console::autocomplete -// TODO: Fix rough documentation +// Helper functions for Console::autocomplete. +// TODO: Fix rough documentation. namespace { void sq_insert_commands(std::list& cmds, HSQUIRRELVM vm, const std::string& table_prefix, const std::string& search_prefix); @@ -333,26 +333,26 @@ sq_insert_command(std::list& cmds, HSQUIRRELVM vm, const std::strin } /** - * calls sq_insert_command for all entries of table/class on top of stack + * Calls sq_insert_command for all entries of table/class on top of stack. */ void sq_insert_commands(std::list& cmds, HSQUIRRELVM vm, const std::string& table_prefix, const std::string& search_prefix) { - sq_pushnull(vm); // push iterator + sq_pushnull(vm); // push iterator. while (SQ_SUCCEEDED(sq_next(vm,-2))) { sq_insert_command(cmds, vm, table_prefix, search_prefix); - sq_pop(vm, 2); // pop key, val + sq_pop(vm, 2); // pop key, val. } - sq_pop(vm, 1); // pop iterator + sq_pop(vm, 1); // pop iterator. } } -// End of Console::autocomplete helper functions +// End of Console::autocomplete helper functions. void Console::autocomplete() { - //int autocompleteFrom = m_inputBuffer.find_last_of(" ();+", m_inputBufferPosition); + // int autocompleteFrom = m_inputBuffer.find_last_of(" ();+", m_inputBufferPosition); int autocompleteFrom = static_cast(m_inputBuffer.find_last_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_->.", m_inputBufferPosition)); if (autocompleteFrom != static_cast(std::string::npos)) { autocompleteFrom += 1; @@ -366,22 +366,22 @@ Console::autocomplete() ready_vm(); - // append all keys of the current root table to list - sq_pushroottable(m_vm); // push root table + // Append all keys of the current root table to list. + sq_pushroottable(m_vm); // push root table. while (true) { - // check all keys (and their children) for matches + // Check all keys (and their children) for matches. sq_insert_commands(cmds, m_vm, "", prefix); - // cycle through parent(delegate) table + // Cycle through parent(delegate) table. SQInteger oldtop = sq_gettop(m_vm); if (SQ_FAILED(sq_getdelegate(m_vm, -1)) || oldtop == sq_gettop(m_vm)) { break; } - sq_remove(m_vm, -2); // remove old table + sq_remove(m_vm, -2); // Remove old table. } - sq_pop(m_vm, 1); // remove table + sq_pop(m_vm, 1); // Remove table. - // depending on number of hits, show matches or autocomplete + // Depending on number of hits, show matches or autocomplete. if (cmds.empty()) { m_buffer.addLines("No known command starts with \"" + prefix + "\""); @@ -389,7 +389,7 @@ Console::autocomplete() if (cmds.size() == 1) { - // one match: just replace input buffer with full command + // One match: just replace input buffer with full command. std::string replaceWith = cmds.front(); m_inputBuffer.replace(autocompleteFrom, prefix.length(), replaceWith); m_inputBufferPosition += static_cast(replaceWith.length() - prefix.length()); @@ -397,7 +397,7 @@ Console::autocomplete() if (cmds.size() > 1) { - // multiple matches: show all matches and set input buffer to longest common prefix + // Multiple matches: show all matches and set input buffer to longest common prefix. std::string commonPrefix = cmds.front(); while (cmds.begin() != cmds.end()) { std::string cmd = cmds.front(); @@ -416,14 +416,14 @@ Console::autocomplete() void Console::parse(const std::string& s) { - // make sure we actually have something to parse + // Make sure we actually have something to parse. if (s.length() == 0) return; - // add line to history + // Add line to history. m_history.push_back(s); m_history_position = m_history.end(); - // split line into list of args + // Split line into list of args. std::vector args; size_t end = 0; while (1) { @@ -433,12 +433,12 @@ Console::parse(const std::string& s) args.push_back(s.substr(start, end-start)); } - // command is args[0] + // Command is args[0]. if (args.size() == 0) return; std::string command = args.front(); args.erase(args.begin()); - // ignore if it's an internal command + // Ignore if it's an internal command. if (consoleCommand(command,args)) return; try { @@ -485,7 +485,7 @@ Console::hide() m_height = 0; m_stayOpen = 0; - // clear input buffer + // Clear the input buffer. } void diff --git a/src/supertux/error_handler.cpp b/src/supertux/error_handler.cpp index e1852706287..92a1c11d0d3 100644 --- a/src/supertux/error_handler.cpp +++ b/src/supertux/error_handler.cpp @@ -50,7 +50,7 @@ ErrorHandler::handle_error(int sig) { m_handing_error = true; // Do not use external stuff (like log_fatal) to limit the risk of causing - // another error, which would restart the handler again + // another error, which would restart the handler again. fprintf(stderr, "\nError: signal %d:\n", sig); print_stack_trace(); close_program(); @@ -64,10 +64,10 @@ ErrorHandler::print_stack_trace() void *array[127]; size_t size; - // get void*'s for all entries on the stack + // Get void*'s for all entries on the stack. size = backtrace(array, 127); - // print out all the frames to stderr + // Print out all the frames to stderr. backtrace_symbols_fd(array, static_cast(size), STDERR_FILENO); #endif } diff --git a/src/supertux/fadetoblack.cpp b/src/supertux/fadetoblack.cpp index 89c39bbfee4..1aa247372d2 100644 --- a/src/supertux/fadetoblack.cpp +++ b/src/supertux/fadetoblack.cpp @@ -44,7 +44,7 @@ FadeToBlack::draw(DrawingContext& context) col.alpha = 1.0f - col.alpha; // The colours are mixed directly in sRGB space, so change alpha for a more - // linear fading (it may only work correctly with black) + // linear fading (it may only work correctly with black). col.alpha = Color::remove_gamma(col.alpha); context.color().draw_filled_rect(Rectf(0, 0, diff --git a/src/supertux/game_manager.cpp b/src/supertux/game_manager.cpp index 370fdfb143c..e922558109c 100644 --- a/src/supertux/game_manager.cpp +++ b/src/supertux/game_manager.cpp @@ -62,7 +62,7 @@ GameManager::start_worldmap(const World& world, const std::string& worldmap_file auto filename = m_savegame->get_player_status().last_worldmap; // If we specified a worldmap filename manually, - // this overrides the default choice of "last worldmap" + // this overrides the default choice of "last worldmap". if (!worldmap_filename.empty()) { filename = worldmap_filename; @@ -109,7 +109,7 @@ GameManager::load_next_worldmap() log_warning << "Can't load world '" << m_next_worldmap << "'" << std::endl; return false; } - start_worldmap(*world, m_next_spawnpoint); // New world, new savegame + start_worldmap(*world, m_next_spawnpoint); // New world, new savegame. return true; } diff --git a/src/supertux/game_object_factory.cpp b/src/supertux/game_object_factory.cpp index 7eb9bb1c3d5..842c52cfe1d 100644 --- a/src/supertux/game_object_factory.cpp +++ b/src/supertux/game_object_factory.cpp @@ -163,7 +163,7 @@ GameObjectFactory::GameObjectFactory() void GameObjectFactory::init_factories() { - // badguys + // Badguys. m_adding_badguys = true; add_factory("angrystone"); add_factory("bouncingsnowball", OBJ_PARAM_DISPENSABLE); @@ -221,7 +221,7 @@ GameObjectFactory::init_factories() add_factory("stumpy", OBJ_PARAM_DISPENSABLE); add_factory("toad", OBJ_PARAM_DISPENSABLE); add_factory("totem", OBJ_PARAM_DISPENSABLE); - add_factory("poisonivy"); // backward compatibility + add_factory("poisonivy"); // Backward compatibilty. add_factory("viciousivy", OBJ_PARAM_DISPENSABLE); add_factory("walking_candle", OBJ_PARAM_DISPENSABLE); add_factory("walkingleaf", OBJ_PARAM_DISPENSABLE); @@ -231,9 +231,9 @@ GameObjectFactory::init_factories() add_factory("zeekling", OBJ_PARAM_DISPENSABLE); m_adding_badguys = false; - // other objects + // Other objects. add_factory("ambient-light"); - add_factory("ambient_sound"); // backward compatibilty + add_factory("ambient_sound"); // Backward compatibilty. add_factory("ambient-sound"); add_factory("background", OBJ_PARAM_WORLDMAP); add_factory("path"); @@ -290,7 +290,7 @@ GameObjectFactory::init_factories() add_factory("wind"); add_factory