Haoyan Zhang / Mbed 2 deprecated el17h2z1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Acid.cpp Source File

Acid.cpp

00001 #include "Acid.h"
00002 
00003 Acid::Acid()
00004 {
00005     
00006 }
00007 
00008 Acid::~Acid()
00009 {
00010     
00011 }
00012 
00013 void Acid::init(int height,int width,int speed)
00014 {
00015      Vector2D Boss_pos = _Boss.get_pos();
00016      _width = width;
00017      _height = height;
00018      // Set Acid's position
00019      _x = Boss_pos.x + 3;
00020      _y = Boss_pos.y + 5; 
00021      
00022      srand(time(NULL));
00023      
00024      _velocity.x = 0;
00025      _velocity.y = 1.5*speed;
00026      
00027 }
00028 
00029 void Acid::draw(N5110 &lcd)
00030 {   
00031     lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
00032 }
00033 
00034 void Acid::update()
00035 {
00036      _x += _velocity.x;
00037      _y += _velocity.y;
00038 }
00039 
00040 void Acid::set_velocity(Vector2D v)
00041 {
00042     _velocity.x = v.x;
00043     _velocity.y = v.y;
00044 }
00045 
00046 Vector2D Acid::get_velocity()
00047 {
00048     Vector2D v = {_velocity.x,_velocity.y};
00049     return v;
00050 }
00051  
00052 Vector2D Acid::get_pos()
00053 {
00054     Vector2D p = {_x,_y};
00055     return p;
00056 }
00057  
00058 void Acid::set_pos(Vector2D p)
00059 {
00060     _x = p.x;
00061     _y = p.y;
00062 }
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072      
00073