/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 16:12:57 UTC
  • Revision ID: josh@9ix.org-20110918161257-zshzdmi0e62idum1
some more stalk logic

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
                         FRICTION(800),
96
96
                         MAXSPEED(80.0f),
97
97
                         ACCELERATION(1200),
98
 
                         STALKSPEED(5.0f)
 
98
                         STALKSPEED(5.0f),
 
99
                         HUNTSPEED(80.0f)
99
100
  {
100
101
    sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
101
102
    sprite->Add("idle", 0, 0, 0.35f);
190
191
    else if (state == "stalk")
191
192
      {
192
193
        aiTime += Monocle::deltaTime;
193
 
 
194
 
        // if we hear the player while stalking (normal range), go to HUNT
195
 
 
 
194
        noiseTime += Monocle::deltaTime;
 
195
 
 
196
        // Go to HUNT if:
 
197
        // * it's been >1s & we hear the player
 
198
        // * we collide with the player
 
199
        Player *player = ((DarkScene *)scene)->player;
 
200
        if ((aiTime > 1.0f &&  
 
201
             (player->position - position).GetSquaredMagnitude() < 
 
202
             pow(player->noisiness, 2) )
 
203
            || Collide("player")
 
204
            )
 
205
          {
 
206
            state == "hunt";
 
207
            direction = (player->position - position).GetNormalized() * HUNTSPEED;
 
208
            // Play hunt noise (REEET!)
 
209
 
 
210
          }
 
211
          
 
212
          
196
213
        //after 6 or 7 seconds on the noiseTime clock, play sound and ping again
197
214
        // if we hit a wall, call off the search?
198
215
        //we'll want to play that sound again
199
216
        // do others go ALERT if we start stalking?
200
 
        // and if we collide with the player?
 
217
        //probably a timeout here too.
201
218
      }
202
219
 
203
220
    velocity += direction * ACCELERATION * Monocle::deltaTime;