]> git.llucax.com Git - z.facultad/75.68/celdas.git/blob - trunk/src/breve/Demo.tz
(no commit message)
[z.facultad/75.68/celdas.git] / trunk / src / breve / Demo.tz
1
2 @use Celdas.
3
4 Controller DemoController.
5
6 CeldasControl : DemoController {
7         + variables:
8                 sensor (object).
9                 leftWheel, rightWheel (object).
10                 vehicle (object).
11
12                 n (int).
13
14         + to init:
15                 for n=0, n<10, n++:
16                         new CeldasObstacle init at-location (20 * sin(n * 6.28 / 10), 1, 20 * cos(n * 6.28 / 10)).
17
18                 vehicle = new CeldasVehicle.
19                 self watch item vehicle.
20
21                 vehicle move to (10, 2, 5).
22
23                 leftWheel = (vehicle add-wheel at (-2, 0, -1.5)).
24                 rightWheel = (vehicle add-wheel at (-2, 0, 1.5)).
25                 vehicle add-wheel at (1, 0, 0).
26
27                 leftWheel set-velocity to 15.0.
28                 rightWheel set-velocity to 15.0.
29
30                 sensor = (vehicle add-sensor at (2.0, .4, 0)).
31
32         + to post-iterate:
33                 value (float).
34                         
35                 value = sensor get-sensor-value.
36
37                 if value < 1: {
38                         leftWheel set-velocity to ((leftWheel get-velocity) + 15).
39                         rightWheel set-velocity to ((rightWheel get-velocity) + 15).
40                 } else if value > 10: {
41                         leftWheel set-velocity to ((leftWheel get-velocity) - 15).
42                         rightWheel set-velocity to ((rightWheel get-velocity) - 15).
43                 }
44
45                 print value.
46
47 }