-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Root Sapling (a.k.a. Corrupted Mole) #2698
Changes from 1 commit
8af51da
4baf94d
c1ea7fb
6a93716
1c2e4cf
ebc10d6
586a7fa
7f4380d
b173066
cba5ca4
b71d000
50bff43
ef11852
9d840ca
bbce263
86ee558
3a82433
3241702
2892df7
7b26652
d60dd60
5ae94bf
19dfa71
94635e7
5182555
6c269b2
4a99708
aea5873
ed042f6
bad5506
1ee0c0e
73cd7bd
72b8d12
f02508f
d7ecaa8
da354a1
e59ee84
f0648e1
e659c62
41d593e
a0f058f
21a0e72
584c72c
87354f0
f37b90b
5a4f34c
396bba9
4ce2da0
4c76868
d110442
a074434
86dceab
1719b09
6cba68a
4e0b393
32ba221
a6f40e2
128837f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,12 @@ | |
#include "supertux/sector.hpp" | ||
#include "util/reader_mapping.hpp" | ||
|
||
static const float ROOT_SAPLING_RANGE = 32.f*20; | ||
static const float ROOT_SAPLING_RANGE = 32.f * 20; | ||
static const float ROOT_SAPLING_SPAWN_TIME = 2.f; | ||
|
||
RootSapling::RootSapling(const ReaderMapping& reader) : | ||
BadGuy(reader, "images/creatures/mole/corrupted/root_sapling.sprite", Direction::UP, | ||
LAYER_TILES-15, "images/creatures/mole/corrupted/core_glow/core_glow.sprite"), | ||
LAYER_TILES - 15, "images/creatures/mole/corrupted/core_glow/core_glow.sprite"), | ||
m_root_timer(), | ||
m_dead(false) | ||
{ | ||
|
@@ -84,15 +84,15 @@ RootSapling::collision_squished(GameObject& object) | |
set_colgroup_active(COLGROUP_DISABLED); | ||
|
||
auto player = dynamic_cast<Player*>(&object); | ||
if (player) { | ||
if (player) | ||
player->bounce(*this); | ||
} | ||
|
||
run_dead_script(); | ||
return true; | ||
} | ||
|
||
HitResponse RootSapling::collision_player(Player &player, const CollisionHit &hit) | ||
HitResponse | ||
RootSapling::collision_player(Player& player, const CollisionHit& hit) | ||
{ | ||
if (m_dir != Direction::DOWN || !hit.bottom) | ||
return BadGuy::collision_player(player, hit); | ||
|
@@ -158,9 +158,9 @@ RootSapling::summon_root() | |
(*axis) = player->get_bbox().get_bottom() + 1; | ||
|
||
bool should_summon = false; | ||
for (TileMap* map : Sector::get().get_solid_tilemaps()) | ||
for (TileMap* tilemap : Sector::get().get_solid_tilemaps()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a more verbose variable name. |
||
{ | ||
const Tile& tile = map->get_tile_at(pos); | ||
const Tile& tile = tilemap->get_tile_at(pos); | ||
if (tile.is_solid()) | ||
{ | ||
should_summon = true; | ||
|
@@ -177,23 +177,23 @@ RootSapling::summon_root() | |
switch (m_dir) | ||
{ | ||
case Direction::UP: | ||
eye = {player->get_bbox().get_middle().x, player->get_bbox().get_bottom() + 1}; | ||
end = {eye.x, eye.y + ROOT_SAPLING_RANGE}; | ||
eye = { player->get_bbox().get_middle().x, player->get_bbox().get_bottom() + 1 }; | ||
end = { eye.x, eye.y + ROOT_SAPLING_RANGE }; | ||
break; | ||
|
||
case Direction::DOWN: | ||
eye = {player->get_bbox().get_middle().x, player->get_bbox().get_top() - 1}; | ||
end = {eye.x, eye.y - ROOT_SAPLING_RANGE}; | ||
eye = { player->get_bbox().get_middle().x, player->get_bbox().get_top() - 1 }; | ||
end = { eye.x, eye.y - ROOT_SAPLING_RANGE }; | ||
break; | ||
|
||
case Direction::LEFT: | ||
eye = {player->get_bbox().get_right() + 1, player->get_bbox().get_middle().y}; | ||
end = {eye.x + ROOT_SAPLING_RANGE, eye.y}; | ||
eye = { player->get_bbox().get_right() + 1, player->get_bbox().get_middle().y }; | ||
end = { eye.x + ROOT_SAPLING_RANGE, eye.y }; | ||
break; | ||
|
||
case Direction::RIGHT: | ||
eye = {player->get_bbox().get_left() - 1, player->get_bbox().get_middle().y}; | ||
end = {eye.x - ROOT_SAPLING_RANGE, eye.y}; | ||
eye = { player->get_bbox().get_left() - 1, player->get_bbox().get_middle().y }; | ||
end = { eye.x - ROOT_SAPLING_RANGE, eye.y }; | ||
break; | ||
|
||
default: assert(false); break; | ||
|
@@ -204,37 +204,33 @@ RootSapling::summon_root() | |
reverse_raycast(eye, end); | ||
|
||
auto tile_p = std::get_if<const Tile*>(&result.hit); | ||
if (tile_p && !result.box.empty()) | ||
{ | ||
switch (m_dir) | ||
{ | ||
case Direction::UP: | ||
case Direction::DOWN: | ||
if ((*tile_p)->is_unisolid()) | ||
return; | ||
(*axis) = result.box.p1().y; | ||
break; | ||
|
||
case Direction::LEFT: | ||
case Direction::RIGHT: | ||
if ((*tile_p)->is_unisolid()) | ||
return; | ||
(*axis) = result.box.p1().x; | ||
break; | ||
|
||
/* | ||
case Direction::DOWN: | ||
case Direction::RIGHT: | ||
(*axis) = reverse_raycast(result.box); | ||
break; | ||
*/ | ||
|
||
default: assert(false); break; | ||
} | ||
} | ||
else | ||
{ | ||
if (!tile_p || result.box.empty()) | ||
return; | ||
|
||
switch (m_dir) | ||
{ | ||
case Direction::UP: | ||
case Direction::DOWN: | ||
if ((*tile_p)->is_unisolid()) | ||
return; | ||
(*axis) = result.box.p1().y; | ||
break; | ||
|
||
case Direction::LEFT: | ||
case Direction::RIGHT: | ||
if ((*tile_p)->is_unisolid()) | ||
return; | ||
(*axis) = result.box.p1().x; | ||
break; | ||
|
||
/* | ||
case Direction::DOWN: | ||
case Direction::RIGHT: | ||
(*axis) = reverse_raycast(result.box); | ||
break; | ||
*/ | ||
|
||
default: assert(false); break; | ||
} | ||
} | ||
|
||
|
@@ -280,22 +276,22 @@ RootSapling::summon_root() | |
bool | ||
RootSapling::should_summon_root(const Rectf& bbox) | ||
{ | ||
for (const auto& solids : Sector::get().get_solid_tilemaps()) { | ||
for (const auto& solids : Sector::get().get_solid_tilemaps()) | ||
{ | ||
if (solids->get_path()) | ||
// Do not support moving tilemaps. Not planned. | ||
continue; | ||
continue; // Do not support moving tilemaps. Not planned. | ||
|
||
// Test with all tiles in the root's hitbox | ||
const Rect test_tiles = solids->get_tiles_overlapping(bbox); | ||
|
||
for (int x = test_tiles.left; x < test_tiles.right; ++x) { | ||
for (int y = test_tiles.top; y < test_tiles.bottom; ++y) { | ||
for (int x = test_tiles.left; x < test_tiles.right; ++x) | ||
{ | ||
for (int y = test_tiles.top; y < test_tiles.bottom; ++y) | ||
{ | ||
const Tile& tile = solids->get_tile(x, y); | ||
|
||
if (!(tile.get_attributes() & Tile::SOLID)) | ||
{ | ||
goto next_tilemap; | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,8 +124,7 @@ class Sprite final | |
Blend get_blend() const; | ||
|
||
bool has_action (const std::string& name) const { return (m_data.get_action(name) != nullptr); } | ||
|
||
std::size_t get_actions_count() { return m_data.actions.size(); } | ||
size_t get_actions_count() const { return m_data.actions.size(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nowhere does the code specify |
||
|
||
private: | ||
void update(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought types came first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions first, then enumerators and variables, so everything is fully organized.