Skip to content
Snippets Groups Projects
projectile.cpp 482 B
Newer Older
#include "projectile.hpp"
#include "terrain.hpp"
#include "settings.hpp"
void projectile::simulateParabolic(float dt) {
	if (pos[2] < -1 || cgp::abs(pos[0]) > terrain_length() / 2 || cgp::abs(pos[1]) > terrain_length() / 2) {
		pos = { 0,0, evaluate_terrain_height(0,0) };
		v = { 3 * rand_interval(), 3 * rand_interval(), 4};
	}
	else {
		pos += v * dt;
		v[2] -= 10 * dt;
	if (pos[2] < evaluate_terrain_height(pos[0], pos[1])) {
		pos = { 0, 0, -1};
		v = { 0,0,0 };