Haoyan Zhang
/
el17h2z1
deemo1
Swarm/Swarm.cpp
- Committer:
- haoyan
- Date:
- 2020-05-14
- Revision:
- 6:b59bc5e15cf3
- Parent:
- 1:8c48fb8ca5e0
File content as of revision 6:b59bc5e15cf3:
#include "Swarm.h" Swarm::Swarm() { } Swarm::~Swarm() { } int Swarmm[6][6] = { {0,0,1,1,0,0}, {0,0,1,1,0,0}, {1,1,1,1,1,1}, {1,1,1,1,1,1}, {0,0,1,1,0,0}, {0,0,1,1,0,0}, }; void Swarm::init(int height, int width, int speed) { _height = height; _width = width; _x = rand() % 64; _y = 2; srand(time(NULL)); _velocity.x = 0; _velocity.y = speed; } void Swarm::draw(N5110 &lcd) { lcd.drawSprite(_x,_y,_height,_width,(int*)Swarmm); } void Swarm::update() { _x += _velocity.x; _y += _velocity.y; } void Swarm::set_velocity(Vector2D v) { _velocity.x = v.x; _velocity.y = v.y; } Vector2D Swarm::get_velocity() { Vector2D v = {_velocity.x,_velocity.y}; return v; } Vector2D Swarm::get_pos() { Vector2D p = {_x,_y}; return p; } void Swarm::set_pos(Vector2D p) { _x = p.x; _y = p.y; }