/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 18:42:06 UTC
  • Revision ID: josh@9ix.org-20110918184206-a6os1dii09n7h4at
continue to work on stalk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
 
85
85
    // How far away can they hear your footsteps?
86
86
    // The circle is diameter 300 at MAXSPEED, 32 (2x your size) at 0 speed
87
 
    noisiness = ((magnitude / MAXSPEED *(400-64)) + 64) /2;
 
87
    noisiness = ((magnitude / MAXSPEED *(300-32)) + 32) /2;
88
88
 
89
89
    dark->position = position;
90
90
 
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
 
            Ping::NewPing(position, 8.0f, 64.0f, 0.15f); 
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
 
        graceTime += Monocle::deltaTime;
234
 
 
235
 
        if ((graceTime > 1.0f) && (maxspeed != DEFAULT_MAXSPEED))
236
 
          maxspeed = DEFAULT_MAXSPEED;
237
 
 
238
 
        // if we hear the player (
239
 
        Player *player = ((DarkScene *)scene)->player;
240
 
        if ( (player->position - position).GetSquaredMagnitude() < 
241
 
             pow(player->noisiness, 2) )
242
 
          {
243
 
            direction = (player->position - position).GetNormalized();
244
 
            aiTime = 0.0f;
245
 
            if (noiseTime > 2.0f) {
246
 
              freakout->Play();
247
 
              Ping::NewPing(position, 8.0f, 64.0f, 0.15f);
248
 
              noiseTime = 0.0f;
249
 
            }
250
 
          }
251
 
 
252
 
        // I guess chill out if it's been a while
253
 
        if (aiTime > 15.0f) {
254
 
            state = "alert";
255
 
            //alert->Play();
256
 
            direction = Vector2::zero;
257
 
            aiTime = 0.0f;
258
 
            noiseTime = 0.0f;
259
 
            graceTime = 0.0f;
260
 
        }
261
 
 
262
 
        // if we collide with you... game over?
263
 
      }
264
225
 
265
226
    velocity += direction * ACCELERATION * Monocle::deltaTime;
266
227