Player character library
PlayerChar.cpp@10:cfeef15cce27, 2017-05-01 (annotated)
- Committer:
- isabelc
- Date:
- Mon May 01 15:54:55 2017 +0000
- Revision:
- 10:cfeef15cce27
- Parent:
- 9:47ef8da7cbf2
- Child:
- 11:989df9be83dd
Changed class names
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
isabelc | 1:219e18b8f20e | 1 | #include "PlayerChar.h" |
isabelc | 3:315d21341563 | 2 | ; |
isabelc | 7:7590ebb0bbe4 | 3 | |
isabelc | 3:315d21341563 | 4 | static int detectiveStill[] = { |
isabelc | 9:47ef8da7cbf2 | 5 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 6 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 7 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 8 | 0,1,1,1,1,1,1,0, |
isabelc | 9:47ef8da7cbf2 | 9 | 0,0,0,0,0,0,0,0, |
isabelc | 9:47ef8da7cbf2 | 10 | 0,0,0,0,0,0,0,0, |
isabelc | 9:47ef8da7cbf2 | 11 | 0,1,1,1,1,1,1,0, |
isabelc | 9:47ef8da7cbf2 | 12 | 1,1,1,1,1,1,1,1, |
isabelc | 9:47ef8da7cbf2 | 13 | 1,0,1,1,1,1,0,1, |
isabelc | 9:47ef8da7cbf2 | 14 | 1,0,1,1,1,1,0,1, |
isabelc | 9:47ef8da7cbf2 | 15 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 16 | 0,0,0,1,1,0,0,0, |
isabelc | 9:47ef8da7cbf2 | 17 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 18 | 0,0,1,1,1,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 19 | 0,0,1,0,0,1,0,0, |
isabelc | 9:47ef8da7cbf2 | 20 | 0,0,1,0,0,1,0,0 |
isabelc | 1:219e18b8f20e | 21 | }; |
isabelc | 1:219e18b8f20e | 22 | |
isabelc | 3:315d21341563 | 23 | // Instantiate the Bitmap object using the data above |
isabelc | 3:315d21341563 | 24 | Bitmap detective1(detectiveStill, 16, 8); // Specify rows and columns in sprite |
isabelc | 3:315d21341563 | 25 | |
isabelc | 4:7bae458055bf | 26 | int _x = 10; |
isabelc | 4:7bae458055bf | 27 | |
isabelc | 10:cfeef15cce27 | 28 | void PlayerChar::update(N5110 &lcd, Gamepad &pad) |
isabelc | 4:7bae458055bf | 29 | { |
isabelc | 4:7bae458055bf | 30 | float _d = pad.get_direction(); |
isabelc | 9:47ef8da7cbf2 | 31 | |
isabelc | 5:31713bfad54e | 32 | // update x value depending on direction of movementmof joystick |
isabelc | 5:31713bfad54e | 33 | // West is decrement as origin is at the top-left so decreasing moves left |
isabelc | 4:7bae458055bf | 34 | if (_d == W) { |
isabelc | 5:31713bfad54e | 35 | _x = _x - 3; |
isabelc | 4:7bae458055bf | 36 | } else if (_d == E) { |
isabelc | 5:31713bfad54e | 37 | _x = _x + 3; |
isabelc | 4:7bae458055bf | 38 | } |
isabelc | 5:31713bfad54e | 39 | // check the x origin to ensure that the character doesn't go off screen |
isabelc | 4:7bae458055bf | 40 | if (_x < 2) { |
isabelc | 4:7bae458055bf | 41 | _x = 2; |
isabelc | 4:7bae458055bf | 42 | } |
isabelc | 4:7bae458055bf | 43 | if (_x > 76) { |
isabelc | 4:7bae458055bf | 44 | _x = 76; |
isabelc | 4:7bae458055bf | 45 | } |
isabelc | 4:7bae458055bf | 46 | detective1.render(lcd, _x, 30); |
isabelc | 8:e192166b28f9 | 47 | |
isabelc | 8:e192166b28f9 | 48 | } |
isabelc | 8:e192166b28f9 | 49 | |
isabelc | 10:cfeef15cce27 | 50 | int PlayerChar::getdex() |
isabelc | 9:47ef8da7cbf2 | 51 | { |
isabelc | 8:e192166b28f9 | 52 | return _x; |
isabelc | 9:47ef8da7cbf2 | 53 | } |