/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 15:57:35 UTC
  • Revision ID: josh@9ix.org-20110919155735-tbo31x7loryc1284
very nice exit sign

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
 
 
63
61
    position.x += velocity.x * Monocle::deltaTime;
64
 
    while (Collide("Solid") || (collider = Collide("creature")))
 
62
    while (Collide("Solid"))
65
63
      {
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
 
 
72
64
        xcol = true;
73
65
        if (velocity.x == 0) { break; }
74
66
        //printf("collision1\n");
76
68
      }
77
69
    if (xcol) {velocity.x = 0;}
78
70
 
79
 
    collider = NULL;
80
71
    position.y += velocity.y * Monocle::deltaTime;
81
 
    while (Collide("Solid") || (collider = Collide("creature")))
 
72
    while (Collide("Solid"))
82
73
      {
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
 
 
89
74
        ycol = true;
90
75
        if (velocity.y == 0) { break; }
91
76
        //printf("collision2\n");
125
110
 
126
111
    alert = Assets::RequestAudio("alert.ogg");
127
112
    freakout = Assets::RequestAudio("freakout.ogg");
128
 
    chomp = Assets::RequestAudio("chomp.ogg");
129
113
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
130
114
    skitter1->SetLoops(0); //loop indefinitely
131
115
    sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
232
216
        // Go back to IDLE if:
233
217
        // * we hit a wall
234
218
        // * we stalk for more than 10-15s
235
 
        if ((aiTime > 15.0f) || Collide("wall") || Collide("creaturewall"))
 
219
        if ((aiTime > 15.0f) || Collide("wall"))
236
220
          {
237
221
            // play frustrated noise?
238
222
            state = "idle";
275
259
            graceTime = 0.0f;
276
260
        }
277
261
 
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
 
        }
 
262
        // if we collide with you... game over?
286
263
      }
287
264
 
288
265
    velocity += direction * ACCELERATION * Monocle::deltaTime;
297
274
    bool ycol = false;
298
275
 
299
276
    position.x += velocity.x * Monocle::deltaTime;
300
 
    while (Collide("Solid") || Collide("creaturewall"))
 
277
    while (Collide("Solid"))
301
278
      {
302
279
        xcol = true;
303
280
        if (velocity.x == 0) { break; }
307
284
    if (xcol) {velocity.x = 0;}
308
285
 
309
286
    position.y += velocity.y * Monocle::deltaTime;
310
 
    while (Collide("Solid") || Collide("creaturewall"))
 
287
    while (Collide("Solid"))
311
288
      {
312
289
        ycol = true;
313
290
        if (velocity.y == 0) { break; }
416
393
        Vector2 s = e->scale;
417
394
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
418
395
      }
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
 
      }
427
396
   
428
397
    Graphics::SetBackgroundColor(Color::green * 0.2f);
429
398