SuperTuxKart
Loading...
Searching...
No Matches
check_goal.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2012-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_CHECK_GOAL_HPP
20#define HEADER_CHECK_GOAL_HPP
21
22#include "tracks/check_structure.hpp"
23#include "utils/cpp2011.hpp"
24#include <line2d.h>
25using namespace irr;
26
27class XMLNode;
28class Track;
29class Vec3;
30
38{
39public:
42 {
43 POINT_FIRST,
44 POINT_CENTER,
45 POINT_LAST
46 };
47private:
50
53
55 core::line2df m_line;
56
59 Vec3 m_p2;
60 Vec3 m_p3;
61
62public:
63 CheckGoal(const XMLNode &node, unsigned int index);
64 virtual ~CheckGoal() {}
65 virtual void update(float dt) OVERRIDE;
66 virtual void trigger(unsigned int kart_index) OVERRIDE;
67 virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
68 int indx) OVERRIDE;
69 virtual void reset(const Track &track) OVERRIDE;
70
71 // ------------------------------------------------------------------------
72 bool getTeam() const { return m_first_goal; }
73 // ------------------------------------------------------------------------
74 const Vec3& getPoint(PointLocation point) const
75 {
76 return (point == POINT_LAST ? m_p3 :
77 (point == POINT_CENTER ? m_p2 : m_p1));
78 }
79 // ------------------------------------------------------------------------
80 virtual CheckStructure* clone() OVERRIDE
81 { return new CheckGoal(*this); }
82}; // CheckGoal
83
84#endif
Implements a simple checkline that will score a point when the soccer ball crosses it.
Definition: check_goal.hpp:38
Vec3 m_previous_ball_position
Previois ball position.
Definition: check_goal.hpp:49
virtual CheckStructure * clone() OVERRIDE
Clone to child process for server usage (atm no sound or scripting).
Definition: check_goal.hpp:80
virtual void reset(const Track &track) OVERRIDE
Initialises the 'previous positions' of all karts with the start position defined for this track.
Definition: check_goal.cpp:102
bool m_first_goal
Which team is this goal for?
Definition: check_goal.hpp:52
Vec3 m_p1
Used by AIs to test whether the ball is likely to goal.
Definition: check_goal.hpp:58
PointLocation
Used by AIs to test whether the ball is likely to goal.
Definition: check_goal.hpp:42
virtual void update(float dt) OVERRIDE
Checks the soccer balls to see if they crossed the line and trigger the goal accordingly.
Definition: check_goal.cpp:52
virtual void trigger(unsigned int kart_index) OVERRIDE
Called when the goal line is triggered.
Definition: check_goal.cpp:75
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx) OVERRIDE
True if going from old_pos to new_pos crosses this checkline.
Definition: check_goal.cpp:89
core::line2df m_line
The line that is tested for being crossed.
Definition: check_goal.hpp:55
Virtual base class for a check structure.
Definition: check_structure.hpp:52
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48