/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-18 22:42:59 UTC
  • Revision ID: josh@9ix.org-20110918224259-0yxyd99mvuadfarf
they hear you more + fixed a bug if they're right on top of you

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
 
    if (Collide("exit")) {
62
 
      Scene *s = GetScene();
63
 
      s->isPaused = true;
64
 
      
65
 
      Text *win1 = new Text("You made it safely through the dark!", 
66
 
                           Assets::RequestFont("LiberationSans-Regular.ttf", 50.0f));
67
 
      win1->position = Vector2(-350,0);
68
 
      s->Add(win1);
69
 
 
70
 
      Text *win2 = new Text("Congratulations!", 
71
 
                           Assets::RequestFont("LiberationSans-Regular.ttf", 50.0f));
72
 
      win2->position = Vector2(-150,50);
73
 
      s->Add(win2);
74
 
    }
75
 
 
76
 
    Collider *collider = NULL;
77
 
 
78
61
    position.x += velocity.x * Monocle::deltaTime;
79
 
    while (Collide("Solid") || (collider = Collide("creature")))
 
62
    while (Collide("Solid"))
80
63
      {
81
 
        // Don't colide with hunters.  We should just die.
82
 
        if (collider) {
83
 
          Creature *c = (Creature *) collider->GetEntity();
84
 
          if (c->state == "hunt") { break; }
85
 
        }
86
 
 
87
64
        xcol = true;
88
65
        if (velocity.x == 0) { break; }
89
66
        //printf("collision1\n");
91
68
      }
92
69
    if (xcol) {velocity.x = 0;}
93
70
 
94
 
    collider = NULL;
95
71
    position.y += velocity.y * Monocle::deltaTime;
96
 
    while (Collide("Solid") || (collider = Collide("creature")))
 
72
    while (Collide("Solid"))
97
73
      {
98
 
        // Don't colide with hunters.  We should just die.
99
 
        if (collider) {
100
 
          Creature *c = (Creature *) collider->GetEntity();
101
 
          if (c->state == "hunt") { break; }
102
 
        }
103
 
 
104
74
        ycol = true;
105
75
        if (velocity.y == 0) { break; }
106
76
        //printf("collision2\n");
140
110
 
141
111
    alert = Assets::RequestAudio("alert.ogg");
142
112
    freakout = Assets::RequestAudio("freakout.ogg");
143
 
    chomp = Assets::RequestAudio("chomp.ogg");
144
113
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
145
114
    skitter1->SetLoops(0); //loop indefinitely
146
115
    sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
239
208
            maxspeed = 0; // give them a running start
240
209
            sniff->Stop();
241
210
            freakout->Play();
242
 
            Ping::NewPing(position, 8.0f, 64.0f, 0.15f); 
 
211
            // TODO: big yellow ping
243
212
            aiTime = 0.0f;
244
213
            noiseTime = 0.0f;
245
214
          }
247
216
        // Go back to IDLE if:
248
217
        // * we hit a wall
249
218
        // * we stalk for more than 10-15s
250
 
        if ((aiTime > 15.0f) || Collide("wall") || Collide("creaturewall"))
 
219
        if ((aiTime > 15.0f) || Collide("wall"))
251
220
          {
252
221
            // play frustrated noise?
253
222
            state = "idle";
275
244
            aiTime = 0.0f;
276
245
            if (noiseTime > 2.0f) {
277
246
              freakout->Play();
278
 
              Ping::NewPing(position, 8.0f, 64.0f, 0.15f);
 
247
              // TODO: big yellow ping
279
248
              noiseTime = 0.0f;
280
249
            }
281
250
          }
290
259
            graceTime = 0.0f;
291
260
        }
292
261
 
293
 
        // if we collide with you, move you back to the starting point
294
 
        if (Collide("player")) {
295
 
          // TODO: first wait a second or 3?
296
 
          chomp->Play();
297
 
          DarkScene *scene = (DarkScene *) GetScene();
298
 
          Entity* playersp = scene->GetFirstEntityWithTag("playerspawner");
299
 
          scene->player->position = playersp->position;
300
 
        }
 
262
        // if we collide with you... game over?
301
263
      }
302
264
 
303
265
    velocity += direction * ACCELERATION * Monocle::deltaTime;
312
274
    bool ycol = false;
313
275
 
314
276
    position.x += velocity.x * Monocle::deltaTime;
315
 
    while (Collide("Solid") || Collide("creaturewall"))
 
277
    while (Collide("Solid"))
316
278
      {
317
279
        xcol = true;
318
280
        if (velocity.x == 0) { break; }
322
284
    if (xcol) {velocity.x = 0;}
323
285
 
324
286
    position.y += velocity.y * Monocle::deltaTime;
325
 
    while (Collide("Solid") || Collide("creaturewall"))
 
287
    while (Collide("Solid"))
326
288
      {
327
289
        ycol = true;
328
290
        if (velocity.y == 0) { break; }
399
361
 
400
362
    Graphics::Set2D(1024, 768);
401
363
 
402
 
    Text *inst1 = new Text("Use arrow keys to move");
403
 
    inst1->position = Vector2(-492, -354);
404
 
    Add(inst1);
405
 
 
406
364
    Text *inst2 = new Text("Press ESC to quit");
407
 
    inst2->position = Vector2(-492, -334); // 20px h, 30px v from U-L corner
 
365
    inst2->position = Vector2(-492, -354); // 20px h, 30px v from U-L corner
408
366
    Add(inst2);
409
367
 
410
368
    Input::DefineMaskKey("left", KEY_LEFT);
435
393
        Vector2 s = e->scale;
436
394
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
437
395
      }
438
 
 
439
 
    std::list<Entity*> *creaturewalls = GetAllTag("creaturewall");
440
 
    for (std::list<Entity*>::iterator i = creaturewalls->begin(); i != creaturewalls->end(); ++i)
441
 
      {
442
 
        Entity *e = (*i);
443
 
        Vector2 s = e->scale;
444
 
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
445
 
      }
446
 
 
447
 
    Entity* exit = GetFirstEntityWithTag("exit");
448
 
    Vector2 s = exit->scale;
449
 
    exit->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
450
 
 
451
396
   
452
397
    Graphics::SetBackgroundColor(Color::green * 0.2f);
453
398