├── README.md ├── docs ├── CWC_Mariohtml5_RT.png ├── CWC_Mariohtml5_zip_TIaPortal.png └── CWC_Mariohtml5_zip_folder.png └── {8F2D1D74-4B07-4F7A-8800-1A75071F21B4} ├── Control ├── Enjine │ ├── animatedSprite.js │ ├── application.js │ ├── camera.js │ ├── collideable.js │ ├── core.js │ ├── drawable.js │ ├── drawableManager.js │ ├── frameSprite.js │ ├── gameCanvas.js │ ├── gameTimer.js │ ├── keyboardInput.js │ ├── resources.js │ ├── sprite.js │ ├── spriteFont.js │ └── state.js ├── LICENSE.md ├── README ├── code │ ├── backgroundGenerator.js │ ├── backgroundRenderer.js │ ├── bulletBill.js │ ├── character.js │ ├── coinAnim.js │ ├── enemy.js │ ├── fireFlower.js │ ├── fireball.js │ ├── flowerEnemy.js │ ├── improvedNoise.js │ ├── level.js │ ├── levelGenerator.js │ ├── levelRenderer.js │ ├── levelState.js │ ├── loadingState.js │ ├── loseState.js │ ├── mapState.js │ ├── midi.js │ ├── mushroom.js │ ├── music.js │ ├── notchSprite.js │ ├── particle.js │ ├── setup.js │ ├── shell.js │ ├── sparkle.js │ ├── spriteCuts.js │ ├── spriteTemplate.js │ ├── titleState.js │ └── winState.js ├── enjine.min.js ├── flipTest.html ├── images │ ├── bgsheet.png │ ├── endscene.gif │ ├── enemysheet.png │ ├── firemariosheet.png │ ├── font.gif │ ├── gameovergost.gif │ ├── itemsheet.png │ ├── logo.gif │ ├── mapsheet.png │ ├── mariosheet.png │ ├── particlesheet.png │ ├── racoonmariosheet.png │ ├── smallmariosheet.png │ ├── title.gif │ └── worldmap.png ├── index.html ├── jquery-3.5.1.min.js ├── mario.min.js ├── midi │ ├── background.mid │ ├── castle.mid │ ├── map.mid │ ├── overground.mid │ ├── title.mid │ ├── underground.mid │ └── urldecode.py ├── minTest.html ├── sounds │ ├── 1-up.mp3 │ ├── 1-up.wav │ ├── breakblock.mp3 │ ├── breakblock.wav │ ├── bump.mp3 │ ├── bump.wav │ ├── cannon.mp3 │ ├── cannon.wav │ ├── coin.mp3 │ ├── coin.wav │ ├── death.mp3 │ ├── death.wav │ ├── exit.mp3 │ ├── exit.wav │ ├── fireball.mp3 │ ├── fireball.wav │ ├── jump.mp3 │ ├── jump.wav │ ├── kick.mp3 │ ├── kick.wav │ ├── mapmusic.mp3 │ ├── message.mp3 │ ├── message.wav │ ├── pipe.mp3 │ ├── pipe.wav │ ├── powerdown.mp3 │ ├── powerdown.wav │ ├── powerup.mp3 │ ├── powerup.wav │ ├── smb3map1.mid │ ├── smb3map1.mp3 │ ├── smb3ovr1.mid │ ├── smb3undr.mid │ ├── smwfortress.mid │ ├── smwovr1.mid │ ├── smwovr2.mid │ ├── smwtitle.mid │ ├── smwtitle.mp3 │ ├── sprout.mp3 │ ├── sprout.wav │ ├── stagestart.mp3 │ ├── stagestart.wav │ ├── stomp.mp3 │ └── stomp.wav └── webcc.min.js ├── assets └── Logo.png └── manifest.json /README.md: -------------------------------------------------------------------------------- 1 | # CWC_Mariohtml5 2 | Infinite Mario in HTML5 JavaScript as custom Web control 3 | 4 | To use the custom web control in WinCC, the hierarchy of folders and files must be 5 | compressed. For WinCC it is necessary that this data is available in ZIP format. The name of 6 | the ZIP file must match the GUID, for this example, "{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}.zip". 7 | 8 | ![zip](https://github.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/blob/master/docs/CWC_Mariohtml5_zip_folder.png) 9 | To install custom web controls for a TIA Portal project, proceed as follows: 10 | 1. Open the directory of your project. 11 | 2. Open the "UserFiles" subfolder. 12 | 3. Create a folder with the name "CustomControls" if is not exist 13 | 4. Store the created program as *.zip archive in the "CustomControls" folder. 14 | 15 | Refresh “My controls” to see it in TIA Portal 16 | ![TIA](https://github.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/blob/master/docs/CWC_Mariohtml5_zip_TIaPortal.png) 17 | 18 | Place the Mario control in the Screen and it Download the RT 19 | 20 | ![CWC_RT](https://github.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/blob/master/docs/CWC_Mariohtml5_RT.png) 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/CWC_Mariohtml5_RT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/docs/CWC_Mariohtml5_RT.png -------------------------------------------------------------------------------- /docs/CWC_Mariohtml5_zip_TIaPortal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/docs/CWC_Mariohtml5_zip_TIaPortal.png -------------------------------------------------------------------------------- /docs/CWC_Mariohtml5_zip_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/docs/CWC_Mariohtml5_zip_folder.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/animatedSprite.js: -------------------------------------------------------------------------------- 1 | /** 2 | Class to represent an uninterrupted set of frames to animate. 3 | */ 4 | 5 | Enjine.AnimationSequence = function(startRow, startColumn, endRow, endColumn) { 6 | this.StartRow = startRow; 7 | this.StartColumn = startColumn; 8 | this.EndRow = endRow; 9 | this.EndColumn = endColumn; 10 | 11 | //sometimes in an animated sprite, we want it to behave like a regular sprite (static) 12 | //this variable will keep it from wasting time updating animation when the sequence 13 | //is only a single frame long, for things like standing or pausing action 14 | this.SingleFrame = false; 15 | 16 | if ((this.StartRow == this.EndRow) && (this.StartColumn == this.EndColumn)) { 17 | this.SingleFrame = true; 18 | } 19 | }; 20 | 21 | /** 22 | Subclass that extends the regular sprite with animation capability. 23 | Code by Rob Kleffner, 2011 24 | */ 25 | 26 | Enjine.AnimatedSprite = function() { 27 | this.LastElapsed = 0; 28 | this.FramesPerSecond = 1 / 20; 29 | this.CurrentSequence = null; 30 | this.Playing = false; 31 | this.Looping = false; 32 | this.Rows = 0; 33 | this.Columns = 0; 34 | 35 | //cheesy dictionary hack to make animation sequences more accessible 36 | this.Sequences = new Object(); 37 | }; 38 | 39 | Enjine.AnimatedSprite.prototype = new Enjine.FrameSprite(); 40 | 41 | Enjine.AnimatedSprite.prototype.Update = function(delta) { 42 | if (this.CurrentSequence.SingleFrame) { 43 | return; 44 | } 45 | if (!this.Playing) { 46 | return; 47 | } 48 | 49 | this.LastElapsed -= delta; 50 | 51 | if (this.LastElapsed > 0) { 52 | return; 53 | } 54 | 55 | this.LastElapsed = this.FramesPerSecond; 56 | this.FrameX += this.FrameWidth; 57 | 58 | //increment the frame 59 | if (this.FrameX > (this.Image.width - this.FrameWidth)) { 60 | this.FrameX = 0; 61 | this.FrameY += this.FrameHeight; 62 | 63 | if (this.FrameY > (this.Image.height - this.FrameHeight)) { 64 | this.FrameY = 0; 65 | } 66 | } 67 | 68 | //check if it's at the end of the animation sequence 69 | var seqEnd = false; 70 | if ((this.FrameX > (this.CurrentSequence.EndColumn * this.FrameWidth)) && (this.FrameY == (this.CurrentSequence.EndRow * this.FrameHeight))) { 71 | seqEnd = true; 72 | } else if (this.FrameX == 0 && (this.FrameY > (this.CurrentSequence.EndRow * this.FrameHeight))) { 73 | seqEnd = true; 74 | } 75 | 76 | //go back to the beginning if looping, otherwise stop playing 77 | if (seqEnd) { 78 | if (this.Looping) { 79 | this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; 80 | this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; 81 | } else { 82 | this.Playing = false; 83 | } 84 | } 85 | }; 86 | 87 | Enjine.AnimatedSprite.prototype.PlaySequence = function(seqName, loop) { 88 | this.Playing = true; 89 | this.Looping = loop; 90 | this.CurrentSequence = this.Sequences["seq_" + seqName]; 91 | this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; 92 | this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; 93 | }; 94 | 95 | Enjine.AnimatedSprite.prototype.StopLooping = function() { 96 | this.Looping = false; 97 | }; 98 | 99 | Enjine.AnimatedSprite.prototype.StopPlaying = function() { 100 | this.Playing = false; 101 | }; 102 | 103 | Enjine.AnimatedSprite.prototype.SetFrameWidth = function(width) { 104 | this.FrameWidth = width; 105 | this.Rows = this.Image.width / this.FrameWidth; 106 | }; 107 | 108 | Enjine.AnimatedSprite.prototype.SetFrameHeight = function(height) { 109 | this.FrameHeight = height; 110 | this.Columns = this.Image.height / this.FrameHeight; 111 | }; 112 | 113 | Enjine.AnimatedSprite.prototype.SetColumnCount = function(columnCount) { 114 | this.FrameWidth = this.Image.width / columnCount; 115 | this.Columns = columnCount; 116 | }; 117 | 118 | Enjine.AnimatedSprite.prototype.SetRowCount = function(rowCount) { 119 | this.FrameHeight = this.Image.height / rowCount; 120 | this.Rows = rowCount; 121 | }; 122 | 123 | Enjine.AnimatedSprite.prototype.AddExistingSequence = function(name, sequence) { 124 | this.Sequences["seq_" + name] = sequence; 125 | }; 126 | 127 | Enjine.AnimatedSprite.prototype.AddNewSequence = function(name, startRow, startColumn, endRow, endColumn) { 128 | this.Sequences["seq_" + name] = new Enjine.AnimationSequence(startRow, startColumn, endRow, endColumn); 129 | }; 130 | 131 | Enjine.AnimatedSprite.prototype.DeleteSequence = function(name) { 132 | if (this.Sequences["seq_" + name] != null) { 133 | delete this.Sequences["seq_" + name]; 134 | } 135 | }; 136 | 137 | Enjine.AnimatedSprite.prototype.ClearSequences = function() { 138 | delete this.Sequences; 139 | this.Sequences = new Object(); 140 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/application.js: -------------------------------------------------------------------------------- 1 | /** 2 | Simple demo of the engine. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Application = function() { 7 | this.canvas = null; 8 | this.timer = null; 9 | this.stateContext = null; 10 | }; 11 | 12 | Enjine.Application.prototype = { 13 | Update: function(delta) { 14 | 15 | this.stateContext.Update(delta); 16 | 17 | this.canvas.BeginDraw(); 18 | 19 | this.stateContext.Draw(this.canvas.BackBufferContext2D); 20 | 21 | this.canvas.EndDraw(); 22 | }, 23 | 24 | Initialize: function(defaultState, resWidth, resHeight) { 25 | this.canvas = new Enjine.GameCanvas(); 26 | this.timer = new Enjine.GameTimer(); 27 | Enjine.KeyboardInput.Initialize(); 28 | this.canvas.Initialize("canvas", resWidth, resHeight); 29 | this.timer.UpdateObject = this; 30 | 31 | this.stateContext = new Enjine.GameStateContext(defaultState); 32 | 33 | this.timer.Start(); 34 | } 35 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/camera.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a camera used to offset drawing of sprites in the world. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Camera = function() { 7 | this.X = 0; 8 | this.Y = 0; 9 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/collideable.js: -------------------------------------------------------------------------------- 1 | /** 2 | Basic bounding box collision object. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Collideable = function(obj, width, height, collisionEvent) { 7 | this.Base = obj; 8 | this.X = obj.X; 9 | this.Y = obj.Y; 10 | this.Width = width; 11 | this.Height = height; 12 | 13 | if (collisionEvent != null) { 14 | this.CollisionEvent = collisionEvent; 15 | } else { 16 | this.CollisionEvent = function() {} 17 | } 18 | }; 19 | 20 | Enjine.Collideable.prototype = { 21 | Update: function() { 22 | this.X = this.Base.X; 23 | this.Y = this.Base.Y; 24 | }, 25 | 26 | CheckCollision: function(other) { 27 | var left1 = this.X, left2 = other.X; 28 | var right1 = (this.X + this.Width), right2 = (other.X + other.Width); 29 | var top1 = this.Y, top2 = other.Y; 30 | var bottom1 = (this.Y + this.Height), bottom2 = other.Y + other.Height; 31 | 32 | if (bottom1 < top2) { 33 | return; 34 | } 35 | if (top1 > bottom2) { 36 | return; 37 | } 38 | if (right1 < left2) { 39 | return; 40 | } 41 | if (left1 > right2) { 42 | return; 43 | } 44 | 45 | //collision, fire the events! 46 | this.CollisionEvent(other); 47 | other.CollisionEvent(this); 48 | } 49 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/core.js: -------------------------------------------------------------------------------- 1 | /** 2 | Define the Enjine namespace and any other miscellaneous setup. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | var Enjine = {}; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/drawable.js: -------------------------------------------------------------------------------- 1 | /** 2 | Base class for all drawable objects, makes ordering automatic. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Drawable = function() { 7 | this.ZOrder = 0; 8 | }; 9 | 10 | Enjine.Drawable.prototype = { 11 | Draw: function(context) { } 12 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/drawableManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | Class to help manage and draw a collection of sprites. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.DrawableManager = function() { 7 | this.Unsorted = true; 8 | this.Objects = []; 9 | }; 10 | 11 | Enjine.DrawableManager.prototype = { 12 | Add: function(object) { 13 | this.Objects.push(object); 14 | this.Unsorted = true; 15 | }, 16 | 17 | AddRange: function(objects) { 18 | this.Objects = this.Objects.concat(objects); 19 | this.Unsorted = true; 20 | }, 21 | 22 | Clear: function() { 23 | this.Objects.splice(0, this.Objects.length); 24 | }, 25 | 26 | Contains: function(obj) { 27 | var i = this.Objects.length; 28 | while (i--) { 29 | if (this.Objects[i] === obj) { 30 | return true; 31 | } 32 | } 33 | return false; 34 | }, 35 | 36 | Remove: function(object) { 37 | var index = this.Objects.indexOf(object); 38 | this.Objects.splice(index, 1); 39 | }, 40 | 41 | RemoveAt: function(index) { 42 | this.Objects.splice(index, 1); 43 | }, 44 | 45 | RemoveRange: function(index, length) { 46 | this.Objects.splice(index, length); 47 | }, 48 | 49 | RemoveList: function(items) { 50 | var i = 0, j = 0; 51 | for (j = 0; j < items.length; i++) { 52 | for (i = 0; i < this.Objects.length; i++) { 53 | if (this.Objects[i] === items[j]) { 54 | this.Objects.splice(i, 1); 55 | items.splice(j, 1); 56 | j--; 57 | break; 58 | } 59 | } 60 | } 61 | }, 62 | 63 | Update: function(delta) { 64 | var i = 0; 65 | for (i = 0; i < this.Objects.length; i++) { 66 | if (this.Objects[i].Update) { 67 | this.Objects[i].Update(delta); 68 | } 69 | } 70 | }, 71 | 72 | Draw: function(context, camera) { 73 | 74 | //sort the sprites based on their 'z depth' to get the correct drawing order 75 | if (this.Unsorted) { 76 | this.Unsorted = false; 77 | this.Objects.sort(function(x1,x2) { return x1.ZOrder - x2.ZOrder; }); 78 | } 79 | 80 | var i = 0; 81 | for (i = 0; i < this.Objects.length; i++) { 82 | if (this.Objects[i].Draw) { 83 | this.Objects[i].Draw(context, camera); 84 | } 85 | } 86 | } 87 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/frameSprite.js: -------------------------------------------------------------------------------- 1 | /** 2 | For sprites that are only a portion of an image. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.FrameSprite = function() { 7 | this.FrameX = 0; 8 | this.FrameY = 0; 9 | this.FrameWidth = 0; 10 | this.FrameHeight = 0; 11 | }; 12 | 13 | Enjine.FrameSprite.prototype = new Enjine.Sprite(); 14 | 15 | Enjine.FrameSprite.prototype.Draw = function(context, camera) { 16 | context.drawImage(this.Image, this.FrameX, this.FrameY, this.FrameWidth, this.FrameHeight, this.X - camera.X, this.Y - camera.Y, this.FrameWidth, this.FrameHeight); 17 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/gameCanvas.js: -------------------------------------------------------------------------------- 1 | /** 2 | Base class to represent a double buffered canvas object. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.GameCanvas = function() { 7 | this.Canvas = null; 8 | this.Context2D = null; 9 | this.BackBuffer = null; 10 | this.BackBufferContext2D = null; 11 | }; 12 | 13 | Enjine.GameCanvas.prototype = { 14 | Initialize: function(canvasId, resWidth, resHeight) { 15 | this.Canvas = document.getElementById(canvasId); 16 | this.Context2D = this.Canvas.getContext("2d"); 17 | this.BackBuffer = document.createElement("canvas"); 18 | this.BackBuffer.width = resWidth; 19 | this.BackBuffer.height = resHeight; 20 | this.BackBufferContext2D = this.BackBuffer.getContext("2d"); 21 | }, 22 | 23 | BeginDraw: function() { 24 | this.BackBufferContext2D.clearRect(0, 0, this.BackBuffer.width, this.BackBuffer.height); 25 | this.Context2D.clearRect(0, 0, this.Canvas.width, this.Canvas.height); 26 | }, 27 | 28 | EndDraw: function() { 29 | this.Context2D.drawImage(this.BackBuffer, 0, 0, this.BackBuffer.width, this.BackBuffer.height, 0, 0, this.Canvas.width, this.Canvas.height); 30 | } 31 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/gameTimer.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a very basic game timer. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.GameTimer = function() { 7 | this.FramesPerSecond = 1000 / 30; 8 | this.LastTime = 0; 9 | this.IntervalFunc = null; 10 | this.UpdateObject = null; 11 | }; 12 | 13 | Enjine.GameTimer.prototype = { 14 | Start: function() { 15 | this.LastTime = new Date().getTime(); 16 | var self = this; 17 | this.IntervalFunc = setInterval(function() { self.Tick() }, this.FramesPerSecond); 18 | }, 19 | 20 | Tick: function() { 21 | if (this.UpdateObject != null) { 22 | var newTime = new Date().getTime(); 23 | var delta = (newTime - this.LastTime) / 1000; 24 | this.LastTime = newTime; 25 | 26 | this.UpdateObject.Update(delta); 27 | } 28 | }, 29 | 30 | Stop: function() { 31 | clearInterval(this.IntervalFunc); 32 | } 33 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/keyboardInput.js: -------------------------------------------------------------------------------- 1 | /** 2 | Class that helps to manage keyboard input. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Keys = { 7 | A: 65, 8 | B: 66, 9 | C: 67, 10 | D: 68, 11 | E: 69, 12 | F: 70, 13 | G: 71, 14 | H: 72, 15 | I: 73, 16 | J: 74, 17 | K: 75, 18 | L: 76, 19 | M: 77, 20 | N: 78, 21 | O: 79, 22 | P: 80, 23 | Q: 81, 24 | R: 82, 25 | S: 83, 26 | T: 84, 27 | U: 85, 28 | V: 86, 29 | W: 87, 30 | X: 88, 31 | Y: 89, 32 | Z: 80, 33 | Left: 37, 34 | Up: 38, 35 | Right: 39, 36 | Down: 40 37 | }; 38 | 39 | Enjine.KeyboardInput = { 40 | Pressed: new Array(), 41 | 42 | Initialize: function() { 43 | var self = this; 44 | document.onkeydown = function(event) { self.KeyDownEvent(event); } 45 | document.onkeyup = function(event) { self.KeyUpEvent(event); } 46 | }, 47 | 48 | IsKeyDown: function(key) { 49 | if (this.Pressed[key] != null) 50 | return this.Pressed[key]; 51 | return false; 52 | }, 53 | 54 | KeyDownEvent: function(event) { 55 | this.Pressed[event.keyCode] = true; 56 | this.PreventScrolling(event); 57 | }, 58 | 59 | KeyUpEvent: function(event) { 60 | this.Pressed[event.keyCode] = false; 61 | this.PreventScrolling(event); 62 | }, 63 | 64 | PreventScrolling: function(event) { 65 | // 37: left, 38: up, 39: right, 40: down 66 | if(event.keyCode >= 37 && event.keyCode <= 40){ 67 | event.preventDefault(); 68 | } 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/resources.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a simple static sprite. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Resources = { 7 | Images: {}, 8 | Sounds: {}, 9 | 10 | Destroy: function() { 11 | delete this.Images; 12 | delete this.Sounds; 13 | return this; 14 | }, 15 | 16 | //***********************/ 17 | //Images 18 | AddImage: function(name, src) { 19 | var tempImage = new Image(); 20 | this.Images[name] = tempImage; 21 | tempImage.src = src; 22 | return this; 23 | }, 24 | 25 | AddImages: function(array) { 26 | for (var i = 0; i < array.length; i++) { 27 | var tempImage = new Image(); 28 | this.Images[array[i].name] = tempImage; 29 | tempImage.src = array[i].src; 30 | } 31 | return this; 32 | }, 33 | 34 | ClearImages: function() { 35 | delete this.Images; 36 | this.Images = new Object(); 37 | return this; 38 | }, 39 | 40 | RemoveImage: function(name) { 41 | delete this.Images[name]; 42 | return this; 43 | }, 44 | 45 | //***********************/ 46 | //Sounds 47 | AddSound: function(name, src, maxChannels) { 48 | this.Sounds[name] = []; 49 | this.Sounds[name].index = 0; 50 | if (!maxChannels) { 51 | maxChannels = 3; 52 | } 53 | for (var i = 0; i < maxChannels; i++) { 54 | this.Sounds[name][i] = new Audio(src); 55 | } 56 | return this; 57 | }, 58 | 59 | ClearSounds: function() { 60 | delete this.Sounds; 61 | this.Sounds = {}; 62 | return this; 63 | }, 64 | 65 | RemoveSound: function(name) { 66 | delete this.Sounds[name]; 67 | return this; 68 | }, 69 | 70 | PlaySound: function(name, loop) { 71 | if (this.Sounds[name].index >= this.Sounds[name].length) { 72 | this.Sounds[name].index = 0; 73 | } 74 | if (loop) { 75 | this.Sounds[name][this.Sounds[name].index].addEventListener("ended", this.LoopCallback, false); 76 | } 77 | this.Sounds[name][this.Sounds[name].index++].play(); 78 | return this.Sounds[name].index; 79 | }, 80 | 81 | PauseChannel: function(name, index) { 82 | if (!this.Sounds[name][index].paused) { 83 | this.Sounds[name][index].pause(); 84 | } 85 | return this; 86 | }, 87 | 88 | PauseSound: function(name) { 89 | for (var i = 0; i < this.Sounds[name].length; i++) { 90 | if (!this.Sounds[name][i].paused) { 91 | this.Sounds[name][i].pause(); 92 | } 93 | } 94 | return this; 95 | }, 96 | 97 | ResetChannel: function(name, index) { 98 | this.Sounds[name][index].currentTime = 0; 99 | this.StopLoop(name, index); 100 | return this; 101 | }, 102 | 103 | ResetSound: function(name) { 104 | for (var i = 0; i < this.Sounds[name].length; i++) { 105 | this.Sounds[name].currentTime = 0; 106 | this.StopLoop(name, i); 107 | } 108 | return this; 109 | }, 110 | 111 | StopLoop: function(name, index) { 112 | this.Sounds[name][index].removeEventListener("ended", this.LoopCallback, false); 113 | }, 114 | 115 | LoopCallback: function() { 116 | this.currentTime = -1; 117 | this.play(); 118 | } 119 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/sprite.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a simple static sprite. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.Sprite = function() { 7 | this.X = 0; 8 | this.Y = 0; 9 | this.Image = null; 10 | }; 11 | 12 | Enjine.Sprite.prototype = new Enjine.Drawable(); 13 | 14 | Enjine.Sprite.prototype.Draw = function(context, camera) { 15 | context.drawImage(this.Image, this.X - camera.X, this.Y - camera.Y); 16 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/spriteFont.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a sprite sheet for a font. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.SpriteFont = function(strings, image, letterWidth, letterHeight, letters) { 7 | this.Image = image; 8 | this.Letters = letters; 9 | this.LetterWidth = letterWidth; 10 | this.LetterHeight = letterHeight; 11 | this.Strings = strings; 12 | }; 13 | 14 | Enjine.SpriteFont.prototype = new Enjine.Drawable(); 15 | 16 | Enjine.SpriteFont.prototype.Draw = function(context, camera) { 17 | for (var s = 0; s < this.Strings.length; s++) { 18 | var string = this.Strings[s]; 19 | for (var i = 0; i < string.String.length; i++) { 20 | var code = string.String.charCodeAt(i); 21 | context.drawImage(this.Image, this.Letters[code].X, this.Letters[code].Y, this.LetterWidth, this.LetterHeight, string.X + this.LetterWidth * (i + 1), string.Y, this.LetterWidth, this.LetterHeight); 22 | } 23 | } 24 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/Enjine/state.js: -------------------------------------------------------------------------------- 1 | /** 2 | Simple State pattern implementation for game states. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Enjine.GameStateContext = function(defaultState) { 7 | this.State = null; 8 | 9 | if (defaultState != null) { 10 | this.State = defaultState; 11 | this.State.Enter(); 12 | } 13 | }; 14 | 15 | Enjine.GameStateContext.prototype = { 16 | ChangeState: function(newState) { 17 | if (this.State != null) { 18 | this.State.Exit(); 19 | } 20 | this.State = newState; 21 | this.State.Enter(); 22 | }, 23 | 24 | Update: function(delta) { 25 | this.State.CheckForChange(this); 26 | this.State.Update(delta); 27 | }, 28 | 29 | Draw: function(delta) { 30 | this.State.Draw(delta); 31 | } 32 | }; 33 | 34 | /** 35 | * Base game state class to at least ensure that all the functions exist. 36 | */ 37 | Enjine.GameState = function() { } 38 | 39 | Enjine.GameState.prototype = { 40 | Enter: function () {}, 41 | Exit: function() {}, 42 | Update: function(delta) {}, 43 | Draw: function(context) {}, 44 | CheckForChange: function(context) {} 45 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/LICENSE.md: -------------------------------------------------------------------------------- 1 | mariohtml5 2 | 3 | This is free and unencumbered software released into the public domain. 4 | 5 | Anyone is free to copy, modify, publish, use, compile, sell, or 6 | distribute this software, either in source code form or as a compiled 7 | binary, for any purpose, commercial or non-commercial, and by any 8 | means. 9 | 10 | In jurisdictions that recognize copyright laws, the author or authors 11 | of this software dedicate any and all copyright interest in the 12 | software to the public domain. We make this dedication for the benefit 13 | of the public at large and to the detriment of our heirs and 14 | successors. We intend this dedication to be an overt act of 15 | relinquishment in perpetuity of all present and future rights to this 16 | software under copyright law. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | 26 | For more information, please refer to -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/README: -------------------------------------------------------------------------------- 1 | This is a clone of Infinite Mario, written in JavaScript for web browsers using HTML5. 2 | 3 | A good demonstration of what can be accomplished with the Canvas and Audio elements. 4 | 5 | Background music currently does not work in any browser besides Firefox 4. I think. There were too many problems with other browsers. 6 | 7 | Ported from the Java version by Notch (Markus Persson). -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/backgroundGenerator.js: -------------------------------------------------------------------------------- 1 | /** 2 | Generates the backgrounds for a level. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.BackgroundGenerator = function(width, height, distant, type) { 7 | this.Width = width; 8 | this.Height = height; 9 | this.Distant = distant; 10 | this.Type = type; 11 | }; 12 | 13 | Mario.BackgroundGenerator.prototype = { 14 | SetValues: function(width, height, distant, type) { 15 | this.Width = width; 16 | this.Height = height; 17 | this.Distant = distant; 18 | this.Type = type; 19 | }, 20 | 21 | CreateLevel: function() { 22 | var level = new Mario.Level(this.Width, this.Height); 23 | switch (this.Type) { 24 | case Mario.LevelType.Overground: 25 | this.GenerateOverground(level); 26 | break; 27 | case Mario.LevelType.Underground: 28 | this.GenerateUnderground(level); 29 | break; 30 | case Mario.LevelType.Castle: 31 | this.GenerateCastle(level); 32 | break; 33 | } 34 | return level; 35 | }, 36 | 37 | GenerateOverground: function(level) { 38 | var range = this.Distant ? 4 : 6; 39 | var offs = this.Distant ? 2 : 1; 40 | var oh = Math.floor(Math.random() * range) + offs; 41 | var h = Math.floor(Math.random() * range) + offs; 42 | 43 | var x = 0, y = 0, h0 = 0, h1 = 0, s = 2; 44 | for (x = 0; x < this.Width; x++) { 45 | oh = h; 46 | while (oh === h) { 47 | h = Math.floor(Math.random() * range) + offs; 48 | } 49 | 50 | for (y = 0; y < this.Height; y++) { 51 | h0 = (oh < h) ? oh : h; 52 | h1 = (oh < h) ? h : oh; 53 | s = 2; 54 | if (y < h0) { 55 | if (this.Distant){ 56 | s = 2; 57 | if (y < 2) { s = y; } 58 | level.SetBlock(x, y, 4 + s * 8); 59 | } else { 60 | level.SetBlock(x, y, 5); 61 | } 62 | } else if (y === h0) { 63 | s = h0 === h ? 0 : 1; 64 | s += this.Distant ? 2 : 0; 65 | level.SetBlock(x, y, s); 66 | } else if (y === h1) { 67 | s = h0 === h ? 0 : 1; 68 | s += this.Distant ? 2 : 0; 69 | level.SetBlock(x, y, s + 16); 70 | } else { 71 | s = (y > h1) ? 1 : 0; 72 | if (h0 === oh) { s = 1 - s; } 73 | s += this.Distant ? 2 : 0; 74 | level.SetBlock(x, y, s + 8); 75 | } 76 | } 77 | } 78 | }, 79 | 80 | GenerateUnderground: function(level) { 81 | var x = 0, y = 0, t = 0, yy = 0; 82 | if (this.Distant) { 83 | var tt = 0; 84 | for (x = 0; x < this.Width; x++) { 85 | if (Math.random() < 0.75) { tt = 1 - tt; } 86 | 87 | for (y = 0; y < this.Height; y++) { 88 | t = tt; 89 | yy = y - 2; 90 | 91 | if (yy < 0 || yy > 4) { 92 | yy = 2; 93 | t = 0; 94 | } 95 | level.SetBlock(x, y, (4 + t + (3 + yy) * 8)); 96 | } 97 | } 98 | } else { 99 | for (x = 0; x < this.Width; x++) { 100 | for (y = 0; y < this.Height; y++) { 101 | t = x % 2; 102 | yy = y - 1; 103 | if (yy < 0 || yy > 7) { 104 | yy = 7; 105 | t = 0; 106 | } 107 | if (t === 0 && yy > 1 && yy < 5) { 108 | t = -1; 109 | yy = 0; 110 | } 111 | 112 | level.SetBlock(x, y, (6 + t + yy * 8)); 113 | } 114 | } 115 | } 116 | }, 117 | 118 | GenerateCastle: function(level) { 119 | var x = 0, y = 0, t = 0, yy = 0; 120 | if (this.Distant) { 121 | for (x = 0; x < this.Width; x++) { 122 | for (y = 0; y < this.Height; y++) { 123 | t = x % 2; 124 | yy = y - 1; 125 | 126 | if (yy > 2 && yy < 5) { 127 | yy = 2; 128 | } else if (yy >= 5) { 129 | yy -= 2; 130 | } 131 | 132 | if (yy < 0) { 133 | t = 0; 134 | yy = 5; 135 | } else if (yy > 4) { 136 | t = 1; 137 | yy = 5; 138 | } else if (t < 1 && yy === 3) { 139 | t = 0; 140 | yy = 3; 141 | } else if (t < 1 && yy > 0 && yy < 3) { 142 | t = 0; 143 | yy = 2; 144 | } 145 | 146 | level.SetBlock(x, y, (1 + t + (yy + 4) * 8)); 147 | } 148 | } 149 | } else { 150 | for (x = 0; x < this.Width; x++) { 151 | for (y = 0; y < this.Height; y++) { 152 | t = x % 3; 153 | yy = y - 1; 154 | 155 | if (yy > 2 && yy < 5) { 156 | yy = 2; 157 | } else if (yy >= 5) { 158 | yy -= 2; 159 | } 160 | 161 | if (yy < 0) { 162 | t = 1; 163 | yy = 5; 164 | } else if (yy > 4) { 165 | t = 2; 166 | yy = 5; 167 | } else if (t < 2 && yy === 4) { 168 | t = 2; 169 | yy = 4; 170 | } else if (t < 2 && yy > 0 && yy < 4) { 171 | t = 4; 172 | yy = -3; 173 | } 174 | 175 | level.SetBlock(x, y, (1 + t + (yy + 3) * 8)); 176 | } 177 | } 178 | } 179 | } 180 | 181 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/backgroundRenderer.js: -------------------------------------------------------------------------------- 1 | /** 2 | Renders a background portion of the level. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.BackgroundRenderer = function(level, width, height, distance) { 7 | this.Level = level; 8 | this.Width = width; 9 | this.Distance = distance; 10 | this.TilesY = ((height / 32) | 0) + 1; 11 | 12 | this.Background = Mario.SpriteCuts.GetBackgroundSheet(); 13 | }; 14 | 15 | Mario.BackgroundRenderer.prototype = new Enjine.Drawable(); 16 | 17 | Mario.BackgroundRenderer.prototype.Draw = function(context, camera) { 18 | var xCam = camera.X / this.Distance; 19 | var x = 0, y = 0, b = null, frame = null; 20 | 21 | //the OR truncates the decimal, quicker than Math.floor 22 | var xTileStart = (xCam / 32) | 0; 23 | //the +1 makes sure the right edge tiles get drawn 24 | var xTileEnd = (((xCam + this.Width) / 32) | 0); 25 | 26 | for (x = xTileStart; x <= xTileEnd; x++) { 27 | for (y = 0; y < this.TilesY; y++) { 28 | b = this.Level.GetBlock(x, y) & 0xff; 29 | frame = this.Background[b % 8][(b / 8) | 0]; 30 | 31 | //bitshifting by five is the same as multiplying by 32 32 | context.drawImage(Enjine.Resources.Images["background"], frame.X, frame.Y, frame.Width, frame.Height, ((x << 5) - xCam) | 0, (y << 5) | 0, frame.Width, frame.Height); 33 | } 34 | } 35 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/bulletBill.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a bullet bill enemy. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.BulletBill = function(world, x, y, dir) { 7 | this.Image = Enjine.Resources.Images["enemies"]; 8 | this.World = world; 9 | this.X = x; 10 | this.Y = y; 11 | this.Facing = dir; 12 | 13 | this.XPicO = 8; 14 | this.YPicO = 31; 15 | this.Height = 12; 16 | this.Width = 4; 17 | this.PicWidth = 16; 18 | this.YPic = 5; 19 | this.XPic = 0; 20 | this.Ya = -5; 21 | this.DeadTime = 0; 22 | this.Dead = false; 23 | this.Anim = 0; 24 | }; 25 | 26 | Mario.BulletBill.prototype = new Mario.NotchSprite(); 27 | 28 | Mario.BulletBill.prototype.CollideCheck = function() { 29 | if (this.Dead) { 30 | return; 31 | } 32 | 33 | var xMarioD = Mario.MarioCharacter.X - this.X, yMarioD = Mario.MarioCharacter.Y - this.Y; 34 | if (xMarioD > -16 && xMarioD < 16) { 35 | if (yMarioD > -this.Height && yMarioD < this.World.Mario.Height) { 36 | if (Mario.MarioCharacter.Y > 0 && yMarioD <= 0 && (!Mario.MarioCharacter.OnGround || !Mario.MarioCharacter.WasOnGround)) { 37 | Mario.MarioCharacter.Stomp(this); 38 | this.Dead = true; 39 | 40 | this.Xa = 0; 41 | this.Ya = 1; 42 | this.DeadTime = 100; 43 | } else { 44 | Mario.MarioCharacter.GetHurt(); 45 | } 46 | } 47 | } 48 | }; 49 | 50 | Mario.BulletBill.prototype.Move = function() { 51 | var i = 0, sideWaysSpeed = 4; 52 | if (this.DeadTime > 0) { 53 | this.DeadTime--; 54 | 55 | if (this.DeadTime === 0) { 56 | this.DeadTime = 1; 57 | for (i = 0; i < 8; i++) { 58 | this.World.AddSprite(new Mario.Sparkle(((this.X + Math.random() * 16 - 8) | 0) + 4, ((this.Y + Math.random() * 8) | 0) + 4, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5)); 59 | } 60 | this.World.RemoveSprite(this); 61 | } 62 | 63 | this.X += this.Xa; 64 | this.Y += this.Ya; 65 | this.Ya *= 0.95; 66 | this.Ya += 1; 67 | 68 | return; 69 | } 70 | 71 | this.Xa = this.Facing * sideWaysSpeed; 72 | this.XFlip = this.Facing === -1; 73 | this.Move(this.Xa, 0); 74 | }; 75 | 76 | Mario.BulletBill.prototype.SubMove = function(xa, ya) { 77 | this.X += xa; 78 | return true; 79 | }; 80 | 81 | Mario.BulletBill.prototype.FireballCollideCheck = function(fireball) { 82 | if (this.DeadTime !== 0) { 83 | return false; 84 | } 85 | 86 | var xD = fireball.X - this.X, yD = fireball.Y - this.Y; 87 | if (xD > -16 && xD < 16) { 88 | if (yD > -this.Height && yD < fireball.Height) { 89 | return true; 90 | } 91 | } 92 | return false; 93 | }; 94 | 95 | Mario.BulletBill.prototype.ShellCollideCheck = function(shell) { 96 | if (this.DeadTime !== 0) { 97 | return false; 98 | } 99 | 100 | var xD = shell.X - this.X, yD = shell.Y - this.Y; 101 | if (xD > -16 && xD < 16) { 102 | if (yD > -this.Height && yD < shell.Height) { 103 | Enjine.Resources.PlaySound("kick"); 104 | this.Dead = true; 105 | this.Xa = 0; 106 | this.Ya = 1; 107 | this.DeadTime = 100; 108 | return true; 109 | } 110 | } 111 | return false; 112 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/character.js: -------------------------------------------------------------------------------- 1 | /** 2 | Global representation of the mario character. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Character = function() { 7 | //these are static in Notch's code... here it doesn't seem necessary 8 | this.Large = false; 9 | this.Fire = false; 10 | this.Coins = 0; 11 | this.Lives = 3; 12 | this.LevelString = "none"; 13 | this.GroundInertia = 0.89; 14 | this.AirInertia = 0.89; 15 | 16 | //non static variables in Notch's code 17 | this.RunTime = 0; 18 | this.WasOnGround = false; 19 | this.OnGround = false; 20 | this.MayJump = false; 21 | this.Ducking = false; 22 | this.Sliding = false; 23 | this.JumpTime = 0; 24 | this.XJumpSpeed = 0; 25 | this.YJumpSpeed = 0; 26 | this.CanShoot = false; 27 | 28 | this.Width = 4; 29 | this.Height = 24; 30 | 31 | //Level scene 32 | this.World = null; 33 | this.Facing = 0; 34 | this.PowerUpTime = 0; 35 | 36 | this.XDeathPos = 0; this.YDeathPos = 0; 37 | this.DeathTime = 0; 38 | this.WinTime = 0; 39 | this.InvulnerableTime = 0; 40 | 41 | //Sprite 42 | this.Carried = null; 43 | 44 | this.LastLarge = false; 45 | this.LastFire = false; 46 | this.NewLarge = false; 47 | this.NewFire = false; 48 | }; 49 | 50 | Mario.Character.prototype = new Mario.NotchSprite(null); 51 | 52 | Mario.Character.prototype.Initialize = function(world) { 53 | this.World = world; 54 | this.X = 32; 55 | this.Y = 0; 56 | this.PowerUpTime = 0; 57 | 58 | //non static variables in Notch's code 59 | this.RunTime = 0; 60 | this.WasOnGround = false; 61 | this.OnGround = false; 62 | this.MayJump = false; 63 | this.Ducking = false; 64 | this.Sliding = false; 65 | this.JumpTime = 0; 66 | this.XJumpSpeed = 0; 67 | this.YJumpSpeed = 0; 68 | this.CanShoot = false; 69 | 70 | this.Width = 4; 71 | this.Height = 24; 72 | 73 | //Level scene 74 | this.World = world; 75 | this.Facing = 0; 76 | this.PowerUpTime = 0; 77 | 78 | this.XDeathPos = 0; this.YDeathPos = 0; 79 | this.DeathTime = 0; 80 | this.WinTime = 0; 81 | this.InvulnerableTime = 0; 82 | 83 | //Sprite 84 | this.Carried = null; 85 | 86 | this.SetLarge(this.Large, this.Fire); 87 | }; 88 | 89 | Mario.Character.prototype.SetLarge = function(large, fire) { 90 | if (fire) { 91 | large = true; 92 | } 93 | if (!large) { 94 | fire = false; 95 | } 96 | 97 | this.LastLarge = this.Large; 98 | this.LastFire = this.Fire; 99 | this.Large = large; 100 | this.Fire = fire; 101 | this.NewLarge = this.Large; 102 | this.NewFire = this.Fire; 103 | 104 | this.Blink(true); 105 | }; 106 | 107 | Mario.Character.prototype.Blink = function(on) { 108 | this.Large = on ? this.NewLarge : this.LastLarge; 109 | this.Fire = on ? this.NewFire : this.LastFire; 110 | 111 | if (this.Large) { 112 | if (this.Fire) { 113 | this.Image = Enjine.Resources.Images["fireMario"]; 114 | } else { 115 | this.Image = Enjine.Resources.Images["mario"]; 116 | } 117 | 118 | this.XPicO = 16; 119 | this.YPicO = 31; 120 | this.PicWidth = this.PicHeight = 32; 121 | } else { 122 | this.Image = Enjine.Resources.Images["smallMario"]; 123 | this.XPicO = 8; 124 | this.YPicO = 15; 125 | this.PicWidth = this.PicHeight = 16; 126 | } 127 | }; 128 | 129 | Mario.Character.prototype.Move = function() { 130 | if (this.WinTime > 0) { 131 | this.WinTime++; 132 | this.Xa = 0; 133 | this.Ya = 0; 134 | return; 135 | } 136 | 137 | if (this.DeathTime > 0) { 138 | this.DeathTime++; 139 | if (this.DeathTime < 11) { 140 | this.Xa = 0; 141 | this.Ya = 0; 142 | } else if (this.DeathTime === 11) { 143 | this.Ya = -15; 144 | } else { 145 | this.Ya += 2; 146 | } 147 | this.X += this.Xa; 148 | this.Y += this.Ya; 149 | return; 150 | } 151 | 152 | if (this.PowerUpTime !== 0) { 153 | if (this.PowerUpTime > 0) { 154 | this.PowerUpTime--; 155 | this.Blink((((this.PowerUpTime / 3) | 0) & 1) === 0); 156 | } else { 157 | this.PowerUpTime++; 158 | this.Blink((((-this.PowerUpTime / 3) | 0) & 1) === 0); 159 | } 160 | 161 | if (this.PowerUpTime === 0) { 162 | this.World.Paused = false; 163 | } 164 | 165 | this.CalcPic(); 166 | return; 167 | } 168 | 169 | if (this.InvulnerableTime > 0) { 170 | this.InvulnerableTime--; 171 | } 172 | 173 | this.Visible = (((this.InvulerableTime / 2) | 0) & 1) === 0; 174 | 175 | this.WasOnGround = this.OnGround; 176 | var sideWaysSpeed = Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) ? 1.2 : 0.6; 177 | 178 | if (this.OnGround) { 179 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Down) && this.Large) { 180 | this.Ducking = true; 181 | } else { 182 | this.Ducking = false; 183 | } 184 | } 185 | 186 | if (this.Xa > 2) { 187 | this.Facing = 1; 188 | } 189 | if (this.Xa < -2) { 190 | this.Facing = -1; 191 | } 192 | 193 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S) || (this.JumpTime < 0 && !this.OnGround && !this.Sliding)) { 194 | if (this.JumpTime < 0) { 195 | this.Xa = this.XJumpSpeed; 196 | this.Ya = -this.JumpTime * this.YJumpSpeed; 197 | this.JumpTime++; 198 | } else if (this.OnGround && this.MayJump) { 199 | Enjine.Resources.PlaySound("jump"); 200 | this.XJumpSpeed = 0; 201 | this.YJumpSpeed = -1.9; 202 | this.JumpTime = 7; 203 | this.Ya = this.JumpTime * this.YJumpSpeed; 204 | this.OnGround = false; 205 | this.Sliding = false; 206 | } else if (this.Sliding && this.MayJump) { 207 | Enjine.Resources.PlaySound("jump"); 208 | this.XJumpSpeed = -this.Facing * 6; 209 | this.YJumpSpeed = -2; 210 | this.JumpTime = -6; 211 | this.Xa = this.XJumpSpeed; 212 | this.Ya = -this.JumpTime * this.YJumpSpeed; 213 | this.OnGround = false; 214 | this.Sliding = false; 215 | this.Facing = -this.Facing; 216 | } else if (this.JumpTime > 0) { 217 | this.Xa += this.XJumpSpeed; 218 | this.Ya = this.JumpTime * this.YJumpSpeed; 219 | this.JumpTime--; 220 | } 221 | } else { 222 | this.JumpTime = 0; 223 | } 224 | 225 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Left) && !this.Ducking) { 226 | if (this.Facing === 1) { 227 | this.Sliding = false; 228 | } 229 | this.Xa -= sideWaysSpeed; 230 | if (this.JumpTime >= 0) { 231 | this.Facing = -1; 232 | } 233 | } 234 | 235 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Right) && !this.Ducking) { 236 | if (this.Facing === -1) { 237 | this.Sliding = false; 238 | } 239 | this.Xa += sideWaysSpeed; 240 | if (this.JumpTime >= 0) { 241 | this.Facing = 1; 242 | } 243 | } 244 | 245 | if ((!Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Left) && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.Right)) || this.Ducking || this.Ya < 0 || this.OnGround) { 246 | this.Sliding = false; 247 | } 248 | 249 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) && this.CanShoot && this.Fire && this.World.FireballsOnScreen < 2) { 250 | Enjine.Resources.PlaySound("fireball"); 251 | this.World.AddSprite(new Mario.Fireball(this.World, this.X + this.Facing * 6, this.Y - 20, this.Facing)); 252 | } 253 | 254 | this.CanShoot = !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A); 255 | this.MayJump = (this.OnGround || this.Sliding) && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S); 256 | this.XFlip = (this.Facing === -1); 257 | this.RunTime += Math.abs(this.Xa) + 5; 258 | 259 | if (Math.abs(this.Xa) < 0.5) { 260 | this.RunTime = 0; 261 | this.Xa = 0; 262 | } 263 | 264 | this.CalcPic(); 265 | 266 | if (this.Sliding) { 267 | this.World.AddSprite(new Mario.Sparkle(this.World, ((this.X + Math.random() * 4 - 2) | 0) + this.Facing * 8, 268 | ((this.Y + Math.random() * 4) | 0) - 24, Math.random() * 2 - 1, Math.random(), 0, 1, 5)); 269 | this.Ya *= 0.5; 270 | } 271 | 272 | this.OnGround = false; 273 | this.SubMove(this.Xa, 0); 274 | this.SubMove(0, this.Ya); 275 | if (this.Y > this.World.Level.Height * 16 + 16) { 276 | this.Die(); 277 | } 278 | 279 | if (this.X < 0) { 280 | this.X = 0; 281 | this.Xa = 0; 282 | } 283 | 284 | if (this.X > this.World.Level.ExitX * 16) { 285 | this.Win(); 286 | } 287 | 288 | if (this.X > this.World.Level.Width * 16) { 289 | this.X = this.World.Level.Width * 16; 290 | this.Xa = 0; 291 | } 292 | 293 | this.Ya *= 0.85; 294 | if (this.OnGround) { 295 | this.Xa *= this.GroundInertia; 296 | } else { 297 | this.Xa *= this.AirInertia; 298 | } 299 | 300 | if (!this.OnGround) { 301 | this.Ya += 3; 302 | } 303 | 304 | if (this.Carried !== null) { 305 | this.Carried.X *= this.X + this.Facing * 8; 306 | this.Carried.Y *= this.Y - 2; 307 | if (!Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A)) { 308 | this.Carried.Release(this); 309 | this.Carried = null; 310 | } 311 | } 312 | }; 313 | 314 | Mario.Character.prototype.CalcPic = function() { 315 | var runFrame = 0, i = 0; 316 | 317 | if (this.Large) { 318 | runFrame = ((this.RunTime / 20) | 0) % 4; 319 | if (runFrame === 3) { 320 | runFrame = 1; 321 | } 322 | if (this.Carried === null && Math.abs(this.Xa) > 10) { 323 | runFrame += 3; 324 | } 325 | if (this.Carried !== null) { 326 | runFrame += 10; 327 | } 328 | if (!this.OnGround) { 329 | if (this.Carried !== null) { 330 | runFrame = 12; 331 | } else if (Math.abs(this.Xa) > 10) { 332 | runFrame = 7; 333 | } else { 334 | runFrame = 6; 335 | } 336 | } 337 | } else { 338 | runFrame = ((this.RunTime / 20) | 0) % 2; 339 | if (this.Carried === null && Math.abs(this.Xa) > 10) { 340 | runFrame += 2; 341 | } 342 | if (this.Carried !== null) { 343 | runFrame += 8; 344 | } 345 | if (!this.OnGround) { 346 | if (this.Carried !== null) { 347 | runFrame = 9; 348 | } else if (Math.abs(this.Xa) > 10) { 349 | runFrame = 5; 350 | } else { 351 | runFrame = 4; 352 | } 353 | } 354 | } 355 | 356 | if (this.OnGround && ((this.Facing === -1 && this.Xa > 0) || (this.Facing === 1 && this.Xa < 0))) { 357 | if (this.Xa > 1 || this.Xa < -1) { 358 | runFrame = this.Large ? 9 : 7; 359 | } 360 | 361 | if (this.Xa > 3 || this.Xa < -3) { 362 | for (i = 0; i < 3; i++) { 363 | this.World.AddSprite(new Mario.Sparkle(this.World, (this.X + Math.random() * 8 - 4) | 0, (this.Y + Math.random() * 4) | 0, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5)); 364 | } 365 | } 366 | } 367 | 368 | if (this.Large) { 369 | if (this.Ducking) { 370 | runFrame = 14; 371 | } 372 | this.Height = this.Ducking ? 12 : 24; 373 | } else { 374 | this.Height = 12; 375 | } 376 | 377 | this.XPic = runFrame; 378 | }; 379 | 380 | Mario.Character.prototype.SubMove = function(xa, ya) { 381 | var collide = false; 382 | 383 | while (xa > 8) { 384 | if (!this.SubMove(8, 0)) { 385 | return false; 386 | } 387 | xa -= 8; 388 | } 389 | while (xa < -8) { 390 | if (!this.SubMove(-8, 0)) { 391 | return false; 392 | } 393 | xa += 8; 394 | } 395 | while (ya > 8) { 396 | if (!this.SubMove(0, 8)) { 397 | return false; 398 | } 399 | ya -= 8; 400 | } 401 | while (ya < -8) { 402 | if (!this.SubMove(0, -8)) { 403 | return false; 404 | } 405 | ya += 8; 406 | } 407 | 408 | if (ya > 0) { 409 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, 0)) { 410 | collide = true; 411 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, 0)) { 412 | collide = true; 413 | } else if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya + 1, xa, ya)) { 414 | collide = true; 415 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya + 1, xa, ya)) { 416 | collide = true; 417 | } 418 | } 419 | if (ya < 0) { 420 | if (this.IsBlocking(this.X + xa, this.Y + ya - this.Height, xa, ya)) { 421 | collide = true; 422 | } else if (collide || this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 423 | collide = true; 424 | } else if (collide || this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 425 | collide = true; 426 | } 427 | } 428 | 429 | if (xa > 0) { 430 | this.Sliding = true; 431 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 432 | collide = true; 433 | } else { 434 | this.Sliding = false; 435 | } 436 | 437 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 438 | collide = true; 439 | } else { 440 | this.Sliding = false; 441 | } 442 | 443 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, ya)) { 444 | collide = true; 445 | } else { 446 | this.Sliding = false; 447 | } 448 | } 449 | if (xa < 0) { 450 | this.Sliding = true; 451 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 452 | collide = true; 453 | } else { 454 | this.Sliding = false; 455 | } 456 | 457 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 458 | collide = true; 459 | } else { 460 | this.Sliding = false; 461 | } 462 | 463 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, ya)) { 464 | collide = true; 465 | } else { 466 | this.Sliding = false; 467 | } 468 | } 469 | 470 | if (collide) { 471 | if (xa < 0) { 472 | this.X = (((this.X - this.Width) / 16) | 0) * 16 + this.Width; 473 | this.Xa = 0; 474 | } 475 | if (xa > 0) { 476 | this.X = (((this.X + this.Width) / 16 + 1) | 0) * 16 - this.Width - 1; 477 | this.Xa = 0; 478 | } 479 | if (ya < 0) { 480 | this.Y = (((this.Y - this.Height) / 16) | 0) * 16 + this.Height; 481 | this.JumpTime = 0; 482 | this.Ya = 0; 483 | } 484 | if (ya > 0) { 485 | this.Y = (((this.Y - 1) / 16 + 1) | 0) * 16 - 1; 486 | this.OnGround = true; 487 | } 488 | 489 | return false; 490 | } else { 491 | this.X += xa; 492 | this.Y += ya; 493 | return true; 494 | } 495 | }; 496 | 497 | Mario.Character.prototype.IsBlocking = function(x, y, xa, ya) { 498 | var blocking = false, block = 0, xx = 0, yy = 0; 499 | 500 | x = (x / 16) | 0; 501 | y = (y / 16) | 0; 502 | if (x === ((this.X / 16) | 0) && y === ((this.Y / 16) | 0)) { 503 | return false; 504 | } 505 | 506 | block = this.World.Level.GetBlock(x, y); 507 | 508 | if (((Mario.Tile.Behaviors[block & 0xff]) & Mario.Tile.PickUpable) > 0) { 509 | this.GetCoin(); 510 | Enjine.Resources.PlaySound("coin"); 511 | this.World.Level.SetBlock(x, y, 0); 512 | for (xx = 0; xx < 2; xx++) { 513 | for (yy = 0; yy < 2; yy++) { 514 | this.World.AddSprite(new Mario.Sparkle(this.World, x * 16 + xx * 8 + ((Math.random() * 8) | 0), y * 16 + yy * 8 + ((Math.random() * 8) | 0), 0, 0, 0, 2, 5)); 515 | } 516 | } 517 | } 518 | 519 | blocking = this.World.Level.IsBlocking(x, y, xa, ya); 520 | if (blocking && ya < 0) { 521 | this.World.Bump(x, y, this.Large); 522 | } 523 | return blocking; 524 | }; 525 | 526 | Mario.Character.prototype.Stomp = function(object) { 527 | var targetY = 0; 528 | 529 | if (this.DeathTime > 0 || this.World.Paused) { 530 | return; 531 | } 532 | 533 | targetY = object.Y - object.Height / 2; 534 | this.SubMove(0, targetY - this.Y); 535 | 536 | if (object instanceof Mario.Enemy || object instanceof Mario.BulletBill) { 537 | 538 | Enjine.Resources.PlaySound("kick"); 539 | this.XJumpSpeed = 0; 540 | this.YJumpSpeed = -1.9; 541 | this.JumpTime = 8; 542 | this.Ya = this.JumpTime * this.YJumpSpeed; 543 | this.OnGround = false; 544 | this.Sliding = false; 545 | this.InvulnerableTime = 1; 546 | } else if (object instanceof Mario.Shell) { 547 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A) && object.Facing === 0) { 548 | this.Carried = object; 549 | object.Carried = true; 550 | } else { 551 | Enjine.Resources.PlaySound("kick"); 552 | this.XJumpSpeed = 0; 553 | this.YJumpSpeed = -1.9; 554 | this.JumpTime = 8; 555 | this.Ya = this.JumpTime * this.YJumpSpeed; 556 | this.OnGround = false; 557 | this.Sliding = false; 558 | this.InvulnerableTime = 1; 559 | } 560 | } 561 | }; 562 | 563 | Mario.Character.prototype.GetHurt = function() { 564 | if (this.DeathTime > 0 || this.World.Paused) { 565 | return; 566 | } 567 | if (this.InvulnerableTime > 0) { 568 | return; 569 | } 570 | 571 | if (this.Large) { 572 | this.World.Paused = true; 573 | this.PowerUpTime = -18; 574 | Enjine.Resources.PlaySound("powerdown"); 575 | if (this.Fire) { 576 | this.SetLarge(true, false); 577 | } else { 578 | this.SetLarge(false, false); 579 | } 580 | this.InvulnerableTime = 32; 581 | } else { 582 | this.Die(); 583 | } 584 | }; 585 | 586 | Mario.Character.prototype.Win = function() { 587 | this.XDeathPos = this.X | 0; 588 | this.YDeathPos = this.Y | 0; 589 | this.World.Paused = true; 590 | this.WinTime = 1; 591 | Enjine.Resources.PlaySound("exit"); 592 | }; 593 | 594 | Mario.Character.prototype.Die = function() { 595 | this.XDeathPos = this.X | 0; 596 | this.YDeathPos = this.Y | 0; 597 | this.World.Paused = true; 598 | this.DeathTime = 1; 599 | Enjine.Resources.PlaySound("death"); 600 | this.SetLarge(false, false); 601 | }; 602 | 603 | Mario.Character.prototype.GetFlower = function() { 604 | if (this.DeathTime > 0 && this.World.Paused) { 605 | return; 606 | } 607 | 608 | if (!this.Fire) { 609 | this.World.Paused = true; 610 | this.PowerUpTime = 18; 611 | Enjine.Resources.PlaySound("powerup"); 612 | this.SetLarge(true, true); 613 | } else { 614 | this.GetCoin(); 615 | Enjine.Resources.PlaySound("coin"); 616 | } 617 | }; 618 | 619 | Mario.Character.prototype.GetMushroom = function() { 620 | if (this.DeathTime > 0 && this.World.Paused) { 621 | return; 622 | } 623 | 624 | if (!this.Large) { 625 | this.World.Paused = true; 626 | this.PowerUpTime = 18; 627 | Enjine.Resources.PlaySound("powerup"); 628 | this.SetLarge(true, false); 629 | } else { 630 | this.GetCoin(); 631 | Enjine.Resources.PlaySound("coin"); 632 | } 633 | }; 634 | 635 | Mario.Character.prototype.Kick = function(shell) { 636 | if (this.DeathTime > 0 && this.World.Paused) { 637 | return; 638 | } 639 | 640 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.A)) { 641 | this.Carried = shell; 642 | shell.Carried = true; 643 | } else { 644 | Enjine.Resources.PlaySound("kick"); 645 | this.InvulnerableTime = 1; 646 | } 647 | }; 648 | 649 | Mario.Character.prototype.Get1Up = function() { 650 | Enjine.Resources.PlaySound("1up"); 651 | this.Lives++; 652 | if (this.Lives === 99) { 653 | this.Lives = 99; 654 | } 655 | }; 656 | 657 | Mario.Character.prototype.GetCoin = function() { 658 | this.Coins++; 659 | if (this.Coins === 100) { 660 | this.Coins = 0; 661 | this.Get1Up(); 662 | } 663 | }; 664 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/coinAnim.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a simple little coin animation when popping out of the box. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.CoinAnim = function(world, x, y) { 7 | this.World = world; 8 | this.Life = 10; 9 | this.Image = Enjine.Resources.Images["map"]; 10 | this.PicWidth = this.PicHeight = 16; 11 | this.X = x * 16; 12 | this.Y = y * 16 - 16; 13 | this.Xa = 0; 14 | this.Ya = -6; 15 | this.XPic = 0; 16 | this.YPic = 2; 17 | }; 18 | 19 | Mario.CoinAnim.prototype = new Mario.NotchSprite(); 20 | 21 | Mario.CoinAnim.prototype.Move = function() { 22 | var x = 0, y = 0; 23 | if (this.Life-- < 0) { 24 | this.World.RemoveSprite(this); 25 | for (x = 0; x < 2; x++) { 26 | for (y = 0; y < 2; y++) { 27 | this.World.AddSprite(new Mario.Sparkle(this.World, (this.X + x * 8 + Math.random() * 8) | 0, (this.Y + y * 8 + Math.random() * 8) | 0, 0, 0, 0, 2, 5)); 28 | } 29 | } 30 | } 31 | 32 | this.XPic = this.Life & 3; 33 | this.X += this.Xa; 34 | this.Y += this.Ya; 35 | this.Ya += 1; 36 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/enemy.js: -------------------------------------------------------------------------------- 1 | /** 2 | A generic template for an enemy in the game. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Enemy = function(world, x, y, dir, type, winged) { 7 | this.GroundInertia = 0.89; 8 | this.AirInertia = 0.89; 9 | this.RunTime = 0; 10 | this.OnGround = false; 11 | this.MayJump = false; 12 | this.JumpTime = 0; 13 | this.XJumpSpeed = 0; 14 | this.YJumpSpeed = 0; 15 | this.Width = 4; 16 | this.Height = 24; 17 | this.DeadTime = 0; 18 | this.FlyDeath = false; 19 | this.WingTime = 0; 20 | this.NoFireballDeath = false; 21 | 22 | this.X = x; 23 | this.Y = y; 24 | this.World = world; 25 | 26 | this.Type = type; 27 | this.Winged = winged; 28 | 29 | this.Image = Enjine.Resources.Images["enemies"]; 30 | 31 | this.XPicO = 8; 32 | this.YPicO = 31; 33 | this.AvoidCliffs = this.Type === Mario.Enemy.RedKoopa; 34 | this.NoFireballDeath = this.Type === Mario.Enemy.Spiky; 35 | 36 | this.YPic = this.Type; 37 | if (this.YPic > 1) { 38 | this.Height = 12; 39 | } 40 | this.Facing = dir; 41 | if (this.Facing === 0) { 42 | this.Facing = 1; 43 | } 44 | 45 | this.PicWidth = 16; 46 | }; 47 | 48 | Mario.Enemy.prototype = new Mario.NotchSprite(); 49 | 50 | Mario.Enemy.prototype.CollideCheck = function() { 51 | if (this.DeadTime !== 0) { 52 | return; 53 | } 54 | 55 | var xMarioD = Mario.MarioCharacter.X - this.X, yMarioD = Mario.MarioCharacter.Y - this.Y; 56 | 57 | if (xMarioD > -this.Width * 2 - 4 && xMarioD < this.Width * 2 + 4) { 58 | if (yMarioD > -this.Height && yMarioD < Mario.MarioCharacter.Height) { 59 | if (this.Type !== Mario.Enemy.Spiky && Mario.MarioCharacter.Ya > 0 && yMarioD <= 0 && (!Mario.MarioCharacter.OnGround || !Mario.MarioCharacter.WasOnGround)) { 60 | Mario.MarioCharacter.Stomp(this); 61 | if (this.Winged) { 62 | this.Winged = false; 63 | this.Ya = 0; 64 | } else { 65 | this.YPicO = 31 - (32 - 8); 66 | this.PicHeight = 8; 67 | 68 | if (this.SpriteTemplate !== null) { 69 | this.SpriteTemplate.IsDead = true; 70 | } 71 | 72 | this.DeadTime = 10; 73 | this.Winged = false; 74 | 75 | if (this.Type === Mario.Enemy.RedKoopa) { 76 | this.World.AddSprite(new Mario.Shell(this.World, this.X, this.Y, 0)); 77 | } else if (this.Type === Mario.Enemy.GreenKoopa) { 78 | this.World.AddSprite(new Mario.Shell(this.World, this.X, this.Y, 1)); 79 | } 80 | } 81 | } else { 82 | Mario.MarioCharacter.GetHurt(); 83 | } 84 | } 85 | } 86 | }; 87 | 88 | Mario.Enemy.prototype.Move = function() { 89 | var i = 0, sideWaysSpeed = 1.75, runFrame = 0; 90 | 91 | this.WingTime++; 92 | if (this.DeadTime > 0) { 93 | this.DeadTime--; 94 | 95 | if (this.DeadTime === 0) { 96 | this.DeadTime = 1; 97 | for (i = 0; i < 8; i++) { 98 | this.World.AddSprite(new Mario.Sparkle(this.World, ((this.X + Math.random() * 16 - 8) | 0) + 4, ((this.Y - Math.random() * 8) | 0) + 4, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5)); 99 | } 100 | this.World.RemoveSprite(this); 101 | } 102 | 103 | if (this.FlyDeath) { 104 | this.X += this.Xa; 105 | this.Y += this.Ya; 106 | this.Ya *= 0.95; 107 | this.Ya += 1; 108 | } 109 | return; 110 | } 111 | 112 | if (this.Xa > 2) { 113 | this.Facing = 1; 114 | } 115 | if (this.Xa < -2) { 116 | this.Facing = -1; 117 | } 118 | 119 | this.Xa = this.Facing * sideWaysSpeed; 120 | 121 | this.MayJump = this.OnGround; 122 | 123 | this.XFlip = this.Facing === -1; 124 | 125 | this.RunTime += Math.abs(this.Xa) + 5; 126 | 127 | runFrame = ((this.RunTime / 20) | 0) % 2; 128 | 129 | if (!this.OnGround) { 130 | runFrame = 1; 131 | } 132 | 133 | if (!this.SubMove(this.Xa, 0)) { 134 | this.Facing = -this.Facing; 135 | } 136 | this.OnGround = false; 137 | this.SubMove(0, this.Ya); 138 | 139 | this.Ya *= this.Winged ? 0.95 : 0.85; 140 | if (this.OnGround) { 141 | this.Xa *= this.GroundInertia; 142 | } else { 143 | this.Xa *= this.AirInertia; 144 | } 145 | 146 | if (!this.OnGround) { 147 | if (this.Winged) { 148 | this.Ya += 0.6; 149 | } else { 150 | this.Ya += 2; 151 | } 152 | } else if (this.Winged) { 153 | this.Ya = -10; 154 | } 155 | 156 | if (this.Winged) { 157 | runFrame = ((this.WingTime / 4) | 0) % 2; 158 | } 159 | 160 | this.XPic = runFrame; 161 | }; 162 | 163 | Mario.Enemy.prototype.SubMove = function(xa, ya) { 164 | var collide = false; 165 | 166 | while (xa > 8) { 167 | if (!this.SubMove(8, 0)) { 168 | return false; 169 | } 170 | xa -= 8; 171 | } 172 | while (xa < -8) { 173 | if (!this.SubMove(-8, 0)) { 174 | return false; 175 | } 176 | xa += 8; 177 | } 178 | while (ya > 8) { 179 | if (!this.SubMove(0, 8)) { 180 | return false; 181 | } 182 | ya -= 8; 183 | } 184 | while (ya < -8) { 185 | if (!this.SubMove(0, -8)) { 186 | return false; 187 | } 188 | ya += 8; 189 | } 190 | 191 | if (ya > 0) { 192 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, 0)) { 193 | collide = true; 194 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, 0)) { 195 | collide = true; 196 | } else if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya + 1, xa, ya)) { 197 | collide = true; 198 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya + 1, xa, ya)) { 199 | collide = true; 200 | } 201 | } 202 | if (ya < 0) { 203 | if (this.IsBlocking(this.X + xa, this.Y + ya - this.Height, xa, ya)) { 204 | collide = true; 205 | } else if (collide || this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 206 | collide = true; 207 | } else if (collide || this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 208 | collide = true; 209 | } 210 | } 211 | 212 | if (xa > 0) { 213 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 214 | collide = true; 215 | } 216 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 217 | collide = true; 218 | } 219 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, ya)) { 220 | collide = true; 221 | } 222 | 223 | if (this.AvoidCliffs && this.OnGround && !this.World.Level.IsBlocking(((this.X + this.Xa + this.Width) / 16) | 0, ((this.Y / 16) + 1) | 0, this.Xa, 1)) { 224 | collide = true; 225 | } 226 | } 227 | if (xa < 0) { 228 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 229 | collide = true; 230 | } 231 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 232 | collide = true; 233 | } 234 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, ya)) { 235 | collide = true; 236 | } 237 | 238 | if (this.AvoidCliffs && this.OnGround && !this.World.Level.IsBlocking(((this.X + this.Xa - this.Width) / 16) | 0, ((this.Y / 16) + 1) | 0, this.Xa, 1)) { 239 | collide = true; 240 | } 241 | } 242 | 243 | if (collide) { 244 | if (xa < 0) { 245 | this.X = (((this.X - this.Width) / 16) | 0) * 16 + this.Width; 246 | this.Xa = 0; 247 | } 248 | if (xa > 0) { 249 | this.X = (((this.X + this.Width) / 16 + 1) | 0) * 16 - this.Width - 1; 250 | this.Xa = 0; 251 | } 252 | if (ya < 0) { 253 | this.Y = (((this.Y - this.Height) / 16) | 0) * 16 + this.Height; 254 | this.JumpTime = 0; 255 | this.Ya = 0; 256 | } 257 | if (ya > 0) { 258 | this.Y = (((this.Y - 1) / 16 + 1) | 0) * 16 - 1; 259 | this.OnGround = true; 260 | } 261 | 262 | return false; 263 | } else { 264 | this.X += xa; 265 | this.Y += ya; 266 | return true; 267 | } 268 | }; 269 | 270 | Mario.Enemy.prototype.IsBlocking = function(x, y, xa, ya) { 271 | x = (x / 16) | 0; 272 | y = (y / 16) | 0; 273 | 274 | if (x === (this.X / 16) | 0 && y === (this.Y / 16) | 0) { 275 | return false; 276 | } 277 | 278 | return this.World.Level.IsBlocking(x, y, xa, ya); 279 | }; 280 | 281 | Mario.Enemy.prototype.ShellCollideCheck = function(shell) { 282 | if (this.DeadTime !== 0) { 283 | return false; 284 | } 285 | 286 | var xd = shell.X - this.X, yd = shell.Y - this.Y; 287 | if (xd > -16 && xd < 16) { 288 | if (yd > -this.Height && yd < shell.Height) { 289 | Enjine.Resources.PlaySound("kick"); 290 | 291 | this.Xa = shell.Facing * 2; 292 | this.Ya = -5; 293 | this.FlyDeath = true; 294 | if (this.SpriteTemplate !== null) { 295 | this.SpriteTemplate.IsDead = true; 296 | } 297 | this.DeadTime = 100; 298 | this.Winged = false; 299 | this.YFlip = true; 300 | return true; 301 | } 302 | } 303 | return false; 304 | }; 305 | 306 | Mario.Enemy.prototype.FireballCollideCheck = function(fireball) { 307 | if (this.DeadTime !== 0) { 308 | return false; 309 | } 310 | 311 | var xd = fireball.X - this.X, yd = fireball.Y - this.Y; 312 | if (xd > -16 && xd < 16) { 313 | if (yd > -this.Height && yd < fireball.Height) { 314 | if (this.NoFireballDeath) { 315 | return true; 316 | } 317 | 318 | Enjine.Resources.PlaySound("kick"); 319 | 320 | this.Xa = fireball.Facing * 2; 321 | this.Ya = -5; 322 | this.FlyDeath = true; 323 | if (this.SpriteTemplate !== null) { 324 | this.SpriteTemplate.IsDead = true; 325 | } 326 | this.DeadTime = 100; 327 | this.Winged = false; 328 | this.YFlip = true; 329 | return true; 330 | } 331 | } 332 | }; 333 | 334 | Mario.Enemy.prototype.BumpCheck = function(xTile, yTile) { 335 | if (this.DeadTime !== 0) { 336 | return; 337 | } 338 | 339 | if (this.X + this.Width > xTile * 16 && this.X - this.Width < xTile * 16 + 16 && yTile === ((this.Y - 1) / 16) | 0) { 340 | Enjine.Resources.PlaySound("kick"); 341 | 342 | this.Xa = -Mario.MarioCharacter.Facing * 2; 343 | this.Ya = -5; 344 | this.FlyDeath = true; 345 | if (this.SpriteTemplate !== null) { 346 | this.SpriteTemplate.IsDead = true; 347 | } 348 | this.DeadTime = 100; 349 | this.Winged = false; 350 | this.YFlip = true; 351 | } 352 | }; 353 | 354 | Mario.Enemy.prototype.SubDraw = Mario.NotchSprite.prototype.Draw; 355 | 356 | Mario.Enemy.prototype.Draw = function(context, camera) { 357 | var xPixel = 0, yPixel = 0; 358 | 359 | if (this.Winged) { 360 | xPixel = ((this.XOld + (this.X - this.XOld) * this.Delta) | 0) - this.XPicO; 361 | yPixel = ((this.YOld + (this.Y - this.YOld) * this.Delta) | 0) - this.YPicO; 362 | 363 | if (this.Type !== Mario.Enemy.RedKoopa && this.Type !== Mario.Enemy.GreenKoopa) { 364 | this.XFlip = !this.XFlip; 365 | context.save(); 366 | context.scale(this.XFlip ? -1 : 1, this.YFlip ? -1 : 1); 367 | context.translate(this.XFlip ? -320 : 0, this.YFlip ? -240 : 0); 368 | context.drawImage(this.Image, (((this.WingTime / 4) | 0) % 2) * 16, 4 * 32, 16, 32, 369 | this.XFlip ? (320 - xPixel - 24) : xPixel - 8, this.YFlip ? (240 - yPixel - 32) : yPixel - 8, 16, 32); 370 | context.restore(); 371 | this.XFlip = !this.XFlip; 372 | } 373 | } 374 | 375 | this.SubDraw(context, camera); 376 | 377 | if (this.Winged) { 378 | xPixel = ((this.XOld + (this.X - this.XOld) * this.Delta) | 0) - this.XPicO; 379 | yPixel = ((this.YOld + (this.Y - this.YOld) * this.Delta) | 0) - this.YPicO; 380 | 381 | if (this.Type === Mario.Enemy.RedKoopa && this.Type === Mario.Enemy.GreenKoopa) { 382 | context.save(); 383 | context.scale(this.XFlip ? -1 : 1, this.YFlip ? -1 : 1); 384 | context.translate(this.XFlip ? -320 : 0, this.YFlip ? -240 : 0); 385 | context.drawImage(this.Image, (((this.WingTime / 4) | 0) % 2) * 16, 4 * 32, 16, 32, 386 | this.XFlip ? (320 - xPixel - 24) : xPixel - 8, this.YFlip ? (240 - yPixel) : yPixel - 8, 16, 32); 387 | context.restore(); 388 | } else { 389 | context.save(); 390 | context.scale(this.XFlip ? -1 : 1, this.YFlip ? -1 : 1); 391 | context.translate(this.XFlip ? -320 : 0, this.YFlip ? -240 : 0); 392 | context.drawImage(this.Image, (((this.WingTime / 4) | 0) % 2) * 16, 4 * 32, 16, 32, 393 | this.XFlip ? (320 - xPixel - 24) : xPixel - 8, this.YFlip ? (240 - yPixel - 32) : yPixel - 8, 16, 32); 394 | context.restore(); 395 | } 396 | } 397 | }; 398 | 399 | //Static variables 400 | Mario.Enemy.RedKoopa = 0; 401 | Mario.Enemy.GreenKoopa = 1; 402 | Mario.Enemy.Goomba = 2; 403 | Mario.Enemy.Spiky = 3; 404 | Mario.Enemy.Flower = 4; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/fireFlower.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a fire powerup. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.FireFlower = function(world, x, y) { 7 | this.Width = 4; 8 | this.Height = 24; 9 | 10 | this.World = world; 11 | this.X = x; 12 | this.Y = y; 13 | this.Image = Enjine.Resources.Images["items"]; 14 | 15 | this.XPicO = 8; 16 | this.YPicO = 15; 17 | this.XPic = 1; 18 | this.YPic = 0; 19 | this.Height = 12; 20 | this.Facing = 1; 21 | this.PicWidth = this.PicHeight = 16; 22 | 23 | this.Life = 0; 24 | }; 25 | 26 | Mario.FireFlower.prototype = new Mario.NotchSprite(); 27 | 28 | Mario.FireFlower.prototype.CollideCheck = function() { 29 | var xMarioD = Mario.MarioCharacter.X - this.X, yMarioD = Mario.MarioCharacter.Y - this.Y; 30 | if (xMarioD > -16 && xMarioD < 16) { 31 | if (yMarioD > -this.Height && yMarioD < Mario.MarioCharacter.Height) { 32 | Mario.MarioCharacter.GetFlower(); 33 | this.World.RemoveSprite(this); 34 | } 35 | } 36 | }; 37 | 38 | Mario.FireFlower.prototype.Move = function() { 39 | if (this.Life < 9) { 40 | this.Layer = 0; 41 | this.Y--; 42 | this.Life++; 43 | return; 44 | } 45 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/fireball.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a fireball. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Fireball = function(world, x, y, facing) { 7 | this.GroundInertia = 0.89; 8 | this.AirInertia = 0.89; 9 | 10 | this.Image = Enjine.Resources.Images["particles"]; 11 | 12 | this.World = world; 13 | this.X = x; 14 | this.Y = y; 15 | this.Facing = facing; 16 | 17 | this.XPicO = 4; 18 | this.YPicO = 4; 19 | this.YPic = 3; 20 | this.XPic = 4; 21 | this.Height = 8; 22 | this.Width = 4; 23 | this.PicWidth = this.PicHeight = 8; 24 | this.Ya = 4; 25 | this.Dead = false; 26 | this.DeadTime = 0; 27 | this.Anim = 0; 28 | this.OnGround = false; 29 | }; 30 | 31 | Mario.Fireball.prototype = new Mario.NotchSprite(); 32 | 33 | Mario.Fireball.prototype.Move = function() { 34 | var i = 0, sideWaysSpeed = 8; 35 | 36 | if (this.DeadTime > 0) { 37 | for (i = 0; i < 8; i++) { 38 | this.World.AddSprite(new Mario.Sparkle(this.World, ((this.X + Math.random() * 8 - 4) | 0) + 4, ((this.Y + Math.random() * 8 - 4) | 0) + 2, Math.random() * 2 - 1 * this.Facing, Math.random() * 2 - 1, 0, 1, 5)); 39 | } 40 | this.World.RemoveSprite(this); 41 | return; 42 | } 43 | 44 | if (this.Facing != 0) { 45 | this.Anim++; 46 | } 47 | 48 | if (this.Xa > 2) { 49 | this.Facing = 1; 50 | } 51 | if (this.Xa < -2) { 52 | this.Facing = -1; 53 | } 54 | 55 | this.Xa = this.Facing * sideWaysSpeed; 56 | 57 | this.World.CheckFireballCollide(this); 58 | 59 | this.FlipX = this.Facing === -1; 60 | 61 | this.XPic = this.Anim % 4; 62 | 63 | if (!this.SubMove(this.Xa, 0)) { 64 | this.Die(); 65 | } 66 | 67 | this.OnGround = false; 68 | this.SubMove(0, this.Ya); 69 | if (this.OnGround) { 70 | this.Ya = -10; 71 | } 72 | 73 | this.Ya *= 0.95; 74 | if (this.OnGround) { 75 | this.Xa *= this.GroundInertia; 76 | } else { 77 | this.Xa *= this.AirInertia; 78 | } 79 | 80 | if (!this.OnGround) { 81 | this.Ya += 1.5; 82 | } 83 | }; 84 | 85 | Mario.Fireball.prototype.SubMove = function(xa, ya) { 86 | var collide = false; 87 | 88 | while (xa > 8) { 89 | if (!this.SubMove(8, 0)) { 90 | return false; 91 | } 92 | xa -= 8; 93 | } 94 | while (xa < -8) { 95 | if (!this.SubMove(-8, 0)) { 96 | return false; 97 | } 98 | xa += 8; 99 | } 100 | while (ya > 8) { 101 | if (!this.SubMove(0, 8)) { 102 | return false; 103 | } 104 | ya -= 8; 105 | } 106 | while (ya < -8) { 107 | if (!this.SubMove(0, -8)) { 108 | return false; 109 | } 110 | ya += 8; 111 | } 112 | 113 | if (ya > 0) { 114 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, 0)) { 115 | collide = true; 116 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, 0)) { 117 | collide = true; 118 | } else if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya + 1, xa, ya)) { 119 | collide = true; 120 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya + 1, xa, ya)) { 121 | collide = true; 122 | } 123 | } 124 | if (ya < 0) { 125 | if (this.IsBlocking(this.X + xa, this.Y + ya - this.Height, xa, ya)) { 126 | collide = true; 127 | } else if (collide || this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 128 | collide = true; 129 | } else if (collide || this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 130 | collide = true; 131 | } 132 | } 133 | 134 | if (xa > 0) { 135 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 136 | collide = true; 137 | } 138 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 139 | collide = true; 140 | } 141 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, ya)) { 142 | collide = true; 143 | } 144 | } 145 | if (xa < 0) { 146 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 147 | collide = true; 148 | } 149 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 150 | collide = true; 151 | } 152 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, ya)) { 153 | collide = true; 154 | } 155 | } 156 | 157 | if (collide) { 158 | if (xa < 0) { 159 | this.X = (((this.X - this.Width) / 16) | 0) * 16 + this.Width; 160 | this.Xa = 0; 161 | } 162 | if (xa > 0) { 163 | this.X = (((this.X + this.Width) / 16 + 1) | 0) * 16 - this.Width - 1; 164 | this.Xa = 0; 165 | } 166 | if (ya < 0) { 167 | this.Y = (((this.Y - this.Height) / 16) | 0) * 16 + this.Height; 168 | this.Ya = 0; 169 | } 170 | if (ya > 0) { 171 | this.Y = (((this.Y - 1) / 16 + 1) | 0) * 16 - 1; 172 | this.OnGround = true; 173 | } 174 | 175 | return false; 176 | } else { 177 | this.X += xa; 178 | this.Y += ya; 179 | return true; 180 | } 181 | }; 182 | 183 | Mario.Fireball.prototype.IsBlocking = function(x, y, xa, ya) { 184 | x = (x / 16) | 0; 185 | y = (y / 16) | 0; 186 | 187 | if (x === (this.X / 16) | 0 && y === (this.Y / 16) | 0) { 188 | return false; 189 | } 190 | 191 | return this.World.Level.IsBlocking(x, y, xa, ya); 192 | }; 193 | 194 | Mario.Fireball.prototype.Die = function() { 195 | this.Dead = true; 196 | this.Xa = -this.Facing * 2; 197 | this.Ya = -5; 198 | this.DeadTime = 100; 199 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/flowerEnemy.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a flower enemy. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.FlowerEnemy = function(world, x, y) { 7 | this.Image = Enjine.Resources.Images["enemies"]; 8 | this.World = world; 9 | this.X = x; 10 | this.Y = y; 11 | this.Facing = 1; 12 | this.Type = Mario.Enemy.Spiky; 13 | this.Winged = false; 14 | this.NoFireballDeath = false; 15 | this.XPic = 0; 16 | this.YPic = 6; 17 | this.YPicO = 24; 18 | this.Height = 12; 19 | this.Width = 2; 20 | this.YStart = y; 21 | this.Ya = -8; 22 | this.Y -= 1; 23 | this.Layer = 0; 24 | this.JumpTime = 0; 25 | this.Tick = 0; 26 | 27 | var i = 0; 28 | for (i = 0; i < 4; i++) { 29 | this.Move(); 30 | } 31 | }; 32 | 33 | Mario.FlowerEnemy.prototype = new Mario.Enemy(); 34 | 35 | Mario.FlowerEnemy.prototype.Move = function() { 36 | var i = 0, xd = 0; 37 | if (this.DeadTime > 0) { 38 | this.DeadTime--; 39 | 40 | if (this.DeadTime === 0) { 41 | this.DeadTime = 1; 42 | for (i = 0; i < 8; i++) { 43 | this.World.AddSprite(new Mario.Sparkle(((this.X + Math.random() * 16 - 8) | 0) + 4, ((this.Y + Math.random() * 8) | 0) + 4, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5)); 44 | } 45 | this.World.RemoveSprite(this); 46 | } 47 | 48 | this.X += this.Xa; 49 | this.Y += this.Ya; 50 | this.Ya *= 0.95; 51 | this.Ya += 1; 52 | 53 | return; 54 | } 55 | 56 | this.Tick++; 57 | 58 | if (this.Y >= this.YStart) { 59 | this.YStart = this.Y; 60 | xd = Math.abs(Mario.MarioCharacter.X - this.X) | 0; 61 | this.JumpTime++; 62 | if (this.JumpTime > 40 && xd > 24) { 63 | this.Ya = -8; 64 | } else { 65 | this.Ya = 0; 66 | } 67 | } else { 68 | this.JumpTime = 0; 69 | } 70 | 71 | this.Y += this.Ya; 72 | this.Ya *= 0.9; 73 | this.Ya += 0.1; 74 | 75 | this.XPic = (((this.Tick / 2) | 0) & 1) * 2 + (((this.Tick / 6) | 0) & 1); 76 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/improvedNoise.js: -------------------------------------------------------------------------------- 1 | /** 2 | Noise function to generate the world maps. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.ImprovedNoise = function(seed) { 7 | this.P = []; 8 | this.Shuffle(seed); 9 | }; 10 | 11 | Mario.ImprovedNoise.prototype = { 12 | Shuffle: function(seed) { 13 | var permutation = []; 14 | var i = 0, j = 0, tmp = 0; 15 | 16 | for (i = 0; i < 256; i++) { 17 | permutation[i] = i; 18 | } 19 | 20 | for (i = 0; i < 256; i++) { 21 | j = ((Math.random() * (256 - 1)) | 0) + i; 22 | tmp = permutation[i]; 23 | permutation[i] = permutation[j]; 24 | permutation[j] = tmp; 25 | this.P[i + 256] = this.P[i] = permutation[i]; 26 | } 27 | }, 28 | 29 | PerlinNoise: function(x, y) { 30 | var i = 0, n = 0, stepSize = 0; 31 | 32 | for (i = 0; i < 8; i++) { 33 | stepSize = 64 / (1 << i); 34 | n += this.Noise(x / stepSize, y / stepSize, 128) / (1 << i); 35 | } 36 | 37 | return n; 38 | }, 39 | 40 | Noise: function(x, y, z) { 41 | var nx = (x | 0) & 255, ny = (y | 0) & 255, nz = (z | 0) & 255; 42 | x -= (x | 0); 43 | y -= (y | 0); 44 | z -= (z | 0); 45 | 46 | var u = this.Fade(x), v = this.Fade(y), w = this.Fade(z); 47 | var A = this.P[nx] + ny, AA = this.P[A] + nz, AB = this.P[A + 1] + nz, 48 | B = this.P[nx + 1] + ny, BA = this.P[B] + nz, BB = this.P[B + 1] + nz; 49 | 50 | return this.Lerp(w, this.Lerp(v, this.Lerp(u, this.Grad(this.P[AA], x, y, z), 51 | this.Grad(this.P[BA], x - 1, y, z)), 52 | this.Lerp(u, this.Grad(this.P[AB], x, y - 1, z), 53 | this.Grad(this.P[BB], x - 1, y - 1, z))), 54 | this.Lerp(v, this.Lerp(u, this.Grad(this.P[AA + 1], x, y, z - 1), 55 | this.Grad(this.P[BA + 1], x - 1, y, z - 1)), 56 | this.Lerp(u, this.Grad(this.P[AB + 1], x, y - 1, z - 1), this.Grad(this.P[BB + 1], x - 1, y - 1, z - 1)))); 57 | }, 58 | 59 | Fade: function(t) { 60 | return t * t * t * (t * (t * 6 - 15) + 10); 61 | }, 62 | 63 | Lerp: function(t, x, y) { 64 | return x + t * (y - x); 65 | }, 66 | 67 | Grad: function(hash, x, y, z) { 68 | var h = hash & 15; 69 | var u = h < 8 ? x : y; 70 | var v = h < 4 ? y : (h === 12 || h === 14) ? x : z; 71 | return ((h & 1) === 0 ? u : -u) + ((h & 2) === 0 ? v : -v); 72 | } 73 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/level.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a playable level in the game. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Tile = { 7 | BlockUpper: 1 << 0, 8 | BlockAll: 1 << 1, 9 | BlockLower: 1 << 2, 10 | Special: 1 << 3, 11 | Bumpable: 1 << 4, 12 | Breakable: 1 << 5, 13 | PickUpable: 1 << 6, 14 | Animated: 1 << 7, 15 | Behaviors: [], 16 | 17 | LoadBehaviors: function() { 18 | var b = []; 19 | b[0] = 0; 20 | b[1] = 20; 21 | b[2] = 28; 22 | b[3] = 0; 23 | b[4] = 130; 24 | b[5] = 130; 25 | b[6] = 130; 26 | b[7] = 130; 27 | b[8] = 2; 28 | b[9] = 2; 29 | b[10] = 2; 30 | b[11] = 2; 31 | b[12] = 2; 32 | b[13] = 0; 33 | b[14] = 138; 34 | b[15] = 0; 35 | b[16] = 162; 36 | b[17] = 146; 37 | b[18] = 154; 38 | b[19] = 162; 39 | b[20] = 146; 40 | b[21] = 146; 41 | b[22] = 154; 42 | b[23] = 146; 43 | b[24] = 2; 44 | b[25] = 0; 45 | b[26] = 2; 46 | b[27] = 2; 47 | b[28] = 2; 48 | b[29] = 0; 49 | b[30] = 2; 50 | b[31] = 0; 51 | b[32] = 192; 52 | b[33] = 192; 53 | b[34] = 192; 54 | b[35] = 192; 55 | b[36] = 0; 56 | b[37] = 0; 57 | b[38] = 0; 58 | b[39] = 0; 59 | b[40] = 2; 60 | b[41] = 2; 61 | b[42] = 0; 62 | b[43] = 0; 63 | b[44] = 0; 64 | b[45] = 0; 65 | b[46] = 2; 66 | b[47] = 0; 67 | b[48] = 0; 68 | b[49] = 0; 69 | b[50] = 0; 70 | b[51] = 0; 71 | b[52] = 0; 72 | b[53] = 0; 73 | b[54] = 0; 74 | b[55] = 0; 75 | b[56] = 2; 76 | b[57] = 2; 77 | 78 | var i = 0; 79 | for (i = 58; i < 128; i++) { 80 | b[i] = 0; 81 | } 82 | 83 | b[128] = 2; 84 | b[129] = 2; 85 | b[130] = 2; 86 | b[131] = 0; 87 | b[132] = 1; 88 | b[133] = 1; 89 | b[134] = 1; 90 | b[135] = 0; 91 | b[136] = 2; 92 | b[137] = 2; 93 | b[138] = 2; 94 | b[139] = 0; 95 | b[140] = 2; 96 | b[141] = 2; 97 | b[142] = 2; 98 | b[143] = 0; 99 | b[144] = 2; 100 | b[145] = 0; 101 | b[146] = 2; 102 | b[147] = 0; 103 | b[148] = 0; 104 | b[149] = 0; 105 | b[150] = 0; 106 | b[151] = 0; 107 | b[152] = 2; 108 | b[153] = 2; 109 | b[154] = 2; 110 | b[155] = 0; 111 | b[156] = 2; 112 | b[157] = 2; 113 | b[158] = 2; 114 | b[159] = 0; 115 | b[160] = 2; 116 | b[161] = 2; 117 | b[162] = 2; 118 | b[163] = 0; 119 | b[164] = 0; 120 | b[165] = 0; 121 | b[166] = 0; 122 | b[167] = 0; 123 | b[168] = 2; 124 | b[169] = 2; 125 | b[170] = 2; 126 | b[171] = 0; 127 | b[172] = 2; 128 | b[173] = 2; 129 | b[174] = 2; 130 | b[175] = 0; 131 | b[176] = 2; 132 | b[177] = 2; 133 | b[178] = 2; 134 | b[179] = 0; 135 | b[180] = 1; 136 | b[181] = 1; 137 | b[182] = 1; 138 | 139 | for (i = 183; i < 224; i++) { 140 | b[i] = 0; 141 | } 142 | 143 | b[224] = 1; 144 | b[225] = 1; 145 | b[226] = 1; 146 | 147 | for (i = 227; i < 256; i++) { 148 | b[i] = 0; 149 | } 150 | 151 | this.Behaviors = b; 152 | } 153 | }; 154 | 155 | Mario.LevelType = { 156 | Overground: 0, 157 | Underground: 1, 158 | Castle: 2 159 | }; 160 | 161 | Mario.Odds = { 162 | Straight: 0, 163 | HillStraight: 1, 164 | Tubes: 2, 165 | Jump: 3, 166 | Cannons: 4 167 | }; 168 | 169 | Mario.Level = function(width, height) { 170 | this.Width = width; 171 | this.Height = height; 172 | this.ExitX = 10; 173 | this.ExitY = 10; 174 | 175 | this.Map = []; 176 | this.Data = []; 177 | this.SpriteTemplates = []; 178 | 179 | var x = 0, y = 0; 180 | for (x = 0; x < this.Width; x++) { 181 | this.Map[x] = []; 182 | this.Data[x] = []; 183 | this.SpriteTemplates[x] = []; 184 | 185 | for (y = 0; y < this.Height; y++) { 186 | this.Map[x][y] = 0; 187 | this.Data[x][y] = 0; 188 | this.SpriteTemplates[x][y] = null; 189 | } 190 | } 191 | }; 192 | 193 | Mario.Level.prototype = { 194 | Update: function() { 195 | var x = 0, y = 0; 196 | for (x = 0; x < this.Width; x++) { 197 | for (y = 0; y < this.Height; y++) { 198 | if (this.Data[x][y] > 0) { 199 | this.Data[x][y]--; 200 | } 201 | } 202 | } 203 | }, 204 | 205 | GetBlockCapped: function(x, y) { 206 | if (x < 0) { x = 0; } 207 | if (y < 0) { y = 0; } 208 | if (x >= this.Width) { x = this.Width - 1; } 209 | if (y >= this.Height) { y = this.Height - 1; } 210 | return this.Map[x][y]; 211 | }, 212 | 213 | GetBlock: function(x, y) { 214 | if (x < 0) { x = 0; } 215 | if (y < 0) { return 0; } 216 | if (x >= this.Width) { x = this.Width - 1; } 217 | if (y >= this.Height) { y = this.Height - 1; } 218 | return this.Map[x][y]; 219 | }, 220 | 221 | SetBlock: function(x, y, block) { 222 | if (x < 0) { return; } 223 | if (y < 0) { return; } 224 | if (x >= this.Width) { return; } 225 | if (y >= this.Height) { return; } 226 | this.Map[x][y] = block; 227 | }, 228 | 229 | SetBlockData: function(x, y, data) { 230 | if (x < 0) { return; } 231 | if (y < 0) { return; } 232 | if (x >= this.Width) { return; } 233 | if (y >= this.Height) { return; } 234 | this.Data[x][y] = data; 235 | }, 236 | 237 | IsBlocking: function(x, y, xa, ya) { 238 | var block = this.GetBlock(x, y); 239 | var blocking = ((Mario.Tile.Behaviors[block & 0xff]) & Mario.Tile.BlockAll) > 0; 240 | blocking |= (ya > 0) && ((Mario.Tile.Behaviors[block & 0xff]) & Mario.Tile.BlockUpper) > 0; 241 | blocking |= (ya < 0) && ((Mario.Tile.Behaviors[block & 0xff]) & Mario.Tile.BlockLower) > 0; 242 | 243 | return blocking; 244 | }, 245 | 246 | GetSpriteTemplate: function(x, y) { 247 | if (x < 0) { return null; } 248 | if (y < 0) { return null; } 249 | if (x >= this.Width) { return null; } 250 | if (y >= this.Height) { return null; } 251 | return this.SpriteTemplates[x][y]; 252 | }, 253 | 254 | SetSpriteTemplate: function(x, y, template) { 255 | if (x < 0) { return; } 256 | if (y < 0) { return; } 257 | if (x >= this.Width) { return; } 258 | if (y >= this.Height) { return; } 259 | this.SpriteTemplates[x][y] = template; 260 | } 261 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/levelGenerator.js: -------------------------------------------------------------------------------- 1 | /** 2 | Generates a psuedo-random procedural level. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.LevelGenerator = function(width, height) { 7 | this.Width = width; 8 | this.Height = height; 9 | this.Odds = []; 10 | this.TotalOdds = 0; 11 | this.Difficulty = 0; 12 | this.Type = 0; 13 | }; 14 | 15 | Mario.LevelGenerator.prototype = { 16 | CreateLevel: function(type, difficulty) { 17 | var i = 0, length = 0, floor = 0, x = 0, y = 0, ceiling = 0, run = 0, level = null; 18 | 19 | this.Type = type; 20 | this.Difficulty = difficulty; 21 | this.Odds[Mario.Odds.Straight] = 20; 22 | this.Odds[Mario.Odds.HillStraight] = 10; 23 | this.Odds[Mario.Odds.Tubes] = 2 + difficulty; 24 | this.Odds[Mario.Odds.Jump] = 2 * difficulty; 25 | this.Odds[Mario.Odds.Cannon] = -10 + 5 * difficulty; 26 | 27 | if (this.Type !== Mario.LevelType.Overground) { 28 | this.Odds[Mario.Odds.HillStraight] = 0; 29 | } 30 | 31 | for (i = 0; i < this.Odds.length; i++) { 32 | if (this.Odds[i] < 0) { 33 | this.Odds[i] = 0; 34 | } 35 | this.TotalOdds += this.Odds[i]; 36 | this.Odds[i] = this.TotalOdds - this.Odds[i]; 37 | } 38 | 39 | level = new Mario.Level(this.Width, this.Height); 40 | length += this.BuildStraight(level, 0, level.Width, true); 41 | while (length < level.Width - 64) { 42 | length += this.BuildZone(level, length, level.Width - length); 43 | } 44 | 45 | floor = this.Height - 1 - (Math.random() * 4) | 0; 46 | level.ExitX = length + 8; 47 | level.ExitY = floor; 48 | 49 | for (x = length; x < level.Width; x++) { 50 | for (y = 0; y < this.Height; y++) { 51 | if (y >= floor) { 52 | level.SetBlock(x, y, 1 + 9 * 16); 53 | } 54 | } 55 | } 56 | 57 | if (type === Mario.LevelType.Castle || type === Mario.LevelType.Underground) { 58 | for (x = 0; x < level.Width; x++) { 59 | if (run-- <= 0 && x > 4) { 60 | ceiling = (Math.random() * 4) | 0; 61 | run = ((Math.random() * 4) | 0) + 4; 62 | } 63 | for (y = 0; y < level.Height; y++) { 64 | if ((x > 4 && y <= ceiling) || x < 1) { 65 | level.SetBlock(x, y, 1 + 9 * 16); 66 | } 67 | } 68 | } 69 | } 70 | 71 | this.FixWalls(level); 72 | 73 | return level; 74 | }, 75 | 76 | BuildZone: function(level, x, maxLength) { 77 | var t = (Math.random() * this.TotalOdds) | 0, type = 0, i = 0; 78 | for (i = 0; i < this.Odds.length; i++) { 79 | if (this.Odds[i] <= t) { 80 | type = i; 81 | } 82 | } 83 | 84 | switch (type) { 85 | case Mario.Odds.Straight: 86 | return this.BuildStraight(level, x, maxLength, false); 87 | case Mario.Odds.HillStraight: 88 | return this.BuildHillStraight(level, x, maxLength); 89 | case Mario.Odds.Tubes: 90 | return this.BuildTubes(level, x, maxLength); 91 | case Mario.Odds.Jump: 92 | return this.BuildJump(level, x, maxLength); 93 | case Mario.Odds.Cannons: 94 | return this.BuildCannons(level, x, maxLength); 95 | } 96 | return 0; 97 | }, 98 | 99 | BuildJump: function(level, xo, maxLength) { 100 | var js = ((Math.random() * 4) | 0) + 2, jl = ((Math.random() * 2) | 0) + 2, length = js * 2 + jl, x = 0, y = 0, 101 | hasStairs = ((Math.random() * 3) | 0) === 0, floor = this.Height - 1 - ((Math.random() * 4) | 0); 102 | 103 | for (x = xo; x < xo + length; x++) { 104 | if (x < xo + js || x > xo + length - js - 1) { 105 | for (y = 0; y < this.Height; y++) { 106 | if (y >= floor) { 107 | level.SetBlock(x, y, 1 + 9 * 16); 108 | } else if (hasStairs) { 109 | if (x < xo + js) { 110 | if (y >= floor - (x - xo) + 1) { 111 | level.SetBlock(x, y, 9); 112 | } 113 | } else { 114 | if (y >= floor - ((xo + length) - x) + 2) { 115 | level.SetBlock(x, y, 9); 116 | } 117 | } 118 | } 119 | } 120 | } 121 | } 122 | 123 | return length; 124 | }, 125 | 126 | BuildCannons: function(level, xo, maxLength) { 127 | alert("cannons"); 128 | var length = ((Math.random() * 10) | 0) + 2, floor = this.Height - 1 - (Math.random() * 4) | 0, 129 | xCannon = xo + 1 + (Math.random() * 4) | 0, x = 0, y = 0, cannonHeight = 0; 130 | 131 | if (length > maxLength) { 132 | length = maxLength; 133 | } 134 | 135 | for (x = xo; x < xo + length; x++) { 136 | if (x > xCannon) { 137 | xCannon += 2 * (Math.random() * 4) | 0; 138 | } 139 | if (xCannon === xo + length - 1) { 140 | xCannon += 10; 141 | } 142 | cannonHeight = floor - ((Math.random() * 4) | 0) - 1; 143 | 144 | for (y = 0; y < this.Height; y++) { 145 | if (y >= floor) { 146 | level.SetBlock(x, y, 1 + 9 * 16); 147 | } else { 148 | if (x === xCannon && y >= cannonHeight) { 149 | if (y === cannonHeight) { 150 | level.SetBlock(x, y, 14); 151 | } else if (y === cannonHeight + 1) { 152 | level.SetBlock(x, y, 14 + 16); 153 | } else { 154 | level.SetBlock(x, y, 14 + 2 * 16); 155 | } 156 | } 157 | } 158 | } 159 | } 160 | 161 | return length; 162 | }, 163 | 164 | BuildHillStraight: function(level, xo, maxLength) { 165 | var length = ((Math.random() * 10) | 0) + 10, floor = this.Height - 1 - (Math.random() * 4) | 0, 166 | x = 0, y = 0, h = floor, keepGoing = true, l = 0, xxo = 0, occupied = [], xx = 0, yy = 0; 167 | 168 | if (length > maxLength) { 169 | length = maxLength; 170 | } 171 | 172 | for (x = xo; x < xo + length; x++) { 173 | for (y = 0; y < this.Height; y++) { 174 | if (y >= floor) { 175 | level.SetBlock(x, y, 1 + 9 * 16); 176 | } 177 | } 178 | } 179 | 180 | this.AddEnemyLine(level, xo + 1, xo + length - 1, floor - 1); 181 | 182 | while (keepGoing) { 183 | h = h - 2 - (Math.random() * 3) | 0; 184 | if (h <= 0) { 185 | keepGoing = false; 186 | } else { 187 | l = ((Math.random() * 5) | 0) + 3; 188 | xxo = ((Math.random() * (length - l - 2)) | 0) + xo + 1; 189 | 190 | if (occupied[xxo - xo] || occupied[xxo - xo + l] || occupied[xxo - xo - 1] || occupied[xxo - xo + l + 1]) { 191 | keepGoing = false; 192 | } else { 193 | occupied[xxo - xo] = true; 194 | occupied[xxo - xo + l] = true; 195 | this.AddEnemyLine(level, xxo, xxo + l, h - 1); 196 | if (((Math.random() * 4) | 0) === 0) { 197 | this.Decorate(level, xxo - 1, xxo + l + 1, h); 198 | keepGoing = false; 199 | } 200 | 201 | for (x = xxo; x < xxo + l; x++) { 202 | for (y = h; y < floor; y++) { 203 | xx = 5; 204 | yy = 9; 205 | if (x === xxo) { 206 | xx = 4; 207 | } 208 | if (x === xxo + l - 1) { 209 | xx = 6; 210 | } 211 | if (y === h) { 212 | yy = 8; 213 | } 214 | 215 | if (level.GetBlock(x, y) === 0) { 216 | level.SetBlock(x, y, xx + yy * 16); 217 | } else { 218 | if (level.GetBlock(x, y) === (4 + 8 * 16)) { 219 | level.SetBlock(x, y, 4 + 11 * 16); 220 | } 221 | if (level.GetBlock(x, y) === (6 + 8 * 16)) { 222 | level.SetBlock(x, y, 6 + 11 * 16); 223 | } 224 | } 225 | } 226 | } 227 | } 228 | } 229 | } 230 | 231 | return length; 232 | }, 233 | 234 | AddEnemyLine: function(level, x0, x1, y) { 235 | var x = 0, type = 0; 236 | for (x = x0; x < x1; x++) { 237 | if (((Math.random() * 35) | 0) < this.Difficulty + 1) { 238 | type = (Math.random() * 4) | 0; 239 | if (this.Difficulty < 1) { 240 | type = Mario.Enemy.Goomba; 241 | } else if (this.Difficulty < 3) { 242 | type = (Math.random() * 3) | 0; 243 | } 244 | level.SetSpriteTemplate(x, y, new Mario.SpriteTemplate(type, ((Math.random() * 35) | 0) < this.Difficulty)); 245 | } 246 | } 247 | }, 248 | 249 | BuildTubes: function(level, xo, maxLength) { 250 | var length = ((Math.random() * 10) | 0) + 5, floor = this.Height - 1 - (Math.random() * 4) | 0, 251 | xTube = xo + 1 + (Math.random() * 4) | 0, tubeHeight = floor - ((Math.random() * 2) | 0) - 2, 252 | x = 0, y = 0, xPic = 0; 253 | 254 | if (length > maxLength) { 255 | length = maxLength; 256 | } 257 | 258 | for (x = xo; x < xo + length; x++) { 259 | if (x > xTube + 1) { 260 | xTube += 3 + ((Math.random() * 4) | 0); 261 | tubeHeight = floor - ((Math.random() * 2) | 0) - 2; 262 | } 263 | if (xTube >= xo + length - 2) { 264 | xTube += 10; 265 | } 266 | 267 | if (x === xTube && ((Math.random() * 11) | 0) < this.Difficulty + 1) { 268 | level.SetSpriteTemplate(x, tubeHeight, new Mario.SpriteTemplate(Mario.Enemy.Flower, false)); 269 | } 270 | 271 | for (y = 0; y < this.Height; y++) { 272 | if (y >= floor) { 273 | level.SetBlock(x, y, 1 + 9 * 16); 274 | } else { 275 | if ((x === xTube || x === xTube + 1) && y >= tubeHeight) { 276 | xPic = 10 + x - xTube; 277 | if (y === tubeHeight) { 278 | level.SetBlock(x, y, xPic); 279 | } else { 280 | level.SetBlock(x, y, xPic + 16); 281 | } 282 | } 283 | } 284 | } 285 | } 286 | 287 | return length; 288 | }, 289 | 290 | BuildStraight: function(level, xo, maxLength, safe) { 291 | var length = ((Math.random() * 10) | 0) + 2, floor = this.Height - 1 - ((Math.random() * 4) | 0), x = 0, y = 0; 292 | 293 | if (safe) { 294 | length = 10 + ((Math.random() * 5) | 0); 295 | } 296 | if (length > maxLength) { 297 | length = maxLength; 298 | } 299 | 300 | for (x = xo; x < xo + length; x++) { 301 | for (y = 0; y < this.Height; y++) { 302 | if (y >= floor) { 303 | level.SetBlock(x, y, 1 + 9 * 16); 304 | } 305 | } 306 | } 307 | 308 | if (!safe) { 309 | if (length > 5) { 310 | this.Decorate(level, xo, xo + length, floor); 311 | } 312 | } 313 | 314 | return length; 315 | }, 316 | 317 | Decorate: function(level, x0, x1, floor) { 318 | if (floor < 1) { 319 | return; 320 | } 321 | 322 | var rocks = true, s = (Math.random() * 4) | 0, e = (Math.random() * 4) | 0, x = 0; 323 | 324 | this.AddEnemyLine(level, x0 + 1, x1 - 1, floor - 1); 325 | 326 | if (floor - 2 > 0) { 327 | if ((x1 - 1 - e) - (x0 + 1 + s) > 1) { 328 | for (x = x0 + 1 + s; x < x1 - 1 - e; x++) { 329 | level.SetBlock(x, floor - 2, 2 + 2 * 16); 330 | } 331 | } 332 | } 333 | 334 | s = (Math.random() * 4) | 0; 335 | e = (Math.random() * 4) | 0; 336 | 337 | if (floor - 4 > 0) { 338 | if ((x1 - 1 - e) - (x0 + 1 + s) > 2) { 339 | for (x = x0 + 1 + s; x < x1 - 1 - e; x++) { 340 | if (rocks) { 341 | if (x !== x0 + 1 && x !== x1 - 2 && ((Math.random() * 3) | 0) === 0) { 342 | if (((Math.random() * 4) | 0) === 0) { 343 | level.SetBlock(x, floor - 4, 4 + 2 + 16); 344 | } else { 345 | level.SetBlock(x, floor - 4, 4 + 1 + 16); 346 | } 347 | } else if (((Math.random() * 4) | 0) === 0) { 348 | if (((Math.random() * 4) | 0) === 0) { 349 | level.SetBlock(x, floor - 4, 2 + 16); 350 | } else { 351 | level.SetBlock(x, floor - 4, 1 + 16); 352 | } 353 | } else { 354 | level.SetBlock(x, floor - 4, 16); 355 | } 356 | } 357 | } 358 | } 359 | } 360 | }, 361 | 362 | FixWalls: function(level) { 363 | var blockMap = [], x = 0, y = 0, xx = 0, yy = 0, blocks = 0; 364 | 365 | for (x = 0; x < this.Width + 1; x++) { 366 | blockMap[x] = []; 367 | 368 | for (y = 0; y < this.Height + 1; y++) { 369 | blocks = 0; 370 | for (xx = x - 1; xx < x + 1; xx++) { 371 | for (yy = y - 1; yy < y + 1; yy++) { 372 | if (level.GetBlockCapped(xx, yy) === (1 + 9 * 16)) { 373 | blocks++; 374 | } 375 | } 376 | } 377 | blockMap[x][y] = blocks === 4; 378 | } 379 | } 380 | 381 | this.Blockify(level, blockMap, this.Width + 1, this.Height + 1); 382 | }, 383 | 384 | Blockify: function(level, blocks, width, height) { 385 | var to = 0, b = [], x = 0, y = 0, xx = 0, yy = 0, i = 0, _xx = 0, _yy = 0; 386 | 387 | for (i = 0; i < 2; i++) { 388 | b[i] = []; 389 | } 390 | 391 | if (this.Type === Mario.LevelType.Castle) { 392 | to = 8; 393 | } else if (this.Type === Mario.LevelType.Underground) { 394 | to = 12; 395 | } 396 | 397 | for (x = 0; x < width; x++) { 398 | for (y = 0; y < height; y++) { 399 | for (xx = x; xx <= x + 1; xx++) { 400 | for (yy = y; yy <= y + 1; yy++) { 401 | _xx = xx; 402 | _yy = yy; 403 | if (_xx < 0) { 404 | _xx = 0; 405 | } 406 | if (_yy < 0) { 407 | _yy = 0; 408 | } 409 | if (_xx > width - 1) { 410 | _xx = width - 1; 411 | } 412 | if (_yy > height - 1) { 413 | _yy = height - 1; 414 | } 415 | 416 | b[xx - x][yy - y] = blocks[_xx][_yy]; 417 | } 418 | } 419 | 420 | if (b[0][0] === b[1][0] && b[0][1] === b[1][1]) { 421 | if (b[0][0] === b[0][1]) { 422 | if (b[0][0]) { 423 | level.SetBlock(x, y, 1 + 9 * 16 + to); 424 | } 425 | } else { 426 | if (b[0][0]) { 427 | level.SetBlock(x, y, 1 + 10 * 16 + to); 428 | } else { 429 | level.SetBlock(x, y, 1 + 8 * 16 + to); 430 | } 431 | } 432 | } else if (b[0][0] === b[0][1] && b[1][0] === b[1][1]) { 433 | if (b[0][0]) { 434 | level.SetBlock(x, y, 2 + 9 * 16 + to); 435 | } else { 436 | level.SetBlock(x, y, 9 * 16 + to); 437 | } 438 | } else if (b[0][0] === b[1][1] && b[0][1] === b[1][0]) { 439 | level.SetBlock(x, y, 1 + 9 * 16 + to); 440 | } else if (b[0][0] === b[1][0]) { 441 | if (b[0][0]) { 442 | if (b[0][1]) { 443 | level.SetBlock(x, y, 3 + 10 * 16 + to); 444 | } else { 445 | level.SetBlock(x, y, 3 + 11 * 16 + to); 446 | } 447 | } else { 448 | if (b[0][1]) { 449 | level.SetBlock(x, y, 2 + 8 * 16 + to); 450 | } else { 451 | level.SetBlock(x, y, 8 * 16 + to); 452 | } 453 | } 454 | } else if (b[0][1] === b[1][1]) { 455 | if (b[0][1]) { 456 | if (b[0][0]) { 457 | level.SetBlock(x, y, 3 + 9 * 16 + to); 458 | } else { 459 | level.SetBlock(x, y, 3 + 8 * 16 + to); 460 | } 461 | } else { 462 | if (b[0][0]) { 463 | level.SetBlock(x, y, 2 + 10 * 16 + to); 464 | } else { 465 | level.SetBlock(x, y, 10 * 16 + to); 466 | } 467 | } 468 | } else { 469 | level.SetBlock(x, y, 1 + 16 * to); 470 | } 471 | } 472 | } 473 | } 474 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/levelRenderer.js: -------------------------------------------------------------------------------- 1 | /** 2 | Renders a playable level. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.LevelRenderer = function(level, width, height) { 7 | this.Width = width; 8 | this.Height = height; 9 | this.Level = level; 10 | this.TilesY = ((height / 16) | 0) + 1; 11 | this.Delta = 0; 12 | this.Tick = 0; 13 | this.Bounce = 0; 14 | this.AnimTime = 0; 15 | 16 | this.Background = Mario.SpriteCuts.GetLevelSheet(); 17 | }; 18 | 19 | Mario.LevelRenderer.prototype = new Enjine.Drawable(); 20 | 21 | Mario.LevelRenderer.prototype.Update = function(delta) { 22 | this.AnimTime += delta; 23 | this.Tick = this.AnimTime | 0; 24 | this.Bounce += delta * 30; 25 | this.Delta = delta; 26 | }; 27 | 28 | Mario.LevelRenderer.prototype.Draw = function(context, camera) { 29 | this.DrawStatic(context, camera); 30 | this.DrawDynamic(context, camera); 31 | }; 32 | 33 | Mario.LevelRenderer.prototype.DrawStatic = function(context, camera) { 34 | var x = 0, y = 0, b = 0, frame = null, xTileStart = (camera.X / 16) | 0, xTileEnd = ((camera.X + this.Width) / 16) | 0; 35 | 36 | for (x = xTileStart; x < xTileEnd + 1; x++) { 37 | for (y = 0; y < this.TilesY; y++) { 38 | b = this.Level.GetBlock(x, y) & 0xff; 39 | if ((Mario.Tile.Behaviors[b] & Mario.Tile.Animated) === 0) { 40 | frame = this.Background[b % 16][(b / 16) | 0]; 41 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, ((x << 4) - camera.X) | 0, (y << 4) | 0, frame.Width, frame.Height); 42 | } 43 | } 44 | } 45 | }; 46 | 47 | Mario.LevelRenderer.prototype.DrawDynamic = function(context, camera) { 48 | var x = 0, y = 0, b = 0, animTime = 0, yo = 0, frame = null; 49 | for (x = (camera.X / 16) | 0; x <= ((camera.X + this.Width) / 16) | 0; x++) { 50 | for (y = (camera.Y / 16) | 0; y <= ((camera.Y + this.Height) / 16) | 0; y++) { 51 | b = this.Level.GetBlock(x, y); 52 | 53 | if (((Mario.Tile.Behaviors[b & 0xff]) & Mario.Tile.Animated) > 0) { 54 | animTime = ((this.Bounce / 3) | 0) % 4; 55 | if ((((b % 16) / 4) | 0) === 0 && ((b / 16) | 0) === 1) { 56 | animTime = ((this.Bounce / 2 + (x + y) / 8) | 0) % 20; 57 | if (animTime > 3) { 58 | animTime = 0; 59 | } 60 | } 61 | if ((((b % 16) / 4) | 0) === 3 && ((b / 16) | 0) === 0) { 62 | animTime = 2; 63 | } 64 | yo = 0; 65 | if (x >= 0 && y >= 0 && x < this.Level.Width && y < this.Level.Height) { 66 | yo = this.Level.Data[x][y]; 67 | } 68 | if (yo > 0) { 69 | yo = (Math.sin((yo - this.Delta) / 4 * Math.PI) * 8) | 0; 70 | } 71 | frame = this.Background[(((b % 16) / 4) | 0) * 4 + animTime][(b / 16) | 0]; 72 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, (x << 4) - camera.X, (y << 4) - camera.Y - yo, frame.Width, frame.Height); 73 | } 74 | } 75 | } 76 | }; 77 | 78 | Mario.LevelRenderer.prototype.DrawExit0 = function(context, camera, bar) { 79 | var y = 0, yh = 0, frame = null; 80 | for (y = this.Level.ExitY - 8; y < this.Level.ExitY; y++) { 81 | frame = this.Background[12][y === this.Level.ExitY - 8 ? 4 : 5]; 82 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, (this.Level.ExitX << 4) - camera.X - 16, (y << 4) - camera.Y, frame.Width, frame.Height); 83 | } 84 | 85 | if (bar) { 86 | yh = this.Level.ExitY * 16 - (3 * 16) - (Math.sin(this.AnimTime) * 3 * 16) - 8;// - ((Math.sin(((this.Bounce + this.Delta) / 20) * 0.5 + 0.5) * 7 * 16) | 0) - 8; 87 | frame = this.Background[12][3]; 88 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, (this.Level.ExitX << 4) - camera.X - 16, yh - camera.Y, frame.Width, frame.Height); 89 | frame = this.Background[13][3]; 90 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, (this.Level.ExitX << 4) - camera.X, yh - camera.Y, frame.Width, frame.Height); 91 | } 92 | }; 93 | 94 | Mario.LevelRenderer.prototype.DrawExit1 = function(context, camera) { 95 | var y = 0, frame = null; 96 | for (y = this.Level.ExitY - 8; y < this.Level.ExitY; y++) { 97 | frame = this.Background[13][y === this.Level.ExitY - 8 ? 4 : 5]; 98 | context.drawImage(Enjine.Resources.Images["map"], frame.X, frame.Y, frame.Width, frame.Height, (this.Level.ExitX << 4) - camera.X + 16, (y << 4) - camera.Y, frame.Width, frame.Height); 99 | } 100 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/levelState.js: -------------------------------------------------------------------------------- 1 | /** 2 | State for actually playing a randomly generated level. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.LevelState = function(difficulty, type) { 7 | this.LevelDifficulty = difficulty; 8 | this.LevelType = type; 9 | this.Level = null; 10 | this.Layer = null; 11 | this.BgLayer = []; 12 | 13 | this.Paused = false; 14 | this.Sprites = null; 15 | this.SpritesToAdd = null; 16 | this.SpritesToRemove = null; 17 | this.Camera = null; 18 | this.ShellsToCheck = null; 19 | this.FireballsToCheck = null; 20 | 21 | this.FontShadow = null; 22 | this.Font = null; 23 | 24 | this.TimeLeft = 0; 25 | this.StartTime = 0; 26 | this.FireballsOnScreen = 0; 27 | this.Tick = 0; 28 | 29 | this.Delta = 0; 30 | 31 | this.GotoMapState = false; 32 | this.GotoLoseState = false; 33 | }; 34 | 35 | Mario.LevelState.prototype = new Enjine.GameState(); 36 | 37 | Mario.LevelState.prototype.Enter = function() { 38 | var levelGenerator = new Mario.LevelGenerator(320, 15), i = 0, scrollSpeed = 0, w = 0, h = 0, bgLevelGenerator = null; 39 | this.Level = levelGenerator.CreateLevel(this.LevelType, this.LevelDifficulty); 40 | 41 | //play music here 42 | if (this.LevelType === Mario.LevelType.Overground) { 43 | Mario.PlayOvergroundMusic(); 44 | } else if (this.LevelType === Mario.LevelType.Underground) { 45 | Mario.PlayUndergroundMusic(); 46 | } else if (this.LevelType === Mario.LevelType.Castle) { 47 | Mario.PlayCastleMusic(); 48 | } 49 | 50 | this.Paused = false; 51 | this.Layer = new Mario.LevelRenderer(this.Level, 320, 240); 52 | this.Sprites = new Enjine.DrawableManager(); 53 | this.Camera = new Enjine.Camera(); 54 | this.Tick = 0; 55 | 56 | this.ShellsToCheck = []; 57 | this.FireballsToCheck = []; 58 | this.SpritesToAdd = []; 59 | this.SpritesToRemove = []; 60 | 61 | this.FontShadow = Mario.SpriteCuts.CreateBlackFont(); 62 | this.Font = Mario.SpriteCuts.CreateWhiteFont(); 63 | 64 | for (i = 0; i < 2; i++) { 65 | scrollSpeed = 4 >> i; 66 | w = ((((this.Level.Width * 16) - 320) / scrollSpeed) | 0) + 320; 67 | h = ((((this.Level.Height * 16) - 240) / scrollSpeed) | 0) + 240; 68 | bgLevelGenerator = new Mario.BackgroundGenerator(w / 32 + 1, h / 32 + 1, i === 0, this.LevelType); 69 | this.BgLayer[i] = new Mario.BackgroundRenderer(bgLevelGenerator.CreateLevel(), 320, 240, scrollSpeed); 70 | } 71 | 72 | Mario.MarioCharacter.Initialize(this); 73 | 74 | this.Sprites.Add(Mario.MarioCharacter); 75 | this.StartTime = 1; 76 | this.TimeLeft = 200; 77 | 78 | this.GotoMapState = false; 79 | this.GotoLoseState = false; 80 | }; 81 | 82 | Mario.LevelState.prototype.Exit = function() { 83 | 84 | delete this.Level; 85 | delete this.Layer; 86 | delete this.BgLayer; 87 | delete this.Sprites; 88 | delete this.Camera; 89 | delete this.ShellsToCheck; 90 | delete this.FireballsToCheck; 91 | delete this.FontShadow; 92 | delete this.Font; 93 | }; 94 | 95 | Mario.LevelState.prototype.CheckShellCollide = function(shell) { 96 | this.ShellsToCheck.push(shell); 97 | }; 98 | 99 | Mario.LevelState.prototype.CheckFireballCollide = function(fireball) { 100 | this.FireballsToCheck.push(fireball); 101 | }; 102 | 103 | Mario.LevelState.prototype.Update = function(delta) { 104 | var i = 0, j = 0, xd = 0, yd = 0, sprite = null, hasShotCannon = false, xCannon = 0, x = 0, y = 0, 105 | dir = 0, st = null, b = 0; 106 | 107 | this.Delta = delta; 108 | 109 | this.TimeLeft -= delta; 110 | if ((this.TimeLeft | 0) === 0) { 111 | Mario.MarioCharacter.Die(); 112 | } 113 | 114 | if (this.StartTime > 0) { 115 | this.StartTime++; 116 | } 117 | 118 | this.Camera.X = Mario.MarioCharacter.X - 160; 119 | if (this.Camera.X < 0) { 120 | this.Camera.X = 0; 121 | } 122 | if (this.Camera.X > this.Level.Width * 16 - 320) { 123 | this.Camera.X = this.Level.Width * 16 - 320; 124 | } 125 | 126 | this.FireballsOnScreen = 0; 127 | 128 | for (i = 0; i < this.Sprites.Objects.length; i++) { 129 | sprite = this.Sprites.Objects[i]; 130 | if (sprite !== Mario.MarioCharacter) { 131 | xd = sprite.X - this.Camera.X; 132 | yd = sprite.Y - this.Camera.Y; 133 | if (xd < -64 || xd > 320 + 64 || yd < -64 || yd > 240 + 64) { 134 | this.Sprites.RemoveAt(i); 135 | } else { 136 | if (sprite instanceof Mario.Fireball) { 137 | this.FireballsOnScreen++; 138 | } 139 | } 140 | } 141 | } 142 | 143 | if (this.Paused) { 144 | for (i = 0; i < this.Sprites.Objects.length; i++) { 145 | if (this.Sprites.Objects[i] === Mario.MarioCharacter) { 146 | this.Sprites.Objects[i].Update(delta); 147 | } else { 148 | this.Sprites.Objects[i].UpdateNoMove(delta); 149 | } 150 | } 151 | } else { 152 | this.Layer.Update(delta); 153 | this.Level.Update(); 154 | 155 | hasShotCannon = false; 156 | xCannon = 0; 157 | this.Tick++; 158 | 159 | for (x = ((this.Camera.X / 16) | 0) - 1; x <= (((this.Camera.X + this.Layer.Width) / 16) | 0) + 1; x++) { 160 | for (y = ((this.Camera.Y / 16) | 0) - 1; y <= (((this.Camera.Y + this.Layer.Height) / 16) | 0) + 1; y++) { 161 | dir = 0; 162 | 163 | if (x * 16 + 8 > Mario.MarioCharacter.X + 16) { 164 | dir = -1; 165 | } 166 | if (x * 16 + 8 < Mario.MarioCharacter.X - 16) { 167 | dir = 1; 168 | } 169 | 170 | st = this.Level.GetSpriteTemplate(x, y); 171 | 172 | if (st !== null) { 173 | if (st.LastVisibleTick !== this.Tick - 1) { 174 | if (st.Sprite === null || !this.Sprites.Contains(st.Sprite)) { 175 | st.Spawn(this, x, y, dir); 176 | } 177 | } 178 | 179 | st.LastVisibleTick = this.Tick; 180 | } 181 | 182 | if (dir !== 0) { 183 | b = this.Level.GetBlock(x, y); 184 | if (((Mario.Tile.Behaviors[b & 0xff]) & Mario.Tile.Animated) > 0) { 185 | if ((((b % 16) / 4) | 0) === 3 && ((b / 16) | 0) === 0) { 186 | if ((this.Tick - x * 2) % 100 === 0) { 187 | xCannon = x; 188 | for (i = 0; i < 8; i++) { 189 | this.AddSprite(new Mario.Sparkle(this, x * 16 + 8, y * 16 + ((Math.random() * 16) | 0), Math.random() * dir, 0, 0, 1, 5)); 190 | } 191 | this.AddSprite(new Mario.BulletBill(this, x * 16 + 8 + dir * 8, y * 16 + 15, dir)); 192 | hasShotCannon = true; 193 | } 194 | } 195 | } 196 | } 197 | } 198 | } 199 | 200 | if (hasShotCannon) { 201 | Enjine.Resources.PlaySound("cannon"); 202 | } 203 | 204 | for (i = 0; i < this.Sprites.Objects.length; i++) { 205 | this.Sprites.Objects[i].Update(delta); 206 | } 207 | 208 | for (i = 0; i < this.Sprites.Objects.length; i++) { 209 | this.Sprites.Objects[i].CollideCheck(); 210 | } 211 | 212 | for (i = 0; i < this.ShellsToCheck.length; i++) { 213 | for (j = 0; j < this.Sprites.Objects.length; j++) { 214 | if (this.Sprites.Objects[j] !== this.ShellsToCheck[i] && !this.ShellsToCheck[i].Dead) { 215 | if (this.Sprites.Objects[j].ShellCollideCheck(this.ShellsToCheck[i])) { 216 | if (Mario.MarioCharacter.Carried === this.ShellsToCheck[i] && !this.ShellsToCheck[i].Dead) { 217 | Mario.MarioCharacter.Carried = null; 218 | this.ShellsToCheck[i].Die(); 219 | } 220 | } 221 | } 222 | } 223 | } 224 | this.ShellsToCheck.length = 0; 225 | 226 | for (i = 0; i < this.FireballsToCheck.length; i++) { 227 | for (j = 0; j < this.Sprites.Objects.length; j++) { 228 | if (this.Sprites.Objects[j] !== this.FireballsToCheck[i] && !this.FireballsToCheck[i].Dead) { 229 | if (this.Sprites.Objects[j].FireballCollideCheck(this.FireballsToCheck[i])) { 230 | this.FireballsToCheck[i].Die(); 231 | } 232 | } 233 | } 234 | } 235 | 236 | this.FireballsToCheck.length = 0; 237 | } 238 | 239 | this.Sprites.AddRange(this.SpritesToAdd); 240 | this.Sprites.RemoveList(this.SpritesToRemove); 241 | this.SpritesToAdd.length = 0; 242 | this.SpritesToRemove.length = 0; 243 | 244 | this.Camera.X = (Mario.MarioCharacter.XOld + (Mario.MarioCharacter.X - Mario.MarioCharacter.XOld) * delta) - 160; 245 | this.Camera.Y = (Mario.MarioCharacter.YOld + (Mario.MarioCharacter.Y - Mario.MarioCharacter.YOld) * delta) - 120; 246 | }; 247 | 248 | Mario.LevelState.prototype.Draw = function(context) { 249 | var i = 0, time = 0, t = 0; 250 | 251 | if (this.Camera.X < 0) { 252 | this.Camera.X = 0; 253 | } 254 | if (this.Camera.Y < 0) { 255 | this.Camera.Y = 0; 256 | } 257 | if (this.Camera.X > this.Level.Width * 16 - 320) { 258 | this.Camera.X = this.Level.Width * 16 - 320; 259 | } 260 | if (this.Camera.Y > this.Level.Height * 16 - 240) { 261 | this.Camera.Y = this.Level.Height * 16 - 240; 262 | } 263 | 264 | for (i = 0; i < 2; i++) { 265 | this.BgLayer[i].Draw(context, this.Camera); 266 | } 267 | 268 | context.save(); 269 | context.translate(-this.Camera.X, -this.Camera.Y); 270 | for (i = 0; i < this.Sprites.Objects.length; i++) { 271 | if (this.Sprites.Objects[i].Layer === 0) { 272 | this.Sprites.Objects[i].Draw(context, this.Camera); 273 | } 274 | } 275 | context.restore(); 276 | 277 | this.Layer.Draw(context, this.Camera); 278 | this.Layer.DrawExit0(context, this.Camera, Mario.MarioCharacter.WinTime === 0); 279 | 280 | context.save(); 281 | context.translate(-this.Camera.X, -this.Camera.Y); 282 | for (i = 0; i < this.Sprites.Objects.length; i++) { 283 | if (this.Sprites.Objects[i].Layer === 1) { 284 | this.Sprites.Objects[i].Draw(context, this.Camera); 285 | } 286 | } 287 | context.restore(); 288 | 289 | this.Layer.DrawExit1(context, this.Camera); 290 | 291 | this.DrawStringShadow(context, "MARIO " + Mario.MarioCharacter.Lives, 0, 0); 292 | this.DrawStringShadow(context, "00000000", 0, 1); 293 | this.DrawStringShadow(context, "COIN", 14, 0); 294 | this.DrawStringShadow(context, " " + Mario.MarioCharacter.Coins, 14, 1); 295 | this.DrawStringShadow(context, "WORLD", 24, 0); 296 | this.DrawStringShadow(context, " " + Mario.MarioCharacter.LevelString, 24, 1); 297 | this.DrawStringShadow(context, "TIME", 34, 0); 298 | time = this.TimeLeft | 0; 299 | if (time < 0) { 300 | time = 0; 301 | } 302 | this.DrawStringShadow(context, " " + time, 34, 1); 303 | 304 | if (this.StartTime > 0) { 305 | t = this.StartTime + this.Delta - 2; 306 | t = t * t * 0.6; 307 | this.RenderBlackout(context, 160, 120, t | 0); 308 | } 309 | 310 | if (Mario.MarioCharacter.WinTime > 0) { 311 | Mario.StopMusic(); 312 | t = Mario.MarioCharacter.WinTime + this.Delta; 313 | t = t * t * 0.2; 314 | 315 | if (t > 900) { 316 | //TODO: goto map state with level won 317 | Mario.GlobalMapState.LevelWon(); 318 | this.GotoMapState = true; 319 | } 320 | 321 | this.RenderBlackout(context, ((Mario.MarioCharacter.XDeathPos - this.Camera.X) | 0), ((Mario.MarioCharacter.YDeathPos - this.Camera.Y) | 0), (320 - t) | 0); 322 | } 323 | 324 | if (Mario.MarioCharacter.DeathTime > 0) { 325 | Mario.StopMusic(); 326 | t = Mario.MarioCharacter.DeathTime + this.Delta; 327 | t = t * t * 0.1; 328 | 329 | if (t > 900) { 330 | //TODO: goto map with level lost 331 | Mario.MarioCharacter.Lives--; 332 | this.GotoMapState = true; 333 | if (Mario.MarioCharacter.Lives <= 0) { 334 | this.GotoLoseState = true; 335 | } 336 | } 337 | 338 | this.RenderBlackout(context, ((Mario.MarioCharacter.XDeathPos - this.Camera.X) | 0), ((Mario.MarioCharacter.YDeathPos - this.Camera.Y) | 0), (320 - t) | 0); 339 | } 340 | }; 341 | 342 | Mario.LevelState.prototype.DrawStringShadow = function(context, string, x, y) { 343 | this.Font.Strings[0] = { String: string, X: x * 8 + 4, Y: y * 8 + 4 }; 344 | this.FontShadow.Strings[0] = { String: string, X: x * 8 + 5, Y: y * 8 + 5 }; 345 | this.FontShadow.Draw(context, this.Camera); 346 | this.Font.Draw(context, this.Camera); 347 | }; 348 | 349 | Mario.LevelState.prototype.RenderBlackout = function(context, x, y, radius) { 350 | if (radius > 320) { 351 | return; 352 | } 353 | 354 | var xp = [], yp = [], i = 0; 355 | for (i = 0; i < 16; i++) { 356 | xp[i] = x + (Math.cos(i * Math.PI / 15) * radius) | 0; 357 | yp[i] = y + (Math.sin(i * Math.PI / 15) * radius) | 0; 358 | } 359 | xp[16] = 0; 360 | yp[16] = y; 361 | xp[17] = 0; 362 | yp[17] = 240; 363 | xp[18] = 320; 364 | yp[18] = 240; 365 | xp[19] = 320; 366 | yp[19] = y; 367 | 368 | context.fillStyle = "#000"; 369 | context.beginPath(); 370 | context.moveTo(xp[19], yp[19]); 371 | for (i = 18; i >= 0; i--) { 372 | context.lineTo(xp[i], yp[i]); 373 | } 374 | context.closePath(); 375 | context.fill(); 376 | 377 | for (i = 0; i < 16; i++) { 378 | xp[i] = x - (Math.cos(i * Math.PI / 15) * radius) | 0; 379 | yp[i] = y - (Math.sin(i * Math.PI / 15) * radius) | 0; 380 | } 381 | //cure a strange problem where the circle gets cut 382 | yp[15] += 5; 383 | 384 | xp[16] = 320; 385 | yp[16] = y; 386 | xp[17] = 320; 387 | yp[17] = 0; 388 | xp[18] = 0; 389 | yp[18] = 0; 390 | xp[19] = 0; 391 | yp[19] = y; 392 | 393 | context.fillStyle = "#000"; 394 | context.beginPath(); 395 | context.moveTo(xp[0], yp[0]); 396 | for (i = 0; i <= xp.length - 1; i++) { 397 | context.lineTo(xp[i], yp[i]); 398 | } 399 | context.closePath(); 400 | context.fill(); 401 | }; 402 | 403 | Mario.LevelState.prototype.AddSprite = function(sprite) { 404 | this.Sprites.Add(sprite); 405 | }; 406 | 407 | Mario.LevelState.prototype.RemoveSprite = function(sprite) { 408 | this.Sprites.Remove(sprite); 409 | }; 410 | 411 | Mario.LevelState.prototype.Bump = function(x, y, canBreakBricks) { 412 | var block = this.Level.GetBlock(x, y), xx = 0, yy = 0; 413 | 414 | if ((Mario.Tile.Behaviors[block & 0xff] & Mario.Tile.Bumpable) > 0) { 415 | this.BumpInto(x, y - 1); 416 | this.Level.SetBlock(x, y, 4); 417 | this.Level.SetBlockData(x, y, 4); 418 | 419 | if ((Mario.Tile.Behaviors[block & 0xff] & Mario.Tile.Special) > 0) { 420 | Enjine.Resources.PlaySound("sprout"); 421 | if (!Mario.MarioCharacter.Large) { 422 | this.AddSprite(new Mario.Mushroom(this, x * 16 + 8, y * 16 + 8)); 423 | } else { 424 | this.AddSprite(new Mario.FireFlower(this, x * 16 + 8, y * 16 + 8)); 425 | } 426 | } else { 427 | Mario.MarioCharacter.GetCoin(); 428 | Enjine.Resources.PlaySound("coin"); 429 | this.AddSprite(new Mario.CoinAnim(this, x, y)); 430 | } 431 | } 432 | 433 | if ((Mario.Tile.Behaviors[block & 0xff] & Mario.Tile.Breakable) > 0) { 434 | this.BumpInto(x, y - 1); 435 | if (canBreakBricks) { 436 | Enjine.Resources.PlaySound("breakblock"); 437 | this.Level.SetBlock(x, y, 0); 438 | for (xx = 0; xx < 2; xx++) { 439 | for (yy = 0; yy < 2; yy++) { 440 | this.AddSprite(new Mario.Particle(this, x * 16 + xx * 8 + 4, y * 16 + yy * 8 + 4, (xx * 2 - 1) * 4, (yy * 2 - 1) * 4 - 8)); 441 | } 442 | } 443 | } 444 | } 445 | }; 446 | 447 | Mario.LevelState.prototype.BumpInto = function(x, y) { 448 | var block = this.Level.GetBlock(x, y), i = 0; 449 | if (((Mario.Tile.Behaviors[block & 0xff]) & Mario.Tile.PickUpable) > 0) { 450 | Mario.MarioCharacter.GetCoin(); 451 | Enjine.Resources.PlaySound("coin"); 452 | this.Level.SetBlock(x, y, 0); 453 | this.AddSprite(new Mario.CoinAnim(x, y + 1)); 454 | } 455 | 456 | for (i = 0; i < this.Sprites.Objects.length; i++) { 457 | this.Sprites.Objects[i].BumpCheck(x, y); 458 | } 459 | }; 460 | 461 | Mario.LevelState.prototype.CheckForChange = function(context) { 462 | if (this.GotoLoseState) { 463 | context.ChangeState(new Mario.LoseState()); 464 | } 465 | else { 466 | if (this.GotoMapState) { 467 | context.ChangeState(Mario.GlobalMapState); 468 | } 469 | } 470 | }; 471 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/loadingState.js: -------------------------------------------------------------------------------- 1 | /** 2 | State that loads all the resources for the game. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.LoadingState = function() { 7 | this.Images = []; 8 | this.ImagesLoaded = false; 9 | this.ScreenColor = 0; 10 | this.ColorDirection = 1; 11 | this.ImageIndex = 0; 12 | this.SoundIndex = 0; 13 | }; 14 | 15 | Mario.LoadingState.prototype = new Enjine.GameState(); 16 | 17 | Mario.LoadingState.prototype.Enter = function() { 18 | var i = 0; 19 | for (i = 0; i < 15; i++) { 20 | this.Images[i] = {}; 21 | } 22 | 23 | this.Images[0].name = "background"; 24 | this.Images[1].name = "endScene"; 25 | this.Images[2].name = "enemies"; 26 | this.Images[3].name = "fireMario"; 27 | this.Images[4].name = "font"; 28 | this.Images[5].name = "gameOverGhost"; 29 | this.Images[6].name = "items"; 30 | this.Images[7].name = "logo"; 31 | this.Images[8].name = "map"; 32 | this.Images[9].name = "mario"; 33 | this.Images[10].name = "particles"; 34 | this.Images[11].name = "racoonMario"; 35 | this.Images[12].name = "smallMario"; 36 | this.Images[13].name = "title"; 37 | this.Images[14].name = "worldMap"; 38 | 39 | this.Images[0].src = "images/bgsheet.png"; 40 | this.Images[1].src = "images/endscene.gif"; 41 | this.Images[2].src = "images/enemysheet.png"; 42 | this.Images[3].src = "images/firemariosheet.png"; 43 | this.Images[4].src = "images/font.gif"; 44 | this.Images[5].src = "images/gameovergost.gif"; 45 | this.Images[6].src = "images/itemsheet.png"; 46 | this.Images[7].src = "images/logo.gif"; 47 | this.Images[8].src = "images/mapsheet.png"; 48 | this.Images[9].src = "images/mariosheet.png"; 49 | this.Images[10].src = "images/particlesheet.png"; 50 | this.Images[11].src = "images/racoonmariosheet.png"; 51 | this.Images[12].src = "images/smallmariosheet.png"; 52 | this.Images[13].src = "images/title.gif"; 53 | this.Images[14].src = "images/worldmap.png"; 54 | 55 | Enjine.Resources.AddImages(this.Images); 56 | 57 | var testAudio = new Audio(); 58 | 59 | if (testAudio.canPlayType("audio/mp3")) { 60 | Enjine.Resources.AddSound("1up", "sounds/1-up.mp3", 1) 61 | .AddSound("breakblock", "sounds/breakblock.mp3") 62 | .AddSound("bump", "sounds/bump.mp3", 4) 63 | .AddSound("cannon", "sounds/cannon.mp3") 64 | .AddSound("coin", "sounds/coin.mp3", 5) 65 | .AddSound("death", "sounds/death.mp3", 1) 66 | .AddSound("exit", "sounds/exit.mp3", 1) 67 | .AddSound("fireball", "sounds/fireball.mp3", 1) 68 | .AddSound("jump", "sounds/jump.mp3") 69 | .AddSound("kick", "sounds/kick.mp3") 70 | .AddSound("pipe", "sounds/pipe.mp3", 1) 71 | .AddSound("powerdown", "sounds/powerdown.mp3", 1) 72 | .AddSound("powerup", "sounds/powerup.mp3", 1) 73 | .AddSound("sprout", "sounds/sprout.mp3", 1) 74 | .AddSound("stagestart", "sounds/stagestart.mp3", 1) 75 | .AddSound("stomp", "sounds/stomp.mp3", 2); 76 | } else { 77 | Enjine.Resources.AddSound("1up", "sounds/1-up.wav", 1) 78 | .AddSound("breakblock", "sounds/breakblock.wav") 79 | .AddSound("bump", "sounds/bump.wav", 2) 80 | .AddSound("cannon", "sounds/cannon.wav") 81 | .AddSound("coin", "sounds/coin.wav", 5) 82 | .AddSound("death", "sounds/death.wav", 1) 83 | .AddSound("exit", "sounds/exit.wav", 1) 84 | .AddSound("fireball", "sounds/fireball.wav", 1) 85 | .AddSound("jump", "sounds/jump.wav", 1) 86 | .AddSound("kick", "sounds/kick.wav", 1) 87 | .AddSound("message", "sounds/message.wav", 1) 88 | .AddSound("pipe", "sounds/pipe.wav", 1) 89 | .AddSound("powerdown", "sounds/powerdown.wav", 1) 90 | .AddSound("powerup", "sounds/powerup.wav", 1) 91 | .AddSound("sprout", "sounds/sprout.wav", 1) 92 | .AddSound("stagestart", "sounds/stagestart.wav", 1) 93 | .AddSound("stomp", "sounds/stomp.wav", 1); 94 | } 95 | 96 | //load the array of tile behaviors 97 | Mario.Tile.LoadBehaviors(); 98 | }; 99 | 100 | Mario.LoadingState.prototype.Exit = function() { 101 | delete this.Images; 102 | }; 103 | 104 | Mario.LoadingState.prototype.Update = function(delta) { 105 | if (!this.ImagesLoaded) { 106 | this.ImagesLoaded = true; 107 | var i = 0; 108 | for (i = 0; i < this.Images.length; i++) { 109 | if (Enjine.Resources.Images[this.Images[i].name].complete !== true) { 110 | this.ImagesLoaded = false; 111 | break; 112 | } 113 | } 114 | } 115 | 116 | this.ScreenColor += this.ColorDirection * 255 * delta; 117 | if (this.ScreenColor > 255) { 118 | this.ScreenColor = 255; 119 | this.ColorDirection = -1; 120 | } else if (this.ScreenColor < 0) { 121 | this.ScreenColor = 0; 122 | this.ColorDirection = 1; 123 | } 124 | }; 125 | 126 | Mario.LoadingState.prototype.Draw = function(context) { 127 | if (!this.ImagesLoaded) { 128 | var color = parseInt(this.ScreenColor, 10); 129 | context.fillStyle = "rgb(" + color + "," + color + "," + color + ")"; 130 | context.fillRect(0, 0, 640, 480); 131 | } else { 132 | context.fillStyle = "rgb(0, 0, 0)"; 133 | context.fillRect(0, 0, 640, 480); 134 | } 135 | }; 136 | 137 | Mario.LoadingState.prototype.CheckForChange = function(context) { 138 | if (this.ImagesLoaded) { 139 | //set up the global map state variable 140 | Mario.GlobalMapState = new Mario.MapState(); 141 | 142 | context.ChangeState(new Mario.TitleState()); 143 | } 144 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/loseState.js: -------------------------------------------------------------------------------- 1 | /** 2 | State shown when the player loses! 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.LoseState = function() { 7 | this.drawManager = null; 8 | this.camera = null; 9 | this.gameOver = null; 10 | this.font = null; 11 | this.wasKeyDown = false; 12 | }; 13 | 14 | Mario.LoseState.prototype = new Enjine.GameState(); 15 | 16 | Mario.LoseState.prototype.Enter = function() { 17 | this.drawManager = new Enjine.DrawableManager(); 18 | this.camera = new Enjine.Camera(); 19 | 20 | this.gameOver = new Enjine.AnimatedSprite(); 21 | this.gameOver.Image = Enjine.Resources.Images["gameOverGhost"]; 22 | this.gameOver.SetColumnCount(9); 23 | this.gameOver.SetRowCount(1); 24 | this.gameOver.AddNewSequence("turnLoop", 0, 0, 0, 8); 25 | this.gameOver.PlaySequence("turnLoop", true); 26 | this.gameOver.FramesPerSecond = 1/15; 27 | this.gameOver.X = 112; 28 | this.gameOver.Y = 68; 29 | 30 | this.font = Mario.SpriteCuts.CreateBlackFont(); 31 | this.font.Strings[0] = { String: "Game over!", X: 116, Y: 160 }; 32 | 33 | this.drawManager.Add(this.font); 34 | this.drawManager.Add(this.gameOver); 35 | }; 36 | 37 | Mario.LoseState.prototype.Exit = function() { 38 | this.drawManager.Clear(); 39 | delete this.drawManager; 40 | delete this.camera; 41 | delete this.gameOver; 42 | delete this.font; 43 | }; 44 | 45 | Mario.LoseState.prototype.Update = function(delta) { 46 | this.drawManager.Update(delta); 47 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) { 48 | this.wasKeyDown = true; 49 | } 50 | }; 51 | 52 | Mario.LoseState.prototype.Draw = function(context) { 53 | this.drawManager.Draw(context, this.camera); 54 | }; 55 | 56 | Mario.LoseState.prototype.CheckForChange = function(context) { 57 | if (this.wasKeyDown && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) { 58 | context.ChangeState(new Mario.TitleState()); 59 | } 60 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/midi.js: -------------------------------------------------------------------------------- 1 | !function(e){function n(){var e,n,t,r=navigator.userAgent,i=navigator.appName,o=""+parseFloat(navigator.appVersion),a=parseInt(navigator.appVersion,10);(n=r.indexOf("Opera"))!=-1?(i="Opera",o=r.substring(n+6),(n=r.indexOf("Version"))!=-1&&(o=r.substring(n+8))):(n=r.indexOf("MSIE"))!=-1?(i="Microsoft Internet Explorer",o=r.substring(n+5)):(n=r.indexOf("Trident"))!=-1?(i="Microsoft Internet Explorer",o=(n=r.indexOf("rv:"))!=-1?r.substring(n+3):"0.0"):(n=r.indexOf("Chrome"))!=-1?(i="Chrome",o=r.substring(n+7)):(n=r.indexOf("Android"))!=-1?(i="Android",o=r.substring(n+8)):(n=r.indexOf("Safari"))!=-1?(i="Safari",o=r.substring(n+7),(n=r.indexOf("Version"))!=-1&&(o=r.substring(n+8))):(n=r.indexOf("Firefox"))!=-1?(i="Firefox",o=r.substring(n+8)):(e=r.lastIndexOf(" ")+1)<(n=r.lastIndexOf("/"))&&(i=r.substring(e,n),o=r.substring(n+1),i.toLowerCase()==i.toUpperCase()&&(i=navigator.appName)),(t=o.indexOf(";"))!=-1&&(o=o.substring(0,t)),(t=o.indexOf(" "))!=-1&&(o=o.substring(0,t)),a=parseInt(""+o,10),isNaN(a)&&(o=""+parseFloat(navigator.appVersion),a=parseInt(navigator.appVersion,10));var s=new Object;return s.browserName=i,s.fullVersion=o,s.majorVersion=a,s.appName=navigator.appName,s.userAgent=navigator.userAgent,s.platform=navigator.platform,s}function t(e,n){var t=document.getElementsByTagName("script")[0],r=document.createElement("script");r.onreadystatechange=function(){"loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,n())},r.onload=function(){n()},r.onerror=function(){j("Error: Cannot load JavaScript file "+e)},r.src=e,r.type="text/javascript",t.parentNode.insertBefore(r,t)}function r(e){if(T=Module.ccall("mid_song_read_wave","number",["number","number","number","number"],[L,w,2*N,H]),0==T)return void f();for(var n=Math.pow(2,15),t=0;t0&&MIDIjs.message_callback("Loading instruments: "+num_missing),j("Loading instruments: "+num_missing),0==num_missing){stream=Module.ccall("mid_istream_open_mem","number",["number","number","number"],[x,midiFileArray.length,!1]);var o=32784,a=Module.ccall("mid_create_options","number",["number","number","number","number"],[E.sampleRate,o,1,2*N]);L=Module.ccall("mid_song_load","number",["number","number"],[stream,a]),rval=Module.ccall("mid_istream_close","number",["number"],[stream]),Module.ccall("mid_song_start","void",["number"],[L]),P=E.createScriptProcessor(N,0,1),w=Module._malloc(2*N),P.onaudioprocess=r,P.connect(E.destination),C=setInterval(s,q),MIDIjs.message_callback&&MIDIjs.message_callback("Playing: "+e),j("Playing: "+e+" ...")}},i.send()}function a(){var e=E.createBuffer(1,44100,44100);for(freq=440,i=0;i<48e3;i++)e.getChannelData(0)[i]=0;var n=E.createBufferSource();n.buffer=e,n.connect(E.destination),n.start(0)}function s(){var e=new Object;0!=F?e.time=E.currentTime-F:e.time=0,MIDIjs.player_callback&&MIDIjs.player_callback(e)}function u(e){b(),H=!1,N=S,l(e)}function l(e){F=0,s(),libtimidity_url=B+"libtimidity.js";for(var n=0;n',document.body.appendChild(n)),C=setInterval(I,q),F=0,P=n,j("Playing "+e+" ...")}function v(){if(P){var e=P;e.lastChild.setAttribute("src","midi/silence.mid"),clearInterval(C),P=0}j(V)}function _(e){y();var n=document.getElementById("scorioMIDI");n?n.lastChild.setAttribute("data",e):(n=document.createElement("div"),n.setAttribute("id","scorioMIDI"),n.innerHTML='',document.body&&document.body.appendChild(n)),C=setInterval(I,q),F=0,P=n,j("Playing "+e+" ...")}function y(){if(P){var e=P;e.parentNode.removeChild(e),clearInterval(C),P=0}j(V)}function h(){for(var e=0;e -16 && xMarioD < 16) { 31 | if (yMarioD > -this.Height && yMarioD < Mario.MarioCharacter.Height) { 32 | Mario.MarioCharacter.GetMushroom(); 33 | this.World.RemoveSprite(this); 34 | } 35 | } 36 | }; 37 | 38 | Mario.Mushroom.prototype.Move = function() { 39 | if (this.Life < 9) { 40 | this.Layer = 0; 41 | this.Y--; 42 | this.Life++; 43 | return; 44 | } 45 | 46 | var sideWaysSpeed = 1.75; 47 | this.Layer = 1; 48 | 49 | if (this.Xa > 2) { 50 | this.Facing = 1; 51 | } 52 | if (this.Xa < -2) { 53 | this.Facing = -1; 54 | } 55 | 56 | this.Xa = this.Facing * sideWaysSpeed; 57 | 58 | this.XFlip = this.Facing === -1; 59 | this.RunTime += Math.abs(this.Xa) + 5; 60 | 61 | if (!this.SubMove(this.Xa, 0)) { 62 | this.Facing = -this.Facing; 63 | } 64 | this.OnGround = false; 65 | this.SubMove(0, this.Ya); 66 | 67 | this.Ya *= 0.85; 68 | if (this.OnGround) { 69 | this.Xa *= this.GroundInertia; 70 | } else { 71 | this.Xa *= this.AirInertia; 72 | } 73 | 74 | if (!this.OnGround) { 75 | this.Ya += 2; 76 | } 77 | }; 78 | 79 | Mario.Mushroom.prototype.SubMove = function(xa, ya) { 80 | var collide = false; 81 | 82 | while (xa > 8) { 83 | if (!this.SubMove(8, 0)) { 84 | return false; 85 | } 86 | xa -= 8; 87 | } 88 | while (xa < -8) { 89 | if (!this.SubMove(-8, 0)) { 90 | return false; 91 | } 92 | xa += 8; 93 | } 94 | while (ya > 8) { 95 | if (!this.SubMove(0, 8)) { 96 | return false; 97 | } 98 | ya -= 8; 99 | } 100 | while (ya < -8) { 101 | if (!this.SubMove(0, -8)) { 102 | return false; 103 | } 104 | ya += 8; 105 | } 106 | 107 | if (ya > 0) { 108 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, 0)) { 109 | collide = true; 110 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, 0)) { 111 | collide = true; 112 | } else if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya + 1, xa, ya)) { 113 | collide = true; 114 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya + 1, xa, ya)) { 115 | collide = true; 116 | } 117 | } 118 | if (ya < 0) { 119 | if (this.IsBlocking(this.X + xa, this.Y + ya - this.Height, xa, ya)) { 120 | collide = true; 121 | } else if (collide || this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 122 | collide = true; 123 | } else if (collide || this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 124 | collide = true; 125 | } 126 | } 127 | 128 | if (xa > 0) { 129 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 130 | collide = true; 131 | } 132 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 133 | collide = true; 134 | } 135 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, ya)) { 136 | collide = true; 137 | } 138 | } 139 | if (xa < 0) { 140 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 141 | collide = true; 142 | } 143 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 144 | collide = true; 145 | } 146 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, ya)) { 147 | collide = true; 148 | } 149 | } 150 | 151 | if (collide) { 152 | if (xa < 0) { 153 | this.X = (((this.X - this.Width) / 16) | 0) * 16 + this.Width; 154 | this.Xa = 0; 155 | } 156 | if (xa > 0) { 157 | this.X = (((this.X + this.Width) / 16 + 1) | 0) * 16 - this.Width - 1; 158 | this.Xa = 0; 159 | } 160 | if (ya < 0) { 161 | this.Y = (((this.Y - this.Height) / 16) | 0) * 16 + this.Height; 162 | this.JumpTime = 0; 163 | this.Ya = 0; 164 | } 165 | if (ya > 0) { 166 | this.Y = (((this.Y - 1) / 16 + 1) | 0) * 16 - 1; 167 | this.OnGround = true; 168 | } 169 | 170 | return false; 171 | } else { 172 | this.X += xa; 173 | this.Y += ya; 174 | return true; 175 | } 176 | }; 177 | 178 | Mario.Mushroom.prototype.IsBlocking = function(x, y, xa, ya) { 179 | x = (x / 16) | 0; 180 | y = (y / 16) | 0; 181 | 182 | if (x === (this.X / 16) | 0 && y === (this.Y / 16) | 0) { 183 | return false; 184 | } 185 | 186 | return this.World.Level.IsBlocking(x, y, xa, ya); 187 | }; 188 | 189 | Mario.Mushroom.prototype.BumpCheck = function(x, y) { 190 | if (this.X + this.Width > x * 16 && this.X - this.Width < x * 16 - 16 && y === ((y - 1) / 16) | 0) { 191 | this.Facing = -Mario.MarioCharacter.Facing; 192 | this.Ya = -10; 193 | } 194 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/music.js: -------------------------------------------------------------------------------- 1 | /* 2 | * using cross platform MIDI library MIDI.js http://www.midijs.net/ 3 | */ 4 | 5 | var midifiles = { 6 | "title" : "midi/title.mid", 7 | "map" : "midi/map.mid", 8 | "background" : "midi/background.mid", 9 | "overground" : "midi/overground.mid", 10 | "underground" : "midi/underground.mid", 11 | "castle" : "midi/castle.mid", 12 | }; 13 | 14 | Mario.PlayMusic = function(name) { 15 | if(name in midifiles) 16 | { 17 | // Currently we stop all playing tracks when playing a new one 18 | // MIDIjs can't play multiple at one time 19 | MIDIjs.stop();; 20 | MIDIjs.play(midifiles[name]); 21 | }else{ 22 | console.error("Cannot play music track " + name + " as i have no data for it."); 23 | } 24 | }; 25 | 26 | Mario.PlayTitleMusic = function() { 27 | Mario.PlayMusic("title"); 28 | }; 29 | 30 | Mario.PlayMapMusic = function() { 31 | Mario.PlayMusic("map"); 32 | }; 33 | 34 | Mario.PlayOvergroundMusic = function() { 35 | Mario.PlayMusic("background"); 36 | }; 37 | 38 | Mario.PlayUndergroundMusic = function() { 39 | Mario.PlayMusic("underground"); 40 | }; 41 | 42 | Mario.PlayCastleMusic = function() { 43 | Mario.PlayMusic("castle"); 44 | }; 45 | 46 | Mario.StopMusic = function() { 47 | MIDIjs.stop(); 48 | }; 49 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/notchSprite.js: -------------------------------------------------------------------------------- 1 | /** 2 | Notch made his own sprite class for this game. Rather than hack around my own, 3 | I directly ported his to JavaScript and used that where needed. 4 | Code by Rob Kleffner, 2011 5 | */ 6 | 7 | Mario.NotchSprite = function(image) { 8 | this.XOld = 0; this.YOld = 0; 9 | this.X = 0; this.Y = 0; 10 | this.Xa = 0; this.Ya = 0; 11 | this.XPic = 0; this.YPic = 0; 12 | this.XPicO = 0; this.YPicO = 0; 13 | this.PicWidth = 32; this.PicHeight = 32; 14 | this.XFlip = false; this.YFlip = false; 15 | this.Visible = true; 16 | this.Image = image; 17 | this.Delta = 0; 18 | this.SpriteTemplate = null; 19 | this.Layer = 1; 20 | }; 21 | 22 | Mario.NotchSprite.prototype = new Enjine.Drawable(); 23 | 24 | Mario.NotchSprite.prototype.Draw = function(context, camera) { 25 | var xPixel = 0, yPixel = 0; 26 | if (!this.Visible) { 27 | return; 28 | } 29 | 30 | xPixel = ((this.XOld + (this.X - this.XOld) * this.Delta) | 0) - this.XPicO; 31 | yPixel = ((this.YOld + (this.Y - this.YOld) * this.Delta) | 0) - this.YPicO; 32 | 33 | context.save(); 34 | context.scale(this.XFlip ? -1 : 1, this.YFlip ? -1 : 1); 35 | context.translate(this.XFlip ? -320 : 0, this.YFlip ? -240 : 0); 36 | context.drawImage(this.Image, this.XPic * this.PicWidth, this.YPic * this.PicHeight, this.PicWidth, this.PicHeight, 37 | this.XFlip ? (320 - xPixel - this.PicWidth) : xPixel, this.YFlip ? (240 - yPixel - this.PicHeight) : yPixel, this.PicWidth, this.PicHeight); 38 | context.restore(); 39 | }; 40 | 41 | Mario.NotchSprite.prototype.Update = function(delta) { 42 | this.XOld = this.X; 43 | this.YOld = this.Y; 44 | this.Move(); 45 | this.Delta = delta; 46 | }; 47 | 48 | Mario.NotchSprite.prototype.UpdateNoMove = function(delta) { 49 | this.XOld = this.X; 50 | this.YOld = this.Y; 51 | this.Delta = 0; 52 | }; 53 | 54 | Mario.NotchSprite.prototype.Move = function() { 55 | this.X += this.Xa; 56 | this.Y += this.Ya; 57 | }; 58 | 59 | Mario.NotchSprite.prototype.GetX = function(delta) { 60 | return ((this.XOld + (this.X - this.XOld) * delta) | 0) - this.XPicO; 61 | }; 62 | 63 | Mario.NotchSprite.prototype.GetY = function(delta) { 64 | return ((this.YOld + (this.Y - this.YOld) * delta) | 0) - this.YPicO; 65 | }; 66 | 67 | Mario.NotchSprite.prototype.CollideCheck = function() { }; 68 | 69 | Mario.NotchSprite.prototype.BumpCheck = function(xTile, yTile) { }; 70 | 71 | Mario.NotchSprite.prototype.Release = function(mario) { }; 72 | 73 | Mario.NotchSprite.prototype.ShellCollideCheck = function(shell) { 74 | return false; 75 | }; 76 | 77 | Mario.NotchSprite.prototype.FireballCollideCheck = function(fireball) { 78 | return false; 79 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/particle.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a piece of a broken block. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Particle = function(world, x, y, xa, ya, xPic, yPic) { 7 | this.World = world; 8 | this.X = x; 9 | this.Y = y; 10 | this.Xa = xa; 11 | this.Ya = ya; 12 | this.XPic = (Math.random() * 2) | 0; 13 | this.YPic = 0; 14 | this.XPicO = 4; 15 | this.YPicO = 4; 16 | 17 | this.PicWidth = 8; 18 | this.PicHeight = 8; 19 | this.Life = 10; 20 | 21 | this.Image = Enjine.Resources.Images["particles"]; 22 | }; 23 | 24 | Mario.Particle.prototype = new Mario.NotchSprite(); 25 | 26 | Mario.Particle.prototype.Move = function() { 27 | if (this.Life - this.Delta < 0) { 28 | this.World.RemoveSprite(this); 29 | } 30 | this.Life -= this.Delta; 31 | 32 | this.X += this.Xa; 33 | this.Y += this.Ya; 34 | this.Ya *= 0.95; 35 | this.Ya += 3; 36 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/setup.js: -------------------------------------------------------------------------------- 1 | /** 2 | Just create the global mario object. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | var Mario = {}; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/shell.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a shell that once belonged to a now expired koopa. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Shell = function(world, x, y, type) { 7 | this.World = world; 8 | this.X = x; 9 | this.Y = y; 10 | 11 | this.YPic = type; 12 | this.Image = Enjine.Resources.Images["enemies"]; 13 | 14 | this.XPicO = 8; 15 | this.YPicO = 31; 16 | this.Width = 4; 17 | this.Height = 12; 18 | this.Facing = 0; 19 | this.PicWidth = 16; 20 | this.XPic = 4; 21 | this.Ya = -5; 22 | 23 | this.Dead = false; 24 | this.DeadTime = 0; 25 | this.Carried = false; 26 | 27 | this.GroundInertia = 0.89; 28 | this.AirInertia = 0.89; 29 | this.OnGround = false; 30 | this.Anim = 0; 31 | }; 32 | 33 | Mario.Shell.prototype = new Mario.NotchSprite(); 34 | 35 | Mario.Shell.prototype.FireballCollideCheck = function(fireball) { 36 | if (this.DeadTime !== 0) { 37 | return false; 38 | } 39 | 40 | var xD = fireball.X - this.X, yD = fireball.Y - this.Y; 41 | if (xD > -16 && xD < 16) { 42 | if (yD > -this.Height && yD < fireball.Height) { 43 | if (this.Facing !== 0) { 44 | return true; 45 | } 46 | 47 | Enjine.Resources.PlaySound("kick"); 48 | 49 | this.Xa = fireball.Facing * 2; 50 | this.Ya = -5; 51 | if (this.SpriteTemplate !== null) { 52 | this.SpriteTemplate.IsDead = true; 53 | } 54 | this.DeadTime = 100; 55 | this.YFlip = true; 56 | 57 | return true; 58 | } 59 | } 60 | return false; 61 | }; 62 | 63 | Mario.Shell.prototype.CollideCheck = function() { 64 | if (this.Carried || this.Dead || this.DeadTime > 0) { 65 | return; 66 | } 67 | 68 | var xMarioD = Mario.MarioCharacter.X - this.X, yMarioD = Mario.MarioCharacter.Y - this.Y; 69 | if (xMarioD > -16 && xMarioD < 16) { 70 | if (yMarioD > -this.Height && yMarioD < Mario.MarioCharacter.Height) { 71 | if (Mario.MarioCharacter.Ya > 0 && yMarioD <= 0 && (!Mario.MarioCharacter.OnGround || !Mario.MarioCharacter.WasOnGround)) { 72 | Mario.MarioCharacter.Stomp(this); 73 | if (this.Facing !== 0) { 74 | this.Xa = 0; 75 | this.Facing = 0; 76 | } else { 77 | this.Facing = Mario.MarioCharacter.Facing; 78 | } 79 | } else { 80 | if (this.Facing !== 0) { 81 | Mario.MarioCharacter.GetHurt(); 82 | } else { 83 | Mario.MarioCharacter.Kick(this); 84 | this.Facing = Mario.MarioCharacter.Facing; 85 | } 86 | } 87 | } 88 | } 89 | }; 90 | 91 | Mario.Shell.prototype.Move = function() { 92 | var sideWaysSpeed = 11, i = 0; 93 | if (this.Carried) { 94 | this.World.CheckShellCollide(this); 95 | return; 96 | } 97 | 98 | if (this.DeadTime > 0) { 99 | this.DeadTime--; 100 | 101 | if (this.DeadTime === 0) { 102 | this.DeadTime = 1; 103 | for (i = 0; i < 8; i++) { 104 | this.World.AddSprite(new Mario.Sparkle(((this.X + Math.random() * 16 - 8) | 0) + 4, ((this.Y + Math.random() * 8) | 0) + 4, Math.random() * 2 - 1, Math.random() * -1, 0, 1, 5)); 105 | } 106 | this.World.RemoveSprite(this); 107 | } 108 | 109 | this.X += this.Xa; 110 | this.Y += this.Ya; 111 | this.Ya *= 0.95; 112 | this.Ya += 1; 113 | return; 114 | } 115 | 116 | if (this.Facing !== 0) { 117 | this.Anim++; 118 | } 119 | 120 | if (this.Xa > 2) { 121 | this.Facing = 1; 122 | } 123 | if (this.Xa < -2) { 124 | this.Facing = -1; 125 | } 126 | 127 | this.Xa = this.Facing * sideWaysSpeed; 128 | 129 | if (this.Facing !== 0) { 130 | this.World.CheckShellCollide(this); 131 | } 132 | 133 | this.XFlip = this.Facing === -1; 134 | 135 | this.XPic = ((this.Anim / 2) | 0) % 4 + 3; 136 | 137 | if (!this.SubMove(this.Xa, 0)) { 138 | Enjine.Resources.PlaySound("bump"); 139 | this.Facing = -this.Facing; 140 | } 141 | this.OnGround = false; 142 | this.SubMove(0, this.Ya); 143 | 144 | this.Ya *= 0.85; 145 | if (this.OnGround) { 146 | this.Xa *= this.GroundInertia; 147 | } else { 148 | this.Xa *= this.AirInertia; 149 | } 150 | 151 | if (!this.OnGround) { 152 | this.Ya += 2; 153 | } 154 | }; 155 | 156 | Mario.Shell.prototype.SubMove = function(xa, ya) { 157 | var collide = false; 158 | 159 | while (xa > 8) { 160 | if (!this.SubMove(8, 0)) { 161 | return false; 162 | } 163 | xa -= 8; 164 | } 165 | while (xa < -8) { 166 | if (!this.SubMove(-8, 0)) { 167 | return false; 168 | } 169 | xa += 8; 170 | } 171 | while (ya > 8) { 172 | if (!this.SubMove(0, 8)) { 173 | return false; 174 | } 175 | ya -= 8; 176 | } 177 | while (ya < -8) { 178 | if (!this.SubMove(0, -8)) { 179 | return false; 180 | } 181 | ya += 8; 182 | } 183 | 184 | if (ya > 0) { 185 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, 0)) { 186 | collide = true; 187 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, 0)) { 188 | collide = true; 189 | } else if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya + 1, xa, ya)) { 190 | collide = true; 191 | } else if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya + 1, xa, ya)) { 192 | collide = true; 193 | } 194 | } 195 | if (ya < 0) { 196 | if (this.IsBlocking(this.X + xa, this.Y + ya - this.Height, xa, ya)) { 197 | collide = true; 198 | } else if (collide || this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 199 | collide = true; 200 | } else if (collide || this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 201 | collide = true; 202 | } 203 | } 204 | 205 | if (xa > 0) { 206 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - this.Height, xa, ya)) { 207 | collide = true; 208 | } 209 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 210 | collide = true; 211 | } 212 | if (this.IsBlocking(this.X + xa + this.Width, this.Y + ya, xa, ya)) { 213 | collide = true; 214 | } 215 | } 216 | if (xa < 0) { 217 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - this.Height, xa, ya)) { 218 | collide = true; 219 | } 220 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya - ((this.Height / 2) | 0), xa, ya)) { 221 | collide = true; 222 | } 223 | if (this.IsBlocking(this.X + xa - this.Width, this.Y + ya, xa, ya)) { 224 | collide = true; 225 | } 226 | } 227 | 228 | if (collide) { 229 | if (xa < 0) { 230 | this.X = (((this.X - this.Width) / 16) | 0) * 16 + this.Width; 231 | this.Xa = 0; 232 | } 233 | if (xa > 0) { 234 | this.X = (((this.X + this.Width) / 16 + 1) | 0) * 16 - this.Width - 1; 235 | this.Xa = 0; 236 | } 237 | if (ya < 0) { 238 | this.Y = (((this.Y - this.Height) / 16) | 0) * 16 + this.Height; 239 | this.Ya = 0; 240 | } 241 | if (ya > 0) { 242 | this.Y = (((this.Y - 1) / 16 + 1) | 0) * 16 - 1; 243 | this.OnGround = true; 244 | } 245 | 246 | return false; 247 | } else { 248 | this.X += xa; 249 | this.Y += ya; 250 | return true; 251 | } 252 | }; 253 | 254 | Mario.Shell.prototype.IsBlocking = function(x, y, xa, ya) { 255 | x = (x / 16) | 0; 256 | y = (y / 16) | 0; 257 | 258 | if (x === ((this.X / 16) | 0) && y === ((this.Y / 16) | 0)) { 259 | return false; 260 | } 261 | 262 | var blocking = this.World.Level.IsBlocking(x, y, xa, ya); 263 | 264 | if (blocking && ya === 0 && xa !== 0) { 265 | this.World.Bump(x, y, true); 266 | } 267 | return blocking; 268 | }; 269 | 270 | Mario.Shell.prototype.BumpCheck = function(x, y) { 271 | if (this.X + this.Width > x * 16 && this.X - this.Width < x * 16 + 16 && y === (((this.Y - 1) / 16) | 0)) { 272 | this.Facing = -Mario.MarioCharacter.Facing; 273 | this.Ya = -10; 274 | } 275 | }; 276 | 277 | Mario.Shell.prototype.Die = function() { 278 | this.Dead = true; 279 | this.Carried = false; 280 | this.Xa = -this.Facing * 2; 281 | this.Ya = -5; 282 | this.DeadTime = 100; 283 | }; 284 | 285 | Mario.Shell.prototype.ShellCollideCheck = function(shell) { 286 | if (this.DeadTime !== 0) { 287 | return false; 288 | } 289 | 290 | var xD = shell.X - this.X, yD = shell.Y - this.Y; 291 | if (xD > -16 && xD < 16) { 292 | if (yD > -this.Height && yD < shell.Height) { 293 | Enjine.Resources.PlaySound("kick"); 294 | if (Mario.MarioCharacter.Carried === shell || Mario.MarioCharacter.Carried === this) { 295 | Mario.MarioCharacter.Carried = null; 296 | } 297 | this.Die(); 298 | shell.Die(); 299 | return true; 300 | } 301 | } 302 | return false; 303 | }; 304 | 305 | Mario.Shell.prototype.Release = function(mario) { 306 | this.Carried = false; 307 | this.Facing = Mario.MarioCharacter.Facing; 308 | this.X += this.Facing * 8; 309 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/sparkle.js: -------------------------------------------------------------------------------- 1 | /** 2 | Represents a little sparkle object in the game. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.Sparkle = function(world, x, y, xa, ya) { 7 | this.World = world; 8 | this.X = x; 9 | this.Y = y; 10 | this.Xa = xa; 11 | this.Ya = ya; 12 | this.XPic = (Math.random() * 2) | 0; 13 | this.YPic = 0; 14 | 15 | this.Life = 10 + ((Math.random() * 5) | 0); 16 | this.XPicStart = this.XPic; 17 | this.XPicO = 4; 18 | this.YPicO = 4; 19 | 20 | this.PicWidth = 8; 21 | this.PicHeight = 8; 22 | this.Image = Enjine.Resources.Images["particles"]; 23 | }; 24 | 25 | Mario.Sparkle.prototype = new Mario.NotchSprite(); 26 | 27 | Mario.Sparkle.prototype.Move = function() { 28 | if (this.Life > 10) { 29 | this.XPic = 7; 30 | } else { 31 | this.XPic = (this.XPicStart + (10 - this.Life) * 0.4) | 0; 32 | } 33 | 34 | if (this.Life-- < 0) { 35 | this.World.RemoveSprite(this); 36 | } 37 | 38 | this.X += this.Xa; 39 | this.Y += this.Ya; 40 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/spriteCuts.js: -------------------------------------------------------------------------------- 1 | /** 2 | Helper to cut up the sprites. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.SpriteCuts = { 7 | 8 | /********************* 9 | * Font related 10 | ********************/ 11 | CreateBlackFont: function() { 12 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(0)); 13 | }, 14 | 15 | CreateRedFont: function() { 16 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(8)); 17 | }, 18 | 19 | CreateGreenFont: function() { 20 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(16)); 21 | }, 22 | 23 | CreateBlueFont: function() { 24 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(24)); 25 | }, 26 | 27 | CreateYellowFont: function() { 28 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(32)); 29 | }, 30 | 31 | CreatePinkFont: function() { 32 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(40)); 33 | }, 34 | 35 | CreateCyanFont: function() { 36 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(48)); 37 | }, 38 | 39 | CreateWhiteFont: function() { 40 | return new Enjine.SpriteFont([], Enjine.Resources.Images["font"], 8, 8, this.GetCharArray(56)); 41 | }, 42 | 43 | GetCharArray: function(y) { 44 | var letters = []; 45 | var i = 0; 46 | for (i = 32; i < 127; i++) { 47 | letters[i] = { X: (i - 32) * 8, Y: y }; 48 | } 49 | return letters; 50 | }, 51 | 52 | /********************* 53 | * Spritesheet related 54 | ********************/ 55 | GetBackgroundSheet: function() { 56 | var sheet = []; 57 | var x = 0, y = 0, width = Enjine.Resources.Images["background"].width / 32, height = Enjine.Resources.Images["background"].height / 32; 58 | 59 | for (x = 0; x < width; x++) { 60 | sheet[x] = []; 61 | 62 | for (y = 0; y < height; y++) { 63 | sheet[x][y] = { X: x * 32, Y: y * 32, Width: 32, Height: 32 }; 64 | } 65 | } 66 | return sheet; 67 | }, 68 | 69 | GetLevelSheet: function() { 70 | var sheet = [], x = 0, y = 0, width = Enjine.Resources.Images["map"].width / 16, height = Enjine.Resources.Images["map"].height / 16; 71 | 72 | for (x = 0; x < width; x++) { 73 | sheet[x] = []; 74 | 75 | for (y = 0; y < height; y++) { 76 | sheet[x][y] = { X: x * 16, Y: y * 16, Width: 16, Height: 16 }; 77 | } 78 | } 79 | return sheet; 80 | } 81 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/spriteTemplate.js: -------------------------------------------------------------------------------- 1 | /** 2 | Creates a specific type of sprite based on the information given. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.SpriteTemplate = function(type, winged) { 7 | this.Type = type; 8 | this.Winged = winged; 9 | this.LastVisibleTick = -1; 10 | this.IsDead = false; 11 | this.Sprite = null; 12 | }; 13 | 14 | Mario.SpriteTemplate.prototype = { 15 | Spawn: function(world, x, y, dir) { 16 | if (this.IsDead) { 17 | return; 18 | } 19 | 20 | if (this.Type === Mario.Enemy.Flower) { 21 | this.Sprite = new Mario.FlowerEnemy(world, x * 16 + 15, y * 16 + 24); 22 | } else { 23 | this.Sprite = new Mario.Enemy(world, x * 16 + 8, y * 16 + 15, dir, this.Type, this.Winged); 24 | } 25 | this.Sprite.SpriteTemplate = this; 26 | world.AddSprite(this.Sprite); 27 | } 28 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/titleState.js: -------------------------------------------------------------------------------- 1 | /** 2 | Displays the title screen and menu. 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.TitleState = function() { 7 | this.drawManager = null; 8 | this.camera = null; 9 | this.logoY = null; 10 | this.bounce = null; 11 | this.font = null; 12 | }; 13 | 14 | Mario.TitleState.prototype = new Enjine.GameState(); 15 | 16 | Mario.TitleState.prototype.Enter = function() { 17 | this.drawManager = new Enjine.DrawableManager(); 18 | this.camera = new Enjine.Camera(); 19 | 20 | var bgGenerator = new Mario.BackgroundGenerator(2048, 15, true, Mario.LevelType.Overground); 21 | var bgLayer0 = new Mario.BackgroundRenderer(bgGenerator.CreateLevel(), 320, 240, 2); 22 | bgGenerator.SetValues(2048, 15, false, Mario.LevelType.Overground); 23 | var bgLayer1 = new Mario.BackgroundRenderer(bgGenerator.CreateLevel(), 320, 240, 1); 24 | 25 | this.title = new Enjine.Sprite(); 26 | this.title.Image = Enjine.Resources.Images["title"]; 27 | this.title.X = 0, this.title.Y = 120; 28 | 29 | this.logo = new Enjine.Sprite(); 30 | this.logo.Image = Enjine.Resources.Images["logo"]; 31 | this.logo.X = 0, this.logo.Y = 0; 32 | 33 | this.font = Mario.SpriteCuts.CreateRedFont(); 34 | this.font.Strings[0] = { String: "Press S to Start", X: 96, Y: 120 }; 35 | 36 | this.logoY = 20; 37 | 38 | this.drawManager.Add(bgLayer0); 39 | this.drawManager.Add(bgLayer1); 40 | 41 | this.bounce = 0; 42 | 43 | Mario.GlobalMapState = new Mario.MapState(); 44 | //set up the global main character variable 45 | Mario.MarioCharacter = new Mario.Character(); 46 | Mario.MarioCharacter.Image = Enjine.Resources.Images["smallMario"]; 47 | 48 | Mario.PlayTitleMusic(); 49 | }; 50 | 51 | Mario.TitleState.prototype.Exit = function() { 52 | Mario.StopMusic(); 53 | 54 | this.drawManager.Clear(); 55 | delete this.drawManager; 56 | delete this.camera; 57 | delete this.font; 58 | }; 59 | 60 | Mario.TitleState.prototype.Update = function(delta) { 61 | this.bounce += delta * 2; 62 | this.logoY = 20 + Math.sin(this.bounce) * 10; 63 | 64 | this.camera.X += delta * 25; 65 | 66 | this.drawManager.Update(delta); 67 | }; 68 | 69 | Mario.TitleState.prototype.Draw = function(context) { 70 | this.drawManager.Draw(context, this.camera); 71 | 72 | context.drawImage(Enjine.Resources.Images["title"], 0, 120); 73 | context.drawImage(Enjine.Resources.Images["logo"], 0, this.logoY); 74 | 75 | this.font.Draw(context, this.Camera); 76 | }; 77 | 78 | Mario.TitleState.prototype.CheckForChange = function(context) { 79 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) { 80 | context.ChangeState(Mario.GlobalMapState); 81 | } 82 | }; 83 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/code/winState.js: -------------------------------------------------------------------------------- 1 | /** 2 | State that's shown when the player wins the game! 3 | Code by Rob Kleffner, 2011 4 | */ 5 | 6 | Mario.WinState = function() { 7 | this.waitTime = 2; 8 | this.drawManager = null; 9 | this.camera = null; 10 | this.font = null; 11 | this.kissing = null; 12 | this.wasKeyDown = false; 13 | }; 14 | 15 | Mario.WinState.prototype = new Enjine.GameState(); 16 | 17 | Mario.WinState.prototype.Enter = function() { 18 | this.drawManager = new Enjine.DrawableManager(); 19 | this.camera = new Enjine.Camera(); 20 | 21 | this.font = Mario.SpriteCuts.CreateBlackFont(); 22 | this.font.Strings[0] = { String: "Thank you for saving me, Mario!", X: 36, Y: 160 }; 23 | 24 | this.kissing = new Enjine.AnimatedSprite(); 25 | this.kissing.Image = Enjine.Resources.Images["endScene"]; 26 | this.kissing.X = 112; 27 | this.kissing.Y = 52; 28 | this.kissing.SetColumnCount(2); 29 | this.kissing.SetRowCount(1); 30 | this.kissing.AddNewSequence("loop", 0, 0, 0, 1); 31 | this.kissing.PlaySequence("loop", true); 32 | this.kissing.FramesPerSecond = 1/2; 33 | 34 | this.waitTime = 2; 35 | 36 | this.drawManager.Add(this.font); 37 | this.drawManager.Add(this.kissing); 38 | }; 39 | 40 | Mario.WinState.prototype.Exit = function() { 41 | this.drawManager.Clear(); 42 | delete this.drawManager; 43 | delete this.camera; 44 | }; 45 | 46 | Mario.WinState.prototype.Update = function(delta) { 47 | this.drawManager.Update(delta); 48 | 49 | if (this.waitTime > 0) { 50 | this.waitTime -= delta; 51 | } else { 52 | if (Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) { 53 | this.wasKeyDown = true; 54 | } 55 | } 56 | }; 57 | 58 | Mario.WinState.prototype.Draw = function(context) { 59 | this.drawManager.Draw(context, this.camera); 60 | }; 61 | 62 | Mario.WinState.prototype.CheckForChange = function(context) { 63 | if (this.waitTime <= 0) { 64 | if (this.wasKeyDown && !Enjine.KeyboardInput.IsKeyDown(Enjine.Keys.S)) { 65 | context.ChangeState(new Mario.TitleState()); 66 | } 67 | } 68 | }; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/enjine.min.js: -------------------------------------------------------------------------------- 1 | var Enjine={GameCanvas:function(){this.BackBufferContext2D=this.BackBuffer=this.Context2D=this.Canvas=null}}; 2 | Enjine.GameCanvas.prototype={Initialize:function(a,b,c){this.Canvas=document.getElementById(a);this.Context2D=this.Canvas.getContext("2d");this.BackBuffer=document.createElement("canvas");this.BackBuffer.width=b;this.BackBuffer.height=c;this.BackBufferContext2D=this.BackBuffer.getContext("2d")},BeginDraw:function(){this.BackBufferContext2D.clearRect(0,0,this.BackBuffer.width,this.BackBuffer.height);this.Context2D.clearRect(0,0,this.Canvas.width,this.Canvas.height)},EndDraw:function(){this.Context2D.drawImage(this.BackBuffer, 3 | 0,0,this.BackBuffer.width,this.BackBuffer.height,0,0,this.Canvas.width,this.Canvas.height)}};Enjine.Keys={A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:80,Left:37,Up:38,Right:39,Down:40}; 4 | Enjine.KeyboardInput={Pressed:[],Initialize:function(){var a=this;document.onkeydown=function(b){a.KeyDownEvent(b)};document.onkeyup=function(b){a.KeyUpEvent(b)}},IsKeyDown:function(a){if(this.Pressed[a]!=null)return this.Pressed[a];return!1},KeyDownEvent:function(a){this.Pressed[a.keyCode]=!0;this.PreventScrolling(a)},KeyUpEvent:function(a){this.Pressed[a.keyCode]=!1;this.PreventScrolling(a)},PreventScrolling:function(a){a.keyCode>=37&&a.keyCode<=40&&a.preventDefault()}}; 5 | Enjine.Resources={Images:{},Sounds:{},Destroy:function(){delete this.Images;delete this.Sounds;return this},AddImage:function(a,b){var c=new Image;this.Images[a]=c;c.src=b;return this},AddImages:function(a){for(var b=0;b=this.Sounds[a].length)this.Sounds[a].index=0;b&&this.Sounds[a][this.Sounds[a].index].addEventListener("ended",this.LoopCallback,!1);this.Sounds[a][this.Sounds[a].index++].play();return this.Sounds[a].index},PauseChannel:function(a,b){this.Sounds[a][b].paused|| 7 | this.Sounds[a][b].pause();return this},PauseSound:function(a){for(var b=0;b0))){this.LastElapsed=this.FramesPerSecond;this.FrameX+=this.FrameWidth;if(this.FrameX>this.Image.width-this.FrameWidth&&(this.FrameX=0,this.FrameY+=this.FrameHeight,this.FrameY>this.Image.height-this.FrameHeight))this.FrameY=0;a=!1;this.FrameX>this.CurrentSequence.EndColumn*this.FrameWidth&&this.FrameY==this.CurrentSequence.EndRow*this.FrameHeight?a=!0:this.FrameX== 18 | 0&&this.FrameY>this.CurrentSequence.EndRow*this.FrameHeight&&(a=!0);if(a)this.Looping?(this.FrameX=this.CurrentSequence.StartColumn*this.FrameWidth,this.FrameY=this.CurrentSequence.StartRow*this.FrameHeight):this.Playing=!1}};Enjine.AnimatedSprite.prototype.PlaySequence=function(a,b){this.Playing=!0;this.Looping=b;this.CurrentSequence=this.Sequences["seq_"+a];this.FrameX=this.CurrentSequence.StartColumn*this.FrameWidth;this.FrameY=this.CurrentSequence.StartRow*this.FrameHeight}; 19 | Enjine.AnimatedSprite.prototype.StopLooping=function(){this.Looping=!1};Enjine.AnimatedSprite.prototype.StopPlaying=function(){this.Playing=!1};Enjine.AnimatedSprite.prototype.SetFrameWidth=function(a){this.FrameWidth=a;this.Rows=this.Image.width/this.FrameWidth};Enjine.AnimatedSprite.prototype.SetFrameHeight=function(a){this.FrameHeight=a;this.Columns=this.Image.height/this.FrameHeight};Enjine.AnimatedSprite.prototype.SetColumnCount=function(a){this.FrameWidth=this.Image.width/a;this.Columns=a}; 20 | Enjine.AnimatedSprite.prototype.SetRowCount=function(a){this.FrameHeight=this.Image.height/a;this.Rows=a};Enjine.AnimatedSprite.prototype.AddExistingSequence=function(a,b){this.Sequences["seq_"+a]=b};Enjine.AnimatedSprite.prototype.AddNewSequence=function(a,b,c,d,e){this.Sequences["seq_"+a]=new Enjine.AnimationSequence(b,c,d,e)};Enjine.AnimatedSprite.prototype.DeleteSequence=function(a){this.Sequences["seq_"+a]!=null&&delete this.Sequences["seq_"+a]}; 21 | Enjine.AnimatedSprite.prototype.ClearSequences=function(){delete this.Sequences;this.Sequences={}};Enjine.Collideable=function(a,b,c,d){this.Base=a;this.X=a.X;this.Y=a.Y;this.Width=b;this.Height=c;this.CollisionEvent=d!=null?d:function(){}};Enjine.Collideable.prototype={Update:function(){this.X=this.Base.X;this.Y=this.Base.Y},CheckCollision:function(a){!(this.Y+this.Heighta.Y+a.Height)&&!(this.X+this.Widtha.X+a.Width)&&(this.CollisionEvent(a),a.CollisionEvent(this))}}; 22 | Enjine.Application=function(){this.stateContext=this.timer=this.canvas=null};Enjine.Application.prototype={Update:function(a){this.stateContext.Update(a);this.canvas.BeginDraw();this.stateContext.Draw(this.canvas.BackBufferContext2D);this.canvas.EndDraw()},Initialize:function(a,b,c){this.canvas=new Enjine.GameCanvas;this.timer=new Enjine.GameTimer;Enjine.KeyboardInput.Initialize();this.canvas.Initialize("canvas",b,c);this.timer.UpdateObject=this;this.stateContext=new Enjine.GameStateContext(a);this.timer.Start()}}; -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/flipTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Infinite Mario - JavaScript 5 | 6 | 7 | 8 | 9 |

Your browser does not support the canvas element.

10 |
11 | 30 | 31 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/bgsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/bgsheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/endscene.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/endscene.gif -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/enemysheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/enemysheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/firemariosheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/firemariosheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/font.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/font.gif -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/gameovergost.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/gameovergost.gif -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/itemsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/itemsheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/logo.gif -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/mapsheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/mapsheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/mariosheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/mariosheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/particlesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/particlesheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/racoonmariosheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/racoonmariosheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/smallmariosheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/smallmariosheet.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/title.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/title.gif -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/worldmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/images/worldmap.png -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Infinite Mario - JavaScript 5 | 6 | 7 | 8 | 9 | 10 |

Your browser does not support the canvas element.

11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/background.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/background.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/castle.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/castle.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/map.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/map.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/overground.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/overground.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/title.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/title.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/underground.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/underground.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/midi/urldecode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import urllib 4 | import sys 5 | 6 | with open (sys.argv[1], "r") as myfile: 7 | data=myfile.read() 8 | print "input data: " + data 9 | decoded = urllib.unquote(data) 10 | with open(sys.argv[1] + ".mid", "w") as text_file: 11 | text_file.write("%s" % (decoded)) 12 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/minTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Infinite Mario - JavaScript 5 | 6 | 7 | 8 | 9 |

Your browser does not support the canvas element.

10 |
11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/1-up.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/1-up.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/1-up.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/1-up.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/breakblock.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/breakblock.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/breakblock.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/breakblock.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/bump.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/bump.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/bump.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/bump.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/cannon.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/cannon.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/cannon.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/cannon.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/coin.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/coin.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/coin.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/coin.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/death.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/death.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/death.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/death.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/exit.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/exit.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/exit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/exit.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/fireball.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/fireball.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/fireball.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/fireball.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/jump.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/jump.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/jump.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/jump.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/kick.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/kick.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/kick.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/kick.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/mapmusic.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/mapmusic.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/message.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/message.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/message.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/message.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/pipe.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/pipe.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/pipe.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/pipe.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerdown.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerdown.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerdown.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerdown.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerup.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerup.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/powerup.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3map1.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3map1.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3map1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3map1.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3ovr1.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3ovr1.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3undr.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smb3undr.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwfortress.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwfortress.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwovr1.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwovr1.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwovr2.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwovr2.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwtitle.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwtitle.mid -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwtitle.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/smwtitle.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/sprout.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/sprout.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/sprout.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/sprout.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stagestart.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stagestart.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stagestart.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stagestart.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stomp.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stomp.mp3 -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stomp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WinCCUnifiedbyHecht/CWC_Mariohtml5/0e150db84afb470c60b962234a88ee532c89c0d3/{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/sounds/stomp.wav -------------------------------------------------------------------------------- /{8F2D1D74-4B07-4F7A-8800-1A75071F21B4}/Control/webcc.min.js: -------------------------------------------------------------------------------- 1 | /* Version 1.4.2, copyright (C) 2018, Siemens AG. All Rights Reserved. */ 2 | var WebCC=WebCC||function(){var a="pending",b=-1,c=window.parent,d=null,e=null,f={},g=[],h={},i=function(){window.clearTimeout(b),window.removeEventListener?window.removeEventListener("message",d):window.detachEvent("onmessage",d)},j=function(a,b,c){var d=document.createElement("script");d.setAttribute("type","text/javascript"),d.setAttribute("src",a),(b||c)&&(d.addEventListener?(b&&d.addEventListener("load",b),c&&d.addEventListener("error",function(){c("Failed to load "+a+" library")})):b&&(d.onreadystatechange=function(){"loaded"===this.readyState||"complete"===this.readyState?b():c&&c()})),document.getElementsByTagName("head")?document.getElementsByTagName("head")[0].appendChild(d):document.getElementsByTagName("body")[0].appendChild(d)},k=function(a){return JSON.stringify({t:"boot",c:a})},l=function(b,c,d){var l,m,n,o,p,q,r={},s=null,t=null,u=null;if(("waiting"===a||"ok"===a)&&"string"==typeof b.data&&b.data.length>0){try{if(r=JSON.parse(b.data),!(r&&r.t&&r.c))throw new Error("Incompatible message received");if("boot"!==r.t)throw new Error("Unknown message received: "+r.t)}catch(v){return}if(m=function(b){a="failed",i(),d({message:b}),swacPostMessage(k({message:"failed"}),"*")},"boot"===r.t&&"pong"===r.c.message){if(n=function(){SWAC.isContainer=!1,a="ok",e=r.c,e.containerVersion=e.containerVersion||"1.0.0",swacPostMessage(k({message:"ok"}),"*")},p=function(){var a,b=g.length,c=null;if("undefined"!=typeof SWAC.Hub.prototype.Extensions)c=SWAC.Hub.prototype.Extensions;else{if("undefined"==typeof WebCC)return n(),void 0;c=WebCC.Extensions}if(null!==t){if(Object.keys(c).length!==t+1&&"undefined"==typeof SWACBoot)return m("Invalid Extension"),void 0;for(var d in c)c.hasOwnProperty(d)&&"undefined"!=typeof h[d]&&(c[h[d]]=c[d],delete c[d],delete h[d])}0===b||"undefined"==typeof WebCC&&SWAC._internal.Utils.checkVersion(u,"1.4.1")<0?n():(a=g.pop(),"undefined"==typeof defineExtension?j(a,p,m):"undefined"==typeof SWACBoot&&"undefined"==typeof WebCC.Extensions?(s=/^\s+|\s+$/g,void 0===a||null===a||""===a.replace(s,"")?m("Failed to load SWAC.Config.Control.URLs library"):(l=function(){"undefined"!=typeof WebCC.Extensions?p():m("Failed to load SWAC.Config.Control.URLs library")},j(a,l,m)),s=null):"$$unknownExtension$$"===a?"undefined"!=typeof SWACBoot?p():m("Unknown Extension"):(t=Object.keys(c).length,j(a,p,"undefined"!=typeof SWACBoot?p:m)))},r.c.extensions)for(q in r.c.extensions)r.c.extensions.hasOwnProperty(q)&&g.unshift(r.c.extensions[q]);u=r.c.containerVersion||"1.0.0","undefined"!=typeof SWAC?p():(s=/^\s+|\s+$/g,void 0===r.c.url||null===r.c.url||""===r.c.url.replace(s,"")?m("Failed to load SWAC.Config.Container.URLs library"):(l=function(){"undefined"!=typeof SWAC||"undefined"!=typeof r.c.namespace&&"undefined"!=typeof window[r.c.namespace]?p():m("Failed to load SWAC.Config.Container.URLs library")},a="upgrading",j(r.c.url,l,m)),s=null)}else if("boot"===r.t&&"ok2"===r.c.message){a="done",i();for(o in e)e.hasOwnProperty(o)&&(f[o]=e[o]);e.message="SWAC successfully loaded",e.auth=e.authentication,delete e.authentication,delete e.url,delete e.extensions,delete e.namespace,r.c.details||(f.details={path:[""]});for(o in r.c)"message"!==o&&r.c.hasOwnProperty(o)&&(f.hasOwnProperty(o)||(f[o]=r.c[o]));delete e._internal,SWAC.Hub.prototype.containerVersion=e.containerVersion,c(e)}else"boot"===r.t&&"peng"===r.c.message&&(i(),d({message:r.c.reason}))}},m=function(){if(c===self){if("object"==typeof swacNative&&"function"==typeof swacNative.postMessage)return swacNative.postMessage;if(window.external&&"function"==typeof window.external.postMessage)return window.external.postMessage}return null},n=function(e,g,j,n,o){j=j||"*",o=o||1e3,g=g||function(){},n=n||"no";var p,q,r,s=[];if("done"===a)return window.setTimeout(function(){g({message:"Boot phase already done"})},0),void 0;if(p=m(),c===self&&"function"!=typeof p&&"function"!=typeof window.swacPostMessage)a="failed",f.details={path:[""]},window.setTimeout(function(){g({message:"Component is not embedded into an iframe"})},0);else{if("function"!=typeof window.swacPostMessage&&(window.swacPostMessage="function"==typeof p?p:function(a,b){return c.postMessage(a,b)}),d=function(a){l(a,e,g)},a="waiting",window.addEventListener?window.addEventListener("message",d,!1):window.attachEvent("onmessage",d),b=window.setTimeout(function(){"done"!==a&&(a="timedout",f.details={path:[""]},i(),g({message:"Bootload sequence timed out"}))},o),null!==arguments[6]&&"undefined"!=typeof arguments[6])for(r=0;r