Stick_Runner

Dependencies:   FXOS8700CQ Gamepad N5110 SDFileSystem mbed

Revision:
0:12cfe63faa6a
Child:
1:db9ff66f67c8
diff -r 000000000000 -r 12cfe63faa6a Gems/Gems.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Gems/Gems.cpp	Fri Apr 28 09:00:21 2017 +0000
@@ -0,0 +1,80 @@
+#include "Gems.h"
+
+Gems::Gems()
+{
+
+}
+
+Gems::~Gems()
+{
+
+}
+
+void Gems::init()
+{
+    _x = rand() % 84;
+    _y = 0;
+    _status = true;
+    counter;
+}
+
+void Gems::draw(N5110 &lcd)
+{
+    // draw Gemss in screen buffer. 
+   //lcd.drawRect(_x-4,_y-3,3,3,FILL_BLACK);
+   //lcd.drawLine(_x-3, _y-3,_x-3,_y+1,1);
+   
+   //lcd.drawCircle(_x,_y,2,FILL_BLACK);
+   lcd.setPixel(_x,_y);
+   lcd.setPixel(_x+1,_y);
+   lcd.setPixel(_x-1,_y);
+   lcd.setPixel(_x,_y+1);
+   lcd.setPixel(_x,_y-1);
+ 
+   
+   
+   
+}
+
+void Gems::Gems_Status(Vector2D p)
+{
+   /* if(((p.x<_x+3)&&(p.x>_x-3))&&((p.y<_y+3)&&(p.y>_y-3))){
+        
+        _status = false;
+        }
+     */   
+        if(_y > HEIGHT)
+        {
+            _status = false;
+        }
+}
+
+void Gems::Gems_Score(Vector2D p)
+{
+    if(((_x-1<p.x)&&(_x+1>p.x))&&((_y-1<p.y)&&(_y+1>p.y))){
+        
+        counter++;
+        }
+}
+
+void Gems::update()
+{
+   _y =_y+2;
+  /* if(!_status)
+   {
+       _y = HEIGHT + 3;
+       }*/
+}
+
+
+
+Vector2D Gems::get_pos() {
+    Vector2D p = {_x,_y};
+    return p;    
+}
+bool Gems::get_status(){
+    return _status;
+    
+    }
+    
+    
\ No newline at end of file