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);
90
SetCollider(new RectangleCollider(32, 32));
92
skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
93
skitter1->SetLoops(0); //loop indefinitely
95
velocity = Vector2::Random() * ACCELERATION;
97
//set aiTime to random so creatures tick at different times
98
aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
101
void Creature::Update()
105
aiTime += Monocle::deltaTime;
112
direction = Vector2::zero;
116
if (state != "wander") {
117
//printf("wander\n");
118
direction = Vector2::Random();
127
velocity += direction * ACCELERATION * Monocle::deltaTime;
129
velocity.x = APPROACH(velocity.x, 0, FRICTION * Monocle::deltaTime);
130
velocity.y = APPROACH(velocity.y, 0, FRICTION * Monocle::deltaTime);
135
position.x += velocity.x * Monocle::deltaTime;
136
while (Collide("Solid"))
139
if (velocity.x == 0) { break; }
140
//printf("collision1\n");
141
position.x -= SIGN(velocity.x, 0.1);
143
if (xcol) {velocity.x = 0;}
145
position.y += velocity.y * Monocle::deltaTime;
146
while (Collide("Solid"))
149
if (velocity.y == 0) { break; }
150
//printf("collision2\n");
151
position.y -= SIGN(velocity.y, 0.1);
153
if (ycol) {velocity.y = 0;}
155
if (velocity.GetSquaredMagnitude() > 20)
158
skitter1->Pause(); //Stop()?
74
163
DarkScene::DarkScene() : Scene()
115
204
player->position = Graphics::GetScreenCenter();
207
Creature *creature = new Creature;
208
creature->position = Graphics::GetScreenCenter();
211
Creature *creature2 = new Creature;
212
creature2->position = Graphics::GetScreenCenter();
118
215
Graphics::SetBackgroundColor(Color::green * 0.2f);