summaryrefslogtreecommitdiff
path: root/src/train.h
blob: 3cd23e421b2fb1801dc835308b202c6909f0faf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include "bitmap.h"
#include "util.h"

class Level;

class Train {
public:
	explicit Train(Level& level)
		: m_sprite("res/car.png"), m_level(level) { }

	void update();
	void draw(Bitmap&, int, int);

	void setPosition(int x, int y);
	// Add a vehicle to the end of this train
	void addVehicle(Train*);

private:
	void findDirection();
	void findNextTile();

	Train* m_next { nullptr };
	Train* m_prev { nullptr };

	Bitmap m_sprite;
	Level& m_level;

	int x { 0 }, y { 0 };
	float m_speed { 0.05f };
	float m_progress { 0.f };

	Direction m_dir { North };
	int m_nextX { 0 }, m_nextY { 0 };
};