/minild29

To get this branch, use:
bzr branch http://9ix.org/bzr/minild29

« back to all changes in this revision

Viewing changes to Dark.cpp

  • Committer: Josh C
  • Date: 2011-09-19 16:45:22 UTC
  • Revision ID: josh@9ix.org-20110919164522-dtd7of8u0ylmvs0s
harder maze, safe zone, they kill you

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
 
85
85
    // How far away can they hear your footsteps?
86
86
    // The circle is diameter 300 at MAXSPEED, 32 (2x your size) at 0 speed
87
 
    noisiness = ((magnitude / MAXSPEED *(300-32)) + 32) /2;
 
87
    noisiness = ((magnitude / MAXSPEED *(400-64)) + 64) /2;
88
88
 
89
89
    dark->position = position;
90
90
 
106
106
    scale = Vector2(0.25, 0.25);
107
107
 
108
108
    AddTag("creature");
 
109
    AddTag("Solid");
109
110
    SetCollider(new RectangleCollider(16, 16));
110
111
 
111
112
    alert = Assets::RequestAudio("alert.ogg");
208
209
            maxspeed = 0; // give them a running start
209
210
            sniff->Stop();
210
211
            freakout->Play();
211
 
            // TODO: big yellow ping
 
212
            Ping::NewPing(position, 8.0f, 64.0f, 0.15f); 
212
213
            aiTime = 0.0f;
213
214
            noiseTime = 0.0f;
214
215
          }
216
217
        // Go back to IDLE if:
217
218
        // * we hit a wall
218
219
        // * we stalk for more than 10-15s
219
 
        if ((aiTime > 15.0f) || Collide("wall"))
 
220
        if ((aiTime > 15.0f) || Collide("wall") || Collide("creaturewall"))
220
221
          {
221
222
            // play frustrated noise?
222
223
            state = "idle";
230
231
      {
231
232
        aiTime += Monocle::deltaTime;
232
233
        noiseTime += Monocle::deltaTime;
 
234
        graceTime += Monocle::deltaTime;
233
235
 
234
 
        if ((aiTime > 1.0f) && (maxspeed != DEFAULT_MAXSPEED))
 
236
        if ((graceTime > 1.0f) && (maxspeed != DEFAULT_MAXSPEED))
235
237
          maxspeed = DEFAULT_MAXSPEED;
236
238
 
237
239
        // if we hear the player (
241
243
          {
242
244
            direction = (player->position - position).GetNormalized();
243
245
            aiTime = 0.0f;
244
 
            if (noiseTime > 1.0f) {
 
246
            if (noiseTime > 2.0f) {
245
247
              freakout->Play();
246
 
              // TODO: big yellow ping
 
248
              Ping::NewPing(position, 8.0f, 64.0f, 0.15f);
247
249
              noiseTime = 0.0f;
248
250
            }
249
251
          }
254
256
            //alert->Play();
255
257
            direction = Vector2::zero;
256
258
            aiTime = 0.0f;
 
259
            noiseTime = 0.0f;
 
260
            graceTime = 0.0f;
257
261
        }
258
262
 
259
 
        // if we collide with you... game over?
 
263
        // if we collide with you, move you back to the starting point
 
264
        if (Collide("player")) {
 
265
          // TODO: first, make chompy noises and wait a second or 3?
 
266
          DarkScene *scene = (DarkScene *) GetScene();
 
267
          Entity* playersp = scene->GetFirstEntityWithTag("playerspawner");
 
268
          scene->player->position = playersp->position;
 
269
        }
260
270
      }
261
271
 
262
272
    velocity += direction * ACCELERATION * Monocle::deltaTime;
271
281
    bool ycol = false;
272
282
 
273
283
    position.x += velocity.x * Monocle::deltaTime;
274
 
    while (Collide("Solid"))
 
284
    while (Collide("Solid") || Collide("creaturewall"))
275
285
      {
276
286
        xcol = true;
277
287
        if (velocity.x == 0) { break; }
281
291
    if (xcol) {velocity.x = 0;}
282
292
 
283
293
    position.y += velocity.y * Monocle::deltaTime;
284
 
    while (Collide("Solid"))
 
294
    while (Collide("Solid") || Collide("creaturewall"))
285
295
      {
286
296
        ycol = true;
287
297
        if (velocity.y == 0) { break; }
390
400
        Vector2 s = e->scale;
391
401
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
392
402
      }
 
403
 
 
404
    std::list<Entity*> *creaturewalls = GetAllTag("creaturewall");
 
405
    for (std::list<Entity*>::iterator i = creaturewalls->begin(); i != creaturewalls->end(); ++i)
 
406
      {
 
407
        Entity *e = (*i);
 
408
        Vector2 s = e->scale;
 
409
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
 
410
      }
393
411
   
394
412
    Graphics::SetBackgroundColor(Color::green * 0.2f);
395
413