/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 18:02:20 UTC
  • Revision ID: josh@9ix.org-20110919180220-flnvccj5mdk3441x
chompy noise, make collisions with hunters work a little better

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    bool xcol = false;
59
59
    bool ycol = false;
60
60
 
 
61
    Collider *collider = NULL;
 
62
 
61
63
    position.x += velocity.x * Monocle::deltaTime;
62
 
    while (Collide("Solid"))
 
64
    while (Collide("Solid") || (collider = Collide("creature")))
63
65
      {
 
66
        // Don't colide with hunters.  We should just die.
 
67
        if (collider) {
 
68
          Creature *c = (Creature *) collider->GetEntity();
 
69
          if (c->state == "hunt") { break; }
 
70
        }
 
71
 
64
72
        xcol = true;
65
73
        if (velocity.x == 0) { break; }
66
74
        //printf("collision1\n");
68
76
      }
69
77
    if (xcol) {velocity.x = 0;}
70
78
 
 
79
    collider = NULL;
71
80
    position.y += velocity.y * Monocle::deltaTime;
72
 
    while (Collide("Solid"))
 
81
    while (Collide("Solid") || (collider = Collide("creature")))
73
82
      {
 
83
        // Don't colide with hunters.  We should just die.
 
84
        if (collider) {
 
85
          Creature *c = (Creature *) collider->GetEntity();
 
86
          if (c->state == "hunt") { break; }
 
87
        }
 
88
 
74
89
        ycol = true;
75
90
        if (velocity.y == 0) { break; }
76
91
        //printf("collision2\n");
110
125
 
111
126
    alert = Assets::RequestAudio("alert.ogg");
112
127
    freakout = Assets::RequestAudio("freakout.ogg");
 
128
    chomp = Assets::RequestAudio("chomp.ogg");
113
129
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
114
130
    skitter1->SetLoops(0); //loop indefinitely
115
131
    sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
216
232
        // Go back to IDLE if:
217
233
        // * we hit a wall
218
234
        // * we stalk for more than 10-15s
219
 
        if ((aiTime > 15.0f) || Collide("wall"))
 
235
        if ((aiTime > 15.0f) || Collide("wall") || Collide("creaturewall"))
220
236
          {
221
237
            // play frustrated noise?
222
238
            state = "idle";
259
275
            graceTime = 0.0f;
260
276
        }
261
277
 
262
 
        // if we collide with you... game over?
 
278
        // if we collide with you, move you back to the starting point
 
279
        if (Collide("player")) {
 
280
          // TODO: first wait a second or 3?
 
281
          chomp->Play();
 
282
          DarkScene *scene = (DarkScene *) GetScene();
 
283
          Entity* playersp = scene->GetFirstEntityWithTag("playerspawner");
 
284
          scene->player->position = playersp->position;
 
285
        }
263
286
      }
264
287
 
265
288
    velocity += direction * ACCELERATION * Monocle::deltaTime;
274
297
    bool ycol = false;
275
298
 
276
299
    position.x += velocity.x * Monocle::deltaTime;
277
 
    while (Collide("Solid"))
 
300
    while (Collide("Solid") || Collide("creaturewall"))
278
301
      {
279
302
        xcol = true;
280
303
        if (velocity.x == 0) { break; }
284
307
    if (xcol) {velocity.x = 0;}
285
308
 
286
309
    position.y += velocity.y * Monocle::deltaTime;
287
 
    while (Collide("Solid"))
 
310
    while (Collide("Solid") || Collide("creaturewall"))
288
311
      {
289
312
        ycol = true;
290
313
        if (velocity.y == 0) { break; }
393
416
        Vector2 s = e->scale;
394
417
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
395
418
      }
 
419
 
 
420
    std::list<Entity*> *creaturewalls = GetAllTag("creaturewall");
 
421
    for (std::list<Entity*>::iterator i = creaturewalls->begin(); i != creaturewalls->end(); ++i)
 
422
      {
 
423
        Entity *e = (*i);
 
424
        Vector2 s = e->scale;
 
425
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
 
426
      }
396
427
   
397
428
    Graphics::SetBackgroundColor(Color::green * 0.2f);
398
429