summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-03-30 21:48:07 -0600
committercflip <cflip@cflip.net>2022-03-30 21:48:07 -0600
commit7803be09b7c0a133b1009408fea2fb1f1474e786 (patch)
tree351120df9e82973dfa5cda0f9945edbdb3936949 /src/main.cpp
parent2b35b393203403704b740f7627af701968c2dfcc (diff)
Store train objects in a unique_ptr
The trains were being destructed after leaving the scope of the addVehicle function. This change makes sure the trains stay allocated for the entire lifetime of the level. Fixes #2
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index dcd5975..25e6fea 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -46,9 +46,7 @@ int main(int argc, char** argv)
int my = y / Scale + yOffs;
auto pos = ScreenToTile({ mx, my });
- Train& train = level.addVehicle();
- train.setPosition(pos.x, pos.y);
- train.setSpeed(0.2f);
+ level.addVehicle(pos.x, pos.y);
}
});