/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 03:32:26 UTC
  • Revision ID: josh@9ix.org-20110917033226-h7qh4w1plypy7wk0
square moving around the screen

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
namespace Dark
4
4
{
5
5
  Player::Player() : Entity(),
6
 
                     VELOCITY(150.0f)
 
6
                     FRICTION(400),
 
7
                     MAXSPEED(60.0f),
 
8
                     ACCELERATION(800)
7
9
  {
8
10
    sprite = new SpriteAnimation("player.png", FILTER_NONE, 64, 64);
9
11
    sprite->Add("idle", 0, 0, 0.35f);
19
21
  {
20
22
    Entity::Update();
21
23
 
 
24
    if (Input::IsKeyMaskHeld("left"))
 
25
      {
 
26
        velocity.x -= ACCELERATION * Monocle::deltaTime;
 
27
      }
 
28
    if (Input::IsKeyMaskHeld("right"))
 
29
      {
 
30
        velocity.x += ACCELERATION * Monocle::deltaTime;
 
31
      }
 
32
    if (Input::IsKeyMaskHeld("up"))
 
33
      {
 
34
        velocity.y -= ACCELERATION * Monocle::deltaTime;
 
35
      }
 
36
    if (Input::IsKeyMaskHeld("down"))
 
37
      {
 
38
        velocity.y += ACCELERATION * Monocle::deltaTime;
 
39
      }
 
40
    
 
41
    // velocity will approach 0 in steps of FRICTION * dt
 
42
    velocity.x = APPROACH(velocity.x, 0, FRICTION * Monocle::deltaTime);
 
43
    velocity.y = APPROACH(velocity.y, 0, FRICTION * Monocle::deltaTime);
 
44
 
 
45
    position += velocity * Monocle::deltaTime;
 
46
 
22
47
    //Scene::GetCamera()->position = position;
23
48
 
24
49
    //...