summaryrefslogtreecommitdiff
path: root/src/level.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/level.cpp')
-rw-r--r--src/level.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/level.cpp b/src/level.cpp
index 54cf7f0..92ec208 100644
--- a/src/level.cpp
+++ b/src/level.cpp
@@ -1,4 +1,5 @@
#include "level.h"
+#include "train.h"
#include "util.h"
Level::Level(int width, int height, Bitmap& tileSprites)
@@ -23,6 +24,13 @@ void Level::set(int x, int y, uint8_t tile)
m_tiles[x + y * m_width] = tile;
}
+void Level::update()
+{
+ for (Train* vehicle : m_vehicles) {
+ if (vehicle) vehicle->update();
+ }
+}
+
void Level::draw(Bitmap& bitmap, int xo, int yo)
{
for (int y = 0; y < 32; ++y) {
@@ -58,6 +66,15 @@ void Level::draw(Bitmap& bitmap, int xo, int yo)
bitmap.blit(m_tileSprites, xx, yy, tx * TileSize, ty * TileSize, TileSize, TileSize);
}
}
+
+ for (Train* vehicle : m_vehicles) {
+ if (vehicle) vehicle->draw(bitmap, xo, yo);
+ }
+}
+
+void Level::addVehicle(Train& vehicle)
+{
+ m_vehicles.emplace_back(&vehicle);
}
void Level::toggleTile(int x, int y)