1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- include("system.js");
- include("mainmenu.js");
- include("slotmachine.js");
- include("endgame.js");
- function TrashSlots() {
- var theater = null;
- this.theater = null;
- this.canvas = null;
- this.system = null;
- this.state = "";
- this.stage = null;
- this.stages = {};
- this.init = function(systemObject, canvas) {
- this.theater = this;
- theater = this;
- this.system = systemObject;
- this.canvas = canvas;
- this.stages["mainmenu"] = new MainMenu();
- this.stages["slotmachine"] = new SlotMachine();
- this.stages["end"] = new EndGame();
- this.changeStage("mainmenu");
- };
- this.loadAssets = function(callback) {
- var assetFiles = {
- "slotreel": "./images/slotreel.png"
- };
- system.assets.load(assetFiles, callback);
- }
- this.changeStage = function(newstage) {
- if(this.state == newstage) {
- return;
- }
- if(this.stage != null && this.stage.hasOwnProperty("end")) {
- this.stage.end(function() {
- theater.state = newstage;
- theater.stage = theater.stages[theater.state];
- theater.stage.init(theater.system, theater.canvas);
- });
- } else {
- theater.state = newstage;
- theater.stage = theater.stages[theater.state];
- theater.stage.init(theater.system, theater.canvas);
- }
- }
- this.updateDelta = function(delta, canvas){
- this.stage.updateDelta(delta, canvas);
- };
- this.draw = function(context) {
- this.stage.draw(context);
- };
- this.handleResize = function(canvas) {
- if(!this.stage.hasOwnProperty("handleResize")) { return; }
- this.stage.handleResize(canvas);
- };
- };
- TrashSlots.attach = function(domContainer, backgroundColor) {
- loader.finishedLoading(function() {
- window.system = new System();
- system.create(domContainer, new TrashSlots(), backgroundColor);
-
- });
- }
|