/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:
179
179
            direction = (player->position - position).GetNormalized();
180
180
            maxspeed = STALKSPEED;
181
181
            aiTime = 0.0f;
182
 
            noiseTime = 0.0f;
183
182
          }
184
183
 
185
184
        // if we've been listening a long time, switch back to idle
192
191
    else if (state == "stalk")
193
192
      {
194
193
        aiTime += Monocle::deltaTime;
195
 
        noiseTime += Monocle::deltaTime;
196
194
 
197
195
        // Go to HUNT if:
198
196
        // * it's been >1s & we hear the player
208
206
            direction = (player->position - position).GetNormalized();
209
207
            //maxspeed = DEFAULT_MAXSPEED;
210
208
            // Play hunt noise (REEET!)
 
209
            //aiTime = 0.0f;
 
210
          }
211
211
 
 
212
        // Go back to IDLE if:
 
213
        // * we hit a wall
 
214
        // * we hunt for more than 10-15s
 
215
        if ((aiTime > 15.0f) || Collide("wall"))
 
216
          {
 
217
            // play frustrated noise?
 
218
            state = "idle";
 
219
            aiTime = 0.0f;
 
220
            sniff->Stop();
 
221
            maxspeed = DEFAULT_MAXSPEED;
 
222
            direction = Vector2::zero;
212
223
          }
213
 
          
214
 
          
215
 
        //after 6 or 7 seconds on the noiseTime clock, play sound and ping again
216
 
        // if we hit a wall, call off the search?
217
 
        //we'll want to play that sound again
218
 
        // do others go ALERT if we start stalking?
219
 
        //probably a timeout here too.
220
224
      }
221
225
 
222
226
    velocity += direction * ACCELERATION * Monocle::deltaTime;
253
257
    Vector2 distance = ((DarkScene *)scene)->player->position - position;
254
258
    if (state == "stalk")
255
259
      {
256
 
        float vol = (distance.GetMagnitude() / 250.0f) + 1.0f;
 
260
        float vol = (distance.GetMagnitude() / -250.0f) + 1.0f;
257
261
        sniff->SetVolume(vol);
258
262
        sniff->Play();
259
263
        sprite->Play("slowmove");