/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-17 15:42:47 UTC
  • Revision ID: josh@9ix.org-20110917154247-vdk48n09rbnrmzgg
footsteps

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
{
5
5
  Player::Player() : Entity(),
6
6
                     FRICTION(400),
7
 
                     MAXSPEED(20.0f),
 
7
                     MAXSPEED(60.0f),
8
8
                     ACCELERATION(800)
9
9
  {
10
10
    sprite = new SpriteAnimation("player.png", FILTER_NONE, 64, 64);
11
11
    sprite->Add("idle", 0, 0, 0.35f);
12
12
    sprite->Play("idle");
13
13
    SetGraphic(sprite);
14
 
    scale = Vector2(0.25, 0.25);
15
14
 
16
15
    AddTag("player");
17
16
 
18
17
    footsteps = Audio::NewDeck(Assets::RequestAudio("footsteps.ogg"));
19
18
    footsteps->SetLoops(0); //loop indefinitely
20
19
    
21
 
    SetCollider(new RectangleCollider(16, 16));
22
 
 
23
 
    dark = new Entity();
24
 
    dark->SetGraphic(new Sprite("dark.png", FILTER_NONE, 2048, 1536)); //alpha?
 
20
    SetCollider(new RectangleCollider(32, 32));
25
21
  }
26
22
 
27
23
  void Player::Update()
77
73
    else
78
74
      footsteps->Pause(); //Stop()?
79
75
 
80
 
    dark->position = position;
81
 
 
82
76
    //Scene::GetCamera()->position = position;
83
77
  }
84
78
 
85
79
  Creature::Creature() : Entity(),
86
80
                         FRICTION(800),
87
 
                         MAXSPEED(15.0f),
 
81
                         MAXSPEED(30.0f),
88
82
                         ACCELERATION(1200)                      
89
83
  {
90
84
    sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
91
85
    sprite->Add("idle", 0, 0, 0.35f);
92
 
    sprite->Add("move", 1, 2, 4.0f);
93
86
    sprite->Play("idle");
94
87
    SetGraphic(sprite);
95
 
    scale = Vector2(0.25, 0.25);
96
88
 
97
89
    AddTag("creature");
98
 
    SetCollider(new RectangleCollider(16, 16));
 
90
    SetCollider(new RectangleCollider(32, 32));
99
91
 
100
92
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
101
93
    skitter1->SetLoops(0); //loop indefinitely
102
94
 
103
 
    velocity = Vector2::Random() * MAXSPEED;
 
95
    velocity = Vector2::Random() * ACCELERATION;
104
96
 
105
97
    //set aiTime to random so creatures tick at different times
106
98
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
113
105
    aiTime += Monocle::deltaTime;
114
106
    if (aiTime > 1.0f)
115
107
      {
116
 
        switch (rand() % 3)
 
108
        switch (rand() % 2)
117
109
          {
118
110
          case 0: // idle
119
111
            //printf("idle\n");
161
153
    if (ycol) {velocity.y = 0;}
162
154
 
163
155
    if (velocity.GetSquaredMagnitude() > 20)
164
 
      {
165
 
        skitter1->Play();
166
 
        sprite->Play("move");
167
 
      }
 
156
      skitter1->Play();
168
157
    else
169
 
      {
170
 
        skitter1->Pause(); //Stop()?
171
 
        sprite->Play("idle");
172
 
      }
 
158
      skitter1->Pause(); //Stop()?
173
159
  }
174
160
 
175
161
  // Scene
214
200
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
215
201
      }
216
202
   
217
 
    player = new Player();
 
203
    Player *player = new Player;
218
204
    player->position = Graphics::GetScreenCenter();
219
205
    Add(player);
220
 
    Add(player->dark);
221
206
 
222
207
    Creature *creature = new Creature;
223
208
    creature->position = Graphics::GetScreenCenter();
257
242
          {
258
243
            isPaused = !isPaused;
259
244
            
260
 
            if (isPaused) {
261
 
              player->dark->isVisible = false;
 
245
            if (isPaused)
262
246
              levelEditor->Enable();
263
 
            } else {
 
247
            else
264
248
              levelEditor->Disable();
265
 
              player->dark->isVisible = true;
266
 
            }
267
249
          }
268
250
      }
269
251
 
276
258
      this->font = Assets::RequestFont("LiberationSans-Regular.ttf", 18.0f);
277
259
    else
278
260
      this->font = font;
279
 
 
280
 
    SetLayer(-2);
281
261
  }
282
262
 
283
263
  void Text::Render()