Projectile Library
Projectile.cpp
- Committer:
- ll14c4p
- Date:
- 2017-05-02
- Revision:
- 3:70c599d9f191
- Parent:
- 2:b079859c59ba
- Child:
- 4:977109f7b9f6
File content as of revision 3:70c599d9f191:
#include "Projectile.h" #include "Player.h" Projectile::Projectile() { } Projectile::~Projectile() { } void Projectile::init() { //Make intial position of projectile = centre of player } void Projectile::draw(N5110 &lcd) { _velocity.x = 0; _velocity.y = -4; if(_x <= -1){ m = 0; } if(_x >= 85){ m = 0; } if(_y <= -1){ m = 0; } if(_y >= 49){ m = 0; } if(m == 0){ _x = WIDTH/2; // Middle of screen // Change these values to change starting position _y = HEIGHT/2; // Near bottom of screen m = m+1; } lcd.drawRect(_x,_y,1,1,FILL_BLACK); printf("projdrawn %d %d \n", _x, _y); printf("playerpos in proj = %d %d \n", playerx, playery); } void Projectile::update() { _x += _velocity.x; _y += _velocity.y; } void Projectile::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } Vector2D Projectile::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } Vector2D Projectile::get_pos() { Vector2D projpos = {_x,_y}; printf("projpos = %f %f \n", projpos.x, projpos.y); return projpos; }