/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:03:52 UTC
  • Revision ID: josh@9ix.org-20110917150352-j6nh9t61px2eitdu
skittering blue square

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
 
 
18
 
    footsteps = Audio::NewDeck(Assets::RequestAudio("footsteps.ogg"));
19
 
    footsteps->SetLoops(0); //loop indefinitely
20
16
    
21
 
    SetCollider(new RectangleCollider(16, 16));
 
17
    SetCollider(new RectangleCollider(32, 32));
22
18
  }
23
19
 
24
20
  void Player::Update()
69
65
      }
70
66
    if (ycol) {velocity.y = 0;}
71
67
 
72
 
    if (velocity.GetSquaredMagnitude() > 20)
73
 
      footsteps->Play();
74
 
    else
75
 
      footsteps->Pause(); //Stop()?
76
68
 
77
69
    //Scene::GetCamera()->position = position;
78
70
  }
79
71
 
80
72
  Creature::Creature() : Entity(),
81
73
                         FRICTION(800),
82
 
                         MAXSPEED(15.0f),
 
74
                         MAXSPEED(30.0f),
83
75
                         ACCELERATION(1200)                      
84
76
  {
85
77
    sprite = new SpriteAnimation("creature.png", FILTER_NONE, 64, 64);
86
78
    sprite->Add("idle", 0, 0, 0.35f);
87
 
    sprite->Add("move", 1, 2, 4.0f);
88
79
    sprite->Play("idle");
89
80
    SetGraphic(sprite);
90
 
    scale = Vector2(0.25, 0.25);
91
81
 
92
82
    AddTag("creature");
93
 
    SetCollider(new RectangleCollider(16, 16));
 
83
    SetCollider(new RectangleCollider(32, 32));
94
84
 
95
85
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
96
86
    skitter1->SetLoops(0); //loop indefinitely
97
87
 
98
 
    velocity = Vector2::Random() * MAXSPEED;
 
88
    velocity = Vector2::Random() * ACCELERATION;
99
89
 
100
90
    //set aiTime to random so creatures tick at different times
101
91
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
108
98
    aiTime += Monocle::deltaTime;
109
99
    if (aiTime > 1.0f)
110
100
      {
111
 
        switch (rand() % 3)
 
101
        switch (rand() % 2)
112
102
          {
113
103
          case 0: // idle
114
104
            //printf("idle\n");
155
145
      }
156
146
    if (ycol) {velocity.y = 0;}
157
147
 
158
 
    if (velocity.GetSquaredMagnitude() > 20)
159
 
      {
160
 
        skitter1->Play();
161
 
        sprite->Play("move");
162
 
      }
 
148
    if (velocity.GetSquaredMagnitude() > 0)
 
149
      skitter1->Play();
163
150
    else
164
 
      {
165
 
        skitter1->Pause(); //Stop()?
166
 
        sprite->Play("idle");
167
 
      }
 
151
      skitter1->Pause(); //Stop()?
168
152
  }
169
153
 
170
154
  // Scene
217
201
    creature->position = Graphics::GetScreenCenter();
218
202
    Add(creature);
219
203
 
220
 
    Creature *creature2 = new Creature;
221
 
    creature2->position = Graphics::GetScreenCenter();
222
 
    Add(creature2);
223
 
 
224
 
    Graphics::SetBackgroundColor(Color::black * 0.2f);
 
204
    Graphics::SetBackgroundColor(Color::green * 0.2f);
225
205
 
226
206
  }
227
207