4 #include "badguy/bouncing_snowball.h"
5 #include "trigger/door.h"
11 static const float WALKSPEED = 80;
13 //TODO: Create sprite, give multiple hitpoints, limit max number of snowballs
14 // Can only be killed when jumping, no idea why
15 Nolok_01::Nolok_01(LispReader& reader)
17 reader.read_float("x", start_position.x);
18 reader.read_float("y", start_position.y);
19 bbox.set_size(31.8, 31.8);
20 sprite = sprite_manager->create("dummyguy");
23 Nolok_01::Nolok_01(float pos_x, float pos_y)
25 start_position.x = pos_x;
26 start_position.y = pos_y;
27 bbox.set_size(31.8, 31.8);
28 sprite = sprite_manager->create("dummyguy");
32 Nolok_01::write(LispWriter& writer)
34 writer.start_list("nolok01");
36 writer.write_float("x", get_pos().x);
37 writer.write_float("y", get_pos().y);
39 writer.end_list("nolok01");
45 physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
46 sprite->set_action(dir == LEFT ? "left" : "right");
47 action_timer.start(SHOOT_TIME, true);
51 Nolok_01::active_action(float elapsed_time)
53 movement = physic.get_movement(elapsed_time);
54 if (action_timer.check()) {
55 physic.set_velocity_y(700);
56 jump_timer.start(JUMP_TIME);
58 if (jump_timer.check()) {
59 sprite->set_action("throw");
60 idle_timer.start(IDLE_TIME);
62 if (idle_timer.check()) {
63 Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT));
64 Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT));
65 physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
66 sprite->set_action(dir == LEFT ? "left" : "right");
71 Nolok_01::collision_squished(Player& player)
73 sprite->set_action("dead");
74 kill_squished(player);
75 Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2"));
80 Nolok_01::collision_solid(GameObject& , const CollisionHit& hit)
82 if(fabsf(hit.normal.y) > .5) { // hit floor or roof?
83 //physic.set_velocity_y(0);
84 } else { // hit right or left
85 dir = dir == LEFT ? RIGHT : LEFT;
86 sprite->set_action(dir == LEFT ? "left" : "right");
87 physic.set_velocity_x(-physic.get_velocity_x());