test 1 doc

Dependencies:   mbed Gamepad2

Committer:
joebarhouch
Date:
Mon May 25 16:17:58 2020 +0000
Revision:
6:00d20886e4f8
Parent:
5:928c2eee4109
Child:
7:530ca713d2b2
Implements map as an array of platforms for easier collision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joebarhouch 5:928c2eee4109 1 #include "Platform.h"
joebarhouch 5:928c2eee4109 2
joebarhouch 6:00d20886e4f8 3 Platform::Platform(int x, int y, int w, int h)
joebarhouch 5:928c2eee4109 4 {
joebarhouch 6:00d20886e4f8 5 _x = x;
joebarhouch 6:00d20886e4f8 6 _y = y;
joebarhouch 6:00d20886e4f8 7 _width = w;
joebarhouch 6:00d20886e4f8 8 _height = h;
joebarhouch 5:928c2eee4109 9 }
joebarhouch 5:928c2eee4109 10
joebarhouch 5:928c2eee4109 11 Platform::~Platform()
joebarhouch 5:928c2eee4109 12 {
joebarhouch 5:928c2eee4109 13
joebarhouch 5:928c2eee4109 14 }
joebarhouch 5:928c2eee4109 15
joebarhouch 6:00d20886e4f8 16
joebarhouch 6:00d20886e4f8 17 ////////////////////// DRAW //////////////////////////
joebarhouch 6:00d20886e4f8 18 void Platform::draws(N5110 &lcd)
joebarhouch 5:928c2eee4109 19 {
joebarhouch 6:00d20886e4f8 20 lcd.drawRect(_x, _y, _width, _height, FILL_TRANSPARENT);
joebarhouch 6:00d20886e4f8 21 //debug prints
joebarhouch 6:00d20886e4f8 22 //printf("x: %i, y: %i, width: %i, height %i \n", x, y, width, height);
joebarhouch 6:00d20886e4f8 23 }
joebarhouch 6:00d20886e4f8 24
joebarhouch 6:00d20886e4f8 25 ////////////////////// POSTITIONS //////////////////////////
joebarhouch 6:00d20886e4f8 26 Vector4 Platform::get_pos()
joebarhouch 6:00d20886e4f8 27 {
joebarhouch 6:00d20886e4f8 28 Vector4 pos = {_x, _y, _width, _height};
joebarhouch 6:00d20886e4f8 29 return pos;
joebarhouch 5:928c2eee4109 30 }
joebarhouch 5:928c2eee4109 31
joebarhouch 6:00d20886e4f8 32
joebarhouch 6:00d20886e4f8 33
joebarhouch 6:00d20886e4f8 34 //------------------------------MAPS-----------------------------------//
joebarhouch 6:00d20886e4f8 35
joebarhouch 6:00d20886e4f8 36 Platform maps[4] = {Platform(0, 15, 20, 3), Platform(64, 15, 20, 3), Platform(0, 40, 20, 3), Platform(64, 40, 20, 3)};
joebarhouch 6:00d20886e4f8 37
joebarhouch 6:00d20886e4f8 38 ////////////////////// DRAW MAP //////////////////////////
joebarhouch 6:00d20886e4f8 39 void drawMap(N5110 &lcd)
joebarhouch 5:928c2eee4109 40 {
joebarhouch 6:00d20886e4f8 41 Vector4 coords;
joebarhouch 6:00d20886e4f8 42 for (int i = 0; i < 4; i++) {
joebarhouch 6:00d20886e4f8 43 maps[i].draws(lcd);
joebarhouch 6:00d20886e4f8 44 coords = maps[i].get_pos();
joebarhouch 6:00d20886e4f8 45
joebarhouch 6:00d20886e4f8 46 //debugs
joebarhouch 6:00d20886e4f8 47 //printf("x: %i, y: %i,w: %i,h: %i \n",coords.x, coords.y, coords.width, coords.height);
joebarhouch 6:00d20886e4f8 48 }
joebarhouch 6:00d20886e4f8 49 //debugs
joebarhouch 6:00d20886e4f8 50 //printf("-----------------------------------------\n");
joebarhouch 5:928c2eee4109 51 }
joebarhouch 5:928c2eee4109 52