/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 19:21:01 UTC
  • Revision ID: josh@9ix.org-20110917192101-8i3cly7ecyt9o46s
"light" in the dark

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(60.0f),
 
7
                     MAXSPEED(20.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);
14
15
 
15
16
    AddTag("player");
16
17
 
17
18
    footsteps = Audio::NewDeck(Assets::RequestAudio("footsteps.ogg"));
18
19
    footsteps->SetLoops(0); //loop indefinitely
19
20
    
20
 
    SetCollider(new RectangleCollider(32, 32));
 
21
    SetCollider(new RectangleCollider(16, 16));
 
22
 
 
23
    dark = new Entity();
 
24
    dark->SetGraphic(new Sprite("dark.png", FILTER_NONE, 2048, 1536)); //alpha?
21
25
  }
22
26
 
23
27
  void Player::Update()
73
77
    else
74
78
      footsteps->Pause(); //Stop()?
75
79
 
 
80
    dark->position = position;
 
81
 
76
82
    //Scene::GetCamera()->position = position;
77
83
  }
78
84
 
79
85
  Creature::Creature() : Entity(),
80
86
                         FRICTION(800),
81
 
                         MAXSPEED(30.0f),
 
87
                         MAXSPEED(15.0f),
82
88
                         ACCELERATION(1200)                      
83
89
  {
84
90
    sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
86
92
    sprite->Add("move", 1, 2, 4.0f);
87
93
    sprite->Play("idle");
88
94
    SetGraphic(sprite);
 
95
    scale = Vector2(0.25, 0.25);
89
96
 
90
97
    AddTag("creature");
91
 
    SetCollider(new RectangleCollider(32, 32));
 
98
    SetCollider(new RectangleCollider(16, 16));
92
99
 
93
100
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
94
101
    skitter1->SetLoops(0); //loop indefinitely
95
102
 
96
 
    velocity = Vector2::Random() * ACCELERATION;
 
103
    velocity = Vector2::Random() * MAXSPEED;
97
104
 
98
105
    //set aiTime to random so creatures tick at different times
99
106
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
106
113
    aiTime += Monocle::deltaTime;
107
114
    if (aiTime > 1.0f)
108
115
      {
109
 
        switch (rand() % 2)
 
116
        switch (rand() % 3)
110
117
          {
111
118
          case 0: // idle
112
119
            //printf("idle\n");
210
217
    Player *player = new Player;
211
218
    player->position = Graphics::GetScreenCenter();
212
219
    Add(player);
 
220
    Add(player->dark);
213
221
 
214
222
    Creature *creature = new Creature;
215
223
    creature->position = Graphics::GetScreenCenter();
219
227
    creature2->position = Graphics::GetScreenCenter();
220
228
    Add(creature2);
221
229
 
222
 
    Graphics::SetBackgroundColor(Color::black * 0.2f);
 
230
    Graphics::SetBackgroundColor(Color::green * 0.2f);
223
231
 
224
232
  }
225
233