SuperTuxKart
Loading...
Searching...
No Matches
spare_tire_ai.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2016 SuperTuxKart-Team
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_SPARE_TIRE_AI_HPP
20#define HEADER_SPARE_TIRE_AI_HPP
21
22#include "karts/controller/battle_ai.hpp"
23
27class SpareTireAI : public BattleAI
28{
29private:
32
35 int m_idx;
36
39
40 // ------------------------------------------------------------------------
41 virtual void findTarget() OVERRIDE;
42 // ------------------------------------------------------------------------
43 void findDefaultPath();
44
45public:
47 // ------------------------------------------------------------------------
48 virtual void crashed(const AbstractKart *k) OVERRIDE;
49 // ------------------------------------------------------------------------
50 virtual void update(int ticks) OVERRIDE;
51 // ------------------------------------------------------------------------
52 virtual void reset() OVERRIDE;
53 // ------------------------------------------------------------------------
54 void spawn(int ticks_to_last);
55 // ------------------------------------------------------------------------
56 void unspawn();
57 // ------------------------------------------------------------------------
60 bool isMoving() const { return m_idx != -1; }
61
62};
63
64#endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
The actual battle AI.
Definition: battle_ai.hpp:33
The AI for spare tire karts in battle mode, allowing kart to gain life.
Definition: spare_tire_ai.hpp:28
int m_idx
The current index of ArenaNode in m_fixed_target_nodes to follow, if it's -1, update is not needed to...
Definition: spare_tire_ai.hpp:35
void findDefaultPath()
Randomly find a start node for spare tire kart to move, called after spawn.
Definition: spare_tire_ai.cpp:83
void unspawn()
Unspawn the SpareTireAI, it will be hidden in the battle mode but not deleted, so it can be called wi...
Definition: spare_tire_ai.cpp:129
int m_timer
Store the time before calling unspawn.
Definition: spare_tire_ai.hpp:38
virtual void crashed(const AbstractKart *k) OVERRIDE
Callback function when a kart crashes into the SpareTireAI, the kart will increase one life if its li...
Definition: spare_tire_ai.cpp:140
void spawn(int ticks_to_last)
Spawn the SpareTireAI, it will start appearing in the battle mode and moving around.
Definition: spare_tire_ai.cpp:113
virtual void update(int ticks) OVERRIDE
Besides calling update from parent class, it will auto unspawn if m_timer reaches zero which it will ...
Definition: spare_tire_ai.cpp:70
virtual void reset() OVERRIDE
Resets the AI when a race is restarted.
Definition: spare_tire_ai.cpp:58
int m_fixed_target_nodes[4]
The 4 bounding boxes ArenaNode to follow.
Definition: spare_tire_ai.hpp:31
bool isMoving() const
Return true if this AI needed to be called update by World, ie it is spawned.
Definition: spare_tire_ai.hpp:60
virtual void findTarget() OVERRIDE
For SpareTireAI, it will pick next node in m_fixed_target_nodes after reach the one in m_idx,...
Definition: spare_tire_ai.cpp:97