summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/studentFunctions/update_position.m
diff options
context:
space:
mode:
Diffstat (limited to 'Kod/bilbana/studentFunctions/update_position.m')
-rw-r--r--Kod/bilbana/studentFunctions/update_position.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/Kod/bilbana/studentFunctions/update_position.m b/Kod/bilbana/studentFunctions/update_position.m
new file mode 100644
index 0000000..dfca55f
--- /dev/null
+++ b/Kod/bilbana/studentFunctions/update_position.m
@@ -0,0 +1,39 @@
+function [car, gateway_passed] = update_position(car_in)
+
+car = car_in;
+
+[lap_car, chk_pnt, time] = get_car_position(car.track_number);
+
+if lap_car == true
+ % New lap
+
+ % Update position on track
+ car.position = 1;
+
+ % Add lap to lap counter
+ car.lap = car.lap + 1;
+
+ % Update gw passed
+ gateway_passed = true;
+
+ % Make sound
+ beep;
+
+elseif chk_pnt == true && car.position ~= 0
+ % CP passed
+
+ % Update position
+ car.position = car.position + 1;
+
+ % update gw passed
+ gateway_passed = true;
+
+ % Make sound
+ beep;
+
+else
+ gateway_passed = false;
+
+end
+
+end \ No newline at end of file