World: Clean warnings, optimize GetBlock
World has a lot of type conversion warnings. Take care of most of them, for a slight performance hit ( :( ). Re-order constructor parameters to match declaration. Move FillColumn to a more appropriate place. GetBlock gets called a lot : use direct memory access of the vector rather than going through bounds checks with .at(). Introduce an integer overload to remove warnings.
This commit is contained in:
parent
7fe17df587
commit
fa75fe4bba
2 changed files with 37 additions and 24 deletions
7
World.h
7
World.h
|
@ -30,8 +30,9 @@ public:
|
|||
int getW() const;
|
||||
int getH() const;
|
||||
|
||||
inline BlockType getBlock(float x, float y) const;
|
||||
void setBlock(BlockType block, int x, int y, int width = 1, int height = 1);
|
||||
inline BlockType getBlock(int x, int y) const;
|
||||
inline BlockType getBlock(float x, float y) const;
|
||||
void setBlock(BlockType block, int x, int y, int width = 1, int height = 1);
|
||||
|
||||
void render(sf::RenderWindow&) const;
|
||||
|
||||
|
@ -50,7 +51,7 @@ private:
|
|||
sf::Color groundColor;
|
||||
sf::Color ceilingColor;
|
||||
|
||||
void fillColumn(sf::RenderWindow&, int column, float scale,
|
||||
void fillColumn(sf::RenderWindow&, unsigned int column, float scale,
|
||||
sf::Color wallColor = sf::Color(84,56,34)) const;
|
||||
/**
|
||||
* Cast a ray from a given position and return the on-screen scale.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue