(x 100)
(y 170)
)
+ (secretarea (x 100) (y 170) (message "This is a Secret Area Test"))
(tilemap
(layer "background")
(solid #f)
#include "dispenser.h"
#include "badguy/bouncing_snowball.h"
#include "badguy/snowball.h"
+#include "badguy/mrbomb.h"
+#include "badguy/mriceblock.h"
Dispenser::Dispenser(LispReader& reader)
}
//TODO: Add launching velocity to badguys
-// Add more badguys and randomizer
+// Add randomizer
// Clean up stuff I copied without understanding what it does :)
-// Stop dispensing when game is paused
+// Stop dispensing when game is paused (timer related problem)
// Lots-O-Stuff (tm)
void
Dispenser::launch_badguy()
//FIXME: Does is_offscreen() work right here?
if (!is_offscreen()) {
if (badguy == "snowball")
- Sector::current()->add_object(new SnowBall(get_pos().x-2, get_pos().y));
+ Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y, dir));
else if (badguy == "bouncingsnowball")
- Sector::current()->add_object(new BouncingSnowball(get_pos().x-2, get_pos().y, dir));
+ Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, dir));
+ else if (badguy == "mrbomb")
+ Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y, dir));
+ else if (badguy == "mriceblock")
+ Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y, dir));
else if (badguy == "random")
{}
}
reader.read_float("y", start_position.y);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("mrbomb");
+ set_direction = false;
}
-MrBomb::MrBomb(float pos_x, float pos_y)
+MrBomb::MrBomb(float pos_x, float pos_y, Direction d)
{
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("mrbomb");
+ set_direction = true;
+ initial_direction = d;
}
void
void
MrBomb::activate()
{
+ if (set_direction) {dir = initial_direction;}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
{
public:
MrBomb(LispReader& reader);
- MrBomb(float pos_x, float pos_y);
+ MrBomb(float pos_x, float pos_y, Direction d);
void activate();
void write(LispWriter& writer);
protected:
bool collision_squished(Player& player);
+ bool set_direction;
+ Direction initial_direction;
};
#endif
reader.read_float("y", start_position.y);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("mriceblock");
+ set_direction = false;
+}
+
+MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d)
+ : ice_state(ICESTATE_NORMAL), squishcount(0)
+{
+ start_position.x = pos_x;
+ start_position.y = pos_y;
+ bbox.set_size(31.8, 31.8);
+ sprite = sprite_manager->create("mriceblock");
+ set_direction = true;
+ initial_direction = d;
}
void
void
MrIceBlock::activate()
{
+ if (set_direction) {dir = initial_direction;}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
{
public:
MrIceBlock(LispReader& reader);
+ MrIceBlock(float pos_x, float pos_y, Direction d);
void activate();
void write(LispWriter& writer);
IceState ice_state;
Timer2 flat_timer;
int squishcount;
+ bool set_direction;
+ Direction initial_direction;
};
#endif
static const float WALKSPEED = 90;
//TODO: Create sprite, give multiple hitpoints, limit max number of snowballs
-// Can only be killed when jumping, no idea why
// Stop actions when pause button is hit (probably a general problem of timers)
Nolok_01::Nolok_01(LispReader& reader)
{
void
Nolok_01::active_action(float elapsed_time)
{
- movement = physic.get_movement(elapsed_time);
if (action_timer.check()) {
- if (action == WALKING) {
- physic.set_velocity_y(700);
- action = JUMPING;
- action_timer.start(JUMP_TIME);
- }
- else if (action == JUMPING) {
+ switch (action) {
+ case WALKING:
+ {
+ physic.set_velocity_y(700);
+ action = JUMPING;
+ action_timer.start(JUMP_TIME);
+ break;
+ }
+ case JUMPING:
+ {
sprite->set_action("throw");
action = SHOOTING;
action_timer.start(SHOOT_TIME);
- }
- else if (action == SHOOTING) {
+ break;
+ }
+ case SHOOTING:
+ {
Sector::current()->add_object(new BouncingSnowball(get_pos().x - 64, get_pos().y, LEFT));
Sector::current()->add_object(new BouncingSnowball(get_pos().x + 64, get_pos().y, RIGHT));
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
action = WALKING;
action_timer.start(WALK_TIME);
+ break;
+ }
}
}
+ movement = physic.get_movement(elapsed_time);
}
bool
protected:
bool collision_squished(Player& player);
Timer2 action_timer;
- enum { WALKING, JUMPING, SHOOTING };
- int action;
+ enum Actions { WALKING, JUMPING, SHOOTING };
+ Actions action;
};
#endif
reader.read_float("y", start_position.y);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("snowball");
+ set_direction = false;
}
-SnowBall::SnowBall(float pos_x, float pos_y)
+SnowBall::SnowBall(float pos_x, float pos_y, Direction d)
{
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("snowball");
+ set_direction = true;
+ initial_direction = d;
}
void
void
SnowBall::activate()
{
+ if (set_direction) {dir = initial_direction;}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
{
public:
SnowBall(LispReader& reader);
- SnowBall(float pos_x, float pos_y);
+ SnowBall(float pos_x, float pos_y, Direction d);
void activate();
void write(LispWriter& writer);
protected:
bool collision_squished(Player& player);
+ bool set_direction;
+ Direction initial_direction;
};
#endif
#include "utils/lispwriter.h"
#include "gameloop.h"
-#define MESSAGE_TIME 3
+#define MESSAGE_TIME 3.5
+//TODO: Count numbers of triggered/total secret areas
SecretAreaTrigger::SecretAreaTrigger(LispReader& reader)
{
reader.read_float("x", bbox.p1.x);
bbox.set_size(32, 32);
reader.read_string("message", message);
+ message_displayed = false;
}
SecretAreaTrigger::SecretAreaTrigger(const Vector& pos)
bbox.set_pos(pos);
bbox.set_size(32, 32);
message = "You found a secret area!";
+ message_displayed = false;
}
SecretAreaTrigger::~SecretAreaTrigger()
SecretAreaTrigger::draw(DrawingContext& context)
{
if (message_timer.started()) {
+ context.push_transform();
+ context.set_translation(Vector(0, 0));
Vector pos = Vector(0, screen->h/2 - gold_text->get_height()/2);
context.draw_center_text(gold_text, message, pos, LAYER_GUI);
- //TODO: Prevent text from scrolling with the rest of the level
+ context.pop_transform();
}
if (message_timer.check()) {
remove_me();
SecretAreaTrigger::event(Player& , EventType type)
{
if(type == EVENT_TOUCH) {
- message_timer.start(MESSAGE_TIME);
+ if (!message_displayed) {
+ message_timer.start(MESSAGE_TIME);
+ message_displayed = true;
+ }
}
}
private:
std::string message;
Timer2 message_timer;
+ bool message_displayed;
};
#endif