/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 04:39:18 UTC
  • Revision ID: josh@9ix.org-20110918043918-eb8i96g094zxhn5q
ping!

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
  Creature::Creature() : Entity(),
95
95
                         FRICTION(800),
96
96
                         MAXSPEED(80.0f),
97
 
                         ACCELERATION(1200),
98
 
                         STALKSPEED(5.0f)
 
97
                         ACCELERATION(1200)                      
99
98
  {
100
99
    sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
101
100
    sprite->Add("idle", 0, 0, 0.35f);
109
108
 
110
109
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
111
110
    skitter1->SetLoops(0); //loop indefinitely
 
111
 
112
112
    alert = Assets::RequestAudio("alert.ogg");
113
 
    stalk = Assets::RequestAudio("stalk.ogg");
114
113
 
115
114
    velocity = Vector2::Random() * MAXSPEED;
116
115
 
166
165
        
167
166
        // if we've been listening past the grace period and hear
168
167
        // something, switch state again
169
 
        // We hear the player at DOUBLE noisiness distance, cuz WE'RE LISNING!
170
 
        Player *player = ((DarkScene *)scene)->player;
171
 
        if ( aiTime > 1.0f && 
172
 
             (player->position - position).GetSquaredMagnitude() < 
173
 
             pow(player->noisiness * 2, 2) )
174
 
          {
175
 
            state = "stalk";
176
 
            stalk->Play();
177
 
            Ping::NewPing(position, 8.0f, 32.0f, 0.15f);
178
 
            direction = (player->position - position).GetNormalized() * STALKSPEED;
179
 
            aiTime = 0.0f;
180
 
            noiseTime = 0.0f;
181
 
          }
182
168
 
183
169
        // if we've been listening a long time, switch back to idle
184
170
        if (aiTime > 5.0f) {
185
171
          //printf("end alert\n");
186
172
          state = "idle";
187
 
          aiTime = 0.0f;
188
173
        }
189
174
      }
190
 
    else if (state == "stalk")
191
 
      {
192
 
        aiTime += Monocle::deltaTime;
193
 
 
194
 
        // if we hear the player while stalking (normal range), go to HUNT
195
 
 
196
 
        //after 6 or 7 seconds on the noiseTime clock, play sound and ping again
197
 
        // if we hit a wall, call off the search?
198
 
        //we'll want to play that sound again
199
 
        // do others go ALERT if we start stalking?
200
 
        // and if we collide with the player?
201
 
      }
202
175
 
203
176
    velocity += direction * ACCELERATION * Monocle::deltaTime;
204
177