Library containing the Game Engine

Committer:
ll14c4p
Date:
Fri Apr 28 15:52:35 2017 +0000
Revision:
2:3b1d8ac1aac1
Parent:
1:13a97de95e46
Child:
3:2f8f003ce4fd
Starting Position Working;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ll14c4p 0:5997fa876927 1 #include "GameEngine.h"
ll14c4p 0:5997fa876927 2
ll14c4p 0:5997fa876927 3 GameEngine::GameEngine()
ll14c4p 0:5997fa876927 4 {
ll14c4p 0:5997fa876927 5
ll14c4p 0:5997fa876927 6 }
ll14c4p 0:5997fa876927 7
ll14c4p 0:5997fa876927 8 GameEngine::~GameEngine()
ll14c4p 0:5997fa876927 9 {
ll14c4p 0:5997fa876927 10
ll14c4p 0:5997fa876927 11 }
ll14c4p 0:5997fa876927 12
ll14c4p 0:5997fa876927 13 void GameEngine::init()
ll14c4p 0:5997fa876927 14 {
ll14c4p 0:5997fa876927 15
ll14c4p 0:5997fa876927 16 }
ll14c4p 0:5997fa876927 17
ll14c4p 0:5997fa876927 18
ll14c4p 0:5997fa876927 19
ll14c4p 0:5997fa876927 20 void GameEngine::read_input(Gamepad &pad)
ll14c4p 0:5997fa876927 21 {
ll14c4p 0:5997fa876927 22 _d = pad.get_direction();
ll14c4p 0:5997fa876927 23 _mag = pad.get_mag();
ll14c4p 0:5997fa876927 24 }
ll14c4p 0:5997fa876927 25
ll14c4p 0:5997fa876927 26 void GameEngine::draw(N5110 &lcd)
ll14c4p 0:5997fa876927 27 {
ll14c4p 0:5997fa876927 28 // draw the elements in the LCD buffer
ll14c4p 0:5997fa876927 29 // player
ll14c4p 0:5997fa876927 30 _p.draw(lcd);
ll14c4p 0:5997fa876927 31 }
ll14c4p 0:5997fa876927 32
ll14c4p 0:5997fa876927 33 void GameEngine::update(Gamepad &pad)
ll14c4p 0:5997fa876927 34 {
ll14c4p 0:5997fa876927 35 // important to update paddles and ball before checking collisions so can
ll14c4p 0:5997fa876927 36 // correct for it before updating the display
ll14c4p 0:5997fa876927 37 _p.update(_d,_mag);
ll14c4p 0:5997fa876927 38
ll14c4p 0:5997fa876927 39 }
ll14c4p 1:13a97de95e46 40
ll14c4p 1:13a97de95e46 41 void GameEngine::get_pos()
ll14c4p 1:13a97de95e46 42 {
ll14c4p 1:13a97de95e46 43 Vector2D player_pos = _p.get_pos();
ll14c4p 1:13a97de95e46 44 printf("yolo swag %f %f \n", player_pos.x, player_pos.y); //top left of player sprite
ll14c4p 2:3b1d8ac1aac1 45 //yolo swag 81.000000 0.000000 top right
ll14c4p 2:3b1d8ac1aac1 46 //yolo swag 0.000000 0.000000 is top left
ll14c4p 2:3b1d8ac1aac1 47 //yolo swag 81.000000 45.000000 bottom right
ll14c4p 1:13a97de95e46 48
ll14c4p 1:13a97de95e46 49 }