Projectile Library

Revision:
3:70c599d9f191
Parent:
2:b079859c59ba
Child:
4:977109f7b9f6
diff -r b079859c59ba -r 70c599d9f191 Projectile.cpp
--- a/Projectile.cpp	Sat Apr 29 13:17:35 2017 +0000
+++ b/Projectile.cpp	Tue May 02 09:43:19 2017 +0000
@@ -11,19 +11,46 @@
 
 }
 
-void Projectile::init(int size,int speed)
+
+void Projectile::init()
 {
-    _size = 1;
     //Make intial position of projectile = centre of player
-    _velocity.x = 0;
-    _velocity.y = speed;
-    _x = playerx;
-    _y = playery;
+
 }
 
+
+
 void Projectile::draw(N5110 &lcd)
-{
-    lcd.drawRect(_x,_y,_size,_size,FILL_BLACK);
+{   
+    _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()
@@ -34,8 +61,8 @@
 
 void Projectile::set_velocity(Vector2D v)
 {
-    _velocity.x = 3;
-    _velocity.y = 3;
+    _velocity.x = v.x;
+    _velocity.y = v.y;
 }
 
 Vector2D Projectile::get_velocity()
@@ -46,12 +73,7 @@
 
 Vector2D Projectile::get_pos()
 {
-    Vector2D ppos = {_x,_y};
-    return ppos;
-}
-
-void Projectile::set_pos(Vector2D p)
-{
-    _x = p.x;
-    _y = p.y;
+    Vector2D projpos = {_x,_y};
+    printf("projpos = %f %f \n", projpos.x, projpos.y);
+    return projpos;
 }
\ No newline at end of file