Skip to content

Commit

Permalink
feat: animal tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadecraft committed Apr 8, 2024
1 parent e277e84 commit b80ca06
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ set(ASSETS
essential.txt
tiv_logo.png
grass1.png
sand.png
yellowpad.png
spike.png
level_0.csv
Expand All @@ -72,6 +73,8 @@ set(ASSETS
enemy_replicator_0.png
enemy_replicator_1.png
enemy_replicator_2.png
enemy_addax_0.png
enemy_addax_1.png
)

foreach(ASSET ${ASSETS})
Expand Down
Binary file added src/assets/enemy_addax_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/enemy_addax_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 7 additions & 27 deletions src/assets/level_2.csv
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
// First Level (level_1)
nextLevelName, level_2
// Bottom colliders
StaticCollider, 3, 25, 6, 2
//StaticCollider, 9, 27, 10, 2
StaticCollider, 19, 25, 6, 2
// Vertical colliders
StaticCollider, 0, 0, 2, 25
StaticCollider, 25, 0, 2, 19
// Main large bottom block
StaticCollider, 23, 29, 80, 19
// Rightmost barrier
StaticCollider, 103, 26, 2, 3
// Ending teleporter
LevelTp, 100, 28
// Spike
Spike, 28, 28
// Static deadly section
StaticDeadly, 33, 28, 5, 2
// Moving Platforms
MovingCollider, 8, 32, 5, 2, 300, 20, 32
MovingCollider, 40, 24, 5, 2, 300, 40, 15
MovingCollider, 47, 15, 5, 2, 300, 45, 15
// Animals
Animal, bird, 50, 15
Animal, fipa, 55, 15
Animal, replicator, 58, 15
// Second level (level_2)
// Cycle back to the start
nextLevelName, level_1
// Bottom collider
StaticCollider, 2, 30, 30, 2
// Next level
LevelTp, 50, 29
Binary file added src/assets/sand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/gamestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ UpdateResult GameState::update() {
Animal* animal1 = new Animal(
"replicator", (*it)->getLocx(), (*it)->getLocy()
);
animal1->teleport(animal1->getLocx() - 0.7, animal1->getLocy());
animal1->teleport(animal1->getLocx() - 1.5, animal1->getLocy()); // -0.7
animal1->setDimensions((*it)->getWidth() * 0.8, (*it)->getHeight() * 0.8);
newToSpawn.push_back(animal1);
Animal* animal2 = new Animal(
"replicator", (*it)->getLocx(), (*it)->getLocy()
);
animal2->teleport(animal2->getLocx() + 0.7, animal2->getLocy());
animal2->teleport(animal2->getLocx() + 1.5, animal2->getLocy());
animal2->setDimensions((*it)->getWidth() * 0.8, (*it)->getHeight() * 0.8);
animal2->reverseDirection();
newToSpawn.push_back(animal2);
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ int main() {

// Main game loop
while (window.isOpen()) {
// TODO: Frame acceleration thing (for consistent speed/timing)
// Poll events
for (auto event = sf::Event{}; window.pollEvent(event);) {
if (event.type == sf::Event::Closed) {
Expand Down
16 changes: 15 additions & 1 deletion src/worldobjects/animal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@ const std::map<std::string, AnimalData> Animal::animalDefaults = {
3.0,
3.0,
{
ObjectAttribute::OverlapDetect,
ObjectAttribute::Collision,
ObjectAttribute::Deadly
}
}
},
{
"addax",
{
"Addax",
"enemy_addax",
2.0,
0,
3.0,
3.0,
{
ObjectAttribute::Collision
}
}
}
};
1 change: 1 addition & 0 deletions src/worldobjects/animal.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Animal : public WorldObject {
bool overlapped = false;
if (object->hasAttribute(ObjectAttribute::Collision)) {
// X movement pushout
// todo: improve time complexity (O(n^2) :skull:)
// todo: better way of doing the 0.1 thing (subtract velocity instead?)
if (locy + height - 0.1 >= object->getLocy() && locy + 0.1 < object->getLocy() + object->getHeight()) {
// Within the y
Expand Down
2 changes: 1 addition & 1 deletion src/worldobjects/staticcollider.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StaticCollider : public WorldObject {
width,
height,
{ 14, 92, 81 },
"assets/grass1.png"
"assets/grass1.png" // TODO: allow rendering sand
};
}
};

0 comments on commit b80ca06

Please sign in to comment.