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.
Diff: Map/Map.cpp
- Revision:
- 8:dd1037c5435b
- Parent:
- 7:0af4ced868f5
- Child:
- 9:1ddb8dc93e48
diff -r 0af4ced868f5 -r dd1037c5435b Map/Map.cpp
--- a/Map/Map.cpp Sat Apr 18 16:36:52 2020 +0000
+++ b/Map/Map.cpp Sun Apr 19 17:46:57 2020 +0000
@@ -1,8 +1,6 @@
#include "Map.h"
#define MAP_TERRIAN_Y_POSITION 42
-AnalogIn adc(PTD5);
-Serial usb(USBTX, USBRX);
Map::Map() {
}
@@ -11,15 +9,15 @@
}
-void Map::init() {
+void Map::init(AnalogIn &adc) {
position_x_map_ = -96;
position_y_map_ = MAP_TERRIAN_Y_POSITION;
- get_random_hight_array();
- get_random_length_array();
+ get_random_hight_array(adc);
+ get_random_length_array(adc);
//usb.printf("randome seed = %f\n", rand_seed_);
}
-void Map::get_random_hight_array(){
+void Map::get_random_hight_array(AnalogIn &adc){
srand(adc.read()*64000);
for(int i = 0; i < 12; i++){
rand_hights_[i]= rand() % 8 + 5;
@@ -30,7 +28,7 @@
//}
}
-void Map::get_random_length_array(){
+void Map::get_random_length_array(AnalogIn &adc){
srand(adc.read()*64000);
for(int i = 0; i < 12; i++){
rand_lengths_[i]= rand() % 16+ 15;
@@ -51,8 +49,8 @@
}
void Map::draw_map(N5110 &lcd, int move_map){
- usb.printf("position_x_map_ = %d\n", position_x_map_);
- usb.printf("move map = %d\n", move_map);
+ //usb.printf("position_x_map_ = %d\n", position_x_map_);
+ //usb.printf("move map = %d\n", move_map);
int reset_position_x_map_to_origonal = position_x_map_;
for(int i = 0; i < 12; i++){
draw_triangle(lcd,rand_hights_[i]);
@@ -65,7 +63,3 @@
return position_x_map_;
}
-void Map::clear_map(N5110 &lcd){
- // Clears spaceship from LCD by drawing a white sprite
- lcd.drawRect(0, 0, 84, 48 , FILL_WHITE);
-}