Skip to content

Commit

Permalink
fix: gravity particles on moving gravity flips appears in the right spot
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahkittyy committed Nov 1, 2022
1 parent 5657703 commit 3397f47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions game/moving_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "debug.hpp"
#include "resource.hpp"
#include "tilemap.hpp"

#include <algorithm>

Expand Down Expand Up @@ -342,6 +343,8 @@ void moving_blob::m_sync_tiles() {
tile.m_yp = tpos.y;
tile.m_xv = m_xv;
tile.m_yv = m_yv;
tile.m_t.m_x = tile.m_xp;
tile.m_t.m_y = tile.m_yp;
debug::get() << "i = " << i << " " << tpos << "\n";
}
}
Expand Down
8 changes: 4 additions & 4 deletions game/tilemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ void tilemap::load(std::string str) {
m_tiles.resize(m_xs * m_ys, tile::empty);
std::istringstream ss(str);
for (int i = 0; i < m_xs * m_ys; ++i) {
m_tiles[i].m_x = i % m_xs;
m_tiles[i].m_y = i / m_xs;
m_tiles[i].m_x = int(i % m_xs);
m_tiles[i].m_y = int(i / m_xs);
if (ss.peek() == '/') {
m_tiles[i].type = tile::empty;
char ch;
Expand Down Expand Up @@ -443,11 +443,11 @@ bool tile::operator!=(const tile_type&& type) const {
return type != this->type;
}

int tile::x() const {
float tile::x() const {
return m_x;
}

int tile::y() const {
float tile::y() const {
return m_y;
}

Expand Down
8 changes: 5 additions & 3 deletions game/tilemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct tile {
bool operator!=(const tile_type&& type) const; // check if a tile is not of a given type
operator int() const; // retrieve the texture index of the tile

int x() const; // x pos of the tile
int y() const; // y pos of the tile
float x() const; // x pos of the tile
float y() const; // y pos of the tile

static std::string description(tile_type type); // a user-friendly description of the tile

Expand All @@ -69,8 +69,10 @@ struct tile {
bool editor_only() const; // tiles only visible in the editor
private:
friend class tilemap;
friend class moving_tile;
friend class moving_blob;
tile(tile_type type, int x, int y);
int m_x = -1, m_y = -1;
float m_x = -1, m_y = -1;
};

// stores and renders all static tiles in a level
Expand Down

0 comments on commit 3397f47

Please sign in to comment.