/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:59:09 UTC
  • Revision ID: josh@9ix.org-20110917195909-v02b0cco0yri61qc
disappear darkness mask in editor mode

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);
85
91
    sprite->Add("idle", 0, 0, 0.35f);
 
92
    sprite->Add("move", 1, 2, 4.0f);
86
93
    sprite->Play("idle");
87
94
    SetGraphic(sprite);
 
95
    scale = Vector2(0.25, 0.25);
88
96
 
89
97
    AddTag("creature");
90
 
    SetCollider(new RectangleCollider(32, 32));
 
98
    SetCollider(new RectangleCollider(16, 16));
91
99
 
92
100
    skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
93
101
    skitter1->SetLoops(0); //loop indefinitely
94
102
 
95
 
    velocity = Vector2::Random() * ACCELERATION;
 
103
    velocity = Vector2::Random() * MAXSPEED;
96
104
 
97
105
    //set aiTime to random so creatures tick at different times
98
106
    aiTime= (float(rand()) / float(RAND_MAX)) * 1.0f;
105
113
    aiTime += Monocle::deltaTime;
106
114
    if (aiTime > 1.0f)
107
115
      {
108
 
        switch (rand() % 2)
 
116
        switch (rand() % 3)
109
117
          {
110
118
          case 0: // idle
111
119
            //printf("idle\n");
153
161
    if (ycol) {velocity.y = 0;}
154
162
 
155
163
    if (velocity.GetSquaredMagnitude() > 20)
156
 
      skitter1->Play();
 
164
      {
 
165
        skitter1->Play();
 
166
        sprite->Play("move");
 
167
      }
157
168
    else
158
 
      skitter1->Pause(); //Stop()?
 
169
      {
 
170
        skitter1->Pause(); //Stop()?
 
171
        sprite->Play("idle");
 
172
      }
159
173
  }
160
174
 
161
175
  // Scene
200
214
        e->SetCollider(new RectangleCollider(s.x * 64, s.y * 64));
201
215
      }
202
216
   
203
 
    Player *player = new Player;
 
217
    player = new Player();
204
218
    player->position = Graphics::GetScreenCenter();
205
219
    Add(player);
 
220
    Add(player->dark);
206
221
 
207
222
    Creature *creature = new Creature;
208
223
    creature->position = Graphics::GetScreenCenter();
242
257
          {
243
258
            isPaused = !isPaused;
244
259
            
245
 
            if (isPaused)
 
260
            if (isPaused) {
 
261
              player->dark->position = Vector2(2048, 1600);
246
262
              levelEditor->Enable();
247
 
            else
 
263
            } else {
248
264
              levelEditor->Disable();
 
265
            }
249
266
          }
250
267
      }
251
268
 
258
275
      this->font = Assets::RequestFont("LiberationSans-Regular.ttf", 18.0f);
259
276
    else
260
277
      this->font = font;
 
278
 
 
279
    SetLayer(-2);
261
280
  }
262
281
 
263
282
  void Text::Render()