# Rally Rush: src/enemy_car.hpp Source File

Loading...
Searching...
No Matches
enemy_car.hpp
Go to the documentation of this file.
#ifndef ENEMY_CAR_HPP
#define ENEMY_CAR_HPP
#include "car_physics.hpp"
#include "car_player.hpp"
#include "godot_cpp/classes/navigation_agent3d.hpp"
namespace godot {
class EnemyCar : public CarPhysics {
GDCLASS(EnemyCar, CarPhysics);
static void _bind_methods();
public:
virtual void _enter_tree() override;
virtual void _process(double delta_time) override;
void damage();
void start_fleeing();
void stop_fleeing();
protected:
void recalculate_navigation();
private:
int next_recalc{0};
int recalc_frame_interval{60};
float turn_target_speed{3.f};
float max_speed{45.f};
float brake_distance{7.f};
float steering_speed{1.5f};
bool flee{false};
NavigationAgent3D *agent{nullptr};
CarPlayer *player{nullptr};
};
}
#endif // !ENEMY_CAR_HPP
car_physics.hpp
car_player.hpp
godot::CarPhysics
Subclass Sandbox for car physics. Uses _integrate_forces and local_velocity to abstract the behaviour...
Definition car_physics.hpp:13
godot::CarPlayer
Sandboxed subclass of CarPhysics.
Definition car_player.hpp:18
godot::EnemyCar
The enemy car, inherits CarPhysics subclass sandbox and uses a NavigationAgent3D to direct it.
Definition enemy_car.hpp:10
godot::EnemyCar::max_speed
float max_speed
Max speed when driving straight ahead.
Definition enemy_car.hpp:36
godot::EnemyCar::_bind_methods
static void _bind_methods()
Register damage function.
Definition enemy_car.cpp:9
godot::EnemyCar::GDCLASS
GDCLASS(EnemyCar, CarPhysics)
godot::EnemyCar::turn_target_speed
float turn_target_speed
Desired speed when approaching a corner.
Definition enemy_car.hpp:34
godot::EnemyCar::recalculate_navigation
void recalculate_navigation()
Calculate a new path to the player.
Definition enemy_car.cpp:51
godot::EnemyCar::agent
NavigationAgent3D * agent
Navigation agent child node.
Definition enemy_car.hpp:44
godot::EnemyCar::brake_distance
float brake_distance
Distance from corners at which to start braking.
Definition enemy_car.hpp:38
godot::EnemyCar::recalc_frame_interval
int recalc_frame_interval
Interval in frames between calls to recalculate_navigation.
Definition enemy_car.hpp:32
godot::EnemyCar::steering_speed
float steering_speed
Speed at which to steer.
Definition enemy_car.hpp:40
godot::EnemyCar::_process
virtual void _process(double delta_time) override
Update current navigation and acceleration. Recalculate path every recalc_frame_interval frames....
Definition enemy_car.cpp:25
godot::EnemyCar::stop_fleeing
void stop_fleeing()
Called from RallyRushGameMode shield pickup end observer. Stop fleeing from the player.
Definition enemy_car.cpp:47
godot::EnemyCar::damage
void damage()
Destroy this object.
Definition enemy_car.cpp:39
godot::EnemyCar::_enter_tree
virtual void _enter_tree() override
Call parent _enter_tree and fetch object references for later use.
Definition enemy_car.cpp:14
godot::EnemyCar::next_recalc
int next_recalc
Frame timer to next recalculate_navigation call.
Definition enemy_car.hpp:30
godot::EnemyCar::flee
bool flee
If true, invert goal direction and drive away from the player.
Definition enemy_car.hpp:42
godot::EnemyCar::start_fleeing
void start_fleeing()
Called from RallyRushGameMode shield pickup observer. Start fleeing from the player.
Definition enemy_car.cpp:43
godot::EnemyCar::player
CarPlayer * player
Reference to the player car.
Definition enemy_car.hpp:46
godot
Definition beacon_powerup.cpp:6