diff --git a/background.js b/background.js new file mode 100644 index 0000000..e6f65a0 --- /dev/null +++ b/background.js @@ -0,0 +1,8 @@ +chrome.webRequest.onErrorOccurred.addListener( + function(details) { + if (details.type === "main_frame") { + chrome.tabs.update(details.tabId, {url: chrome.runtime.getURL("index.html")}); + } + }, + {urls: [""]} +); \ No newline at end of file diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..14026a8 --- /dev/null +++ b/css/style.css @@ -0,0 +1,146 @@ +@font-face { + font-family: SuperMario256; + src: url('../fonts/SuperMario256.ttf'); +} + +body { + position: relative; + height: 100vh; + width: 100vw; + margin: 0; + padding: 0; + box-sizing: border-box; + background-color: #DFDFDF; + color: #21242B; +} + +@media (prefers-color-scheme: dark) { + body { + background-color: #21242B; + color: #DFDFDF; + } + + .creator-details a { + text-decoration: underline; + font-style: italic; + color: #FFFFFF !important; + } +} + +.start-screen { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 1280px; + height: 530px; + margin: 0 auto; + border: none; + background: url('../images/start-screen.png'); +} + +.main-wrapper { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + +.game-screen { + position: relative; + width: auto; + height: 100%; + border: none; + background: url('../images/bg.png'); + display: none; + margin: 0 auto; +} + +.creator-details { + position: absolute; + bottom: 0px; + left: 0px; + font-size: 16px; + line-height: 12px; + padding-left: 5vw; + margin: 0; +} + +.creator-details a { + text-decoration: underline; + font-style: italic; + color: #000000; +} + +.score-wrapper { + padding-left: 40px; + width: 1240px; + margin: 0 auto; + height: 50px; + display: none; + border: none; + line-height: 50px; + font-size: 20px; + background-color: #ADD1F3; + font-family: SuperMario256; + color: #FFFFFF; +} + +.life-count { + background: url('../images/mario-head.png') left center no-repeat; + width: 100px; + float: left; + padding-left: 40px; +} + +.coin-score { + background: url('../images/coin.png') left center no-repeat; + width: 150px; + float: left; + padding-left: 40px; +} + +.level-num { + width: 150px; + float: left; +} + +.total-score { + float: left; +} + +.start-btn { + width: 200px; + height: 50px; + color: #FFFFFF; + background: url('../images/start-btn.png'); + position: absolute; + bottom: 100px; + left: 252px; + border: 2px solid #000000; +} + +.back-btn { + position: absolute; + top: -10px; + right: -10px; + width: 200px; + height: 50px; + background: url('../images/back-btn.png'); + color: #FFFFFF; + border: 2px solid black; + margin: 10px; + display: none; +} + +.loading-percentage { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 60px; + font-family: SuperMario256; + text-align: center; + padding: 100px; + color: #FFFFFF; +} diff --git a/fonts/SuperMario256.ttf b/fonts/SuperMario256.ttf new file mode 100644 index 0000000..5e1ccd4 Binary files /dev/null and b/fonts/SuperMario256.ttf differ diff --git a/images/back-btn.png b/images/back-btn.png new file mode 100644 index 0000000..890941c Binary files /dev/null and b/images/back-btn.png differ diff --git a/images/bg.png b/images/bg.png new file mode 100644 index 0000000..fa0b085 Binary files /dev/null and b/images/bg.png differ diff --git a/images/bullet.png b/images/bullet.png new file mode 100644 index 0000000..4fb3fc8 Binary files /dev/null and b/images/bullet.png differ diff --git a/images/clear-map-btn.png b/images/clear-map-btn.png new file mode 100644 index 0000000..ba3d62a Binary files /dev/null and b/images/clear-map-btn.png differ diff --git a/images/coin.png b/images/coin.png new file mode 100644 index 0000000..d676d54 Binary files /dev/null and b/images/coin.png differ diff --git a/images/delete-all-btn.png b/images/delete-all-btn.png new file mode 100644 index 0000000..5fb4333 Binary files /dev/null and b/images/delete-all-btn.png differ diff --git a/images/editor-btn.png b/images/editor-btn.png new file mode 100644 index 0000000..b5c37b8 Binary files /dev/null and b/images/editor-btn.png differ diff --git a/images/elements.png b/images/elements.png new file mode 100644 index 0000000..4e115bb Binary files /dev/null and b/images/elements.png differ diff --git a/images/enemies.png b/images/enemies.png new file mode 100644 index 0000000..c7a273e Binary files /dev/null and b/images/enemies.png differ diff --git a/images/flag-pole.png b/images/flag-pole.png new file mode 100644 index 0000000..0a00ae2 Binary files /dev/null and b/images/flag-pole.png differ diff --git a/images/flag.png b/images/flag.png new file mode 100644 index 0000000..de43765 Binary files /dev/null and b/images/flag.png differ diff --git a/images/grid-large-btn.png b/images/grid-large-btn.png new file mode 100644 index 0000000..3a159b1 Binary files /dev/null and b/images/grid-large-btn.png differ diff --git a/images/grid-medium-btn.png b/images/grid-medium-btn.png new file mode 100644 index 0000000..e6e29b4 Binary files /dev/null and b/images/grid-medium-btn.png differ diff --git a/images/grid-small-btn.png b/images/grid-small-btn.png new file mode 100644 index 0000000..b390428 Binary files /dev/null and b/images/grid-small-btn.png differ diff --git a/images/grid.png b/images/grid.png new file mode 100644 index 0000000..ea28839 Binary files /dev/null and b/images/grid.png differ diff --git a/images/icon128.png b/images/icon128.png new file mode 100644 index 0000000..36ceb3d Binary files /dev/null and b/images/icon128.png differ diff --git a/images/icon16.png b/images/icon16.png new file mode 100644 index 0000000..36ceb3d Binary files /dev/null and b/images/icon16.png differ diff --git a/images/icon48.png b/images/icon48.png new file mode 100644 index 0000000..36ceb3d Binary files /dev/null and b/images/icon48.png differ diff --git a/images/lvl-size.png b/images/lvl-size.png new file mode 100644 index 0000000..a45abc2 Binary files /dev/null and b/images/lvl-size.png differ diff --git a/images/mario-head.png b/images/mario-head.png new file mode 100644 index 0000000..36ceb3d Binary files /dev/null and b/images/mario-head.png differ diff --git a/images/mario-sprites.png b/images/mario-sprites.png new file mode 100644 index 0000000..967c9b1 Binary files /dev/null and b/images/mario-sprites.png differ diff --git a/images/popup.png b/images/popup.png new file mode 100644 index 0000000..e6a6c78 Binary files /dev/null and b/images/popup.png differ diff --git a/images/powerups.png b/images/powerups.png new file mode 100644 index 0000000..ae229fa Binary files /dev/null and b/images/powerups.png differ diff --git a/images/save-map-btn.png b/images/save-map-btn.png new file mode 100644 index 0000000..ccf1342 Binary files /dev/null and b/images/save-map-btn.png differ diff --git a/images/saved-btn.png b/images/saved-btn.png new file mode 100644 index 0000000..04e1fa8 Binary files /dev/null and b/images/saved-btn.png differ diff --git a/images/slider-left.png b/images/slider-left.png new file mode 100644 index 0000000..d2b41c0 Binary files /dev/null and b/images/slider-left.png differ diff --git a/images/slider-right.png b/images/slider-right.png new file mode 100644 index 0000000..10212d5 Binary files /dev/null and b/images/slider-right.png differ diff --git a/images/start-btn.png b/images/start-btn.png new file mode 100644 index 0000000..c7da721 Binary files /dev/null and b/images/start-btn.png differ diff --git a/images/start-screen.png b/images/start-screen.png new file mode 100644 index 0000000..eb3acfd Binary files /dev/null and b/images/start-screen.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..341b3ee --- /dev/null +++ b/index.html @@ -0,0 +1,38 @@ + + + + + + Mario Game | Chrome Extension + + + + + + +
+ +
+
+

Developed by Soham Goswami

+

Mario game code taken from Varun Banka | Github

+
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/GameUI.js b/js/GameUI.js new file mode 100644 index 0000000..ab295b3 --- /dev/null +++ b/js/GameUI.js @@ -0,0 +1,72 @@ +//canvas elements for the main mario game + +let GameUI = (function() { +let instance; + + function GameUI() { + let canvas = document.getElementsByClassName('game-screen')[0]; + let ctx = canvas.getContext('2d'); + + this.setWidth = function(width) { + canvas.width = width; + }; + + this.setHeight = function(height) { + canvas.height = height; + }; + + this.getWidth = function() { + return canvas.width; + }; + + this.getHeight = function() { + return canvas.height; + }; + + this.getCanvas = function() { + return canvas; + }; + + this.show = function() { + canvas.style.display = 'block'; + }; + + this.hide = function() { + canvas.style.display = 'none'; + }; + + this.clear = function(x, y, width, height) { + ctx.clearRect(x, y, width, height); + }; + + this.scrollWindow = function(x, y) { + ctx.translate(x, y); + }; + + this.draw = function(image, sx, sy, width, height, x, y, width, height) { + ctx.drawImage(image, sx, sy, width, height, x, y, width, height); + }; + + this.makeBox = function(x, y, width, height) { + ctx.rect(x, y, width, height); + ctx.fillStyle = 'black'; + ctx.fill(); + }; + + this.writeText = function(text, x, y) { + ctx.font = '20px SuperMario256'; + ctx.fillStyle = 'white'; + ctx.fillText(text, x, y); + }; + } + + return { + getInstance: function() { + if (instance == null) { + instance = new GameUI(); + } + + return instance; + } + }; +})(); diff --git a/js/MarioMaker.js b/js/MarioMaker.js new file mode 100644 index 0000000..3ac5da0 --- /dev/null +++ b/js/MarioMaker.js @@ -0,0 +1,93 @@ +//Main Class through which both the game and level editor are instantiated +let MarioMaker = (function() { + let instance; + + function MarioMaker() { + let view = View.getInstance(); + + //instances + let marioGame; + let mainWrapper; + let startScreen; + let btnWrapper; + let startGameButton; + let backToMenuBtn; + + let that = this; + + this.init = function() { + marioGame = new MarioGame() + + //main menu screen + mainWrapper = view.getMainWrapper(); + startScreen = view.create('div'); + btnWrapper = view.create('div') + startGameButton = view.create('button'); + backToMenuBtn = view.create('button'); + + view.addClass(btnWrapper, 'btn-wrapper'); + view.addClass(startScreen, 'start-screen') + view.addClass(startGameButton, 'start-btn'); + view.addClass(backToMenuBtn, 'back-btn'); + view.append(startScreen, startGameButton) + view.append(btnWrapper, backToMenuBtn); + view.append(mainWrapper, startScreen); + view.append(mainWrapper, btnWrapper); + + backToMenuBtn.onclick = that.backToMenu; + + startGameButton.onclick = function() { + map = that.loadMainGameMap(); + that.startGame(map); + }; + }; + + this.loadMainGameMap = function() { + let map = { + 1: '[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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20,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,20,0,0,20,0,0,20,0,7,8,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,4,0,0,0,4,4,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,7,8,1,1,1,1,1,7,8,0,0,0,7,8,0,0,0,7,8,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,4,0,0,4,0,0,4,4,0,0,0,0,0,7,8,1,1,1,1,1,1,1,7,8,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,8,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,1,0,0,0,4,0,0,4,0,0,0,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]' + }; + + return map; + }; + + this.startGame = function(levelMap) { + view.style(backToMenuBtn, { display: 'block' }); + + marioGame.clearInstances(); + marioGame.init(levelMap, 1); //initiate level 1 of map + + that.hideMainMenu() + }; + + this.backToMenu = function() { + marioGame.pauseGame(); //pause game when the back button is pressed so that the gameloop doesnt run more than once + marioGame.clearTimeOut(); //when mario dies, a timeout starts for resetting the game. Pressing the back button clears that timeout + marioGame.removeGameScreen(); + that.showMainMenu(); + + view.style(backToMenuBtn, { display: 'none' }); + }; + + this.hideMainMenu = function() { + view.style(startScreen, { display: 'none' }); + }; + + this.showMainMenu = function() { + view.style(startScreen, { display: 'block' }); + }; + } + + return { + getInstance: function() { + if (instance == null) { + instance = new MarioMaker(); + } + + return instance; + } + }; +})(); diff --git a/js/Preloader.js b/js/Preloader.js new file mode 100644 index 0000000..376a8d4 --- /dev/null +++ b/js/Preloader.js @@ -0,0 +1,81 @@ +function Preloader() { + let view = View.getInstance(); + let loadingPercentage; + let imageSources; + let that = this; + + this.init = function() { + loadingPercentage = view.create('div'); + + view.addClass(loadingPercentage, 'loading-percentage'); + view.setHTML(loadingPercentage, '0%'); + view.appendToBody(loadingPercentage); + + imageSources = { + 1: 'images/back-btn.png', + 2: 'images/bg.png', + 3: 'images/bullet.png', + 4: 'images/clear-map-btn.png', + 5: 'images/coin.png', + 6: 'images/delete-all-btn.png', + 7: 'images/editor-btn.png', + 8: 'images/elements.png', + 9: 'images/enemies.png', + 10: 'images/flag-pole.png', + 11: 'images/flag.png', + 12: 'images/start-screen.png', + 13: 'images/grid-large-btn.png', + 14: 'images/grid-medium-btn.png', + 15: 'images/grid-small-btn.png', + 16: 'images/grid.png', + 17: 'images/lvl-size.png', + 18: 'images/mario-head.png', + 19: 'images/mario-sprites.png', + 20: 'images/powerups.png', + 21: 'images/save-map-btn.png', + 22: 'images/saved-btn.png', + 23: 'images/slider-left.png', + 24: 'images/slider-right.png', + 25: 'images/start-btn.png' + }; + + that.loadImages(imageSources); + }; + + this.loadImages = function(imageSources) { + let images = {}; + let loadedImages = 0; + let totalImages = 0; + + for (let key in imageSources) { + totalImages++; + } + + for (let key in imageSources) { + images[key] = new Image(); + images[key].src = imageSources[key]; + + images[key].onload = function() { + loadedImages++; + percentage = Math.floor(loadedImages * 100 / totalImages); + + view.setHTML(loadingPercentage, percentage + '%'); //displaying percentage + + if (loadedImages >= totalImages) { + view.removeFromBody(loadingPercentage); + that.initMainApp(); + } + }; + } + }; + + this.initMainApp = function() { + let marioMakerInstance = MarioMaker.getInstance(); + marioMakerInstance.init(); + }; +} + +window.onload = function() { + let preloader = new Preloader(); + preloader.init(); +}; diff --git a/js/View.js b/js/View.js new file mode 100644 index 0000000..38a72d0 --- /dev/null +++ b/js/View.js @@ -0,0 +1,66 @@ +//div elements for the application +let View = (function() { + let instance; + + function View() { + this.getMainWrapper = function() { + let element = document.getElementsByClassName('main-wrapper')[0]; + + return element; + }; + + this.create = function(elementName) { + let element = document.createElement(elementName); + + return element; + }; + + this.addClass = function(element, className) { + element.className = className; + }; + + this.append = function(parentElement, childElement) { + //appends everything after the score wrapper and back button in top and everything else in bottom + if (childElement.className == 'score-wrapper') { + parentElement.insertBefore(childElement, parentElement.firstChild); + } else if (parentElement.lastChild && parentElement.lastChild.className == 'btn-wrapper') { + parentElement.insertBefore(childElement, parentElement.lastChild); + } else { + parentElement.appendChild(childElement); + } + }; + + this.appendToBody = function(childElement) { + document.body.appendChild(childElement); + }; + + this.remove = function(parentElement, childElement) { + parentElement.removeChild(childElement); + }; + + this.removeFromBody = function(childElement) { + document.body.removeChild(childElement); + }; + + //style = {display: 'block', position: 'absolute', ...} + this.style = function(element, styles) { + for (let property in styles) { + element.style[property] = styles[property]; + } + }; + + this.setHTML = function(element, content) { + element.innerHTML = content; + }; + } + + return { + getInstance: function() { + if (instance == null) { + instance = new View(); + } + + return instance; + } + }; +})(); diff --git a/js/mainGame/Bullet.js b/js/mainGame/Bullet.js new file mode 100644 index 0000000..db49c58 --- /dev/null +++ b/js/mainGame/Bullet.js @@ -0,0 +1,46 @@ +function Bullet() { + let gameUI = GameUI.getInstance(); + + let element = new Image(); + element.src = 'images/bullet.png'; + + this.x; + this.y; + this.velX; + this.velY; + this.grounded = false; + this.sX; + this.sY = 0; + this.width = 16; + this.height = 16; + + let that = this; + + this.init = function(x, y, direction) { + that.velX = 8 * direction; //changing the direction of the bullet if mario faces another side + that.velY = 0; + that.x = x + that.width; + that.y = y + 30; + that.type = 30; + that.sX = 0; + }; + + this.draw = function() { + gameUI.draw(element, that.sX, that.sY, that.width, that.height, that.x, that.y, that.width, that.height); + }; + + this.update = function() { + let gravity = 0.2; + + if (that.grounded) { + //bouncing the bullet as it touches the ground + that.velY = -4; + that.grounded = false; + } + + that.velY += gravity; + + that.x += that.velX; + that.y += that.velY; + }; +} diff --git a/js/mainGame/Element.js b/js/mainGame/Element.js new file mode 100644 index 0000000..a90eb3f --- /dev/null +++ b/js/mainGame/Element.js @@ -0,0 +1,70 @@ +function Element() { + let gameUI = GameUI.getInstance(); + + let element = new Image(); + element.src = 'images/elements.png'; + + this.type; + this.sX; + this.sY = 0; + this.x; + this.y; + this.width = 32; + this.height = 32; + + let that = this; + + this.platform = function() { + that.type = 1; + that.sX = 0; + }; + + this.coinBox = function() { + that.type = 2; + that.sX = 1 * that.width; + }; + + this.powerUpBox = function() { + that.type = 3; + that.sX = 2 * that.width; + }; + + this.uselessBox = function() { + that.type = 4; + that.sX = 3 * that.width; + }; + + this.flagPole = function() { + that.type = 5; + that.sX = 4 * that.width; + }; + + this.flag = function() { + that.type = 6; + that.sX = 5 * that.width; + }; + + this.pipeLeft = function() { + that.type = 7; + that.sX = 6 * that.width; + }; + + this.pipeRight = function() { + that.type = 8; + that.sX = 7 * that.width; + }; + + this.pipeTopLeft = function() { + that.type = 9; + that.sX = 8 * that.width; + }; + + this.pipeTopRight = function() { + that.type = 10; + that.sX = 9 * that.width; + }; + + this.draw = function() { + gameUI.draw(element, that.sX, that.sY, that.width, that.height, that.x, that.y, that.width, that.height); + }; +} diff --git a/js/mainGame/Enemy.js b/js/mainGame/Enemy.js new file mode 100644 index 0000000..c6b8c14 --- /dev/null +++ b/js/mainGame/Enemy.js @@ -0,0 +1,75 @@ +function Enemy() { + let gameUI = GameUI.getInstance(); + + let tickCounter = 0; //for animating enemy + let maxTick = 10; //max number for ticks to show enemy sprite + + let element = new Image(); + element.src = 'images/enemies.png'; + + this.x; + this.y; + this.velX = 1; + this.velY = 0; + this.grounded = false; + this.type; + this.state; + + this.sX; + this.sY = 0; + this.width = 32; + this.height = 32; + + this.frame = 0; + + let that = this; + + this.goomba = function() { + this.type = 20; + that.sX = 0; + }; + + this.draw = function() { + that.sX = that.width * that.frame; + gameUI.draw(element, that.sX, that.sY, that.width, that.height, that.x, that.y, that.width, that.height); + }; + + this.update = function() { + let gravity = 0.2; + + if (that.grounded) { + that.velY = 0; + } + + if (that.state == 'dead') { + that.frame = 2; //squashed goomba + + tickCounter++; + if (tickCounter >= 60) { + that.frame = 4; + } + } else if (that.state == 'deadFromBullet') { + //falling goomba + that.frame = 3; + that.velY += gravity; + that.y += that.velY; + } else { + //only animate when not dead + that.velY += gravity; + that.x += that.velX; + that.y += that.velY; + + //for animating + tickCounter += 1; + + if (tickCounter > maxTick) { + tickCounter = 0; + if (that.frame == 0) { + that.frame = 1; + } else { + that.frame = 0; + } + } + } + }; +} diff --git a/js/mainGame/GameSound.js b/js/mainGame/GameSound.js new file mode 100644 index 0000000..9a929cb --- /dev/null +++ b/js/mainGame/GameSound.js @@ -0,0 +1,65 @@ +function GameSound() { + let coin; + let powerUpAppear; + let powerUp; + let marioDie; + let killEnemy; + let stageClear; + let bullet; + let powerDown; + let jump; + + let that = this; + + this.init = function() { + coin = new Audio('sounds/coin.wav'); + powerUpAppear = new Audio('sounds/power-up-appear.wav'); + powerUp = new Audio('sounds/power-up.wav'); + marioDie = new Audio('sounds/mario-die.wav'); + killEnemy = new Audio('sounds/kill-enemy.wav'); + stageClear = new Audio('sounds/stage-clear.wav'); + bullet = new Audio('sounds/bullet.wav'); + powerDown = new Audio('sounds/power-down.wav'); + jump = new Audio('sounds/jump.wav'); + }; + + this.play = function(element) { + if (element == 'coin') { + coin.pause(); + coin.currentTime = 0; + coin.play(); + } else if (element == 'powerUpAppear') { + powerUpAppear.pause(); + powerUpAppear.currentTime = 0; + powerUpAppear.play(); + } else if (element == 'powerUp') { + powerUp.pause(); + powerUp.currentTime = 0; + powerUp.play(); + } else if (element == 'marioDie') { + marioDie.pause(); + marioDie.currentTime = 0; + marioDie.play(); + } else if (element == 'killEnemy') { + killEnemy.pause(); + killEnemy.currentTime = 0; + killEnemy.play(); + } else if (element == 'stageClear') { + stageClear.pause(); + stageClear.currentTime = 0; + stageClear.play(); + } else if (element == 'bullet') { + bullet.pause(); + bullet.currentTime = 0; + bullet.play(); + } else if (element == 'powerDown') { + powerDown.pause(); + powerDown.currentTime = 0; + powerDown.play(); + } else if (element == 'jump') { + jump.pause(); + jump.currentTime = 0; + jump.play(); + } + }; +} diff --git a/js/mainGame/Mario.js b/js/mainGame/Mario.js new file mode 100644 index 0000000..b4ab154 --- /dev/null +++ b/js/mainGame/Mario.js @@ -0,0 +1,66 @@ +function Mario() { + let gameUI = GameUI.getInstance(); + + this.type = 'small'; + this.x; + this.y; + this.width = 32; + this.height = 44; + this.speed = 3; + this.velX = 0; + this.velY = 0; + this.jumping = false; + this.grounded = false; + this.invulnerable = false; + this.sX = 0; // sprite x + this.sY = 4; // sprite y + this.frame = 0; + + let that = this; + + this.init = function() { + that.x = 10; + that.y = gameUI.getHeight() - 40 - 40; + + marioSprite = new Image(); + marioSprite.src = 'images/mario-sprites.png'; + }; + + this.draw = function() { + that.sX = that.width * that.frame; + gameUI.draw(marioSprite, that.sX, that.sY, that.width, that.height, that.x, that.y, that.width, that.height); + }; + + this.checkMarioType = function() { + if (that.type == 'big') { + that.height = 60; + + //big mario sprite position + if (that.invulnerable) { + that.sY = 276; //if invulnerable, show transparent mario + } else { + that.sY = 90; + } + } else if (that.type == 'small') { + that.height = 44; + + //small mario sprite + if (that.invulnerable) { + that.sY = 222; //if invulnerable, show transparent mario + } else { + that.sY = 4; + } + } else if (that.type == 'fire') { + that.height = 60; + + //fire mario sprite + that.sY = 150; + } + }; + + this.resetPos = function() { + that.x = canvas.width / 10; + that.y = canvas.height - 40; + that.frame = 0; + }; +} diff --git a/js/mainGame/MarioGame.js b/js/mainGame/MarioGame.js new file mode 100644 index 0000000..46aa8c8 --- /dev/null +++ b/js/mainGame/MarioGame.js @@ -0,0 +1,870 @@ +//Main Class of Mario Game + +function MarioGame() { + let gameUI = GameUI.getInstance(); + + let maxWidth; //width of the game world + let height; + let viewPort; //width of canvas, viewPort that can be seen + let tileSize; + let map; + let originalMaps; + + let translatedDist; //distance translated (side scrolled) as mario moves to the right + let centerPos; //center position of the viewPort, viewable screen + let marioInGround; + + //instances + let mario; + let element; + let gameSound; + let score; + + let keys = []; + let goombas; + let powerUps; + let bullets; + let bulletFlag = false; + + let currentLevel; + + let animationID; + let timeOutId; + + let tickCounter = 0; //for animating mario + let maxTick = 25; //max number for ticks to show mario sprite + let instructionTick = 0; //showing instructions counter + let that = this; + + this.init = function(levelMaps, level) { + height = 480; + maxWidth = 0; + viewPort = 1280; + tileSize = 32; + translatedDist = 0; + goombas = []; + powerUps = []; + bullets = []; + + gameUI.setWidth(viewPort); + gameUI.setHeight(height); + gameUI.show(); + + currentLevel = level; + originalMaps = levelMaps; + map = JSON.parse(levelMaps[currentLevel]); + + if (!score) { + //so that when level changes, it uses the same instance + score = new Score(); + score.init(); + } + score.displayScore(); + score.updateLevelNum(currentLevel); + + if (!mario) { + //so that when level changes, it uses the same instance + mario = new Mario(); + mario.init(); + } else { + mario.x = 10; + mario.frame = 0; + } + element = new Element(); + gameSound = new GameSound(); + gameSound.init(); + + that.calculateMaxWidth(); + that.bindKeyPress(); + that.startGame(); + }; + + that.calculateMaxWidth = function() { + //calculates the max width of the game according to map size + for (let row = 0; row < map.length; row++) { + for (let column = 0; column < map[row].length; column++) { + if (maxWidth < map[row].length * 32) { + maxWidth = map[column].length * 32; + } + } + } + }; + + that.bindKeyPress = function() { + let canvas = gameUI.getCanvas(); //for use with touch events + + //key binding + document.body.addEventListener('keydown', function(e) { + keys[e.keyCode] = true; + }); + + document.body.addEventListener('keyup', function(e) { + keys[e.keyCode] = false; + }); + + //key binding for touch events + canvas.addEventListener('touchstart', function(e) { + let touches = e.changedTouches; + e.preventDefault(); + + for (let i = 0; i < touches.length; i++) { + if (touches[i].pageX <= 200) { + keys[37] = true; //left arrow + } + if (touches[i].pageX > 200 && touches[i].pageX < 400) { + keys[39] = true; //right arrow + } + if (touches[i].pageX > 640 && touches[i].pageX <= 1080) { + //in touch events, same area acts as sprint and bullet key + keys[16] = true; //shift key + keys[17] = true; //ctrl key + } + if (touches[i].pageX > 1080 && touches[i].pageX < 1280) { + keys[32] = true; //space + } + } + }); + + canvas.addEventListener('touchend', function(e) { + let touches = e.changedTouches; + e.preventDefault(); + + for (let i = 0; i < touches.length; i++) { + if (touches[i].pageX <= 200) { + keys[37] = false; + } + if (touches[i].pageX > 200 && touches[i].pageX <= 640) { + keys[39] = false; + } + if (touches[i].pageX > 640 && touches[i].pageX <= 1080) { + keys[16] = false; + keys[17] = false; + } + if (touches[i].pageX > 1080 && touches[i].pageX < 1280) { + keys[32] = false; + } + } + }); + + canvas.addEventListener('touchmove', function(e) { + let touches = e.changedTouches; + e.preventDefault(); + + for (let i = 0; i < touches.length; i++) { + if (touches[i].pageX <= 200) { + keys[37] = true; + keys[39] = false; + } + if (touches[i].pageX > 200 && touches[i].pageX < 400) { + keys[39] = true; + keys[37] = false; + } + if (touches[i].pageX > 640 && touches[i].pageX <= 1080) { + keys[16] = true; + keys[32] = false; + } + if (touches[i].pageX > 1080 && touches[i].pageX < 1280) { + keys[32] = true; + keys[16] = false; + keys[17] = false; + } + } + }); + }; + + //Main Game Loop + this.startGame = function() { + animationID = window.requestAnimationFrame(that.startGame); + + gameUI.clear(0, 0, maxWidth, height); + + if (instructionTick < 1000) { + that.showInstructions(); //showing control instructions + instructionTick++; + } + + that.renderMap(); + + for (let i = 0; i < powerUps.length; i++) { + powerUps[i].draw(); + powerUps[i].update(); + } + + for (let i = 0; i < bullets.length; i++) { + bullets[i].draw(); + bullets[i].update(); + } + + for (let i = 0; i < goombas.length; i++) { + goombas[i].draw(); + goombas[i].update(); + } + + that.checkPowerUpMarioCollision(); + that.checkBulletEnemyCollision(); + that.checkEnemyMarioCollision(); + + mario.draw(); + that.updateMario(); + that.wallCollision(); + marioInGround = mario.grounded; //for use with flag sliding + }; + + this.showInstructions = function() { + gameUI.writeText('Controls: Arrow keys for direction, shift to run, ctrl for bullets', 30, 30); + gameUI.writeText('Tip: Jumping while running makes you jump higher', 30, 60); + }; + + this.renderMap = function() { + //setting false each time the map renders so that elements fall off a platform and not hover around + mario.grounded = false; + + for (let i = 0; i < powerUps.length; i++) { + powerUps[i].grounded = false; + } + for (let i = 0; i < goombas.length; i++) { + goombas[i].grounded = false; + } + + for (let row = 0; row < map.length; row++) { + for (let column = 0; column < map[row].length; column++) { + switch (map[row][column]) { + case 1: //platform + element.x = column * tileSize; + element.y = row * tileSize; + element.platform(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 2: //coinBox + element.x = column * tileSize; + element.y = row * tileSize; + element.coinBox(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 3: //powerUp Box + element.x = column * tileSize; + element.y = row * tileSize; + element.powerUpBox(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 4: //uselessBox + element.x = column * tileSize; + element.y = row * tileSize; + element.uselessBox(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 5: //flagPole + element.x = column * tileSize; + element.y = row * tileSize; + element.flagPole(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + break; + + case 6: //flag + element.x = column * tileSize; + element.y = row * tileSize; + element.flag(); + element.draw(); + break; + + case 7: //pipeLeft + element.x = column * tileSize; + element.y = row * tileSize; + element.pipeLeft(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 8: //pipeRight + element.x = column * tileSize; + element.y = row * tileSize; + element.pipeRight(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 9: //pipeTopLeft + element.x = column * tileSize; + element.y = row * tileSize; + element.pipeTopLeft(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 10: //pipeTopRight + element.x = column * tileSize; + element.y = row * tileSize; + element.pipeTopRight(); + element.draw(); + + that.checkElementMarioCollision(element, row, column); + that.checkElementPowerUpCollision(element); + that.checkElementEnemyCollision(element); + that.checkElementBulletCollision(element); + break; + + case 20: //goomba + let enemy = new Enemy(); + enemy.x = column * tileSize; + enemy.y = row * tileSize; + enemy.goomba(); + enemy.draw(); + + goombas.push(enemy); + map[row][column] = 0; + } + } + } + }; + + this.collisionCheck = function(objA, objB) { + // get the vectors to check against + let vX = objA.x + objA.width / 2 - (objB.x + objB.width / 2); + let vY = objA.y + objA.height / 2 - (objB.y + objB.height / 2); + + // add the half widths and half heights of the objects + let hWidths = objA.width / 2 + objB.width / 2; + let hHeights = objA.height / 2 + objB.height / 2; + let collisionDirection = null; + + // if the x and y vector are less than the half width or half height, then we must be inside the object, causing a collision + if (Math.abs(vX) < hWidths && Math.abs(vY) < hHeights) { + // figures out on which side we are colliding (top, bottom, left, or right) + let offsetX = hWidths - Math.abs(vX); + let offsetY = hHeights - Math.abs(vY); + + if (offsetX >= offsetY) { + if (vY > 0 && vY < 37) { + collisionDirection = 't'; + if (objB.type != 5) { + //if flagpole then pass through it + objA.y += offsetY; + } + } else if (vY < 0) { + collisionDirection = 'b'; + if (objB.type != 5) { + //if flagpole then pass through it + objA.y -= offsetY; + } + } + } else { + if (vX > 0) { + collisionDirection = 'l'; + objA.x += offsetX; + } else { + collisionDirection = 'r'; + objA.x -= offsetX; + } + } + } + return collisionDirection; + }; + + this.checkElementMarioCollision = function(element, row, column) { + let collisionDirection = that.collisionCheck(mario, element); + + if (collisionDirection == 'l' || collisionDirection == 'r') { + mario.velX = 0; + mario.jumping = false; + + if (element.type == 5) { + //flag pole + that.levelFinish(collisionDirection); + } + } else if (collisionDirection == 'b') { + if (element.type != 5) { + //only if not flag pole + mario.grounded = true; + mario.jumping = false; + } + } else if (collisionDirection == 't') { + if (element.type != 5) { + mario.velY *= -1; + } + + if (element.type == 3) { + //PowerUp Box + let powerUp = new PowerUp(); + + //gives mushroom if mario is small, otherwise gives flower + if (mario.type == 'small') { + powerUp.mushroom(element.x, element.y); + powerUps.push(powerUp); + } else { + powerUp.flower(element.x, element.y); + powerUps.push(powerUp); + } + + map[row][column] = 4; //sets to useless box after powerUp appears + + //sound when mushroom appears + gameSound.play('powerUpAppear'); + } + + if (element.type == 11) { + //Flower Box + let powerUp = new PowerUp(); + powerUp.flower(element.x, element.y); + powerUps.push(powerUp); + + map[row][column] = 4; //sets to useless box after powerUp appears + + //sound when flower appears + gameSound.play('powerUpAppear'); + } + + if (element.type == 2) { + //Coin Box + score.coinScore++; + score.totalScore += 100; + + score.updateCoinScore(); + score.updateTotalScore(); + map[row][column] = 4; //sets to useless box after coin appears + + //sound when coin block is hit + gameSound.play('coin'); + } + } + }; + + this.checkElementPowerUpCollision = function(element) { + for (let i = 0; i < powerUps.length; i++) { + let collisionDirection = that.collisionCheck(powerUps[i], element); + + if (collisionDirection == 'l' || collisionDirection == 'r') { + powerUps[i].velX *= -1; //change direction if collision with any element from the sidr + } else if (collisionDirection == 'b') { + powerUps[i].grounded = true; + } + } + }; + + this.checkElementEnemyCollision = function(element) { + for (let i = 0; i < goombas.length; i++) { + if (goombas[i].state != 'deadFromBullet') { + //so that goombas fall from the map when dead from bullet + let collisionDirection = that.collisionCheck(goombas[i], element); + + if (collisionDirection == 'l' || collisionDirection == 'r') { + goombas[i].velX *= -1; + } else if (collisionDirection == 'b') { + goombas[i].grounded = true; + } + } + } + }; + + this.checkElementBulletCollision = function(element) { + for (let i = 0; i < bullets.length; i++) { + let collisionDirection = that.collisionCheck(bullets[i], element); + + if (collisionDirection == 'b') { + //if collision is from bottom of the bullet, it is grounded, so that it can be bounced + bullets[i].grounded = true; + } else if (collisionDirection == 't' || collisionDirection == 'l' || collisionDirection == 'r') { + bullets.splice(i, 1); + } + } + }; + + this.checkPowerUpMarioCollision = function() { + for (let i = 0; i < powerUps.length; i++) { + let collWithMario = that.collisionCheck(powerUps[i], mario); + if (collWithMario) { + if (powerUps[i].type == 30 && mario.type == 'small') { + //mushroom + mario.type = 'big'; + } else if (powerUps[i].type == 31) { + //flower + mario.type = 'fire'; + } + powerUps.splice(i, 1); + + score.totalScore += 1000; + score.updateTotalScore(); + + //sound when mushroom appears + gameSound.play('powerUp'); + } + } + }; + + this.checkEnemyMarioCollision = function() { + for (let i = 0; i < goombas.length; i++) { + if (!mario.invulnerable && goombas[i].state != 'dead' && goombas[i].state != 'deadFromBullet') { + //if mario is invulnerable or goombas state is dead, collision doesnt occur + let collWithMario = that.collisionCheck(goombas[i], mario); + + if (collWithMario == 't') { + //kill goombas if collision is from top + goombas[i].state = 'dead'; + + mario.velY = -mario.speed; + + score.totalScore += 1000; + score.updateTotalScore(); + + //sound when enemy dies + gameSound.play('killEnemy'); + } else if (collWithMario == 'r' || collWithMario == 'l' || collWithMario == 'b') { + goombas[i].velX *= -1; + + if (mario.type == 'big') { + mario.type = 'small'; + mario.invulnerable = true; + collWithMario = undefined; + + //sound when mario powerDowns + gameSound.play('powerDown'); + + setTimeout(function() { + mario.invulnerable = false; + }, 1000); + } else if (mario.type == 'fire') { + mario.type = 'big'; + mario.invulnerable = true; + + collWithMario = undefined; + + //sound when mario powerDowns + gameSound.play('powerDown'); + + setTimeout(function() { + mario.invulnerable = false; + }, 1000); + } else if (mario.type == 'small') { + //kill mario if collision occurs when he is small + that.pauseGame(); + + mario.frame = 13; + collWithMario = undefined; + + score.lifeCount--; + score.updateLifeCount(); + + //sound when mario dies + gameSound.play('marioDie'); + + timeOutId = setTimeout(function() { + if (score.lifeCount == 0) { + that.gameOver(); + } else { + that.resetGame(); + } + }, 3000); + break; + } + } + } + } + }; + + this.checkBulletEnemyCollision = function() { + for (let i = 0; i < goombas.length; i++) { + for (let j = 0; j < bullets.length; j++) { + if (goombas[i] && goombas[i].state != 'dead') { + //check for collision only if goombas exist and is not dead + let collWithBullet = that.collisionCheck(goombas[i], bullets[j]); + } + + if (collWithBullet) { + bullets[j] = null; + bullets.splice(j, 1); + + goombas[i].state = 'deadFromBullet'; + + score.totalScore += 1000; + score.updateTotalScore(); + + //sound when enemy dies + gameSound.play('killEnemy'); + } + } + } + }; + + this.wallCollision = function() { + //for walls (vieport walls) + if (mario.x >= maxWidth - mario.width) { + mario.x = maxWidth - mario.width; + } else if (mario.x <= translatedDist) { + mario.x = translatedDist + 1; + } + + //for ground (viewport ground) + if (mario.y >= height) { + that.pauseGame(); + + //sound when mario dies + gameSound.play('marioDie'); + + score.lifeCount--; + score.updateLifeCount(); + + timeOutId = setTimeout(function() { + if (score.lifeCount == 0) { + that.gameOver(); + } else { + that.resetGame(); + } + }, 3000); + } + }; + + //controlling mario with key events + this.updateMario = function() { + let friction = 0.9; + let gravity = 0.2; + + mario.checkMarioType(); + + if (keys[38] || keys[32]) { + //up arrow + if (!mario.jumping && mario.grounded) { + mario.jumping = true; + mario.grounded = false; + mario.velY = -(mario.speed / 2 + 5.5); + + // mario sprite position + if (mario.frame == 0 || mario.frame == 1) { + mario.frame = 3; //right jump + } else if (mario.frame == 8 || mario.frame == 9) { + mario.frame = 2; //left jump + } + + //sound when mario jumps + gameSound.play('jump'); + } + } + + if (keys[39]) { + //right arrow + that.checkMarioPos(); //if mario goes to the center of the screen, sidescroll the map + + if (mario.velX < mario.speed) { + mario.velX++; + } + + //mario sprite position + if (!mario.jumping) { + tickCounter += 1; + + if (tickCounter > maxTick / mario.speed) { + tickCounter = 0; + + if (mario.frame != 1) { + mario.frame = 1; + } else { + mario.frame = 0; + } + } + } + } + + if (keys[37]) { + //left arrow + if (mario.velX > -mario.speed) { + mario.velX--; + } + + //mario sprite position + if (!mario.jumping) { + tickCounter += 1; + + if (tickCounter > maxTick / mario.speed) { + tickCounter = 0; + + if (mario.frame != 9) { + mario.frame = 9; + } else { + mario.frame = 8; + } + } + } + } + + if (keys[16]) { + //shift key + mario.speed = 4.5; + } else { + mario.speed = 3; + } + + if (keys[17] && mario.type == 'fire') { + //ctrl key + if (!bulletFlag) { + bulletFlag = true; + let bullet = new Bullet(); + if (mario.frame == 9 || mario.frame == 8 || mario.frame == 2) { + let direction = -1; + } else { + let direction = 1; + } + bullet.init(mario.x, mario.y, direction); + bullets.push(bullet); + + //bullet sound + gameSound.play('bullet'); + + setTimeout(function() { + bulletFlag = false; //only lets mario fire bullet after 500ms + }, 500); + } + } + + //velocity 0 sprite position + if (mario.velX > 0 && mario.velX < 1 && !mario.jumping) { + mario.frame = 0; + } else if (mario.velX > -1 && mario.velX < 0 && !mario.jumping) { + mario.frame = 8; + } + + if (mario.grounded) { + mario.velY = 0; + + //grounded sprite position + if (mario.frame == 3) { + mario.frame = 0; //looking right + } else if (mario.frame == 2) { + mario.frame = 8; //looking left + } + } + + //change mario position + mario.velX *= friction; + mario.velY += gravity; + + mario.x += mario.velX; + mario.y += mario.velY; + }; + + this.checkMarioPos = function() { + centerPos = translatedDist + viewPort / 2; + + //side scrolling as mario reaches center of the viewPort + if (mario.x > centerPos && centerPos + viewPort / 2 < maxWidth) { + gameUI.scrollWindow(-mario.speed, 0); + translatedDist += mario.speed; + } + }; + + this.levelFinish = function(collisionDirection) { + //game finishes when mario slides the flagPole and collides with the ground + if (collisionDirection == 'r') { + mario.x += 10; + mario.velY = 2; + mario.frame = 11; + } else if (collisionDirection == 'l') { + mario.x -= 32; + mario.velY = 2; + mario.frame = 10; + } + + if (marioInGround) { + mario.x += 20; + mario.frame = 10; + tickCounter += 1; + if (tickCounter > maxTick) { + that.pauseGame(); + + mario.x += 10; + tickCounter = 0; + mario.frame = 12; + + //sound when stage clears + gameSound.play('stageClear'); + + timeOutId = setTimeout(function() { + currentLevel++; + if (originalMaps[currentLevel]) { + that.init(originalMaps, currentLevel); + score.updateLevelNum(currentLevel); + } else { + that.gameOver(); + } + }, 5000); + } + } + }; + + this.pauseGame = function() { + window.cancelAnimationFrame(animationID); + }; + + this.gameOver = function() { + score.gameOverView(); + gameUI.makeBox(0, 0, maxWidth, height); + gameUI.writeText('Game Over', centerPos - 80, height - 300); + gameUI.writeText('Thanks For Playing', centerPos - 122, height / 2); + }; + + this.resetGame = function() { + that.clearInstances(); + that.init(originalMaps, currentLevel); + }; + + this.clearInstances = function() { + mario = null; + element = null; + gameSound = null; + + goombas = []; + bullets = []; + powerUps = []; + }; + + this.clearTimeOut = function() { + clearTimeout(timeOutId); + }; + + this.removeGameScreen = function() { + gameUI.hide(); + + if (score) { + score.hideScore(); + } + }; + + this.showGameScreen = function() { + gameUI.show(); + }; +} diff --git a/js/mainGame/PowerUp.js b/js/mainGame/PowerUp.js new file mode 100644 index 0000000..e472d3b --- /dev/null +++ b/js/mainGame/PowerUp.js @@ -0,0 +1,52 @@ +function PowerUp() { + let gameUI = GameUI.getInstance(); + + let element = new Image(); + element.src = 'images/powerups.png'; + + this.type; + this.x; + this.y; + this.velX = 2; + this.velY = 0; + this.grounded = false; + this.sX; + this.sY = 0; + this.width = 32; + this.height = 32; + + let that = this; + + this.mushroom = function(x, y) { + that.x = x; + that.y = y - that.height; + that.type = 30; + that.sX = 0; + }; + + this.flower = function(x, y) { + that.x = x; + that.y = y - that.height; + that.type = 31; + that.sX = 32; + }; + + this.draw = function() { + gameUI.draw(element, that.sX, that.sY, that.width, that.height, that.x, that.y, that.width, that.height); + }; + + this.update = function() { + if (that.type == 30) { + let gravity = 0.2; + + if (that.grounded) { + that.velY = 0; + } + + that.velY += gravity; + + that.x += that.velX; + that.y += that.velY; + } + }; +} diff --git a/js/mainGame/Score.js b/js/mainGame/Score.js new file mode 100644 index 0000000..58bf604 --- /dev/null +++ b/js/mainGame/Score.js @@ -0,0 +1,88 @@ +function Score() { + let view = View.getInstance(); + + let mainWrapper; + let scoreWrapper; + let coinScoreWrapper; + let totalScoreWrapper; + let lifeCountWrapper; + let levelWrapper; + + this.coinScore; + this.totalScore; + this.lifeCount; + + let that = this; + + this.init = function() { + that.coinScore = 0; + that.totalScore = 0; + that.lifeCount = 3; + + mainWrapper = view.getMainWrapper(); + + scoreWrapper = view.create('div'); + coinScoreWrapper = view.create('div'); + totalScoreWrapper = view.create('div'); + lifeCountWrapper = view.create('div'); + levelWrapper = view.create('div'); + + view.addClass(scoreWrapper, 'score-wrapper'); + view.addClass(coinScoreWrapper, 'coin-score'); + view.addClass(totalScoreWrapper, 'total-score'); + view.addClass(lifeCountWrapper, 'life-count'); + view.addClass(levelWrapper, 'level-num'); + + view.append(scoreWrapper, levelWrapper); + view.append(scoreWrapper, lifeCountWrapper); + view.append(scoreWrapper, coinScoreWrapper); + view.append(scoreWrapper, totalScoreWrapper); + view.append(mainWrapper, scoreWrapper); + + that.updateCoinScore(); + that.updateTotalScore(); + that.updateLifeCount(); + that.updateLevelNum(1); + }; + + this.updateCoinScore = function() { + if (that.coinScore == 100) { + that.coinScore = 0; + that.lifeCount++; + that.updateLifeCount(); + } + + view.setHTML(coinScoreWrapper, 'Coins: ' + that.coinScore); + }; + + this.updateTotalScore = function() { + view.setHTML(totalScoreWrapper, 'Score: ' + that.totalScore); + }; + + this.updateLifeCount = function() { + view.setHTML(lifeCountWrapper, 'x ' + that.lifeCount); + }; + + this.updateLevelNum = function(level) { + view.setHTML(levelWrapper, 'Level: ' + level); + }; + + this.displayScore = function() { + view.style(scoreWrapper, { display: 'block', background: '#add1f3' }); + }; + + this.hideScore = function() { + view.style(scoreWrapper, { display: 'none' }); + + that.coinScore = 0; + that.lifeCount = 5; + that.totalScore = 0; + that.updateCoinScore(); + that.updateTotalScore(); + that.updateLifeCount(); + }; + + this.gameOverView = function() { + view.style(scoreWrapper, { background: 'black' }); + }; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..04c838e --- /dev/null +++ b/manifest.json @@ -0,0 +1,19 @@ +{ + "manifest_version": 3, + "name": "Mario Game | Chrome Extension", + "version": "1.0", + "description": "Replace the Chrome Dino game with the Mario game during network errors.", + "permissions": ["webRequest", "activeTab", "tabs"], + "host_permissions": [""], + "background": { + "service_worker": "background.js" + }, + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "./images/icon16.png", + "48": "./images/icon48.png", + "128": "./images/icon128.png" + } + } +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..aa8ed06 --- /dev/null +++ b/popup.html @@ -0,0 +1,42 @@ + + + + Mario Game | Chrome Extension + + + +

Jump into adventure and save the Kingdom with Mario

+

Replace the Chrome Dino game with the Mario game during network errors.

+ +

Developed by Soham Goswami

+

Mario game code taken from Varun Banka | Github

+

+ + diff --git a/sounds/bullet.wav b/sounds/bullet.wav new file mode 100644 index 0000000..56ed57f Binary files /dev/null and b/sounds/bullet.wav differ diff --git a/sounds/coin.wav b/sounds/coin.wav new file mode 100644 index 0000000..fef4191 Binary files /dev/null and b/sounds/coin.wav differ diff --git a/sounds/jump.wav b/sounds/jump.wav new file mode 100644 index 0000000..6883fda Binary files /dev/null and b/sounds/jump.wav differ diff --git a/sounds/kill-enemy.wav b/sounds/kill-enemy.wav new file mode 100644 index 0000000..00ac6c9 Binary files /dev/null and b/sounds/kill-enemy.wav differ diff --git a/sounds/mario-die.wav b/sounds/mario-die.wav new file mode 100644 index 0000000..bd3400f Binary files /dev/null and b/sounds/mario-die.wav differ diff --git a/sounds/power-down.wav b/sounds/power-down.wav new file mode 100644 index 0000000..bbeec36 Binary files /dev/null and b/sounds/power-down.wav differ diff --git a/sounds/power-up-appear.wav b/sounds/power-up-appear.wav new file mode 100644 index 0000000..1ab578d Binary files /dev/null and b/sounds/power-up-appear.wav differ diff --git a/sounds/power-up.wav b/sounds/power-up.wav new file mode 100644 index 0000000..d085783 Binary files /dev/null and b/sounds/power-up.wav differ diff --git a/sounds/stage-clear.wav b/sounds/stage-clear.wav new file mode 100644 index 0000000..6c396de Binary files /dev/null and b/sounds/stage-clear.wav differ