/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 16:54:23 UTC
  • Revision ID: josh@9ix.org-20110917165423-wflahgpej1hbjowe
harder to see creatures

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);
92
86
    sprite->Add("move", 1, 2, 4.0f);
93
87
    sprite->Play("idle");
94
88
    SetGraphic(sprite);
95
 
    scale = Vector2(0.25, 0.25);
96
89
 
97
90
    AddTag("creature");
98
 
    SetCollider(new RectangleCollider(16, 16));
 
91
    SetCollider(new RectangleCollider(32, 32));
99
92
 
100
93
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
101
94
    skitter1->SetLoops(0); //loop indefinitely
102
95
 
103
 
    velocity = Vector2::Random() * MAXSPEED;
 
96
    velocity = Vector2::Random() * ACCELERATION;
104
97
 
105
98
    //set aiTime to random so creatures tick at different times
106
99
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
113
106
    aiTime += Monocle::deltaTime;
114
107
    if (aiTime > 1.0f)
115
108
      {
116
 
        switch (rand() % 3)
 
109
        switch (rand() % 2)
117
110
          {
118
111
          case 0: // idle
119
112
            //printf("idle\n");
214
207
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
215
208
      }
216
209
   
217
 
    player = new Player();
 
210
    Player *player = new Player;
218
211
    player->position = Graphics::GetScreenCenter();
219
212
    Add(player);
220
 
    Add(player->dark);
221
213
 
222
214
    Creature *creature = new Creature;
223
215
    creature->position = Graphics::GetScreenCenter();
227
219
    creature2->position = Graphics::GetScreenCenter();
228
220
    Add(creature2);
229
221
 
230
 
    Graphics::SetBackgroundColor(Color::green * 0.2f);
 
222
    Graphics::SetBackgroundColor(Color::black * 0.2f);
231
223
 
232
224
  }
233
225
 
257
249
          {
258
250
            isPaused = !isPaused;
259
251
            
260
 
            if (isPaused) {
261
 
              player->dark->position = Vector2(2048, 1600);
 
252
            if (isPaused)
262
253
              levelEditor->Enable();
263
 
            } else {
 
254
            else
264
255
              levelEditor->Disable();
265
 
            }
266
256
          }
267
257
      }
268
258
 
275
265
      this->font = Assets::RequestFont("LiberationSans-Regular.ttf", 18.0f);
276
266
    else
277
267
      this->font = font;
278
 
 
279
 
    SetLayer(-2);
280
268
  }
281
269
 
282
270
  void Text::Render()