Ikenna Adrian Ozoemena 201157039
Dependencies: mbed
Weapons/Weapons.cpp
- Committer:
- ikenna1
- Date:
- 2019-04-09
- Revision:
- 9:241a1a7d8527
- Child:
- 14:88ca5b1a111a
File content as of revision 9:241a1a7d8527:
#include "Weapons.h" Weapons::Weapons() { } Weapons::~Weapons() { } //Obtains the player position coordinates in the initialisation stage. void Weapons::init(int ship_xpos, int ship_ypos, int ship_width) { //printf("ship x, ship y = %d , %d \n", playerx, playery); _ship_xpos = ship_xpos + (ship_width/2); _ship_ypos = ship_ypos; } void Weapons::draw(N5110 &lcd) { /* The ship x position does not seem to be updating we need to pass the _ship_xpos froreset the ship class to here _ship_xpos = ship._ship_xpos _ship_ypos = ship._ship_ypos */ _velocity.x = 0; //Projectile doesn't move sideways. _velocity.y = -1; //Projectile moves upwards on screen. //resets once projectile reaches top of screen if(_y <= -1){ reset= 0; } if(reset == 0){ _x = _ship_xpos; _y = _ship_ypos; reset = reset+1; } lcd.drawRect(_x,_y,1,4,FILL_BLACK); // printf("Ship x and y pos, reset = %d , %d ,%d \n", _ship_xpos, _ship_ypos, reset); } void Weapons::update() { _x = _x + _velocity.x; _y = _y + _velocity.y; } Vector2D Weapons::get_pos() { Vector2D pos = {_x,_y}; return pos; } void Weapons::set_pos(Vector2D p) { _x = p.x; _y = p.y; }