src/proto2/GameState.cc
author saiam
Thu, 20 Nov 2008 22:45:10 +0000
changeset 86 ed31ece6f340
parent 66 1415a2d45686
child 94 08bebac3d0c2
permissions -rw-r--r--
Segfault <3 (mik? oli odotettavaa)
26
5685602aeb9c it works \o/
terom
parents:
diff changeset
     1
5685602aeb9c it works \o/
terom
parents:
diff changeset
     2
#include "GameState.hh"
5685602aeb9c it works \o/
terom
parents:
diff changeset
     3
60
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
     4
void LocalPlayer::handleMove (PlayerInput_Move input) {
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
     5
    float fx = 0, fy = 0;
26
5685602aeb9c it works \o/
terom
parents:
diff changeset
     6
50
9e1a6506f5a1 some rough-handed code modifications towards a newer, better, working Physics
terom
parents: 26
diff changeset
     7
    // handle up/down/left/right
54
b8b043ba0abd fix some more compiler errors...
terom
parents: 50
diff changeset
     8
    if (input & INPUT_MOVE_UP)
60
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
     9
            fy -= PLAYER_MOVE_FORCE;
50
9e1a6506f5a1 some rough-handed code modifications towards a newer, better, working Physics
terom
parents: 26
diff changeset
    10
    
54
b8b043ba0abd fix some more compiler errors...
terom
parents: 50
diff changeset
    11
    if (input & INPUT_MOVE_DOWN)
60
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
    12
            fy += PLAYER_MOVE_FORCE;
26
5685602aeb9c it works \o/
terom
parents:
diff changeset
    13
54
b8b043ba0abd fix some more compiler errors...
terom
parents: 50
diff changeset
    14
    if (input & INPUT_MOVE_LEFT)
60
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
    15
            fx -= PLAYER_MOVE_FORCE;
50
9e1a6506f5a1 some rough-handed code modifications towards a newer, better, working Physics
terom
parents: 26
diff changeset
    16
54
b8b043ba0abd fix some more compiler errors...
terom
parents: 50
diff changeset
    17
    if (input & INPUT_MOVE_RIGHT)
60
26571fd9a8d1 physics is starting to work
terom
parents: 58
diff changeset
    18
            fx += PLAYER_MOVE_FORCE;
50
9e1a6506f5a1 some rough-handed code modifications towards a newer, better, working Physics
terom
parents: 26
diff changeset
    19
    
66
1415a2d45686 working simple network-physics code
terom
parents: 60
diff changeset
    20
    if (fx || fy) {
1415a2d45686 working simple network-physics code
terom
parents: 60
diff changeset
    21
        // apply force
1415a2d45686 working simple network-physics code
terom
parents: 60
diff changeset
    22
        applyForce(Vector(fx, fy), INPUT_INTERVAL_MS);
1415a2d45686 working simple network-physics code
terom
parents: 60
diff changeset
    23
    }
26
5685602aeb9c it works \o/
terom
parents:
diff changeset
    24
}