/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:28:45 UTC
  • Revision ID: josh@9ix.org-20110918182845-4hn7df1fr378bql0
andĀ theĀ asset

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;
182
183
          }
183
184
 
184
185
        // if we've been listening a long time, switch back to idle
191
192
    else if (state == "stalk")
192
193
      {
193
194
        aiTime += Monocle::deltaTime;
 
195
        noiseTime += Monocle::deltaTime;
194
196
 
195
197
        // Go to HUNT if:
196
198
        // * it's been >1s & we hear the player
206
208
            direction = (player->position - position).GetNormalized();
207
209
            //maxspeed = DEFAULT_MAXSPEED;
208
210
            // 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;
223
212
          }
 
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.
224
220
      }
225
221
 
226
222
    velocity += direction * ACCELERATION * Monocle::deltaTime;
257
253
    Vector2 distance = ((DarkScene *)scene)->player->position - position;
258
254
    if (state == "stalk")
259
255
      {
260
 
        float vol = (distance.GetMagnitude() / -250.0f) + 1.0f;
 
256
        float vol = (distance.GetMagnitude() / 250.0f) + 1.0f;
261
257
        sniff->SetVolume(vol);
262
258
        sniff->Play();
263
259
        sprite->Play("slowmove");