How to use clearWorld method in wpt

Best JavaScript code snippet using wpt

StateManager.js

Source:StateManager.js Github

copy

Full Screen

1/* jshint newcap: false */2/**3* @author Richard Davey <rich@photonstorm.com>4* @copyright 2014 Photon Storm Ltd.5* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}6*/7/**8* The State Manager is responsible for loading, setting up and switching game states.9*10* @class Phaser.StateManager11* @constructor12* @param {Phaser.Game} game - A reference to the currently running game.13* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with.14*/15Phaser.StateManager = function (game, pendingState) {16 /**17 * @property {Phaser.Game} game - A reference to the currently running game.18 */19 this.game = game;20 /**21 * @property {Object} states - The object containing Phaser.States.22 */23 this.states = {};24 /**25 * @property {Phaser.State} _pendingState - The state to be switched to in the next frame.26 * @private27 */28 this._pendingState = null;29 if (typeof pendingState !== 'undefined' && pendingState !== null)30 {31 this._pendingState = pendingState;32 }33 /**34 * @property {boolean} _clearWorld - Clear the world when we switch state?35 * @private36 */37 this._clearWorld = false;38 /**39 * @property {boolean} _clearCache - Clear the cache when we switch state?40 * @private41 */42 this._clearCache = false;43 /**44 * @property {boolean} _created - Flag that sets if the State has been created or not.45 * @private46 */47 this._created = false;48 /**49 * @property {array} _args - Temporary container when you pass vars from one State to another.50 * @private51 */52 this._args = [];53 /**54 * @property {string} current - The current active State object (defaults to null).55 */56 this.current = '';57 /**58 * @property {function} onInitCallback - This will be called when the state is started (i.e. set as the current active state).59 */60 this.onInitCallback = null;61 /**62 * @property {function} onPreloadCallback - This will be called when init states (loading assets...).63 */64 this.onPreloadCallback = null;65 /**66 * @property {function} onCreateCallback - This will be called when create states (setup states...).67 */68 this.onCreateCallback = null;69 /**70 * @property {function} onUpdateCallback - This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).71 */72 this.onUpdateCallback = null;73 /**74 * @property {function} onRenderCallback - This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).75 */76 this.onRenderCallback = null;77 /**78 * @property {function} onPreRenderCallback - This will be called before the State is rendered and before the stage is cleared.79 */80 this.onPreRenderCallback = null;81 /**82 * @property {function} onLoadUpdateCallback - This will be called when the State is updated but only during the load process.83 */84 this.onLoadUpdateCallback = null;85 /**86 * @property {function} onLoadRenderCallback - This will be called when the State is rendered but only during the load process.87 */88 this.onLoadRenderCallback = null;89 /**90 * @property {function} onPausedCallback - This will be called when the state is paused.91 */92 this.onPausedCallback = null;93 /**94 * @property {function} onResumedCallback - This will be called when the state is resumed from a paused state.95 */96 this.onResumedCallback = null;97 /**98 * @property {function} onShutDownCallback - This will be called when the state is shut down (i.e. swapped to another state).99 */100 this.onShutDownCallback = null;101};102Phaser.StateManager.prototype = {103 /**104 * The Boot handler is called by Phaser.Game when it first starts up.105 * @method Phaser.StateManager#boot106 * @private107 */108 boot: function () {109 this.game.onPause.add(this.pause, this);110 this.game.onResume.add(this.resume, this);111 this.game.load.onLoadComplete.add(this.loadComplete, this);112 if (this._pendingState !== null)113 {114 if (typeof this._pendingState === 'string')115 {116 // State was already added, so just start it117 this.start(this._pendingState, false, false);118 }119 else120 {121 this.add('default', this._pendingState, true);122 }123 }124 },125 /**126 * Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it.127 * The State can be either a Phaser.State object (or an object that extends it), a plain JavaScript object or a function.128 * If a function is given a new state object will be created by calling it.129 *130 * @method Phaser.StateManager#add131 * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".132 * @param {Phaser.State|object|function} state - The state you want to switch to.133 * @param {boolean} [autoStart=false] - If true the State will be started immediately after adding it.134 */135 add: function (key, state, autoStart) {136 if (typeof autoStart === "undefined") { autoStart = false; }137 var newState;138 if (state instanceof Phaser.State)139 {140 newState = state;141 }142 else if (typeof state === 'object')143 {144 newState = state;145 newState.game = this.game;146 }147 else if (typeof state === 'function')148 {149 newState = new state(this.game);150 }151 this.states[key] = newState;152 if (autoStart)153 {154 if (this.game.isBooted)155 {156 this.start(key);157 }158 else159 {160 this._pendingState = key;161 }162 }163 return newState;164 },165 /**166 * Delete the given state.167 * @method Phaser.StateManager#remove168 * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".169 */170 remove: function (key) {171 if (this.current === key)172 {173 this.callbackContext = null;174 this.onInitCallback = null;175 this.onShutDownCallback = null;176 this.onPreloadCallback = null;177 this.onLoadRenderCallback = null;178 this.onLoadUpdateCallback = null;179 this.onCreateCallback = null;180 this.onUpdateCallback = null;181 this.onRenderCallback = null;182 this.onPausedCallback = null;183 this.onResumedCallback = null;184 this.onDestroyCallback = null;185 }186 delete this.states[key];187 },188 /**189 * Start the given State. If a State is already running then State.shutDown will be called (if it exists) before switching to the new State.190 *191 * @method Phaser.StateManager#start192 * @param {string} key - The key of the state you want to start.193 * @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)194 * @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.195 * @param {...*} parameter - Additional parameters that will be passed to the State.init function (if it has one).196 */197 start: function (key, clearWorld, clearCache) {198 if (typeof clearWorld === "undefined") { clearWorld = true; }199 if (typeof clearCache === "undefined") { clearCache = false; }200 if (this.checkState(key))201 {202 // Place the state in the queue. It will be started the next time the game loop starts.203 this._pendingState = key;204 this._clearWorld = clearWorld;205 this._clearCache = clearCache;206 if (arguments.length > 3)207 {208 this._args = Array.prototype.splice.call(arguments, 3);209 }210 }211 },212 /**213 * Restarts the current State. State.shutDown will be called (if it exists) before the State is restarted.214 *215 * @method Phaser.StateManager#restart216 * @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)217 * @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.218 * @param {...*} parameter - Additional parameters that will be passed to the State.init function if it has one.219 */220 restart: function (clearWorld, clearCache) {221 if (typeof clearWorld === "undefined") { clearWorld = true; }222 if (typeof clearCache === "undefined") { clearCache = false; }223 // Place the state in the queue. It will be started the next time the game loop starts.224 this._pendingState = this.current;225 this._clearWorld = clearWorld;226 this._clearCache = clearCache;227 if (arguments.length > 3)228 {229 this._args = Array.prototype.splice.call(arguments, 3);230 }231 },232 /**233 * Used by onInit and onShutdown when those functions don't exist on the state234 * @method Phaser.StateManager#dummy235 * @private236 */237 dummy: function () {238 },239 /**240 * preUpdate is called right at the start of the game loop. It is responsible for changing to a new state that was requested previously.241 *242 * @method Phaser.StateManager#preUpdate243 */244 preUpdate: function () {245 if (this._pendingState && this.game.isBooted)246 {247 // Already got a state running?248 if (this.current)249 {250 this.onShutDownCallback.call(this.callbackContext, this.game);251 this.game.tweens.removeAll();252 this.game.camera.reset();253 this.game.input.reset(true);254 this.game.physics.clear();255 this.game.time.removeAll();256 if (this._clearWorld)257 {258 this.game.world.shutdown();259 if (this._clearCache === true)260 {261 this.game.cache.destroy();262 }263 }264 }265 this.setCurrentState(this._pendingState);266 if (this.onPreloadCallback)267 {268 this.game.load.reset();269 this.onPreloadCallback.call(this.callbackContext, this.game);270 // Is the loader empty?271 if (this.game.load.totalQueuedFiles() === 0)272 {273 this.loadComplete();274 }275 else276 {277 // Start the loader going as we have something in the queue278 this.game.load.start();279 }280 }281 else282 {283 // No init? Then there was nothing to load either284 this.loadComplete();285 }286 if (this.current === this._pendingState)287 {288 this._pendingState = null;289 }290 }291 },292 /**293 * Checks if a given phaser state is valid. A State is considered valid if it has at least one of the core functions: preload, create, update or render.294 *295 * @method Phaser.StateManager#checkState296 * @param {string} key - The key of the state you want to check.297 * @return {boolean} true if the State has the required functions, otherwise false.298 */299 checkState: function (key) {300 if (this.states[key])301 {302 var valid = false;303 if (this.states[key]['preload']) { valid = true; }304 if (this.states[key]['create']) { valid = true; }305 if (this.states[key]['update']) { valid = true; }306 if (this.states[key]['render']) { valid = true; }307 if (valid === false)308 {309 console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions: preload, create, update or render");310 return false;311 }312 return true;313 }314 else315 {316 console.warn("Phaser.StateManager - No state found with the key: " + key);317 return false;318 }319 },320 /**321 * Links game properties to the State given by the key.322 * @method Phaser.StateManager#link323 * @param {string} key - State key.324 * @protected325 */326 link: function (key) {327 this.states[key].game = this.game;328 this.states[key].add = this.game.add;329 this.states[key].make = this.game.make;330 this.states[key].camera = this.game.camera;331 this.states[key].cache = this.game.cache;332 this.states[key].input = this.game.input;333 this.states[key].load = this.game.load;334 this.states[key].math = this.game.math;335 this.states[key].sound = this.game.sound;336 this.states[key].scale = this.game.scale;337 this.states[key].state = this;338 this.states[key].stage = this.game.stage;339 this.states[key].time = this.game.time;340 this.states[key].tweens = this.game.tweens;341 this.states[key].world = this.game.world;342 this.states[key].particles = this.game.particles;343 this.states[key].rnd = this.game.rnd;344 this.states[key].physics = this.game.physics;345 },346 /**347 * Sets the current State. Should not be called directly (use StateManager.start)348 * @method Phaser.StateManager#setCurrentState349 * @param {string} key - State key.350 * @private351 */352 setCurrentState: function (key) {353 this.callbackContext = this.states[key];354 this.link(key);355 // Used when the state is set as being the current active state356 this.onInitCallback = this.states[key]['init'] || this.dummy;357 this.onPreloadCallback = this.states[key]['preload'] || null;358 this.onLoadRenderCallback = this.states[key]['loadRender'] || null;359 this.onLoadUpdateCallback = this.states[key]['loadUpdate'] || null;360 this.onCreateCallback = this.states[key]['create'] || null;361 this.onUpdateCallback = this.states[key]['update'] || null;362 this.onPreRenderCallback = this.states[key]['preRender'] || null;363 this.onRenderCallback = this.states[key]['render'] || null;364 this.onPausedCallback = this.states[key]['paused'] || null;365 this.onResumedCallback = this.states[key]['resumed'] || null;366 // Used when the state is no longer the current active state367 this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy;368 this.current = key;369 this._created = false;370 this.onInitCallback.apply(this.callbackContext, this._args);371 this._args = [];372 },373 /**374 * Gets the current State.375 *376 * @method Phaser.StateManager#getCurrentState377 * @return Phaser.State378 * @public379 */380 getCurrentState: function() {381 return this.states[this.current];382 },383 /**384 * @method Phaser.StateManager#loadComplete385 * @protected386 */387 loadComplete: function () {388 if (this._created === false && this.onCreateCallback)389 {390 this._created = true;391 this.onCreateCallback.call(this.callbackContext, this.game);392 }393 else394 {395 this._created = true;396 }397 },398 /**399 * @method Phaser.StateManager#pause400 * @protected401 */402 pause: function () {403 if (this._created && this.onPausedCallback)404 {405 this.onPausedCallback.call(this.callbackContext, this.game);406 }407 },408 /**409 * @method Phaser.StateManager#resume410 * @protected411 */412 resume: function () {413 if (this._created && this.onResumedCallback)414 {415 this.onResumedCallback.call(this.callbackContext, this.game);416 }417 },418 /**419 * @method Phaser.StateManager#update420 * @protected421 */422 update: function () {423 if (this._created && this.onUpdateCallback)424 {425 this.onUpdateCallback.call(this.callbackContext, this.game);426 }427 else428 {429 if (this.onLoadUpdateCallback)430 {431 this.onLoadUpdateCallback.call(this.callbackContext, this.game);432 }433 }434 },435 /**436 * @method Phaser.StateManager#preRender437 * @protected438 */439 preRender: function () {440 if (this.onPreRenderCallback)441 {442 this.onPreRenderCallback.call(this.callbackContext, this.game);443 }444 },445 /**446 * @method Phaser.StateManager#render447 * @protected448 */449 render: function () {450 if (this._created && this.onRenderCallback)451 {452 if (this.game.renderType === Phaser.CANVAS)453 {454 this.game.context.save();455 this.game.context.setTransform(1, 0, 0, 1, 0, 0);456 }457 this.onRenderCallback.call(this.callbackContext, this.game);458 if (this.game.renderType === Phaser.CANVAS)459 {460 this.game.context.restore();461 }462 }463 else464 {465 if (this.onLoadRenderCallback)466 {467 this.onLoadRenderCallback.call(this.callbackContext, this.game);468 }469 }470 },471 /**472 * Removes all StateManager callback references to the State object, nulls the game reference and clears the States object.473 * You don't recover from this without rebuilding the Phaser instance again.474 * @method Phaser.StateManager#destroy475 */476 destroy: function () {477 this.callbackContext = null;478 this.onInitCallback = null;479 this.onShutDownCallback = null;480 this.onPreloadCallback = null;481 this.onLoadRenderCallback = null;482 this.onLoadUpdateCallback = null;483 this.onCreateCallback = null;484 this.onUpdateCallback = null;485 this.onRenderCallback = null;486 this.onPausedCallback = null;487 this.onResumedCallback = null;488 this.onDestroyCallback = null;489 this.game = null;490 this.states = {};491 this._pendingState = null;492 }493};...

Full Screen

Full Screen

karelsim.worlds.js

Source:karelsim.worlds.js Github

copy

Full Screen

...11function(karelsim) {1213karelsim.world_Sample1 = function() {14 "use strict";15 clearWorld(5, 4);16 wall(1.5, 1.5, karelsim.RIGHT);17 wall(2 , 1.5, karelsim.RIGHT + karelsim.LEFT);18 wall(2.5, 1.5, karelsim.TOP + karelsim.RIGHT + karelsim.LEFT); 19 wall(3 , 1.5, karelsim.RIGHT + karelsim.LEFT);20 wall(3.5, 1.5, karelsim.LEFT);21 wall(1.5, 2.5, karelsim.TOP);22 wall(1.5, 3 , karelsim.TOP + karelsim.BOTTOM);23 wall(1.5, 3.5, karelsim.RIGHT + karelsim.BOTTOM);24 wall(2 , 3.5, karelsim.RIGHT + karelsim.LEFT);25 wall(2.5, 3.5, karelsim.LEFT);26 wall(2.5, 2 , karelsim.TOP + karelsim.BOTTOM);27 wall(2.5, 2.5, karelsim.RIGHT + karelsim.BOTTOM);28 wall(3 , 2.5, karelsim.RIGHT + karelsim.LEFT);29 wall(3.5, 2.5, karelsim.TOP + karelsim.LEFT);30 wall(3.5, 3 , karelsim.TOP + karelsim.BOTTOM);31 wall(3.5, 3.5, karelsim.BOTTOM);32 beeper(4, 2);33 beeper(3, 3);34 beeper(1, 3);35 beeper(1, 4);36 karel(1, 1, 'north');37 return 0;38};3940karelsim.world_Sample2 = function() {41 "use strict";42 clearWorld(5, 4);43 wall(1.5, 1.5, karelsim.TOP + karelsim.BOTTOM);44 wall(1.5, 2 , karelsim.TOP + karelsim.BOTTOM);45 wall(1.5, 2.5, karelsim.TOP + karelsim.BOTTOM + karelsim.RIGHT);46 wall(1.5, 3 , karelsim.TOP + karelsim.BOTTOM);47 wall(1.5, 3.5, karelsim.TOP + karelsim.BOTTOM);48 wall(2 , 2.5, karelsim.LEFT + karelsim.RIGHT);49 wall(2.5, 2.5, karelsim.LEFT + karelsim.RIGHT);50 wall(3 , 2.5, karelsim.LEFT + karelsim.RIGHT);51 wall(3.5, 2.5, karelsim.LEFT + karelsim.RIGHT);52 beeper(5, 2);53 beeper(3, 4);54 beeper(1, 2);55 karel(5, 4, 'south');56 return 0;57};5859karelsim.world_Sample3 = function() {60 "use strict";61 clearWorld(5, 4);62 63 wall(1 , 1.5, karelsim.RIGHT + karelsim.LEFT);64 wall(1.5, 1.5, karelsim.RIGHT + karelsim.LEFT);65 wall(2 , 1.5, karelsim.RIGHT + karelsim.LEFT);66 wall(2.5, 1.5, karelsim.RIGHT + karelsim.LEFT); 67 wall(3 , 1.5, karelsim.RIGHT + karelsim.LEFT);68 wall(3.5, 1.5, karelsim.RIGHT + karelsim.LEFT);69 wall(4 , 1.5, karelsim.RIGHT + karelsim.LEFT);7071 wall(2 , 2.5, karelsim.RIGHT + karelsim.LEFT);72 wall(2.5, 2.5, karelsim.RIGHT + karelsim.LEFT);73 wall(3 , 2.5, karelsim.RIGHT + karelsim.LEFT);74 wall(3.5, 2.5, karelsim.RIGHT + karelsim.LEFT); 75 wall(4 , 2.5, karelsim.RIGHT + karelsim.LEFT);76 wall(4.5, 2.5, karelsim.RIGHT + karelsim.LEFT);77 wall(5 , 2.5, karelsim.RIGHT + karelsim.LEFT);78 79 wall(1 , 3.5, karelsim.RIGHT + karelsim.LEFT);80 wall(1.5, 3.5, karelsim.RIGHT + karelsim.LEFT);81 wall(2 , 3.5, karelsim.RIGHT + karelsim.LEFT);82 wall(2.5, 3.5, karelsim.RIGHT + karelsim.LEFT); 83 wall(3 , 3.5, karelsim.RIGHT + karelsim.LEFT);84 wall(3.5, 3.5, karelsim.RIGHT + karelsim.LEFT);85 wall(4 , 3.5, karelsim.RIGHT + karelsim.LEFT);86 87 beeper(1, 4);88 karel(1, 1, 'east');89 return 0;90};9192karelsim.world_EmptySevenBySevenWithKarelInMiddle = function() {93 "use strict";94 clearWorld(7, 7);95 karel(4, 4, 'north');96 return 0;97};9899karelsim.world_EmptyTenByFour = function() {100 "use strict";101 clearWorld(10, 4);102 karel(1, 1, 'north');103 return 0;104};105106karelsim.world_EmptyEightByEight = function() {107 "use strict";108 clearWorld(8, 8);109 karel(1, 1, 'north');110 return 0;111};112113karelsim.world_EightByEightWithBeepers1 = function() {114 "use strict";115 clearWorld(8, 8);116 beeper(7, 5);117 beeper(6, 2);118 beeper(3, 8);119 beeper(3, 3);120 beeper(2, 7);121 beeper(1, 5);122 karel(1, 1, 'north');123 return 0;124};125126karelsim.world_EightByEightWithBeepers2 = function() {127 "use strict";128 clearWorld(8, 8);129 beeper(8, 7);130 beeper(8, 5);131 beeper(7, 2);132 beeper(6, 2);133 beeper(5, 5);134 beeper(3, 8);135 beeper(2, 5);136 beeper(1, 3);137 karel(1, 1, 'north');138 return 0;139};140141karelsim.world_EightByEightWithBeepers3 = function() {142 "use strict";143 clearWorld(8, 8);144 beeper(2, 7);145 beeper(7, 2);146 beeper(7, 7);147 beeper(5, 5);148 beeper(5, 4);149 beeper(4, 5);150 beeper(4, 4);151 beeper(2, 2);152 karel(1, 1, 'north');153 return 0;154};155156// Wide, short world with nothing in it... perfect for dropping lots of beepers in patterns157karelsim.world_EightByEightWithRandomBeepers = function() {158 "use strict";159 var rnd, ii, x, y;160 clearWorld(8, 8);161 karel(1, 1, 'north');162 rnd = Math.floor(Math.random() * 10) + 1;163 for (ii = 0; ii < rnd; ii += 1) {164 x = Math.floor(Math.random() * 8) + 1;165 y = Math.floor(Math.random() * 8) + 1;166 if ( ( x === 1 ) && ( y == 1 ) ) {167 // Skip... don't put a beeper at Karel's s starting point168 } else {169 if ( karelsim.isBeeperAt(x, y) ) {170 // Skip... don't put a beeper down where one already exists171 } else {172 beeper(x, y);173 }174 }175 }176 return 0;177};178179karelsim.world_TwelveByFourWithHurdles1 = function() {180 "use strict";181 clearWorld(12, 4);182 wall(2.5, 1, karelsim.TOP+karelsim.BOTTOM);183 wall(4.5, 1, karelsim.TOP+karelsim.BOTTOM);184 wall(6.5, 1, karelsim.TOP+karelsim.BOTTOM);185 wall(9.5, 1, karelsim.TOP+karelsim.BOTTOM);186 karel(1, 1, 'east');187 beeper(12, 1);188 return 0;189};190191karelsim.world_TwelveByFourWithHurdles2 = function() {192 "use strict";193 clearWorld(12, 4);194 wall(2.5, 1, karelsim.TOP+karelsim.BOTTOM); wall(2.5, 1.5, karelsim.TOP+karelsim.BOTTOM); wall(2.5, 2, karelsim.TOP+karelsim.BOTTOM);195 wall(5.5, 1, karelsim.TOP+karelsim.BOTTOM);196 wall(6.5, 1, karelsim.TOP+karelsim.BOTTOM); wall(6.5, 1.5, karelsim.TOP+karelsim.BOTTOM); wall(6.5, 2, karelsim.TOP+karelsim.BOTTOM);197 wall(9.5, 1, karelsim.TOP+karelsim.BOTTOM);198 wall(11.5, 1, karelsim.TOP+karelsim.BOTTOM);199 karel(1, 1, 'east');200 beeper(12, 1);201 return 0;202};203204karelsim.world_TwelveByFourWithHurdles3 = function() {205 "use strict";206 clearWorld(12, 4);207 wall(1.5, 1, karelsim.TOP+karelsim.BOTTOM); wall(1.5, 1.5, karelsim.TOP+karelsim.BOTTOM); wall(1.5, 2, karelsim.TOP+karelsim.BOTTOM);208 wall(4.5, 1, karelsim.TOP+karelsim.BOTTOM); wall(4.5, 1.5, karelsim.TOP+karelsim.BOTTOM); wall(4.5, 2, karelsim.TOP+karelsim.BOTTOM); wall(4.5, 2.5, karelsim.TOP+karelsim.BOTTOM); wall(4.5, 3, karelsim.TOP+karelsim.BOTTOM);209 wall(8.5, 1, karelsim.TOP+karelsim.BOTTOM); wall(8.5, 1.5, karelsim.TOP+karelsim.BOTTOM); wall(8.5, 2, karelsim.TOP+karelsim.BOTTOM);210 wall(9.5, 1, karelsim.TOP+karelsim.BOTTOM);211 wall(11.5, 1, karelsim.TOP+karelsim.BOTTOM);212 karel(1, 1, 'east');213 beeper(12, 1);214 return 0;215};216217karelsim.world_TwelveByFourWithRandomHurdles = function() {218 "use strict";219 var nn, ii, xx, hh, jj;220 clearWorld(12, 4);221 222 nn = Math.floor(Math.random() * 5) + 1; // Between 1 and 5 hurdles223 for (ii = 0; ii < nn; ii += 1) {224 xx = Math.floor(Math.random() * 9) + 2.5; // Hurdle x-position between 2.5 and 9.5225 hh = Math.floor(Math.random() * 5) + 1; // Hurdle height between 1 and 5 'half walls'226 for (jj = 0.5; jj < (hh+1)/2; jj += 0.5) {227 wall(xx, jj, karelsim.TOP+karelsim.BOTTOM);228 }229 }230 karel(1, 1, 'east');231 beeper(12, 1);232 return 0;233};234235karelsim.world_EmptyTwelveByEightWithBeepersInBag = function() {236 "use strict";237 clearWorld(12, 8);238 setNumBeepersInKarelsBag(1000);239 karel(1, 1, 'north');240 return 0;241};242243karelsim.world_TwelveByTwelveMaze1 = function() {244 "use strict";245 var sts;246 sts = worldString("[1;12;12;1;1;north;0_0_0|0_0_0_0_0_0|0_0_4;_<-L_|_B_R-t--->_|_R---;0|0_0|0|0_0|0_0|0|0_0_0;_~---/_|_B_|_B_~-b---L_;0_0_0_0|0|0|0|0_0_0_0_0;_<-----b-r_|_l-------t-;0|0_0_0_0|0|0|0_0_0_0|0;_|_R-t-L_|_T_|_<--->_|_;0|0_0|0_0|0_0|0|0_0|0|0;_~---/_B_l---/_~-L_|_|_;0_0_0_0|0|0_0_0_0_0|0|0;_<-t---/_|_<-------/_|_;0|0|0_0_0|0|0_0_0_0_0|0;_|_|__---/_|_<---t---r_;0|0|0_0_0_0|0|0_0|0_0|0;_T_l-----t-/_|_B_|_B_|_;0_0|0_0_0|0_0|0|0|0|0|0;---r_<---/_<-/_|_|_|_|_;0_0|0|0_0_0|0_0|0|0|0|0;_B_T_|_<---/_R-b-b-/_|_;0|0_0|0|0_0_0_0_0_0_0|0;_~---/_~-------L_R---/_;0_0_0_0_0_0_0_0_0_0_0_0]");247 // 0 1 2 3 4 5 6 7 8 9 248 return sts;249};250251karelsim.world_Greetings = function() { ...

Full Screen

Full Screen

Game.ts

Source:Game.ts Github

copy

Full Screen

1import {LayaGame} from '../../abstract/LayaInterface';2import World from './World';3import * as Phaser from 'phaser';4import {AbstractSence} from '../../abstract/AbstractSence';5export default class Game implements LayaGame {6 realGame: Phaser.Game;7 world: World;8 constructor(game: Phaser.Game) {9 this.realGame = game;10 }11 setWorld(world: World) {12 this.world = world;13 }14 getWorld() {15 return this.world;16 }17 getRealObject(): Phaser.Game {18 return this.realGame;19 }20 senceJump(sence: string, clearWorld?: boolean, clearCache?: boolean): void {21 this.realGame.state.start(sence, clearWorld, clearCache);22 }23 registerSence(key: string, state: AbstractSence): void {24 this.realGame.state.add(key, state);25 }26 startSence(name: string, clearWorld: boolean, clearCache?: boolean): void {27 this.realGame.state.start(name, clearWorld, clearCache);28 }29 destroy() {30 this.realGame.destroy();31 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.clearWorld();2wpt.addBox(0,0,0,1,1,1,1);3wpt.addSphere(0,0,0,1,1,1,1);4wpt.addCylinder(0,0,0,1,1,1,1);5wpt.addCone(0,0,0,1,1,1,1);6wpt.addTorus(0,0,0,1,1,1,1);7wpt.addCylinder(0,0,0,1,1,1,1);8wpt.addCone(0,0,0,1,1,1,1);9wpt.addTorus(0,0,0,1,1,1,1);10wpt.addCylinder(0,0,0,1,1,1,1);11wpt.addCone(0,0,0,1,1,1,1);12wpt.addTorus(0,0,0,1,1,1,1);13wpt.addCylinder(0,0,0,1,1,1,1);14wpt.addCone(0,0,0,1,1,1,1);15wpt.addTorus(0,0,0,1,1,1,1);16wpt.addCylinder(0,0,0,1,1,1,1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new wpt('API_KEY');3wpt.clearWorld(function(err, data) {4 if (err) {5 console.log('Error: ', err);6 } else {7 console.log('Data: ', data);8 }9});10var wpt = require('wpt');11var wpt = new wpt('API_KEY');12wpt.clearLocations(function(err, data) {13 if (err) {14 console.log('Error: ', err);15 } else {16 console.log('Data: ', data);17 }18});19var wpt = require('wpt');20var wpt = new wpt('API_KEY');21wpt.getLocations(function(err, data) {22 if (err) {23 console.log('Error: ', err);24 } else {25 console.log('Data: ', data);26 }27});28var wpt = require('wpt');29var wpt = new wpt('API_KEY');30wpt.getTesters(function(err, data) {31 if (err) {32 console.log('Error: ', err);33 } else {34 console.log('Data: ', data);35 }36});37var wpt = require('wpt');38var wpt = new wpt('API_KEY');39wpt.getLocations(function(err, data) {40 if (err) {41 console.log('Error: ', err);42 } else {43 console.log('Data: ', data);44 }45});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful