/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:21:36 UTC
  • Revision ID: josh@9ix.org-20110918032136-bprcfnl3jg5xmjsx
track palyer noisiness, beginnings of "alert" state for creatures

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
 
 
114
112
    velocity = Vector2::Random() * MAXSPEED;
115
113
 
116
114
    //set aiTime to random so creatures tick at different times
117
115
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
118
 
 
119
 
    state = "idle";
120
116
  }
121
117
 
122
118
  void Creature::Update()
151
147
        if ( (player->position - position).GetSquaredMagnitude() < 
152
148
             pow(player->noisiness, 2) )
153
149
          {
154
 
            //printf("alert\n");
155
150
            state = "alert";
156
 
            alert->Play();
 
151
            // TODO: Play startled noise
157
152
            direction = Vector2::zero;
158
153
            // TODO: Play pulse animation (yellow?)
159
154
            aiTime = 0.0f; // diff variable?  stateTime?
167
162
        // something, switch state again
168
163
 
169
164
        // 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
 
        }
174
165
      }
175
166
 
176
167
    velocity += direction * ACCELERATION * Monocle::deltaTime;