Debian Codegraph @

src/game/offtrackdetector.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2015 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef OFFTRACKDETECTOR_HPP
17 #define OFFTRACKDETECTOR_HPP
18
19 #include <memory>
20
21 #include <MCVector2d>
22
23 class Car;
24 class Track;
25 class TrackTile;
26
27 //! Detects if a car is off the track.
28 class OffTrackDetector
29 {
30 public:
31 //! Constructor.
32 OffTrackDetector(Car & car);
33
34 //! Set the current track.
35 void setTrack(std::shared_ptr<Track> track);
36
37 //! Update.
38 void update();
39
40 private:
41 //! Test if the given location is off the track on the given tile.
42 bool isOffTrack(MCVector2dF tire, const TrackTile & tile) const;
43
44 Car & m_car;
45
46 std::shared_ptr<Track> m_track;
47
48 float m_tileWLimit;
49
50 float m_tileHLimit;
51 };
52
53 #endif // OFFTRACKDETECTOR_HPP