4 #include "badguy/bouncing_snowball.h"
5 #include "trigger/door.h"
11 static const float WALKSPEED = 90;
13 //TODO: Create sprite, give multiple hitpoints, limit max number of snowballs
14 // Stop actions when pause button is hit (probably a general problem of timers)
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, 63.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, 63.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");
48 action_timer.start(WALK_TIME);
52 Nolok_01::active_action(float elapsed_time)
54 if (action_timer.check()) {
58 physic.set_velocity_y(700);
60 action_timer.start(JUMP_TIME);
65 sprite->set_action("throw");
67 action_timer.start(SHOOT_TIME);
72 Sector::current()->add_object(new BouncingSnowball(get_pos().x - 64, get_pos().y, LEFT));
73 Sector::current()->add_object(new BouncingSnowball(get_pos().x + 64, get_pos().y, RIGHT));
74 physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
75 sprite->set_action(dir == LEFT ? "left" : "right");
77 action_timer.start(WALK_TIME);
82 movement = physic.get_movement(elapsed_time);
86 Nolok_01::collision_squished(Player& player)
88 sprite->set_action("dead");
89 kill_squished(player);
90 Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2"));
95 Nolok_01::collision_solid(GameObject& , const CollisionHit& hit)
97 if(fabsf(hit.normal.y) > .5){ // hit floor or roof?
98 if (action != JUMPING) physic.set_velocity_y(0);
99 } else { // hit right or left
100 dir = dir == LEFT ? RIGHT : LEFT;
101 sprite->set_action(dir == LEFT ? "left" : "right");
102 physic.set_velocity_x(-physic.get_velocity_x());