/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 21:57:43 UTC
  • Revision ID: josh@9ix.org-20110918215743-5vlccbqee5hqqk9b
I really don't need the source AUPs.  There's enough crap in here 
already.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
    AddTag("creature");
109
109
    SetCollider(new RectangleCollider(16, 16));
110
110
 
111
 
    alert = Assets::RequestAudio("alert.ogg");
112
 
    freakout = Assets::RequestAudio("freakout.ogg");
113
111
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
114
112
    skitter1->SetLoops(0); //loop indefinitely
 
113
    alert = Assets::RequestAudio("alert.ogg");
115
114
    sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
116
115
    sniff->SetLoops(0);
117
116
 
203
202
            || Collide("player")
204
203
            )
205
204
          {
206
 
            state = "hunt";
 
205
            //state = "hunt";
207
206
            direction = (player->position - position).GetNormalized();
208
 
            maxspeed = 0; // give them a running start
209
 
            sniff->Stop();
210
 
            freakout->Play();
211
 
            // TODO: big yellow ping
212
 
            aiTime = 0.0f;
213
 
            noiseTime = 0.0f;
 
207
            //maxspeed = DEFAULT_MAXSPEED;
 
208
            // Play hunt noise (REEET!)
 
209
            //aiTime = 0.0f;
214
210
          }
215
211
 
216
212
        // Go back to IDLE if:
217
213
        // * we hit a wall
218
 
        // * we stalk for more than 10-15s
 
214
        // * we hunt for more than 10-15s
219
215
        if ((aiTime > 15.0f) || Collide("wall"))
220
216
          {
221
217
            // play frustrated noise?
226
222
            direction = Vector2::zero;
227
223
          }
228
224
      }
229
 
    else if (state == "hunt")
230
 
      {
231
 
        aiTime += Monocle::deltaTime;
232
 
        noiseTime += Monocle::deltaTime;
233
 
 
234
 
        if ((aiTime > 1.0f) && (maxspeed != DEFAULT_MAXSPEED))
235
 
          maxspeed = DEFAULT_MAXSPEED;
236
 
 
237
 
        // if we hear the player (
238
 
        Player *player = ((DarkScene *)scene)->player;
239
 
        if ( (player->position - position).GetSquaredMagnitude() < 
240
 
             pow(player->noisiness, 2) )
241
 
          {
242
 
            direction = (player->position - position).GetNormalized();
243
 
            aiTime = 0.0f;
244
 
            if (noiseTime > 1.0f) {
245
 
              freakout->Play();
246
 
              // TODO: big yellow ping
247
 
              noiseTime = 0.0f;
248
 
            }
249
 
          }
250
 
 
251
 
        // I guess chill out if it's been a while
252
 
        if (aiTime > 15.0f) {
253
 
            state = "alert";
254
 
            //alert->Play();
255
 
            direction = Vector2::zero;
256
 
            aiTime = 0.0f;
257
 
        }
258
 
 
259
 
        // if we collide with you... game over?
260
 
      }
261
225
 
262
226
    velocity += direction * ACCELERATION * Monocle::deltaTime;
263
227