forked from robertkleffner/mariohtml5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt the Mario to the structure of a CustomWebControl
Adapt the Mario to the structure of a CustomWebControl. Add the WebCC.min for the communication in WinCC Unified
- Loading branch information
1 parent
bf8e599
commit 5858e41
Showing
121 changed files
with
5,791 additions
and
5,723 deletions.
There are no files selected for viewing
278 changes: 139 additions & 139 deletions
278
Enjine/animatedSprite.js → ...71F21B4}/Control/Enjine/animatedSprite.js
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,140 @@ | ||
/** | ||
Class to represent an uninterrupted set of frames to animate. | ||
*/ | ||
|
||
Enjine.AnimationSequence = function(startRow, startColumn, endRow, endColumn) { | ||
this.StartRow = startRow; | ||
this.StartColumn = startColumn; | ||
this.EndRow = endRow; | ||
this.EndColumn = endColumn; | ||
|
||
//sometimes in an animated sprite, we want it to behave like a regular sprite (static) | ||
//this variable will keep it from wasting time updating animation when the sequence | ||
//is only a single frame long, for things like standing or pausing action | ||
this.SingleFrame = false; | ||
|
||
if ((this.StartRow == this.EndRow) && (this.StartColumn == this.EndColumn)) { | ||
this.SingleFrame = true; | ||
} | ||
}; | ||
|
||
/** | ||
Subclass that extends the regular sprite with animation capability. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.AnimatedSprite = function() { | ||
this.LastElapsed = 0; | ||
this.FramesPerSecond = 1 / 20; | ||
this.CurrentSequence = null; | ||
this.Playing = false; | ||
this.Looping = false; | ||
this.Rows = 0; | ||
this.Columns = 0; | ||
|
||
//cheesy dictionary hack to make animation sequences more accessible | ||
this.Sequences = new Object(); | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype = new Enjine.FrameSprite(); | ||
|
||
Enjine.AnimatedSprite.prototype.Update = function(delta) { | ||
if (this.CurrentSequence.SingleFrame) { | ||
return; | ||
} | ||
if (!this.Playing) { | ||
return; | ||
} | ||
|
||
this.LastElapsed -= delta; | ||
|
||
if (this.LastElapsed > 0) { | ||
return; | ||
} | ||
|
||
this.LastElapsed = this.FramesPerSecond; | ||
this.FrameX += this.FrameWidth; | ||
|
||
//increment the frame | ||
if (this.FrameX > (this.Image.width - this.FrameWidth)) { | ||
this.FrameX = 0; | ||
this.FrameY += this.FrameHeight; | ||
|
||
if (this.FrameY > (this.Image.height - this.FrameHeight)) { | ||
this.FrameY = 0; | ||
} | ||
} | ||
|
||
//check if it's at the end of the animation sequence | ||
var seqEnd = false; | ||
if ((this.FrameX > (this.CurrentSequence.EndColumn * this.FrameWidth)) && (this.FrameY == (this.CurrentSequence.EndRow * this.FrameHeight))) { | ||
seqEnd = true; | ||
} else if (this.FrameX == 0 && (this.FrameY > (this.CurrentSequence.EndRow * this.FrameHeight))) { | ||
seqEnd = true; | ||
} | ||
|
||
//go back to the beginning if looping, otherwise stop playing | ||
if (seqEnd) { | ||
if (this.Looping) { | ||
this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; | ||
this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; | ||
} else { | ||
this.Playing = false; | ||
} | ||
} | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.PlaySequence = function(seqName, loop) { | ||
this.Playing = true; | ||
this.Looping = loop; | ||
this.CurrentSequence = this.Sequences["seq_" + seqName]; | ||
this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; | ||
this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.StopLooping = function() { | ||
this.Looping = false; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.StopPlaying = function() { | ||
this.Playing = false; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetFrameWidth = function(width) { | ||
this.FrameWidth = width; | ||
this.Rows = this.Image.width / this.FrameWidth; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetFrameHeight = function(height) { | ||
this.FrameHeight = height; | ||
this.Columns = this.Image.height / this.FrameHeight; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetColumnCount = function(columnCount) { | ||
this.FrameWidth = this.Image.width / columnCount; | ||
this.Columns = columnCount; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetRowCount = function(rowCount) { | ||
this.FrameHeight = this.Image.height / rowCount; | ||
this.Rows = rowCount; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.AddExistingSequence = function(name, sequence) { | ||
this.Sequences["seq_" + name] = sequence; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.AddNewSequence = function(name, startRow, startColumn, endRow, endColumn) { | ||
this.Sequences["seq_" + name] = new Enjine.AnimationSequence(startRow, startColumn, endRow, endColumn); | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.DeleteSequence = function(name) { | ||
if (this.Sequences["seq_" + name] != null) { | ||
delete this.Sequences["seq_" + name]; | ||
} | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.ClearSequences = function() { | ||
delete this.Sequences; | ||
this.Sequences = new Object(); | ||
/** | ||
Class to represent an uninterrupted set of frames to animate. | ||
*/ | ||
|
||
Enjine.AnimationSequence = function(startRow, startColumn, endRow, endColumn) { | ||
this.StartRow = startRow; | ||
this.StartColumn = startColumn; | ||
this.EndRow = endRow; | ||
this.EndColumn = endColumn; | ||
|
||
//sometimes in an animated sprite, we want it to behave like a regular sprite (static) | ||
//this variable will keep it from wasting time updating animation when the sequence | ||
//is only a single frame long, for things like standing or pausing action | ||
this.SingleFrame = false; | ||
|
||
if ((this.StartRow == this.EndRow) && (this.StartColumn == this.EndColumn)) { | ||
this.SingleFrame = true; | ||
} | ||
}; | ||
|
||
/** | ||
Subclass that extends the regular sprite with animation capability. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.AnimatedSprite = function() { | ||
this.LastElapsed = 0; | ||
this.FramesPerSecond = 1 / 20; | ||
this.CurrentSequence = null; | ||
this.Playing = false; | ||
this.Looping = false; | ||
this.Rows = 0; | ||
this.Columns = 0; | ||
|
||
//cheesy dictionary hack to make animation sequences more accessible | ||
this.Sequences = new Object(); | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype = new Enjine.FrameSprite(); | ||
|
||
Enjine.AnimatedSprite.prototype.Update = function(delta) { | ||
if (this.CurrentSequence.SingleFrame) { | ||
return; | ||
} | ||
if (!this.Playing) { | ||
return; | ||
} | ||
|
||
this.LastElapsed -= delta; | ||
|
||
if (this.LastElapsed > 0) { | ||
return; | ||
} | ||
|
||
this.LastElapsed = this.FramesPerSecond; | ||
this.FrameX += this.FrameWidth; | ||
|
||
//increment the frame | ||
if (this.FrameX > (this.Image.width - this.FrameWidth)) { | ||
this.FrameX = 0; | ||
this.FrameY += this.FrameHeight; | ||
|
||
if (this.FrameY > (this.Image.height - this.FrameHeight)) { | ||
this.FrameY = 0; | ||
} | ||
} | ||
|
||
//check if it's at the end of the animation sequence | ||
var seqEnd = false; | ||
if ((this.FrameX > (this.CurrentSequence.EndColumn * this.FrameWidth)) && (this.FrameY == (this.CurrentSequence.EndRow * this.FrameHeight))) { | ||
seqEnd = true; | ||
} else if (this.FrameX == 0 && (this.FrameY > (this.CurrentSequence.EndRow * this.FrameHeight))) { | ||
seqEnd = true; | ||
} | ||
|
||
//go back to the beginning if looping, otherwise stop playing | ||
if (seqEnd) { | ||
if (this.Looping) { | ||
this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; | ||
this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; | ||
} else { | ||
this.Playing = false; | ||
} | ||
} | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.PlaySequence = function(seqName, loop) { | ||
this.Playing = true; | ||
this.Looping = loop; | ||
this.CurrentSequence = this.Sequences["seq_" + seqName]; | ||
this.FrameX = this.CurrentSequence.StartColumn * this.FrameWidth; | ||
this.FrameY = this.CurrentSequence.StartRow * this.FrameHeight; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.StopLooping = function() { | ||
this.Looping = false; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.StopPlaying = function() { | ||
this.Playing = false; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetFrameWidth = function(width) { | ||
this.FrameWidth = width; | ||
this.Rows = this.Image.width / this.FrameWidth; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetFrameHeight = function(height) { | ||
this.FrameHeight = height; | ||
this.Columns = this.Image.height / this.FrameHeight; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetColumnCount = function(columnCount) { | ||
this.FrameWidth = this.Image.width / columnCount; | ||
this.Columns = columnCount; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.SetRowCount = function(rowCount) { | ||
this.FrameHeight = this.Image.height / rowCount; | ||
this.Rows = rowCount; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.AddExistingSequence = function(name, sequence) { | ||
this.Sequences["seq_" + name] = sequence; | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.AddNewSequence = function(name, startRow, startColumn, endRow, endColumn) { | ||
this.Sequences["seq_" + name] = new Enjine.AnimationSequence(startRow, startColumn, endRow, endColumn); | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.DeleteSequence = function(name) { | ||
if (this.Sequences["seq_" + name] != null) { | ||
delete this.Sequences["seq_" + name]; | ||
} | ||
}; | ||
|
||
Enjine.AnimatedSprite.prototype.ClearSequences = function() { | ||
delete this.Sequences; | ||
this.Sequences = new Object(); | ||
}; |
68 changes: 34 additions & 34 deletions
68
Enjine/application.js → ...75071F21B4}/Control/Enjine/application.js
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
/** | ||
Simple demo of the engine. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.Application = function() { | ||
this.canvas = null; | ||
this.timer = null; | ||
this.stateContext = null; | ||
}; | ||
|
||
Enjine.Application.prototype = { | ||
Update: function(delta) { | ||
|
||
this.stateContext.Update(delta); | ||
|
||
this.canvas.BeginDraw(); | ||
|
||
this.stateContext.Draw(this.canvas.BackBufferContext2D); | ||
|
||
this.canvas.EndDraw(); | ||
}, | ||
|
||
Initialize: function(defaultState, resWidth, resHeight) { | ||
this.canvas = new Enjine.GameCanvas(); | ||
this.timer = new Enjine.GameTimer(); | ||
Enjine.KeyboardInput.Initialize(); | ||
this.canvas.Initialize("canvas", resWidth, resHeight); | ||
this.timer.UpdateObject = this; | ||
|
||
this.stateContext = new Enjine.GameStateContext(defaultState); | ||
|
||
this.timer.Start(); | ||
} | ||
/** | ||
Simple demo of the engine. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.Application = function() { | ||
this.canvas = null; | ||
this.timer = null; | ||
this.stateContext = null; | ||
}; | ||
|
||
Enjine.Application.prototype = { | ||
Update: function(delta) { | ||
|
||
this.stateContext.Update(delta); | ||
|
||
this.canvas.BeginDraw(); | ||
|
||
this.stateContext.Draw(this.canvas.BackBufferContext2D); | ||
|
||
this.canvas.EndDraw(); | ||
}, | ||
|
||
Initialize: function(defaultState, resWidth, resHeight) { | ||
this.canvas = new Enjine.GameCanvas(); | ||
this.timer = new Enjine.GameTimer(); | ||
Enjine.KeyboardInput.Initialize(); | ||
this.canvas.Initialize("canvas", resWidth, resHeight); | ||
this.timer.UpdateObject = this; | ||
|
||
this.stateContext = new Enjine.GameStateContext(defaultState); | ||
|
||
this.timer.Start(); | ||
} | ||
}; |
16 changes: 8 additions & 8 deletions
16
Enjine/camera.js → ...00-1A75071F21B4}/Control/Enjine/camera.js
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** | ||
Represents a camera used to offset drawing of sprites in the world. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.Camera = function() { | ||
this.X = 0; | ||
this.Y = 0; | ||
/** | ||
Represents a camera used to offset drawing of sprites in the world. | ||
Code by Rob Kleffner, 2011 | ||
*/ | ||
|
||
Enjine.Camera = function() { | ||
this.X = 0; | ||
this.Y = 0; | ||
}; |
Oops, something went wrong.