Home
Appendix A – VRML source for city.wrl
Contents
1. do action Car 3 14 position X Y Z2 turn right i setRotation Car 0 1 0 2 355 Xl is X 2 5 Zl is Z 2 5 move to position Car position X Y 2 position X1 Y 21 5 setRotation Car 0 1 0 1 57 Z2 is Zl 32 move_to_position Car position X1 Y Z1 position X1 Y Z2 32 do_action Car 4 71 position X Y Z turn_right setRotation Car 0 1 0 3 925 XI TSK 2 5 IS 2 La move to position Car position X Y 2 position X1 Y 21 5 setRotation Car 0 1 0 3 14 X2 is XI 32 move to position Car position X1 Y Z21 position X2 Y 21 32 do action Car 0 0 position X Y Z2 turn left setRotation Car 0 1 0 0 785 XL Ge Ros 21 3 e eS move to position Car position X Y Z position X1 Y 21 10 setRotation Car 0 1 0 1 57 22 16 MEL 32 move to position Car position X1 Y Z21 position X1 Y 22 32 28 do action Car 1 57 position X Y Z turn left setRotation Car 0 1 0 2 355 Xl ASIA 545 ALISA 15 55 move to position Car position X Y 2Z position X1 Y 21 10 setRotation Car 0 1 0 3 14 X2 is LA 32 move to position Car position X1 Y Z21 position X2 Y 21 32 do action Car 3 14 position X Y Z2 turn left setRotation Car 0 1 0 3 925 XC uS X vv bubus ZV 3s ZA 5555 move to position Car position X Y Z position X1 Y 21 10 setRotation Car 0 1 0 4 71 A2 is Z1 d 32 move to position Car position X1 Y Z21 position X1 Y 22 32 do action Car 4 71 position X Y Z2 turn left
2. setRotation Car 0 1 0 0 785 Xl is X 5 5 Z1 is Z 5 5 move to position Car position X Y Z position X1 Y 21 10 setRotation Car 0 1 0 0 0 X2 is XI 32 move to position Car position X1 Y Z21 position X2 Y 21 32 do action Car 0 0 position X Y Z turn back setRotation Car 0 1 0 1 57 Zl is Z 3 move to position Car position X Y Z position X Y 21 3 setRotation Car 0 1 0 3 14 Xl is X 32 move to position Car position X Y Z1 position X1 Y 21 32 do action Car 1 57 position X Y Z2 turn back setRotation Car 0 1 0 3 14 Xl is X 3 move to position Car position X Y Z2 position X1 Y 2 3 setRotation Car 0 1 0 4 71 Lis E 32 move_to_position Car position X1 Y Z position X1 Y Z1 32 do_action Car 3 14 position X Y Z turn_back setRotation Car 0 1 0 4 71 Zl is Z 3 move to position Car position X Y Z2 position X Y 21 3 setRotation Car 0 1 0 0 0 Xl ws X 32 move to position Car position X Y Z1 position X1 Y 21 32 do action Car 4 71 position X Y Z2 turn back setRotation Car 0 1 0 0 0 Xl is X 3 move to position Car position X Y 2 position X1 Y 2 3 setRotation Car 0 1 0 1 57 Zl is 2 32 move to position Car position X1 Y 2 position X1 Y 21 32 do action format Unrecognised Action n oe oo oe Interpolates an object s position between two points move to position Object position X Y 2 0 setPosition O
3. wasp cs vu nl wasp Welcome to Checkpoint City os 11 Appendix A VRML source for city wrl VRML V2 0 utf8 EXTERNPROTO RoadStraight exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString roadURL exposedField MFString sidewalkURL road_protos wrl RoadStraight EXTERNPROTO RoadStraight2 exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString roadURL exposedField MFString sidewalkURL road_protos wrl RoadStraight2 EXTERNPROTO RoadBend exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString roadURL exposedField MFString sidewalkURL road_protos wrl RoadBend EXTERNPROTO RoadT exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString roadURL exposedField MFString sidewalkURL road_protos wrl RoadT EXTERNPROTO RoadCross exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString roadURL exposedField MFString sidewalkURL road protos wrl RoadCross EXTERNPROTO Car exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField SFBool bindCarView exposedField SFRotation wheelRotation exposedField SFColor carDiffuseColor exposedField SFColo
4. 1255 10 checkpoint 3 20 5 455 10 checkpoint 4 85 5 145 10 checkpoint 5 85 e 65 10 checkpoint 6 25 5 5 10 checkpoint 7 125 eb 25 10 checkpoint 8 105 5y 1257 20 checkpoint 9 D VAP 12554 20 checkpoint 10 165 Dr 9b 20 checkpoint 11 25 2550 85520 checkpoint 12 85 e 5 20 checkpoint 13 125 5 105 20 checkpoint 14 5 e 65 20 checkpoint 15 60 255 0655 30 checkpoint 16 65 55 65 30 checkpoint 17 65 by 45 30 checkpoint 18 65 v g 254 30 checkpoint 19 45 255 1257 30 checkpoint 20 85 2D 85 25 end object checkpoint 26 oo Traffic Object oo oo Controls an autonomous car travelling through the city object traffic bcilib traffic Car position X Y Z format Traffic thread active w n Car setPosition Car X Y 2 CX is X 40 1 CZ is Z 40 1 traffic loop Car CX CZ oo traffic loop ObjectID CrossingX CrossingZ oo oo Main traffic loop directing the cars from current location to destination traffic_loop Car CX CZ random RD1 random RD2 CX1 is truncate RD1 5 1 CZ1 is truncate RD2 5 1 route CX CZ CX1 CZ1 Path drive to destination Path Car sleep 5000 traffic_loop Car CX1 C21 oo drive_to_destination Route Object oo oo moves object to destination using a calculated route 9 drive to destination C1I
5. CX CZ turn right CZL is CZ 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn right CX1 is CX 1 connected CX CZ CX1 CZ If there is no input and forward amp right decide action 0 0 CX CZ turn left C21 is cz 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn left CX1 is CX 1 connected CX CZ CX1 CZ if possible on the crossing if possible If there is no input and forward is not possible go right are not possible go left 23 decide action 3 14 CX CZ turn left CZ1 is CZ 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn left EXT is CX cb connected CX CZ CX1 CZ 1 9 If nothing succeeds return no action decide action no action oo do_action CarRotation Action oo oo Executes the given action Just let the car keep going forward handled in vrml do action keep going Make the car turn to the right do action 1 57 turn right setRotation carTransform 0 1 0 3 14 delay 1000 1 do action R turn right RI is R 1 57 setRotation carTransform 0 1 0 R1 delay 1000 I Make the car turn to the left do action 3 14 turn left setRotation carTransform 0 1 0 1 57 delay 1000 do action R turn left Rl is R 1 57 setRotation carTransform 0 1 0 R1 delay 1000 9 Not a recognised a
6. Destination reached if there is only 1 element left drive to destination C1 C2 Path2 Car getRotation Car 0 1 0 CarRotation decide action CarRotation C1 C2 Action nonvar Action getPosition Car X Y Z do_action Car CarRotation position X Y Z Action Path3 C2 Path2 drive_to_destination Path3 Car drive to destination format ERROR n oo decide action CarRotation CurrentCrossing DestinationCrossing Action oo oo Decides which action must be taken to reach the destination crossing decide action 0 0 CX1 CZ CX2 CZ go straight CX1 lt CX2 decide action 1 57 CX CZ1 CX CZ2 go straight CZ1 gt CZ2 decide action 3 14 CX1 CZ CX2 CZ go straight CX1 gt CX2 decide action 4 71 CX CZ21 CX CZ2 go straight CZ1 lt CZ2 decide action 0 0 CX CZ1 CX CZ2 turn right CZ1 CZ2 decide action 1 57 CX1 CZ CX2 CZ turn right CX1 lt CX2 decide action 3 14 CX CZ1 CX CZ22 turn right CZ1 CZ2 decide action 4 71 CX1 CZ CX2 CZ turn right CX1 gt CX2 decide action 0 0 CX CZ1 CX CZ2 turn left CZ1 gt CZ2 27 decide action 1 57 CX1 CZ2 CX2 CZ turn left CX1 gt decide action 3 14 CX CZ21 CX CZ2 turn left CZI lt decide action 4 71 CX1 CZ2 CX2 CZ turn left CXl lt decide action 0 0 CX1 CZ CX2 CZ turn back CX1 gt decide action 1
7. RoadStraig RoadCross RoadStraig RoadStraig RoadStraig RoadT RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadBend RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadStraig RoadT RoadStraig RoadStraig RoadStraig RoadBend Park Til Park Park Park Park kyScraper kyScraper kyScraper kyScraper kyScraper kyScraper kyScraper kyScraper kyScraper End o ANNNNNNN WN City Buil ht2 ht ht ht2 ht ht ht ht ht2 ht2 ht2 ht ht ht ht ht2 ht ht ht ht2 ht ht ht ht2 ht ht ht2 ht Cransi Cransi Surrounding Terrain Terrain Windmill Windmill Windmill Windmill Windmill Windmill Windmill Windmill Windmill Windmill Checkpoi DEF checkPt CheckPoint Player c Cranst Cranst Cranst crans crans Cranst transl lation 67 transl Cranst Cranst crans crans crans Cransli trans trans trans trans trans trans trans trans trans trans trans trans trans trans trans tion 62 EN o ation 67 5 0 62 5 0 82 ation 67 ation 72 ation 72 ation 72 ation 77 ation 77 lation 77 VUVVVVBV VVV NW tion 82 Mopo tion 62 tion 62 tion 62 tion 62 tion 62 5 translation 62 tion 82 tion 82 tion 82 tion 82 tion 82 tion 82 tion 8
8. 1 translation 100 8 180 rotation 0 0 translation 150 8 180 rotation 0 D translation 50 8 180 rotation 0 1 0 translation 10 9 50 rotation 0 1 0 1 translation 10 6 150 rotation 0 o nt ar DEF carTransform Transform translation 10 0 55 6 5 children DEF VP CAR 1 Viewpoint translation 30 5 5 scale 2 2 2 0 1 571 17 position 10 2 0 orientation 0 1 0 1 57 description Behind Car DEF PLAYER_CAR Car scale 0 3 0 3 0 3 wheelRotation 0 1 0 0 bindCarView TRUE DEF VP_CAR_2 Viewpoint position 85 210 85 orientation 0 577 0 577 0 5TT 2 095 description Top Down ROUTE TS1 isActive TO VP CAR 2 set bind Traffic DEF carl Car scale 3 3 3 carDiffuseColor 0 1 0 carEmissiveColor 0 4 O translation 0 10 0 DEF car2 Car scale 3 3 3 carDiffuseColor 0 1 1 carEmissiveColor 0 4 4 translation 0 10 0 rotation 0 1 0 3 14 DEF car3 Car scale 3 3 3 carDiffuseColor 1 O carEmissiveColor 4 4 O translation 0 10 0 rotation 0 0 1 57 DEF car4 Car scale 3 3 3 carDiffuseColor 1 O0 carEmissiveColor 4 O 4 translation 0 10 O rotation 0 1 0 4 71 DEF car5 Car scale 3 3 3 carDiffuseColor 0 1 0 carEmissiveColor 0 4 O translation 0 10 0 DEF car6 Car scale 3 3 3 carDiffuseColor 0 1 1 carEmissiveColor 0 4 4 translation 0 10 0 rotation 0 1 0 3 14 DEF car7 Car scale 3 3 3 carDiffuseColor 1 0 0 carEmissiveColor 4 O 0 translation O 10 O rota
9. 7 3 If car on a crossing and right key is pressed decide action CarAngle Xpos Zpos CrossingX CrossingZ Action turn to right Finds the action to execute based on current location and player input if possible 22 If car is on a crossing and left key is pressed turn to left decide action 0 0 CX CZ turn left getSFInt32 carControl leftDown 1 CZ1 is CZ 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn left getSFInt32 carControl leftDown 1 CX1 is CX 1 connected CX CZ CX1 CZ 1 decide action 3 14 CX CZ turn left getSFInt32 carControl leftDown 1 CZl is CZ 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn left getSFInt32 carControl leftDown 1 Cxi is CX 4 1 connected CX CZ CX1 CZ If there is no input let car go forward decide action 0 0 CX CZ keep going CX1 is CX 1 connected CX CZ CX1 CZ decide action 1 57 CX CZ keep going CZl is CZ 1 connected CX CZ CX CZ1 1 decide action 3 14 CX CZ keep going CX1 is CX 1 connected CX CZ CX1 CZ decide action 1 57 CX CZ keep going CZ1 is CZ 1 connected CX CZ CX CZ1 1 decide action 0 0 CX CZ turn right CAT IS CZ sks 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn right CXT vs CX 4 3 connected CX CZ CX1 CZ decide action 3 14
10. clause takes as parameters the object name and the current crossing coordinates It uses the random I clause to retrieve a set of destination coordinates Next a route from the current location to the destination is calculated using the route 3 clause Then this route is being passed to the drive to destination 2 clause that takes car of driving the car to the new destination At the destination the car waits for 5 seconds and then the traffic loop 3 is executed again to drive to the next destination Drive to destination 2 takes as parameters the object name and a route which is a list of X Z pairs representing connected crossings that can be used to drive from the current location to the destination The first two pairs from this list are extracted The first pair represents the current crossing the second pair represents an adjacent crossing that must be traveled to in order to reach the final destination To obtain the action that must be taken from the current to the next crossing decide action 4 is used which will return one of the following actions go straight turn right turn left or turn back The clause do action 4 takes care of executing each of these actions and after it is finished the car will be at the next crossing The first element of the list is no longer needed The second element is now the current location and is passed along with the rest of the route to the drive to destination 2 clause again The stop condition to break t
11. directOutput TRUE ROUTE ROUTE ROUTE ROUTE INPUT SENSOR actionKeyPress TO carControl actionKeyPressed INPUT SENSOR actionKeyRelease TO carControl actionKeyRelease tsl fraction changed TO carControl moveCar carControl soundTime TO AC2 startTime 20 Appendix B DLP Source For ccity pl oo oo oo Multimedia Authoring II 2006 oo oo oo Marco Bouterse 1142828 Final Project Checkpoint City 9 9 9 9 9 9 9 9 9 9 9 9 OM 9 9 0 0 0 9 9 0 0 9 0 0 0 0 9 0 0 0 9 9 0 9 9 66 6 0 6 0 0 0 0 00 00 00 0000007070707 0 00 00 0000 oo Controller object oo oo Sets up the different opjects object ccity bcilib URL of the VRML world var url city prototypes city wrl main Enable debug output text area Browser Set output Browser Load the world loadURL url format The game will start in 5 seconds n sleep 5000 format The game has started n Start Traffic _Trafficl new traffic carl position 41 0 55 6 5 sleep 100 _Traffic2 new traffic car2 position 129 0 55 163 5 sleep 100 _Traffic3 new traffic car3 position 86 5 0 55 89 sleep 100 _Traffic4 new traffic car4 position 3 5 0 55 41 sleep 100 _Traffic5 new traffic car5 position 41 0 55 86 5 sleep 100 Start checkpoints _Checkpoint new checkpoint o Start player control Car new playe
12. increased Then the wait for the player to hit the checkpoint begins which is handled by the check collision 3 clause If there has been a collision the checkpoint id is decremented and game_loop 1 is recursively called using the new id If the id hits 0 the player has found all checkpoints and this is communicated to the VRML script in city wrl which displays the final score for the player The score eguals the number of seconds still left when the player hits the last checkpoint The clause check_collision 3 loops forever until a collision is detected between the car and the checkpoint This uses a fairly simple approach by monitoring the distance between the center of the checkpoint and the center of the car If this drops below a certain threshold value a collision is detected and the game_loop 1 can continue To calculate the distance the distance 5 clause is used It uses Pythagoras to calculate the distance between two points Traffic object The constructor traffic 2 takes as parameters the name of the VRML object in this case a car and the position to start from These starting positions are very specific they should be on the right lane exactly one unit on a crossing If the starting position is wrong the car won t stay on the roads all the time The constructor starts by positioning the car at the start position then calculates the crossing coordinates that the car is on and finally starts the traffic loop 3 The traffic loop 3
13. layout There are only straight streets because curved streets introduce a lot of extra problems that cannot be dealt with in the scope of this project The space between the roads is filled with either buildings or parks The design in the picture also shows elevation differences between roads introducing bridges and or tunnels On crossings with roads coming in from all directions there should be traffic lights that are either operated on a time based cycle or act more intelligently by detecting whether there is a car waiting and turn to green if there aren t any cars waiting for the other directions first come first served basis System Design All visible elements city buildings roads cars etc will be created using VRML The gameplay is partly implemented in JavaScript nodes embedded in the VRML code and partly in DLP To ensure smooth movement the forward movement of the player car will be implemented in VRML Most of the game logic the car controls and the traffic cars will be controlled by DLP code Targets To be successful the game should have the following properties 1 Smooth driving experience player must be in control 2 Collision Detection to detect when hitting checkpoints and other cars 3 Autonomous cars computer guided traffic must drive believable 4 Solid gameplay game must be challenging and fun z ie Technical Description This part gives a technical ov
14. little more time to fine tune everything and really create a game that is challenging and fun to play Possible Extensions If I had more time to work on this project I would start with getting the collision detection system working so the traffic in the city has a real use I would also extend the control over the player s car so that it stays in one lane and can change between lanes on straight roads so the traffic can be evaded safely The traffic agents can also be extended to become smarter so they would stop for traffic lights and other cars This would really improve the overall gameplay After that some fancy features can be introduced like pedestrian agents a menu structure no need to restart browser an introduction on first startup background music etc The city can also be bigger than it is now this is actually very easy to realize because all that is needed are new roads in VRML that follow the grid layout and new road 2 statements in the DLP code 10 References The Annotated VRML 2 0 Reference Manual Rick Carey and Gavin Bell Addison Wesley 1997 Blaxxun Platform 7 0 Documentation http developer blaxxun com doc wwhelp js html frames htm gt Distributed Logic Programming for Virtual Environments Zhisheng Huang Anton Eli ns and Cees Visser PROLOG Built in Documentation help system gt DLP Release Notes http d1p cs vu nl ctv dlpinfo docs readme html WASP Project Homepage http
15. 2 tion 82 tion 82 tion 82 Ei i 823 52 57 62 67 72 77 aa 01 1 0 0 0 0 0 0 u e 2 rp 0 2 200 62 5 0 82 u o 2 62 82 aa co E Ur Gr Ut 01 UT T 01 UT UT a 50 6445 50 72 5077 5 rotation 0 1 0 1 571 5 rotation 0 10 1 571 5 rotation 0 10 1 571 5 xXotatrom 0 l 0 1 571 5 rotation 0 10 1 571 5 rotation 0 10 1 571 5 rotation 0 1 5 rotation 0 10 1 571 0 2 5 rotation 0 1 0 1 571 0 7 5 0 12 0 17 0 22 0 27 0323 037 0 42 0 47 04525 Ji 70 53 translation 82 tion 82 tion 82 tion 82 tion 82 5 0 82 5 rotation 0 1 0 3 142 s t so 5 rotation 0 1 0 3 142 P 20 5 5 0 82 5 rotation 0 1 0 3 142 u rotation 0 1 0 1 571 o 1591 0 62 5 rotation 0 1 UT UT UT g UT UT A UT 0 UT O Uoc es translation 12 5 0 07 12 5 translation 72 5 0 07 32 5 scale 1 1 3 67 translation 12 5 0 07 55 scale 1 1 1 3333 translation 22 5 0 07 72 5 scale 2 3333 1 1 ding Tiles translation 32 5 0 12 5 translation 52 5 0 12 5 translation 12 5 0 32 5 translation 32 5 0 32 5 translation 52 5 0 32 5 translation 32 5 0 52 5 translation 52 5 0 52 5 translation 52 5 0 72 5 translation 72 5 0 72 5 f world scaling Transform translation 50 9 10 rotation 0 o translation 100 9 10 rotation 0 D translation 150 9 10 rotation 0 0 1 translation 185 14 35 rotation 0 57 translation 180 7 5 100 rotation 0 1 0
16. 57 CX CZ1 CX CZ2 turn back CZI lt decide action 3 14 CX1 CZ2 CX2 CZ turn back CX1 lt decide action 4 71 CX CZ21 CX CZ2 turn back CZ1 gt decide action no action oo do_action Object Orientation Position Action oo oo Moves the object from current crossing to the next one do_action Car 0 0 position X Y Z go_straight X1 is X 40 CX2 C22 CX2 CX2 CZ2 CX2 CZ2 move_to_position Car position X Y Z position X1 Y Z 40 do_action Car 1 57 position X Y Z go_straight Zl is Z 40 move to position Car position X Y 2 position X Y 21 40 do action Car 3 14 position X Y 2 go straight X1 is X 40 move to position Car position X Y 2 position X1 Y 2 40 do action Car 4 71 position X Y 2 go straight Zl is Z 40 move to position Car position X Y 2 position X Y 21 40 do action Car 0 0 position X Y Z2 turn right i setRotation Car 0 1 0 0 785 Xl is X 2 5 Z1 is Z 2 5 move to position Car position X Y 2 position X1 Y 21 5 setRotation Car 0 1 0 4 71 Z2 is Zl 32 move to position Car position X1 Y Z21 position X1 Y 22 32 do action Car 1 57 position X Y Z2 turn right setRotation Car 0 1 0 0 785 X is X t 2 5 ZL is Z 2 5 move_to_position Car position X Y Z position X1 Y Z1 5 setRotation Car 0 1 0 0 0 X2 Us Xl 32 move to position Car position X1 Y Z21 position X2 Y 21 32
17. 571 5 0 42 5 rotation 0 0 1 571 5 0 62 5 rotation 0 03 55 5 0 82 5 rotation 0 O I 571 50 2 5 rotation 0 0 1 571 5 0 22 5 rotation 0 O 13571 5 0 42 5 rotation 0 0 1 571 5 0 62 5 rotation 0 0 1 571 5 0 82 5 rotation 0 Or TST translation 42 5 0 2 5 tion 42 5 0 7 5 tion 42 5 0 12 5 tion 42 5 0 17 5 tion 42 5 0 22 5 tion 42 5 0 27 5 tion 42 5 0 32 5 tron 42 5 0 3155 tion 42 5 0 42 5 tion 42 5 0 47 5 tion 42 5 0 52 5 Erion 42 5 0 57 5 tion 42 5 0 62 5 rotation 0 1 0 3 142 tion 42 5 0 67 5 tion 42 5 0 72 5 tion 42 5 0 77 5 translation 42 5 0 82 5 rotation 0 1 0 3 142 tion 47 5 0 2 5 rotation 0 D 15541 tion 47 5 0 22 5 rotation 0 0 1 571 tion 47 5 0 42 5 rotation 0 D 1 571 tion 47 5 0 62 5 rotation 0 D Te SL tion 47 5 0 82 5 rotation XO 0 1 571 tion 52 5 U 2 5 rotation O 0 1 571 tion 52 5 0 22 5 rotation 0 O 1 571 tion 52 5 0 42 5 rotation 0 Or 1 571 tion 52 5 0 62 5 rotation 0 OA SAE tion 52 5 0 82 5 rotation 0 0 1 571 tion 57 59 0 2 5 rotation O 0 1 571 tion 57 5 0 22 5 rotation 0 0 1 5171 tion 57 5 0 42 5 rotation 0 0 1571 tion 37 5 0 62 5 rotation 0 0 1 571 tion 57 5 0 82 5 rotation 0 Od BEL translation 62 5 0 2 5 clon 62 5 Oo YS Lion 6255 0 12 5 tion 62 5 0 17 5 translation 62 5 0 22 5 rotation 0 1 0 1 571 tion 62 5 0 27 5 tion 62 5 0 32 5 klon 62 5 0 37 5 translation 62 5 0 42 5 rotation 0 1 0 1 571 tion 62 5 0 47 5 16 RoadStraig
18. Checkpoint City Project Report Marco Bouterse 1142828 mcbouter cs vu nl Multimedia Authoring Il Vrije Universiteit September 2006 www cs vu nl mcbouter mma2 Introduction Multimedia Authoring II is about creating interactive web experiences using Distributed Logic Programming DLP and the Virtual Reality Modeling Language VRML DLP offers object oriented parallel logic programming and is able to manipulate objects in a VRML world This report describes my final project for this course a checkpoint racing game that can be played in a web browser using the mentioned techniques First the system design will be presented followed by a technical description of the implementation Then a user manual is presented that explains all controls and features of the game Finally a discussion of the solution and possible extensions will be presented Contents INTRODUCTION sakni 1 CONTENTS Er 2 GAME DESIGN issbiiccissnssodasssinnsananininanblk nni Tone ases asas esas Ce Se e ae aS as Osee So akalalabak kakaaakaniaanak a 3 GENERAL OVERVIEW 0 saati oi s s Ne aa H S S Sa a aaa aaa ananasa 3 TARGET SYSTEM amp REQUIREMENTS tiaaaaaaaaaaai aaasananannannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnaia 3 PLAYING A GAME toco ge a a asia 3 WORLD DESIGN s A EE 3 SYSTEM DESIGN So bos eee ee AI ldd E TE ea 4 ENTUM 4 TECHNICAL DESCRIPTION siss 5 VRMIEOBTECTS too Eb e dd ME 5 Checkpoint Wr quce Deco adaa i oc ia dou em o Ne De ms dud a
19. WWWWNnNNNNNNDNDD O1 Ut O1 O1 UT Oi 4 Os ds UT dS ds uS C uS CD is C C C CO IPSO YN 00 IO I2 DO EF HH o O V V 2 Q gt WN end object traffic
20. aited for traffic lights minded each other and tried to avoid crashes were not entirely feasible in the given amount of time A lot of time has been spend on finding improving and creating VRML models to put together a nice city environment Programming the game logic using Distributed Logic Programming was also a very time consuming job This was due to the fact that my Prolog foundation wasn t as rock solid as it could have been resulting in many time spent on searching for certain Prolog features or finding out how to do something that is trivial in a procedural language in logic programming Many hours have been spent trying to find and fix the bug that causes the controls to fail at random moments I did not succeed in this and I still don t know why this is happening A possible solution seems to be to let DLP handle the car s forward motion but this doesn t look good at all motion is not smooth Also built in fixes to reset the car once it strays off course do not seem to work It looks like once the error occurs the complete DLP car thread fails to continue working Also the fact that there aren t a lot of tools and support for DLP programming did not contribute to a very smooth development process Having the summer vacation in between the creation of the final project was an obstacle too that did not improve the continuity of the project After all I ended up with a game that works and has reasonable gameplay although I could have used a
21. bcilib I N var nrofCheckPoints var collisionRadius ll wW checkpoint format Checkpoint thread active n setSFBool ts2 enabled true game_loop nrOfCheckPoints oo game loop CheckpointID oo oo Main control loop for checkpoint thread game loop 0 format YOU WIN setSFBool ts2 enabled false game loop CP checkpoint CP X Y Z T setPosition checkPt X Y Z getsFInt32 countScript clock C CL IS CAT SetSFInt32 countScript clock C1 setSFBool cpSound loop true sleep 800 setSFBool cpSound loop false check collision X 2 10 CP1 is CP 1 game loop CP1 game loop format ERROR oo check_collision CarX CarZ DistanceToCar oo oo Keeps looping until the distance between the car and checkpoint is small enough check_collision _ _ D D lt collisionRadius setPosition checkPt 0 100 0 check collision X 2 getPosition carTransform Xcar _ Zcar distance Xcar Zcar X 2 D1 delay 50 check collision X 2 D1 oo distance X1 21 X2 22 Distance oe oe Calculates the distance between two points in 2d plane distance X1 21 X2 22 D Xdiff is X2 XI Zdiff is Z2 Z1 D is sqrt Xdiff Xdiff Zdiff Zdiff oo checkpoint id X Y Z timelimit oo Database of checkpoint locations time to reach them checkpoint 1 125 D 65 10 checkpoint 2 165 2 55
22. bject X Y 2 move to position Object position X1 Y1 Z1 position X2 Y2 22 C Cl is Gels Xdif is X2 X1 Zdif is Z2 Z1 X is X1 Xdif C Z is Z1 Zdif C setPosition Object X Y1 2 sleep 50 move to position Object CurrentPosition DestinationPosition InterpolationFactor move to position Object position X Y1 2 position X2 Y2 22 C1 oo route CrossingA CrossingB RouteFromAtoB oo oo Calculates route from A to B route A B Path route hlp A B Path A route hlp A B Path connected A B Path A B route hlp A B Path Between connected A C member C Between Between2 C Between route hlp C B Path2 Between2 Path A Path2 oo connected CrossingA CrossingB oo oo Two crossings are connected if there exists a road from A to B or from B to A connected X1 21 X2 22 road X1 21 X2 22 road I X2 22 X1 Z21 Sroad X1 21 X2 Z2 Represents connected roads 2 1 O sos sos N NOP OWED Wt N N 04 Q 4S A o oS sos sos sos oS 05 is MWh SM oS H O t Q Ci U W N N HOT BG NNSS IN N H o w Q Ut 4 WN UT S T CO BW E H O t Q Ot BWWD IM H o V o AnnnFP PPP RP RPWWWW
23. ction do action format ERROR oo connected CrossingA CrossingB oo oe Two crossings are connected if there exists a road from A to B or from B to A connected X1 21 X2 22 road X1 21 X2 22 road I X2 22 X1 Z21 oo road X1 21 X2 22 oo oo Represents road that connects X1 21 with X2 22 The roadmap looks like this oo oo T 2 3 4 5 decode Te pen ach 9 Or TR ducis H 3 0 X d ox 24 kk xk ox Em ng mp an ke oo road 1 1 2 1 road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road road NUBUWRMIUWWOh MN OS OS so RS o oS oM M NUBWOWRMNIWW H ss oS oS M NS NS S M oS OPPWWNHNRFRPUBWWNNEFERP UB BWWNDN EH On On Nut Ut s WD UT BO WB W t U au W 0 MH sos PUNH VUUVUVUVVUVBUABBUBBRVUBVR GWW M NUNNNEMNMNMFM MH M O1 O1 O1 Oi ds 4S uS uS uS uS Y W C UU U CO CO Y PO NN NIN IO lO lO E E RRA E p ES end_object player_car oo Checkpoint object oo oo Handles checkpoints and timer object checkpoint
24. erview of the game It is split into two main parts the VRML part and the DLP part The VRML part describes all objects and their properties and scripts The DLP part describes all DLP objects that control elements in the game VRML Objects These objects can be found at www cs vu nl mcbouter mma2 vrml city prototypes Checkpoint wrl This file contains the prototype for the checkpoint object consisting of a 3D letter C enclosed by a transparent shape The checkpoint is rotated along its Y axis by using interpolators and ROUTE statements This object was created using Flux studio City wrl This file contains the main VRML code that is loaded into the browser by the DLP code It puts all other pieces together resulting in a virtual city It starts by loading all external prototypes from the other files A skybox is set up that represents the sky by night Using the road pieces from road protos wrl the city roads are pieced together like a jigsaw puzzle A five by five grid is created and the spaces between are filled by parks and skyscrapers As a finishing touch the surrounding terrain is put into place and a couple of windmill objects are placed in it Next the objects that are manipulated by DLP code are declared the checkpoint the player s car and the other traffic The file ends with two scripts The first one implements the timer and decrements it every second If the timer drops below 11 the time left will be shown in a red co
25. he checkpoint in time a new one appears somewhere in the city and the timer is increased The player wins when all checkpoints have been reached in time Traffic prevents the player from reaching the checkpoints easily Target System amp Requirements The game should be playable with a standard Windows computer that is not too old performance will suffer from slow processors To play the game Internet Explorer with the Blaxxun plugin www blaxxun com is required Playing a game The player will start a new game by selecting Start Game from the menu if available otherwise the game will start automatically when finished loading the program He can control a car that drives to the streets of a virtual city The car drives automatically the player can control it by braking changing lane or turning at a crossing using the arrow keys on the keyboard The goal is to find the checkpoint before a timer runs out If the player drives the car through the checkpoint the timer is increased with a certain amount of time and another checkpoint appears somewhere in the city The game is finished when the timer runs out the player hits another car or if all checkpoints are reached player wins World Design The virtual world that the game is situated in represents a city with streets These streets are organized as a 5x5 grid The nodes in this grid are the crossings and the edges are roads The figure on the left shows a grid based street
26. he recursion is when the list only contains 1 element namely the current location In this case the destination has been reached Decide action 4 just compares current location and destination based on current orientation to decide whether to go straight turn to the left or right or go back The clause do action 4 takes care of the needed animation and moves the car from the current crossing to the next one possibly rounding a corner in the process It uses move to position 4 interpolates between two points to do this The last important clause of the traffic object is route 3 This clause takes as parameters the coordinates of the current crossing coordinates of the destination crossing and returns a route between these crossings as a list of X Z pairs representing the crossings that must be passed to reach the destination It doesn t use a shortest path algorithm but it keeps a list with intermediate crossings and doesn t visit the same crossing more than once to prevent getting stuck in cycles Finally the traffic object has its own private copy of the road database and the connected 2 clause User Manual Starting a game To start a new game open a new browser window of Internet Explorer and enter the URL http www cs vu nl mcbouter mma2 Look for Final Project and click on the link named Checkpoint City The game will now be loaded into the browser window As soon as the world has been loaded the game will start automaticall
27. ht2 RoadStraight2 RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight RoadT RoadStraight RoadStraight2 RoadStraight RoadT RoadStraight RoadStraight2 RoadStraight RoadT RoadStraight Cranst Cranst Cranst crans Cranst crans crans crans crans crans crans Cranst Cranst Cranst Cranst crans crans crans crans crans crans crans Cranst Cranst Cranst crans crans crans crans crans crans Cranst Cranst Cranst crans Cranst Cranst Cranst Cranst Cranst Cranst Cranst Cranst Cranst Cranst Cranst crans crans crans crans crans crans Cranst crans Cranst Cranst Cranst Cranst Cranst Cranst crans crans Cranst Cranst X owo owo ooo o Vo owo m Doppp ooo om Uyyy yov ypy ypy yyy ooo o ooo o o ooo o tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion tion 22 22 22 22 224 22 5 22 225 22 224 22 224 2T 21 21 24 21 325 32 32 32 324 34 37 373 37 37 50 125 5 01765 5 022 5 50 27 5 OZ 50 37 5 5054205 50 47 5 5405245 5 045 14 5 50 62 5 rotation 0 1 0 1 571 5 0 82 5 rotation 0 0 1 571 50 2 5 rotation O 0 1 53 5 0 22 5 rotation 0 0 1 571 5 0 42 5 rotation 0 O 10571 5 0 62 5 rotation 0 0 1571 5 0 82 5 rotation O 01571 50 2 5 rotation O 0 1 571 5 0 22 5 rotation 0 0 1
28. lause Decide action 6 takes as parameters the car s orientation the relative position and the nearest crossing s coordinates It returns the action to follow Basically there are 6 different situations 1 The car is not on a crossing just let the car go forward return action is keep going In all following situations the car is on a crossing 2 Ifthe right arrow key is pressed check if there is a road to the right using the connected clause If there is a road rotate the car 90 degrees to the right Return action is turn right 3 Ifthe left arrow key is pressed check if there is a road to the left using the connected clause If there is a road rotate the car 90 degrees to the left Return action is turn left 4 Ifthere is no input check if there is a road on the other side of the crossing if so make the car keep going straight Return action is keep going 5 If there is no input and it is not possible to go forward check if there is a road to the right if so return action will be turn right 6 If there is no input and it is not possible to go forward or right check if there is a road to the left if so return action will be turn left 7 The above situations should cover all possible events except dead end streets but they should not be there If none of the above succeeds the catch all clause will return no action This is considered as an error and should not happen The do action 2 clause is responsible for executi
29. lor If the timer reaches O the sentence GAME OVER will be displayed The second script handles the input and forward movement of the player s car Every 1 100 of a second the script is invoked and calls the moveCar function that calculates the car s current speed and forwards the car in the current direction The actionKeyPressed function updates the current input status left right amp down key A complete listing of this file is provided in appendix A Park wrl Contains the prototype for the park areas Basically just a Box shape with a grass texture applied to it This object was created by hand using an editor Player car wrl Contains the car model prototype that is used for all cars in the game It also contains a Wheel prototype that is used to represent the wheels of the car Using some code the wheels are rotating as if the car is driving It is also possible to change the steering angle of the front wheels through the prototype interface Also the emissive and diffuse colors of the car can be changed through its interface The object is based on a vrml1 model found on the internet I converted it to vrml2 using 3d studio max and made it into a prototype added wheel spin wheel steering gave it new colors and added color control Road protos wrl This file contains the basic road pieces for building a city including objects that are found on these pieces It contains prototypes for a traffic light created from scratch
30. ng the action It takes as parameters the car s orientation and the action to be taken If the action is keep going nothing is done because the car will automatically be forwarded by the VRML script in city wrl If the action is turn left or turn right the car is rotated 90 degrees in the proper direction followed by a 1 second pause to prevent the car from multiple rotations on a crossing The connected 2 clause is used to find out connections between crossings Two crossings A and B are connected if there is a road from A to B or from B to A The roads are represented by a database of road clauses The crossings are identified by a X Z pair 1 1 being the top left crossing if viewed from above and VRML world coordinates 0 0 are at top left 5 5 is then the bottom right crossing Also see the DLP source for a schematic representation Road X1 Z1 X2 Z2 means that there is a road from crossing X1 Z1 to crossing X2 Z2 Checkpoint object The constructor starts with enabling the timer in city wrl which causes the timer to start counting down on screen Then the game_loop I clause is started The game loop 1 clause takes the current checkpoint id as a parameter It looks up that specific checkpoint in a database and retrieves the info position in X Y and Z coordinates and the number of seconds that the player has to find that checkpoint Using this info the checkpoint is positioned at the retrieved coordinates and the timer is
31. ntScript timerEnabled TO tsl enabled ts2 enabled TO tsl enabled countScript startClap TO ACl startTime Control script DEF carControl Script eventIn SFInt32 actionKeyPressed eventIn SFInt32 actionKeyRelease eventIn SFFloat moveCar eventOut SFTime soundTime field SFFloat wheelAngle 0 0 field SFFloat posX 10 field SFFloat posY 0 55 field SFFloat posZ 6 5 field SFFloat speed 0 field SFFloat acceleration 01 field SFFloat brake 0 field SFInt32 leftDown 0 field SFInt32 rightDown O field SFVec3f direction 1 0 0 field SFNode car USE PLAYER CAR field SFNode cart USE carTransform url javascript function initialize wheelAngle 0 0 function actionKeyPressed value time if value 1006 amp amp leftDown 0 leftDown 1 print left else if value 1007 amp amp rightDown 0 rightDown 1 print right else if value 1005 brake 05 soundTime time function actionKeyRelease value time if value 1006 leftDown 0 else if value 1007 rightDown 0 else if value 1005 brake 0 function moveCar value time 19 if speed 5 speed acceleration brake if speed 5 speed brake if speed 0 speed 0 direction cart rotation multVec new SFVec3f 1 0 0 posX speed direction x posX posY speed direction y posY posZ speed direction z posZ cart translation new SFVec3f posX posY pos2
32. ould be NONE for gameplay DEF NI1 NavigationInfo type NONE headlight FALSE PointLight ambientIntensity 5 attenuation 1 0 0 color 6 6 6 intensity 5 location 85 10 85 radius 120 Background backUrl textures space 1 back jpg leftUrl textures space 1 left jpg frontUrl textures space 1 front jpg rightUrl textures space 1 right jpg bottomUrl textures space 1 bottom jpg topUrl textures space 1 top jpg Fog color 7 9 7 visibilityRange 600 http www blaxxun com vrml protos nodes wrlidMouseSensor 13 DEF INPUT_SENSOR KeySensor DEF MOUSE SENSOR MouseSensor User Interface Layer2D children Transform translation 0 3 0 children Shape appearance Appearance material DEF TXTMAT Material diffuseColor 0 0 0 specularColor 0 0 O emissiveColor 1 1 1 ambientIntensity 0 transparency 0 3 geometry DEF TEXT1 Text fontStyle FontStyle family Times New Roman Arial justify MIDDLE size 0 11 string Welcome to Checkpoint City Transform translation 8 6 0 children DEF TS1 TouchSensor Shape appearance Appearance material Material diffuseColor 0 0 0 specularColor 0 0 0 emissiveColor 7 5 5 ambientIntensity 0 transparency 0 4 geometry Box size 2 2 1 Shape appearance Appearance material Material diffuseColor 0 0 0 specularColor 0 0 0 emissiveColor 1 1 0 ambientIntensity 0
33. r 5 Cily wr a E R Das D Park Write o t esa eS uter dO MES A gee 5 Player car wr toc ai a asad S dal sod tu A d o DV Salat 9 Road protos WEL saus dE A vet a a a 6 SKYSCTAPEFWF MT id jona ak 6 TOFFOUTM E S eoo eater rrt xt da cote tb fe bad ente Re xo UE et 6 Windmill ice dida 6 DEPLOBIECTS slab ER 6 Cty ODJE E i ir o ta E To va geo eta Darse pua aou k k 6 Player Car OD CCE ie nudato vc kka AAA t dv eA ETUR EA EA doda dd ut 6 Ch ckpoint object ace LISTAR TARA ad d Duros dL 7 Traffic ODI OA ic e a k dus 8 USER MANU Assa 9 STARTINGA GAMES de a E AE d e 9 PEAYINGSA GAME oe DS do doe EE deste etate dio Muscat 9 CONTROL S zoi E 9 KNOWN BUG S nt sni a lr BRA pere 9 DISCUSSION amp FUTURE WORK a 22 22 0 000 0000oooo00onnn0o0000000000000000000000000000000000 10 DEVELOPMENT PROCESS aiaaaaaaaaaaaada aaaaasaaaaaasanansannnnannnnnnannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnaaa 10 POSSIBLE EXTENSIONS sitas aliada 10 REFERENCES fii siss kisan 11 APPENDIX A VRML SOURCE FOR CITY WRL 000000000000000000000 0 0 12 APPENDIX B DLP SOURCE FOR CCITY PL ooo oo ov 0000 00000000000000000000000000000000 21 Game Design General Overview Checkpoint City is an arcade racing game implemented in DLP and VRML The player controls a car driving through a virtual city The goal is to find the next checkpoint before a timer runs out When the player reaches t
34. r car end object ccity oo Player object oo oo Controls the player s car object player car bcilib var distanceBetweenCrossings 40 player car format Car thread active n setSFBool tsl enabled true update Car control loop update repeat getRotation carTransform 0 1 0 R getPosition carTransform X Y Z nonvar X nonvar 2 X1 is X mod distanceBetweenCrossings Zl is Z mod distanceBetweenCrossings CX is X distanceBetweenCrossings CZ is Z distanceBetweenCrossings decide action R X1 Z21 CX CZ Action nonvar Action do action R Action delay 50 fail I oe oo oo If car is not on a crossing just go straight decide action X keep going X decide action X keep going decide action Z keep going decide action Z2 keep going NN 9 decide action 0 0 _ _ CX CZ turn_right getSFInt32 carControl rightDown 1 CZ1 is CZ 1 connected CX CZ CX CZ1 decide action 1 57 CX CZ turn right getSFInt32 carControl rightDown 1 CX1 is CX 1 connected CX CZ CX1 CZ decide action 3 14 CX CZ turn right getSFInt32 carControl rightDown 1 CZl Us CL E Ay connected CX CZ CX CZ1 1 decide action 1 57 CX CZ turn right getSFInt32 carControl rightDown 1 CX1 is CX 1 connected CX CZ CX1 CZ gt lt gt lt 7 3
35. r carEmissiveColor player car wrl Car EXTERNPROTO Park exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale exposedField MFString grassURL park wrl EXTERNPROTO SkyScraper exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale 12 skyscraper wrl EXTERNPROTO CheckPoint exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale checkpoint wrl EXTERNPROTO Terrain terrain wrl EXTERNPROTO Windmill exposedField SFVec3f translation exposedField SFRotation rotation exposedField SFVec3f scale windmill wrl EXTERNPROTO KeySensor eventIn SFBool eventsProcessed exposedField SFBool enabled eventOut SFInt32 keyPress eventOut SFInt32 keyRelease eventOut SFInt32 actionKeyPress eventOut SFInt32 actionKeyRelease eventOut SFBool shiftKey changed eventOut SFBool controlKey changed eventOut SFBool altKey changed eventOut SFBool isActive urn inet blaxxun com node KeySensor http www blaxxun com vrml protos nodes wrl KeySensor EXTERNPROTO MouseSensor eventIn SFBool eventsProcessed exposedField SFBool enabled eventOut SFVec2f client eventOut SFVec2f position eventOut SFBool lButton eventOut SFBool mButton eventOut SFBool rButton eventOut SFFloat mouseWheel eventOut SFBool isActive urn inet blaxxun com node MouseSensor Type sh
36. t easier a MAP button is available on the lower right corner of the screen Click and hold to change the perspective to a top down view that looks over the entire city Releasing the left mouse button will return to the default view behind the car Known Bugs gt As for now there is no collision detection between cars driving through the city and between the player s car and those cars gt Sometimes the control seems to be lost and the player s car just drives straight on off road This is very annoying and lots of time has been spent to find out what goes wrong No solution has been found yet Sometimes not all textures are loaded into the VRML world Sometimes a key press is not detected properly so the car doesn t turn Discussion amp Future Work Development Process Looking back at my original design and expectations I must conclude that they were a little too ambitious I imagined a completely drivable car including gas brake and steering that could move freely through a city reacting to the environment realistically crashes with buildings reacting to curbs etc The fact that VRML doesn t really have a good input system that allows for detecting multiple key presses at the same time gas and steer for example prevented this approach In the original design there were also elevation differences resulting in bridges something that also appeared to be hard to implement Finally the independent car agents that w
37. the main object that loads the world into the browser sets up the text area for debugging purposes and then creates different threads for the game objects First five traffic threads are started that each manage a single car traveling randomly through the city Next the checkpoint thread is started that takes care of displaying the checkpoints and checks if the player drives through them It also increases the timer that is maintained in the city wrl file Finally the player_car thread is started that manages the player s car and the user input Player_car object The constructor clause of player car 0 activates the TimeSensor ts1 in city wrl causing the car to start moving forward regardless which direction it is traveling in It then starts the main loop clause update 0 Update 0 is an endless loop that checks the position and orientation of the car it then calculates the relative position of the car using modulo to be able to determine if the car is on a crossing or not Also the coordinates of the closest crossing are calculated so if the car is actually on the crossing the game knows which crossing it 1s on It then executes the decide_action 6 clause to determine which action should be taken The possible actions are gt keep going Just let the car keep going forward gt turn right Make the car turn right on a crossing turn left Make the car turn left on a crossing The chosen action is then executed by the do action 2 c
38. tion O 0 1 57 DEF car8 Car scale 3 3 3 carDiffuseColor 0 1 0 carEmissiveColor 0 4 O translation 0 10 0 DEF car9 Car scale 3 3 3 carDiffuseColor 0 1 1 carEmissiveColor 0 4 4 translation 0 10 0 rotation 0 1 0 3 14 DEF tsl TimeSensor loop TRUE enabled FALSE cycleInterval 01 DEF ts2 TimeSensor loop TRUE enabled FALSE cycleInterval 1 counter script DEF countScript Script eventIn SFTime cycleTime eventIn SFBool gameFinished eventOut SFBool timerEnabled eventOut SFTime startClap field SFInt32 clock 5 field SFNode counttxt USE TEXT1 field SFNode txtapp USE TXTMAT field SFString timeLeft Time Left field SFString count field SFString gameOver GAME OVER field SFString playerWins You Have Won field SFString score Score url javascript function initialize function cycleTime value time if clock gt 0 clock count new SFString clock toString if clock 0 counttxt string new MFString gameOver timerEnabled false counttxt string new MFString timeLeft count if clock 11 txtapp emissiveColor new SFColor 1 0 0 txtapp emissiveColor new SFColor 1 1 0 function gameFinished value time ROUTE ROUTE ROUTE ROUTE ROUTE if value false counttxt string new MFString playerWins score count startClap time ts2 cycleTime TO countScript cycleTime ts2 enabled TO countScript gameFinished cou
39. traight translation 7 5 0 2 5 rotation 0 1 0 1 571 RoadStraight translation 7 5 0 22 5 rotation 0 1 0 1 571 RoadStraight translation 7 5 0 42 5 rotation 0 1 0 1 571 RoadStraight translation 7 5 0 82 5 rotation 0 1 0 1 571 RoadStraight2 translation 12 5 0 2 5 rotation O 0 57 RoadStraight2 translation 12 5 0 22 5 rotation 0 0 1 7571 RoadStraight2 translation 12 5 0 42 5 rotation O 0 L571 RoadStraight2 translation 12 5 0 82 5 rotation 0 0 1 571 RoadStraight translation 17 5 0 2 5 rotation 0 01 511 RoadStraight translation 17 5 0 22 5 rotation 0 O 1 571 RoadStraight translation 17 5 0 42 5 rotation 0 0 1 571 RoadStraight translation 17 5 0 82 5 rotation 0 0 1 571 RoadT translation 22 5 0 2 5 RoadStraight translation 22 5 0 7 5 RoadStraight2 RoadStraight RoadCross RoadStraight RoadStraight2 RoadStraight RoadCross RoadStraight RoadStraight2 RoadStraight RoadBend RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight2 RoadStraight2 RoadStraight2 RoadStraight2 RoadStraight2 RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight RoadT RoadStraight RoadStraight2 RoadStraight RoadCross RoadStraight RoadStraight2 RoadStraight RoadCross RoadStraight RoadStraight2 RoadStraight RoadCross RoadStraight RoadStraight2 RoadStraight RoadT RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight RoadStraight2 RoadStraight2 RoadStraight2 RoadStraig
40. transparency 0 1 geometry Text fontStyle FontStyle family Arial justify MIDDLE size 0 1 string MAP Sound effects Sound location 85 l 85 maxBack 500 14 maxF ront 500 minBack 200 minFront 200 spatialize FALSE intensity 1 source DEF AC1 AudioClip url sound applause wav loop FALSE Sound location 85 1 85 maxBack 500 maxFront 500 minBack 200 minFront 200 Spatialize FALSE intensity 1 source DEF cpSound AudioClip url sound chimes wav loop FALSE Sound location 85 1 85 maxBack 500 maxFront 500 minBack 200 minFront 200 spatialize FALSE intensity 1 source DEF AC2 AudioClip url sound carbrake wav loop FALSE City roads Transform scale 222 children RoadBend translation 2 5 0 2 5 RoadStraight translation 2 5 0 7 5 RoadStraight2 translation 2 5 0 12 5 RoadStraight translation 2 5 0 17 5 RoadT translation 2 5 0 22 5 rotation 0 1 0 1 571 RoadStraight translation 2 5 0 27 5 RoadStraight2 translation 2 5 0 32 5 RoadStraight translation 2 5 0 37 5 RoadT translation 2 5 0 42 5 rotation 0 1 0 1 571 RoadStraight translation 2 5 0 47 5 RoadStraight2 translation 2 5 0 52 5 RoadStraight translation 2 5 0 57 5 RoadStraight translation 2 5 0 62 5 RoadStraight translation 2 5 0 67 5 RoadStraight2 translation 2 5 0 72 5 RoadStraight translation 2 5 0 77 5 RoadBend translation 2 5 0 82 5 rotation 0 1 0 1 571 RoadS
41. using Flux Studio a street lamp based on existing model and road pieces that can contain these objects RoadStraight contains a straight road with sidewalks RoadStraight2 is almost the same but also has a street lamp on one side of the road that is activated if the player is nearby RoadBend is a sort of L shaped piece that can be used for corners RoadT contains a T section with roads coming in from 3 sides The final piece is RoadCross and contains a full crossing with 4 incoming roads including traffic lights and a script that operates the traffic lights based on a 20 second time interval Opposing traffic lights are green at the same time then go to orange and finally to red At that point the other two traffic lights will switch to green etc Skyscraper wrl Contains the prototype for a skyscraper model that is converted from an existing vrmll model The colors have been adapted to fit the mood of the game better Terrain wrl Holds the prototype for the terrain that surrounds the city limits Created using a text editor It contains a couple of textured ElevationGrid nodes that define the terrain s height at several points Windmill wrl This file contains the prototype for a windmill that is created by converting an existing vrml1 model The model is enhanced by adding code to animate the windmill DLP Objects These objects are found in the file ccity pl a listing of this file is found in appendix B Ccity object This is
42. y If the car starts to drive forward the game has begun To make sure that the key presses are detected click twice in the displayed area The game can also be started by directly entering the full URL http www cs vu nl mcbouter mma2 exercises checkpoint city html Playing a game The object of the game is to drive through the virtual city searching for checkpoints The checkpoint has to be found before the timer that is displayed on screen runs down to zero If the checkpoint has been found and hit by driving through along it The timer is increased by a certain amount and the checkpoint moves to another location There are two possible endings to the game If the timer reaches zero the game is over and the player has lost If all checkpoints are found before the time runs out the player has won The player scores points if he has any seconds left on the timer Controls The controls are very simple The car is moved forward automatically if no input is given If the car is about to drive off the road it will be automatically turned in a possible direction by the game To make the car turn left press and hold the left key when reaching a crossing After the car has turned the key can be released The same with the right key for making a right turn It is not possible to turn off road Besides the left and right arrow key the only other key that can be used is the down arrow key which acts as a brake To make finding the checkpoin
Download Pdf Manuals
Related Search
Related Contents
PDFファイル リーフレット Marshall electronic LR150 Musical Instrument Amplifier User Manual Mode d`emploi User Manual 1x8 DMX Splitter Endosymbiotic Computing - University of California, Irvine Samsung Galaxy TabPRO 10.1 MDRC-2124 Copyright © All rights reserved.
Failed to retrieve file