---frogger.nlogo
来自「NETLOGO」· NLOGO 代码 · 共 1,030 行 · 第 1/2 页
NLOGO
1,030 行
to level-5 create-car -4 -5 270 .3 create-car 0 -5 270 .3 create-car 4 -5 270 .3 create-car 7 -5 270 .3 create-car -3 -4 90 .2 create-car -5 -4 90 .2 create-car 5 -4 90 .2 create-car 1 -4 90 .2 create-car 8 -4 90 .2 create-car -4 -3 270 .3 create-car 0 -3 270 .3 create-car 4 -3 270 .3 create-car 7 -3 270 .3 create-car -3 -2 90 .2 create-car -5 -2 90 .2 create-car 4 -2 90 .2 create-car 1 -2 90 .2 create-car 7 -2 90 .2 create-car 0 -1 270 .3 create-car 5 -1 270 .3 create-car -7 -1 270 .3 create-car -3 -1 270 .3 create-log -5 3 2 .2 create-log 0 5 2 .1 create-log -5 7 2 .2 create-river-turtle -4 4 2 .3 create-river-turtle 4 4 3 .3 create-river-turtle -7 4 2 .3 create-river-turtle -1 6 2 .3 create-river-turtle -8 6 2 .3 create-river-turtle 3 6 3 .3 make-river-turtle-dive 5end; *** NetLogo Model Copyright Notice ***;; This model was created as part of the project:; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN; CLASSROOMS. The project gratefully acknowledges the support of the; National Science Foundation (REPP program) -- grant number REC #9814682.;; Copyright 2002 by Uri Wilensky. Updated 2002. All rights reserved.;; Permission to use, modify or redistribute this model is hereby granted,; provided that both of the following requirements are followed:; a) this copyright notice is included.; b) this model will not be redistributed for profit without permission; from Uri Wilensky.; Contact Uri Wilensky for appropriate licenses for redistribution for; profit.;; To refer to this model in academic publications, please use:; Wilensky, U. (2002). NetLogo Frogger model.; http://ccl.northwestern.edu/netlogo/models/Frogger.; Center for Connected Learning and Computer-Based Modeling,; Northwestern University, Evanston, IL.;; *** End of NetLogo Model Copyright Notice ***@#$#@#$#@GRAPHICS-WINDOW327106673508820.011000CC-WINDOW9297298436Command CenterBUTTON348399415436LEFTset action 1NIL1TOBSERVERBUTTON415399482436RIGHTset action 2NIL1TOBSERVERBUTTON383363447400UPset action 4NIL1TOBSERVERBUTTON384435448472DOWNset action 3NIL1TOBSERVERBUTTON371814051New GamesetupNIL1TOBSERVERBUTTON1831728650StartgoT1TOBSERVERMONITOR18274295123Frogs Leftlives01MONITOR182125295174NILLevel01MONITOR182176295225Time Lefttime-left31SLIDER2274171107start-livesstart-lives15511NILSLIDER22174171207start-timestart-time10606051NILSLIDER22123171156start-levelstart-level15111NILMONITOR182227295276Frog Jumpsjumps01TEXTBOX502391645448You may also move by clicking in the graphics window.@#$#@#$#@WHAT IS IT?-----------This model is based on the classic arcade game, Frogger. The object of the game is to get the frog, found at the bottom of the screen, across the traffic and river to a safe lily pad at the top of the screen.There are two main obstacles to overcome, the road and the river. The road has cars and trucks moving at various speeds that are liable to run over the frog. Once you have crossed the road safely, you must overcome the danger lurking in the river. Unfortunately, you will die if you jump in the river, so you must keep moving towards the lily pads by jumping on the logs or sets of turtles moving back and forth in the river's current.You must also avoid getting pushed off the edge of the screen by a log or turtle. In addition, in the later levels, some of the turtles will dive under water -- if you happen to be standing on them you will drown! Finally, you must also get across the board before the allotted amount of time runs out.HOW TO USE IT-------------Buttons:- NEW-GAME resets the game- START starts the game- The direction buttons (UP, DOWN, LEFT, RIGHT) will move your frog in that directionAnother way to move is to use your mouse. Just click in the direction you want to move (one click per jump). (If you click diagonally, the frog jumps up or down, not left or right. This makes crossing the river easier.)Monitors- FROGS LEFT tells you how many remaining lives you have- LEVEL monitors the current level you are playing- TIME LEFT shows you how much time remains - FROG JUMPS tells you how many jumps you has takenSliders START-LIVES will determine how many lives you will start with START-TIME sets how much time you start out with START-LEVEL is used to determine which level you will start onIdentifying Things in the Board:- Green Frog: This is you.- Truck: This is a truck. Avoid at all costs. They are usually pretty slow.- Car: This is a car. Avoid at all costs. They are usually fast.- Brown Squares: This is a log. You need to jump onto these to get across the river.- Turtle: This is a turtle. You need to jump onto these. Avoid ones that dive.- Green Circles: This is the lily pad. You want to get on these to win the level.- Blue Squares: This is the river. You can't land on this.- Gray Squares: This is the road. You can jump on this, but watch out for vehicles.- Green Patches: This is grass. You are pretty safe here.THINGS TO TRY-------------See if you can get through all of the levels.Try to beat your previous time.Try to make as few jumps as possible in the time allotted.Try to use as few lives as possible.THINGS TO NOTICE----------------Determine how many jumps it would take to get across the board without obstacles.Determine how many jumps it would take to get across the board with obstacles.How does each of the two questions above related to the time it takes you to complete a level?If you take just as many jumps with obstacles as without, why does it take different durations of time to get across?EXTENDING THE MODEL-------------------Write your own levels by altering the code in the Procedures tab.Add some bonuses or additional hazards.Implement a scoring system.Write a robot script that will move your frog automatically.NETLOGO FEATURES-----------------This model uses breeds to implement the different moving game pieces.The every command is used to control the speed of the game.The user-message command presents messages to the user.mouse-down?, mouse-xcor, and mouse-ycor are used to detect and handle mouse clicks.RELATED MODELS--------------Pac Man, TetrisCREDITS AND REFERENCES----------------------To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Frogger model. http://ccl.northwestern.edu/netlogo/models/Frogger. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.@#$#@#$#@defaulttrue0Polygon -7566196 true true 150 5 40 250 150 205 260 250turtletrue0Circle -11352576 true false 90 52 124Circle -11352576 true false 90 70 119Circle -11352576 true false 94 129 112Polygon -11352576 true false 91 99 93 187 207 187 213 112 91 99Polygon -7566196 true true 149 14 123 27 126 53 129 57 151 52 174 57 182 28Polygon -7566196 true true 95 85 51 76 48 101 89 101Polygon -7566196 true true 93 191 54 212 76 235 99 206Polygon -7566196 true true 207 88 248 65 257 98Polygon -7566196 true true 252 96 207 98 208 88 245 84Polygon -7566196 true true 206 188 250 204 240 233 200 201 206 188Circle -16777216 true false 133 30 7Circle -16777216 true false 161 30 6Line -7566196 true 149 79 149 192Line -7566196 true 116 89 117 190Line -7566196 true 190 89 190 184Line -7566196 true 118 192 190 189Line -7566196 true 117 89 145 79Line -7566196 true 151 80 190 93Line -7566196 true 117 122 148 113Line -7566196 true 151 113 185 122Line -7566196 true 119 160 185 158Line -7566196 true 120 145 146 136Line -7566196 true 146 136 188 143frogtrue0Polygon -11352576 true false 149 12 115 32 89 60 75 134 89 210 131 224 149 224 169 224 211 210 225 134 209 56 179 26 149 12Polygon -11352576 true false 93 60 35 72 17 114 33 118 47 80 87 74Polygon -11352576 true false 81 180 43 214 67 260 85 258 57 216 85 192Polygon -11352576 true false 209 62 261 68 283 110 267 110 253 78 211 72 209 62Polygon -11352576 true false 219 172 261 212 231 260 215 250 245 216 215 184Circle -1 true false 112 41 23Circle -1 true false 165 40 23Circle -16777216 true false 119 48 8Circle -16777216 true false 173 48 8Polygon -7566196 true true 149 11 115 33 87 59 31 69 11 119 35 125 49 89 85 83 75 133 81 179 39 215 65 263 87 259 61 215 83 193 87 209 127 223 171 223 211 211 217 185 239 215 209 249 231 263 263 209 217 169 225 131 215 73 251 85 263 115 287 115 263 63 207 53 179 25 149 11 149 11cartrue0Rectangle -7566196 true true 75 30 225 278Polygon -7566196 true true 75 28 91 14 211 16 225 30 211 54 79 38Polygon -7566196 true trueRectangle -16711681 true false 93 114 209 128Rectangle -16711681 true false 97 232 205 240Line -16777216 false 97 144 97 212Line -16777216 false 203 146 203 208Line -16777216 false 99 36 199 36Line -16777216 false 201 36 201 98Line -16777216 false 97 36 97 92Line -16777216 false 97 92 121 68Line -16777216 false 121 68 171 68Line -16777216 false 171 68 177 68Line -16777216 false 177 68 199 90Rectangle -7566196 true true 195 92 207 98Rectangle -7566196 true true 199 94 205 100Rectangle -7566196 true true 99 39 199 99Line -16777216 false 111 91 183 91Circle -256 true false 75 13 16Circle -256 true false 209 15 16Polygon -7566196 true true 75 27 89 15 109 15 109 31Polygon -7566196 true true 91 23 79 27 81 31Polygon -7566196 true true 209 15 225 31 219 37 187 27Circle -256 true false 211 13 12Polygon -7566196 true true 209 15 221 27 203 29Line -16777216 false 99 37 99 39Line -16777216 false 99 91 99 35Circle -256 true false 75 11 13Line -16777216 false 199 37 199 91Rectangle -7566196 true true 90 33 98 95Circle -256 true false 211 15 12Rectangle -7566196 true true 195 31 205 95Line -16777216 false 195 37 195 89Rectangle -7566196 true true 93 35 101 95Rectangle -7566196 true true 191 33 199 95Rectangle -7566196 true true 95 33 101 43Rectangle -7566196 true true 97 31 103 43Rectangle -65536 true false 77 273 89 277Rectangle -65536 true false 211 273 223 277Rectangle -65536 true false 77 269 97 275Rectangle -65536 true false 205 271 221 277Rectangle -65536 true false 207 269 223 275Rectangle -65536 true false 87 269 95 275Rectangle -7566196 true true 87 39 217 89Rectangle -7566196 true true 89 23 205 99Rectangle -7566196 true true 128 61 214 111Rectangle -7566196 true true 77 31 147 111Rectangle -16777216 true false 89 15 209 17Rectangle -16777216 true false 91 17 211 19Rectangle -7566196 true true 91 51 213 113Rectangle -7566196 true true 77 265 223 277Rectangle -7566196 true true 97 16 199 24Rectangle -16777216 true false 99 22 197 28truck2true0Rectangle -1 true false 45 0 255 282Rectangle -7566196 true true 45 0 255 282Rectangle -1 true false 45 0 255 282trucktrue0Rectangle -16777216 true false 45 60 255 196Polygon -16777216 true false 45 58 75 28 225 28 255 58 235 90 63 90Rectangle -16711681 true false 77 50 223 60Rectangle -16777216 true false 121 194 181 216Rectangle -16777216 true false 121 196 181 228Rectangle -1 true false 45 224 255 302Rectangle -7566196 true true 45 224 255 312Rectangle -1 true false 45 224 253 302Polygon -7566196 true true 45 196 253 196 253 54 225 26 77 26 43 60Polygon -7566196 true true 43 60 43 196 75 196 75 56 43 60Rectangle -16711681 true false 79 40 221 50Circle -16777216 true false 51 168 20Circle -16777216 true false 221 168 20Rectangle -1 true false 203 224 255 312Polygon -7566196 true true 233 196 255 196 255 56 225 26 245 170 245 190Rectangle -16711681 true false 79 40 221 56padfalse0Polygon -16776961 true false 15 296 35 188 17 118 30 43 51 24 87 19 204 17 229 30 272 23 275 73 266 99 268 185 273 251 256 261 278 298Polygon -16776961 true false 205 17 260 24 272 251 267 281 209 223Circle -11352576 true false 51 124 65Circle -11352576 true false 73 180 120Circle -16711936 true false 102 39 143Circle -11352576 true false 172 127 91Circle -16711936 true false 34 168 74Circle -16711936 true false 177 207 82Circle -11352576 true false 46 25 79Rectangle -16776961 true false 9 13 32 298Polygon -16776961 true false 42 175 32 204 25 159Rectangle -16776961 true false 24 13 42 44Rectangle -16776961 true false 29 13 275 19Rectangle -16776961 true false 264 13 284 299Rectangle -16776961 true false 10 296 284 304Polygon -11352576 true false 111 295 155 295 148 298Polygon -11352576 true false 110 296 145 298Polygon -11352576 true false 111 296Polygon -11352576 true false 144 298 115 299 109 295 110 290Polygon -16776961 true false 102 17 82 22 41 35 35 19 39 15Polygon -16776961 true false 215 15 271 15 267 29Polygon -16776961 true false 214 17 240 14 243 23 223 25Rectangle -16776961 true false 16 18 279 342Circle -16711936 true false 29 44 119Circle -11352576 true false 50 138 168Circle -16711936 true false 170 149 101Circle -11352576 true false 129 29 123splashfalse0Polygon -1 true false 147 119 96 57 55 64 29 69 68 71 110 87Polygon -1 true false 115 134 56 137 28 166 71 149Polygon -1 true false 195 131 249 93 271 125 235 128Polygon -1 true false 169 171 222 187 250 251 215 196Polygon -1 true false 134 161 78 205 85 260 98 206Circle -1 true false 111 110 72Polygon -1 true false 148 110 195 127 207 154 153 183 101 159 111 132@#$#@#$#@NetLogo 1.2.1@#$#@#$#@@#$#@#$#@@#$#@#$#@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?