diff options
author | cflip <cflip@cflip.net> | 2022-03-24 09:16:57 -0600 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2022-03-24 09:16:57 -0600 |
commit | 09cc67351ec68ed37b2e664c9654f9aabd8fa33b (patch) | |
tree | b55de41df42050729e6c5d0db93a29c1b31933ce | |
parent | 0d99c20d0fafcf2b86d9d33430659de76b030395 (diff) |
Don't create a copy of the train graphics per vehicle
-rw-r--r-- | src/train.cpp | 4 | ||||
-rw-r--r-- | src/train.h | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/train.cpp b/src/train.cpp index d3ea7fb..cfbae97 100644 --- a/src/train.cpp +++ b/src/train.cpp @@ -3,6 +3,8 @@ #include "bitmap.h" #include "level.h" +static const Bitmap SPRITES("res/car.png"); + void Train::update() { if (m_next) { @@ -42,7 +44,7 @@ void Train::draw(Bitmap& bitmap, int xo, int yo) int tx = 0; if (m_dir == East || m_dir == West) tx = 24; - bitmap.blit(m_sprite, xx, yy, tx, 0, TileSize, TileSize); + bitmap.blit(SPRITES, xx, yy, tx, 0, TileSize, TileSize); } void Train::setPosition(int tx, int ty) diff --git a/src/train.h b/src/train.h index 178583f..d47818e 100644 --- a/src/train.h +++ b/src/train.h @@ -8,7 +8,7 @@ class Level; class Train { public: explicit Train(Level& level) - : m_sprite("res/car.png"), m_level(level) { } + : m_level(level) { } void update(); void draw(Bitmap&, int, int); @@ -25,7 +25,6 @@ private: Train* m_next { nullptr }; Train* m_prev { nullptr }; - Bitmap m_sprite; Level& m_level; int x { 0 }, y { 0 }; |