66
69
if (ycol) {velocity.y = 0;}
71
if (velocity.GetSquaredMagnitude() > 20)
74
footsteps->Pause(); //Stop()?
69
76
//Scene::GetCamera()->position = position;
79
Creature::Creature() : Entity(),
84
sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
85
sprite->Add("idle", 0, 0, 0.35f);
86
sprite->Add("move", 1, 2, 4.0f);
91
SetCollider(new RectangleCollider(32, 32));
93
skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
94
skitter1->SetLoops(0); //loop indefinitely
96
velocity = Vector2::Random() * ACCELERATION;
98
//set aiTime to random so creatures tick at different times
99
aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
102
void Creature::Update()
106
aiTime += Monocle::deltaTime;
113
direction = Vector2::zero;
117
if (state != "wander") {
118
//printf("wander\n");
119
direction = Vector2::Random();
128
velocity += direction * ACCELERATION * Monocle::deltaTime;
130
velocity.x = APPROACH(velocity.x, 0, FRICTION * Monocle::deltaTime);
131
velocity.y = APPROACH(velocity.y, 0, FRICTION * Monocle::deltaTime);
136
position.x += velocity.x * Monocle::deltaTime;
137
while (Collide("Solid"))
140
if (velocity.x == 0) { break; }
141
//printf("collision1\n");
142
position.x -= SIGN(velocity.x, 0.1);
144
if (xcol) {velocity.x = 0;}
146
position.y += velocity.y * Monocle::deltaTime;
147
while (Collide("Solid"))
150
if (velocity.y == 0) { break; }
151
//printf("collision2\n");
152
position.y -= SIGN(velocity.y, 0.1);
154
if (ycol) {velocity.y = 0;}
156
if (velocity.GetSquaredMagnitude() > 20)
159
sprite->Play("move");
163
skitter1->Pause(); //Stop()?
164
sprite->Play("idle");
74
170
DarkScene::DarkScene() : Scene()
115
211
player->position = Graphics::GetScreenCenter();
118
Graphics::SetBackgroundColor(Color::green * 0.2f);
214
Creature *creature = new Creature;
215
creature->position = Graphics::GetScreenCenter();
218
Creature *creature2 = new Creature;
219
creature2->position = Graphics::GetScreenCenter();
222
Graphics::SetBackgroundColor(Color::black * 0.2f);