/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 03:38:46 UTC
  • Revision ID: josh@9ix.org-20110918033846-f2unltomwd0ula81
alert noise

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
110
110
    skitter1->SetLoops(0); //loop indefinitely
111
111
 
 
112
    alert = Assets::RequestAudio("alert.ogg");
 
113
 
112
114
    velocity = Vector2::Random() * MAXSPEED;
113
115
 
114
116
    //set aiTime to random so creatures tick at different times
115
117
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
 
118
 
 
119
    state = "idle";
116
120
  }
117
121
 
118
122
  void Creature::Update()
147
151
        if ( (player->position - position).GetSquaredMagnitude() < 
148
152
             pow(player->noisiness, 2) )
149
153
          {
 
154
            //printf("alert\n");
150
155
            state = "alert";
151
 
            // TODO: Play startled noise
 
156
            alert->Play();
152
157
            direction = Vector2::zero;
153
158
            // TODO: Play pulse animation (yellow?)
154
159
            aiTime = 0.0f; // diff variable?  stateTime?
162
167
        // something, switch state again
163
168
 
164
169
        // if we've been listening a long time, switch back to idle
 
170
        if (aiTime > 5.0f) {
 
171
          //printf("end alert\n");
 
172
          state = "idle";
 
173
        }
165
174
      }
166
175
 
167
176
    velocity += direction * ACCELERATION * Monocle::deltaTime;