/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 17:12:23 UTC
  • Revision ID: josh@9ix.org-20110917171223-hsvrl6q7mxxbc1sv
creatures move less, make everything smaller

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