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