Player character library

Committer:
isabelc
Date:
Tue May 02 14:46:26 2017 +0000
Revision:
11:989df9be83dd
Parent:
10:cfeef15cce27
Child:
12:9bc551a4cab9
Doxygen commenting and other comments added throughout

Who changed what in which revision?

UserRevisionLine numberNew 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 11:989df9be83dd 28 /** Update
isabelc 11:989df9be83dd 29 *
isabelc 11:989df9be83dd 30 * Prints the speech at the start of the game.
isabelc 11:989df9be83dd 31 * @param lcd - a reference to the instance of N5110 screen
isabelc 11:989df9be83dd 32 * @param pad - a reference to the instance of the gampad library
isabelc 11:989df9be83dd 33 */
isabelc 10:cfeef15cce27 34 void PlayerChar::update(N5110 &lcd, Gamepad &pad)
isabelc 4:7bae458055bf 35 {
isabelc 4:7bae458055bf 36 float _d = pad.get_direction();
isabelc 11:989df9be83dd 37 //printf("Direction from joystick: %I", _d);
isabelc 9:47ef8da7cbf2 38
isabelc 11:989df9be83dd 39 // update x value depending on direction of movement of joystick
isabelc 5:31713bfad54e 40 // West is decrement as origin is at the top-left so decreasing moves left
isabelc 4:7bae458055bf 41 if (_d == W) {
isabelc 5:31713bfad54e 42 _x = _x - 3;
isabelc 4:7bae458055bf 43 } else if (_d == E) {
isabelc 5:31713bfad54e 44 _x = _x + 3;
isabelc 4:7bae458055bf 45 }
isabelc 11:989df9be83dd 46 //printf("_x value: %I", _x);
isabelc 11:989df9be83dd 47
isabelc 5:31713bfad54e 48 // check the x origin to ensure that the character doesn't go off screen
isabelc 11:989df9be83dd 49 if (_x < 2) {
isabelc 11:989df9be83dd 50 _x = 2; //if attempts to move left place at edge of screen
isabelc 11:989df9be83dd 51 } else if (_x > 76) {
isabelc 11:989df9be83dd 52 _x = 76; //if attempts to move right place at edge of screen
isabelc 4:7bae458055bf 53 }
isabelc 11:989df9be83dd 54 //printf(_x value after limits: %I", _x);
isabelc 11:989df9be83dd 55
isabelc 4:7bae458055bf 56 detective1.render(lcd, _x, 30);
isabelc 8:e192166b28f9 57 }
isabelc 8:e192166b28f9 58
isabelc 11:989df9be83dd 59 /** Get Detective X Positon
isabelc 11:989df9be83dd 60 *
isabelc 11:989df9be83dd 61 * Returns the x value of the player character.
isabelc 11:989df9be83dd 62 */
isabelc 10:cfeef15cce27 63 int PlayerChar::getdex()
isabelc 9:47ef8da7cbf2 64 {
isabelc 8:e192166b28f9 65 return _x;
isabelc 11:989df9be83dd 66 //printf("X value of player character in PlayerChar class: %I");
isabelc 9:47ef8da7cbf2 67 }