diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -5,6 +5,7 @@ #include "windows.h" #include "bitmap.h" #include "level.h" +#include "train.h" #include "iostream" #pragma comment(lib, "winmm.lib") // For audio files @@ -89,6 +90,7 @@ int main(int argc, char **argv) Level level(32, 32); Bitmap bitmap(Width, Height); + TrainCar car(0, 0); //bool audio_play1 = PlaySound(TEXT("res\\Starliner.wav"), NULL, SND_LOOP | SND_ASYNC); //Adds Starliner.wav and plays it on startup and loops, @@ -98,8 +100,6 @@ int main(int argc, char **argv) int xDrag, yDrag; bool isDragging = false; - - window.onMouseDown([&](int button, int x, int y) { if (button == 1) { static const auto update_direction = [&](int xt, int yt) { @@ -128,6 +128,12 @@ int main(int argc, char **argv) xDrag = x; yDrag = y; isDragging = true; + } else { + float mx = x / Scale + xOffs; + float my = y / Scale + yOffs; + auto pos = screenToTile({ mx, my }); + car.x = pos.x; + car.y = pos.y; } }); @@ -148,6 +154,8 @@ int main(int argc, char **argv) while (!window.shouldClose()) { window.update(); DrawLevel(bitmap, tiles, level, xOffs, yOffs); + car.update(level); + car.draw(bitmap, xOffs, yOffs); window.draw(bitmap); } |