/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:51:34 UTC
  • Revision ID: josh@9ix.org-20110919185134-4sgy1r2m1jjfdody
fix spurs

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
 
61
78
    position.x += velocity.x * Monocle::deltaTime;
62
 
    while (Collide("Solid"))
 
79
    while (Collide("Solid") || (collider = Collide("creature")))
63
80
      {
 
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
 
64
87
        xcol = true;
65
88
        if (velocity.x == 0) { break; }
66
89
        //printf("collision1\n");
68
91
      }
69
92
    if (xcol) {velocity.x = 0;}
70
93
 
 
94
    collider = NULL;
71
95
    position.y += velocity.y * Monocle::deltaTime;
72
 
    while (Collide("Solid"))
 
96
    while (Collide("Solid") || (collider = Collide("creature")))
73
97
      {
 
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
 
74
104
        ycol = true;
75
105
        if (velocity.y == 0) { break; }
76
106
        //printf("collision2\n");
106
136
    scale = Vector2(0.25, 0.25);
107
137
 
108
138
    AddTag("creature");
109
 
    AddTag("Solid");
110
139
    SetCollider(new RectangleCollider(16, 16));
111
140
 
112
141
    alert = Assets::RequestAudio("alert.ogg");
113
142
    freakout = Assets::RequestAudio("freakout.ogg");
 
143
    chomp = Assets::RequestAudio("chomp.ogg");
114
144
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
115
145
    skitter1->SetLoops(0); //loop indefinitely
116
146
    sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
262
292
 
263
293
        // if we collide with you, move you back to the starting point
264
294
        if (Collide("player")) {
265
 
          // TODO: first, make chompy noises and wait a second or 3?
 
295
          // TODO: first wait a second or 3?
 
296
          chomp->Play();
266
297
          DarkScene *scene = (DarkScene *) GetScene();
267
298
          Entity* playersp = scene->GetFirstEntityWithTag("playerspawner");
268
299
          scene->player->position = playersp->position;
368
399
 
369
400
    Graphics::Set2D(1024, 768);
370
401
 
 
402
    Text *inst1 = new Text("Use arrow keys to move");
 
403
    inst1->position = Vector2(-492, -354);
 
404
    Add(inst1);
 
405
 
371
406
    Text *inst2 = new Text("Press ESC to quit");
372
 
    inst2->position = Vector2(-492, -354); // 20px h, 30px v from U-L corner
 
407
    inst2->position = Vector2(-492, -334); // 20px h, 30px v from U-L corner
373
408
    Add(inst2);
374
409
 
375
410
    Input::DefineMaskKey("left", KEY_LEFT);
408
443
        Vector2 s = e->scale;
409
444
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
410
445
      }
 
446
 
 
447
    Entity* exit = GetFirstEntityWithTag("exit");
 
448
    Vector2 s = exit->scale;
 
449
    exit->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
 
450
 
411
451
   
412
452
    Graphics::SetBackgroundColor(Color::green * 0.2f);
413
453