Skip to content
Snippets Groups Projects
Commit 528b402f authored by Marie AUDOUARD's avatar Marie AUDOUARD
Browse files

corrected dragon breath + trajectory

parent 1b83f0e7
No related branches found
No related tags found
No related merge requests found
......@@ -42,18 +42,24 @@ void dragon::update_mvt()
timer_mvt.update();
float t = timer_mvt.t;
// clear trajectory when the timer restart + begin going in a circle
if (t < timer_mvt.t_min + 0.2f) //modified (was originally +0.1f so we are sure it passes through, even with low FPS)
// clear trajectory when gone past the first point
if (t > keyframe.key_times[1])
{
keyframe.trajectory.clear();
// Forget there was a first point so it goes in circles
if (timer_mvt.t_min == 0) {
timer_mvt.t_min = keyframe.key_times[1];
timer_mvt.t = keyframe.key_times[1] + t;
t = keyframe.key_times[1] + t;
keyframe.key_positions[0] = keyframe.key_positions[1];
keyframe.key_times[0] = keyframe.key_times[1];
numarray<vec3> key_positions;
numarray<float> key_times;
key_positions.resize(keyframe.key_positions.size() - 1);
key_times.resize(keyframe.key_positions.size() - 1);
for (int i = 0; i < keyframe.key_positions.size() - 1; i++) {
key_positions[i] = keyframe.key_positions[i + 1];
key_times[i] = keyframe.key_times[i + 1];
}
keyframe.key_positions = key_positions;
keyframe.key_times = key_times;
}
}
......
......@@ -95,8 +95,8 @@ void scene_structure::initialize()
float dragon_size = 0.5f;
numarray<vec3> dragon_keypos;
dragon_keypos.resize(14);
dragon_keypos[0] = { cos(-1) * terrain_length() / 2, sin(-1) * terrain_length() / 2, evaluate_terrain_height(terrain_length() / 2,terrain_length() / 2) };
for (int i = 1; i < 14; i++) dragon_keypos[i] = { cos( 2 * Pi * double(i%7-3)/3.0) * terrain_length() / 3, sin(2 * Pi * double(i % 7 - 3) / 3.0) * terrain_length() / 3, 0 };
dragon_keypos[0] = { cos(0) * terrain_length() / 2, sin(0) * terrain_length() / 2, evaluate_terrain_height(terrain_length() / 2,terrain_length() / 2) };
for (int i = 1; i < 14; i++) dragon_keypos[i] = { cos( 2 * Pi * double(i)/13.0) * terrain_length() / 3, sin(2 * Pi * double(i) / 13.0) * terrain_length() / 3, 0 };
numarray<float> dragon_keytimes = { 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f, 120.0f, 130.0f };
dragons.add_dragon(dragon_pos, dragon_size, dragon_keypos, dragon_keytimes);
......@@ -164,7 +164,7 @@ void scene_structure::initialize()
smoke.texture.initialize_texture_2d_on_gpu(smoke_grid[0], GL_REPEAT, GL_REPEAT);
//DRAGON FIRE
mesh fire_mesh = mesh_primitive_cone(3, 15, {0,0,0}, {-1,0,0}, false);
mesh fire_mesh = mesh_primitive_cone(3, 15, {18,0,0}, {-1,0,0}, false);
image_structure fire_breath_animation;
fire_breath_animation = image_load_file("assets/dragon/fire.png");
fire_breath_grid = image_split_grid(fire_breath_animation, 6, 5);
......@@ -218,14 +218,13 @@ void scene_structure::display_frame()
numarray<vec3> dragon_keypos;
dragon_keypos.resize(14);
float phase = rand_interval(0, 5);
dragon_keypos[0] = { cos(-1 + phase) * terrain_length() / 2, sin(-1 + phase) * terrain_length() / 2, evaluate_terrain_height(terrain_length() / 2,terrain_length() / 2) };
for (int i = 1; i < 14; i++) dragon_keypos[i] = { cos(phase + 2 * Pi * double(i % 7 - 3) / 3.0) * terrain_length() / 3, sin(phase + 2 * Pi * double(i % 7 - 3) / 3.0) * terrain_length() / 3, 0 };
dragon_keypos[0] = { cos(phase) * terrain_length() / 2, sin(phase) * terrain_length() / 2, evaluate_terrain_height(terrain_length() / 2,terrain_length() / 2) };
for (int i = 1; i < 14; i++) dragon_keypos[i] = { cos(phase + 2 * Pi * double(i) / 13.0) * terrain_length() / 3, sin(phase + 2 * Pi * double(i) / 13.0) * terrain_length() / 3, 0 };
numarray<float> dragon_keytimes = { 0.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f, 120.0f, 130.0f };
dragons.add_dragon(dragon_pos, dragon_size, dragon_keypos, dragon_keytimes);
//If it's the start of a new day, make bats go away
for (int i = 0; i < bats.N; i++) {
std::cout << "bat go away";
if (!bats.bats_prop[i].isdead) {
bats.bats_prop[i].keyframe.key_positions = { bats.bats_prop[i].pos, bats.bats_prop[i].pos + vec3(5,5,15), bats.bats_prop[i].pos + vec3(15,15,30), bats.bats_prop[i].pos + vec3(35,35,70) };
bats.bats_prop[i].keyframe.key_times = { 0,5,10, 20 };
......@@ -239,7 +238,6 @@ void scene_structure::display_frame()
//once they are far enough, remove bats
if (day_time() > 8 && day_time() < 9) {
bats.reset();
std::cout << "bat removed";
}
display_bats();
......@@ -409,9 +407,9 @@ void scene_structure::display_fire_breath(vec3 pos, rotation_transform rot, floa
glDepthMask(false);
int frame = 3 * t; //cast to int
fire_breath.texture.update(fire_breath_grid[frame]);
fire_breath.model.scaling_xyz = { double(9*t + 20) / (9*duration + 20),1,1 };
fire_breath.model.translation = pos;
fire_breath.model.rotation = rot;
fire_breath.model.translation = pos + 20 * double(9*t + 20) / (9*duration + 20) * rot * vec3(1, 0, 0);
fire_breath.model.scaling_xyz = { double(9 * t + 20) / (9 * duration + 20),1,1 };
draw(fire_breath, environment);
glDepthMask(true);
glDisable(GL_BLEND);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment