Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Pokemon.cpp
00001 #include "Pokemon.h" 00002 00003 void Pokemon::init(int x, int y, int size, int speed){ 00004 _x = x; 00005 _y = y; 00006 _size = size; 00007 00008 _velocity.x = speed; 00009 _velocity.y = speed; 00010 } 00011 00012 void Pokemon::draw(N5110 &lcd){ 00013 lcd.drawRect(_x,_y,_size,_size,FILL_BLACK); 00014 } 00015 00016 void Pokemon::update(){ 00017 _x += _velocity.x; 00018 _y += _velocity.y; 00019 } 00020 00021 void Pokemon::set_velocity(Position2D v){ 00022 _velocity.x = v.x; 00023 _velocity.y = v.y; 00024 } 00025 00026 void Pokemon::set_pos(Position2D p){ 00027 _x = p.x; 00028 _y = p.y; 00029 } 00030 00031 void Pokemon::pokemon_caught(){ 00032 _x = rand() % 84 ; 00033 _y = rand() % 48 ; 00034 } 00035 00036 00037 Position2D Pokemon::get_velocity(){ return {_velocity.x,_velocity.y}; } 00038 00039 Position2D Pokemon::get_pos() { return {_x,_y}; } 00040 00041 int Pokemon::get_size() { return _size; } 00042 00043
Generated on Wed Jul 13 2022 12:24:57 by
1.7.2