Early commits of my project

Dependencies:   mbed Gamepad N5110

Committer:
el17arm
Date:
Wed Mar 13 16:38:21 2019 +0000
Revision:
6:6294bf4eafc8
implementing class but needs debugging

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17arm 6:6294bf4eafc8 1 #include "Sprites.h"
el17arm 6:6294bf4eafc8 2 #include "main.h"
el17arm 6:6294bf4eafc8 3 #include "Gamepad.h"
el17arm 6:6294bf4eafc8 4
el17arm 6:6294bf4eafc8 5 Gamepad pad;
el17arm 6:6294bf4eafc8 6
el17arm 6:6294bf4eafc8 7 Sprites::Sprites()
el17arm 6:6294bf4eafc8 8 {
el17arm 6:6294bf4eafc8 9 }
el17arm 6:6294bf4eafc8 10
el17arm 6:6294bf4eafc8 11 Sprites::~Sprites()
el17arm 6:6294bf4eafc8 12 {
el17arm 6:6294bf4eafc8 13 }
el17arm 6:6294bf4eafc8 14
el17arm 6:6294bf4eafc8 15 void Sprites::miner_move(int x_direction, int y_direction)
el17arm 6:6294bf4eafc8 16 {
el17arm 6:6294bf4eafc8 17
el17arm 6:6294bf4eafc8 18
el17arm 6:6294bf4eafc8 19
el17arm 6:6294bf4eafc8 20 const int miner_right[13][5] = {
el17arm 6:6294bf4eafc8 21 0,0,0,1,1,
el17arm 6:6294bf4eafc8 22 0,1,1,1,1,
el17arm 6:6294bf4eafc8 23 0,1,0,1,0,
el17arm 6:6294bf4eafc8 24 0,1,1,1,1,
el17arm 6:6294bf4eafc8 25 0,1,1,1,0,
el17arm 6:6294bf4eafc8 26 0,0,1,0,0,
el17arm 6:6294bf4eafc8 27 1,1,1,1,1,
el17arm 6:6294bf4eafc8 28 1,1,1,1,1,
el17arm 6:6294bf4eafc8 29 1,1,1,1,1,
el17arm 6:6294bf4eafc8 30 0,1,1,1,0,
el17arm 6:6294bf4eafc8 31 0,1,0,1,0,
el17arm 6:6294bf4eafc8 32 0,1,1,1,1,
el17arm 6:6294bf4eafc8 33 };
el17arm 6:6294bf4eafc8 34
el17arm 6:6294bf4eafc8 35 const int miner_left[13][5] = {
el17arm 6:6294bf4eafc8 36 1,1,0,0,0,
el17arm 6:6294bf4eafc8 37 1,1,1,1,0,
el17arm 6:6294bf4eafc8 38 0,1,0,1,0,
el17arm 6:6294bf4eafc8 39 1,1,1,1,0,
el17arm 6:6294bf4eafc8 40 0,1,1,1,0,
el17arm 6:6294bf4eafc8 41 0,0,1,0,0,
el17arm 6:6294bf4eafc8 42 1,1,1,1,1,
el17arm 6:6294bf4eafc8 43 1,1,1,1,1,
el17arm 6:6294bf4eafc8 44 1,1,1,1,1,
el17arm 6:6294bf4eafc8 45 0,1,1,1,0,
el17arm 6:6294bf4eafc8 46 0,1,0,1,0,
el17arm 6:6294bf4eafc8 47 1,1,1,1,0,
el17arm 6:6294bf4eafc8 48 };
el17arm 6:6294bf4eafc8 49
el17arm 6:6294bf4eafc8 50 lcd.clear();
el17arm 6:6294bf4eafc8 51
el17arm 6:6294bf4eafc8 52
el17arm 6:6294bf4eafc8 53 Direction d = pad.get_direction();
el17arm 6:6294bf4eafc8 54 printf("Direction = %i\n",d);
el17arm 6:6294bf4eafc8 55
el17arm 6:6294bf4eafc8 56 lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right);
el17arm 6:6294bf4eafc8 57
el17arm 6:6294bf4eafc8 58
el17arm 6:6294bf4eafc8 59 if (d==3) {
el17arm 6:6294bf4eafc8 60
el17arm 6:6294bf4eafc8 61 x_direction = x_direction + 1;
el17arm 6:6294bf4eafc8 62 lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right);
el17arm 6:6294bf4eafc8 63 lcd.refresh();
el17arm 6:6294bf4eafc8 64 wait(0.05);
el17arm 6:6294bf4eafc8 65
el17arm 6:6294bf4eafc8 66 }
el17arm 6:6294bf4eafc8 67
el17arm 6:6294bf4eafc8 68 if (d == 7) {
el17arm 6:6294bf4eafc8 69
el17arm 6:6294bf4eafc8 70 x_direction = x_direction - 1;
el17arm 6:6294bf4eafc8 71 lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_left);
el17arm 6:6294bf4eafc8 72 lcd.refresh();
el17arm 6:6294bf4eafc8 73 wait(0.05);
el17arm 6:6294bf4eafc8 74 }
el17arm 6:6294bf4eafc8 75 //lcd.drawSprite(WIDTH/2 + x,HEIGHT/2 + y,13,5,(int *)miner);
el17arm 6:6294bf4eafc8 76 //lcd.refresh();
el17arm 6:6294bf4eafc8 77
el17arm 6:6294bf4eafc8 78 if(pad.check_event(Gamepad::A_PRESSED)) {
el17arm 6:6294bf4eafc8 79
el17arm 6:6294bf4eafc8 80
el17arm 6:6294bf4eafc8 81 printf("A pressed");
el17arm 6:6294bf4eafc8 82 y_direction = y_direction - 6;
el17arm 6:6294bf4eafc8 83 lcd.clear();
el17arm 6:6294bf4eafc8 84 lcd.drawSprite(WIDTH/2 + x_direction,HEIGHT/2 + y_direction,13,5,(int *)miner_right);
el17arm 6:6294bf4eafc8 85 lcd.refresh();
el17arm 6:6294bf4eafc8 86 wait(0.2);
el17arm 6:6294bf4eafc8 87 y_direction = y_direction + 6;
el17arm 6:6294bf4eafc8 88 }
el17arm 6:6294bf4eafc8 89 }