├── .gitignore ├── src ├── client │ ├── assets │ │ ├── favicon.ico │ │ ├── fonts │ │ │ ├── Mario.ttf │ │ │ ├── PipeDream.ttf │ │ │ └── PressStart2P.ttf │ │ ├── kirbySplash.png │ │ ├── marioSplash.png │ │ ├── readme │ │ │ ├── game.png │ │ │ ├── gamescreen.png │ │ │ ├── splashpage.png │ │ │ ├── controllers.jpg │ │ │ ├── controllers2.JPG │ │ │ └── megacontroller.png │ │ ├── marioLevel │ │ │ ├── box.png │ │ │ ├── ground.png │ │ │ ├── ledge.png │ │ │ ├── ledge2.png │ │ │ ├── pipe2.png │ │ │ ├── marioStar.png │ │ │ └── MarioLevelBackground.png │ │ ├── megamanSplash.png │ │ ├── pikachuSplash.png │ │ ├── sprites │ │ │ ├── mario2.png │ │ │ ├── megamanNew1.png │ │ │ ├── kirbySprite2.png │ │ │ └── pikachuSprite.png │ │ ├── main_background.png │ │ ├── player_selection2.png │ │ ├── weapons │ │ │ ├── bullet0.png │ │ │ ├── bullet1.png │ │ │ ├── bullet2.png │ │ │ └── bullet3.png │ │ ├── controller │ │ │ ├── left_button.png │ │ │ ├── mario_star.png │ │ │ ├── fire_button2.png │ │ │ ├── fire_button3.png │ │ │ ├── jump_button2.png │ │ │ ├── jump_button3.png │ │ │ ├── right_button.png │ │ │ ├── kirbyController.png │ │ │ ├── marioController.png │ │ │ ├── megamanController.png │ │ │ └── pikachuController.png │ │ ├── sounds │ │ │ ├── SuperMarioBros.mp3 │ │ │ └── Pacman-death-sound.mp3 │ │ └── css │ │ │ └── fonts.css │ ├── css │ │ ├── main.css │ │ └── controller.css │ ├── js │ │ ├── main.js │ │ ├── controller.js │ │ └── chars.js │ ├── layout.html │ ├── controller.html │ └── states │ │ ├── splash.js │ │ ├── gameover.js │ │ ├── game.js │ │ └── menu.js └── server │ ├── routes │ └── index.js │ └── app.js ├── package.json ├── README.md └── gulpfile.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /src/client/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/favicon.ico -------------------------------------------------------------------------------- /src/client/assets/fonts/Mario.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/fonts/Mario.ttf -------------------------------------------------------------------------------- /src/client/assets/kirbySplash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/kirbySplash.png -------------------------------------------------------------------------------- /src/client/assets/marioSplash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioSplash.png -------------------------------------------------------------------------------- /src/client/assets/readme/game.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/game.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/box.png -------------------------------------------------------------------------------- /src/client/assets/megamanSplash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/megamanSplash.png -------------------------------------------------------------------------------- /src/client/assets/pikachuSplash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/pikachuSplash.png -------------------------------------------------------------------------------- /src/client/assets/sprites/mario2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sprites/mario2.png -------------------------------------------------------------------------------- /src/client/assets/fonts/PipeDream.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/fonts/PipeDream.ttf -------------------------------------------------------------------------------- /src/client/assets/main_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/main_background.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/ground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/ground.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/ledge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/ledge.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/ledge2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/ledge2.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/pipe2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/pipe2.png -------------------------------------------------------------------------------- /src/client/assets/player_selection2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/player_selection2.png -------------------------------------------------------------------------------- /src/client/assets/readme/gamescreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/gamescreen.png -------------------------------------------------------------------------------- /src/client/assets/readme/splashpage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/splashpage.png -------------------------------------------------------------------------------- /src/client/assets/weapons/bullet0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/weapons/bullet0.png -------------------------------------------------------------------------------- /src/client/assets/weapons/bullet1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/weapons/bullet1.png -------------------------------------------------------------------------------- /src/client/assets/weapons/bullet2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/weapons/bullet2.png -------------------------------------------------------------------------------- /src/client/assets/weapons/bullet3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/weapons/bullet3.png -------------------------------------------------------------------------------- /src/client/assets/fonts/PressStart2P.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/fonts/PressStart2P.ttf -------------------------------------------------------------------------------- /src/client/assets/readme/controllers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/controllers.jpg -------------------------------------------------------------------------------- /src/client/assets/readme/controllers2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/controllers2.JPG -------------------------------------------------------------------------------- /src/client/assets/sprites/megamanNew1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sprites/megamanNew1.png -------------------------------------------------------------------------------- /src/client/assets/controller/left_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/left_button.png -------------------------------------------------------------------------------- /src/client/assets/controller/mario_star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/mario_star.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/marioStar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/marioStar.png -------------------------------------------------------------------------------- /src/client/assets/readme/megacontroller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/readme/megacontroller.png -------------------------------------------------------------------------------- /src/client/assets/sounds/SuperMarioBros.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sounds/SuperMarioBros.mp3 -------------------------------------------------------------------------------- /src/client/assets/sprites/kirbySprite2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sprites/kirbySprite2.png -------------------------------------------------------------------------------- /src/client/assets/sprites/pikachuSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sprites/pikachuSprite.png -------------------------------------------------------------------------------- /src/client/assets/controller/fire_button2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/fire_button2.png -------------------------------------------------------------------------------- /src/client/assets/controller/fire_button3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/fire_button3.png -------------------------------------------------------------------------------- /src/client/assets/controller/jump_button2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/jump_button2.png -------------------------------------------------------------------------------- /src/client/assets/controller/jump_button3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/jump_button3.png -------------------------------------------------------------------------------- /src/client/assets/controller/right_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/right_button.png -------------------------------------------------------------------------------- /src/client/assets/controller/kirbyController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/kirbyController.png -------------------------------------------------------------------------------- /src/client/assets/controller/marioController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/marioController.png -------------------------------------------------------------------------------- /src/client/assets/sounds/Pacman-death-sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/sounds/Pacman-death-sound.mp3 -------------------------------------------------------------------------------- /src/client/assets/controller/megamanController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/megamanController.png -------------------------------------------------------------------------------- /src/client/assets/controller/pikachuController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/controller/pikachuController.png -------------------------------------------------------------------------------- /src/client/assets/marioLevel/MarioLevelBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KayTV/not-so-super-smash-bros/HEAD/src/client/assets/marioLevel/MarioLevelBackground.png -------------------------------------------------------------------------------- /src/server/routes/index.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | 4 | router.get('/', function(req, res, next) { 5 | res.render('index'); 6 | }); 7 | 8 | module.exports = router; 9 | -------------------------------------------------------------------------------- /src/client/assets/css/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'PressStart2P'; 3 | src: url('../fonts/PressStart2P.ttf'); 4 | } 5 | 6 | @font-face { 7 | font-family: 'Mario'; 8 | src: url('../fonts/Mario.ttf'); 9 | } 10 | 11 | @font-face { 12 | font-family: 'PipeDream'; 13 | src: url('../fonts/PipeDream.ttf'); 14 | } 15 | -------------------------------------------------------------------------------- /src/client/css/main.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Press+Start+2P); 2 | 3 | body { 4 | padding: 50px; 5 | font-family: 25px "Press Start 2P", "Lucida Grande", Helvetica, Arial, sans-serif; 6 | display: flex; 7 | } 8 | 9 | a { 10 | color: #00B7FF; 11 | } 12 | 13 | canvas { 14 | margin: 0 auto; 15 | } 16 | -------------------------------------------------------------------------------- /src/client/css/controller.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: grey; 3 | /*margin-top: 5%;*/ 4 | font-family: 'Press Start 2P', cursive; 5 | } 6 | 7 | div { 8 | -webkit-touch-callout: none !important; 9 | -webkit-user-select: none 10 | } 11 | 12 | p { 13 | text-align: center; 14 | } 15 | 16 | #picture { 17 | text-align: center; 18 | } 19 | 20 | #picture img { 21 | height: 10%; 22 | width: 10%; 23 | } 24 | 25 | #firePowerUp { 26 | height: 20%; 27 | width: 20%; 28 | } 29 | -------------------------------------------------------------------------------- /src/client/js/main.js: -------------------------------------------------------------------------------- 1 | var socket = io(); 2 | 3 | var game = new Phaser.Game(800, 600, Phaser.AUTO, 'Not-So-Super-Smash'); 4 | 5 | function Main() {} 6 | 7 | Main.prototype = { 8 | preload: function() { 9 | game.load.image('load-bg', 'assets/main_background.png'); 10 | game.load.script('splash', 'states/splash.js'); 11 | }, 12 | create: function() { 13 | game.state.add('Splash', Splash); 14 | game.state.start('Splash'); 15 | } 16 | }; 17 | 18 | game.state.add('Main', Main); 19 | game.state.start('Main'); 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "_example", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "start": "node ./src/server/app.js" 7 | }, 8 | "dependencies": { 9 | "body-parser": "~1.13.2", 10 | "cookie-parser": "~1.3.5", 11 | "debug": "~2.2.0", 12 | "express": "~4.13.1", 13 | "morgan": "~1.6.1", 14 | "phaser": "^2.4.8", 15 | "serve-favicon": "~2.3.0", 16 | "socket.io": "^1.4.6", 17 | "swig": "^1.4.2" 18 | }, 19 | "devDependencies": { 20 | "browser-sync": "2.9.6", 21 | "gulp": "^3.9.0", 22 | "gulp-clean": "^0.3.1", 23 | "gulp-concat": "^2.6.0", 24 | "gulp-connect": "^2.2.0", 25 | "gulp-jshint": "^1.11.2", 26 | "gulp-minify-css": "^1.2.1", 27 | "gulp-nodemon": "^2.0.4", 28 | "gulp-uglify": "^1.4.2", 29 | "jshint-stylish": "^2.0.1", 30 | "run-sequence": "^1.1.4" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/client/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
34 |
38 |
42 |
46 |
50 | Not So Super Smash Bros is a multiplayer game that mimics the Nintendo game of Super Smash Brothers. This game is built with socket.io and phaser.io. To play this game, you will need a few things:
7 |You will then go to the link to the game on your computer and then each person will go to the same link on their phone as well. You will then on your computer click the 'HOST GAME' button and enter in the given number on your phone. Once you have more than one player, you can start the game! Each character has 100 HP points, whoever is the last one standing, wins! Remember to have fun!
13 | 14 |*** For those of you that are unsure on what Super Smash Brothers is, it is a multiplayer fighting game. You battle against the other people in the game by shooting them with your weapon. The controller that will appear on your phone has 5 buttons, left arrow to move left, right arrow to move right, a jump button, a fire button that allows you to shoot your opponents, and a star button that gives you a power up. The power up will let you shoot in multiple directions.***
15 | 16 |Star button on your controller is your power up. Once you see your character change color of the game screen, your power up is activated. Press the star button to use it
18 | 19 |You must have node and gulp installed in order to download this game
21 |To Download this game:
22 |
32 |
33 |
42 |
43 |
47 |
--------------------------------------------------------------------------------
/src/client/js/controller.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function(){
2 | $('#controls').hide();
3 | var socket = io();
4 | var right = false;
5 | var left = false;
6 | var jump = false;
7 | var fire = false;
8 | var player = null;
9 | var firePowerUp = false;
10 | var playerColor;
11 | var colors = ['#bf1313', '#1111bd', '#eac84d', '#11bd13' ];
12 | var playerPic;
13 | var pic = ['../assets/controller/megamanController.png', '../assets/controller/kirbyController.png', '../assets/controller/pikachuController.png', '../assets/controller/marioController.png'];
14 |
15 | $('#join').on('click', function() {
16 | var gameRoom = $('#user-input').val();
17 | socket.emit('new-player', {gameRoom: gameRoom});
18 |
19 | socket.on('invalid-room', function() {
20 | $('#error').html('Invalid Room
'); 21 | }) 22 | 23 | socket.on('success-join', function(playerNum) { 24 | if( playerNum <= 3) { 25 | console.log("PlayerNum:", playerNum); 26 | player = playerNum; 27 | 28 | playerColor = colors[playerNum]; 29 | playerPic = pic[playerNum]; 30 | $('body').css('background-color', playerColor); 31 | $('#picture').html('Too many players in room
'); 41 | }) 42 | }) 43 | 44 | document.fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.documentElement.webkitRequestFullScreen; 45 | 46 | 47 | $('#move-right').on('touchstart', function(event){ 48 | event.preventDefault(); 49 | right = true; 50 | }); 51 | 52 | $('#move-right').on('touchend', function(event){ 53 | event.preventDefault(); 54 | right = false; 55 | }); 56 | 57 | $('#move-left').on('touchstart', function(event){ 58 | event.preventDefault(); 59 | left = true; 60 | }); 61 | 62 | $('#move-left').on('touchend', function(event){ 63 | event.preventDefault(); 64 | left = false; 65 | }); 66 | 67 | $('#jump').on('touchstart', function(event){ 68 | event.preventDefault(); 69 | jump = true; 70 | }); 71 | 72 | $('#jump').on('touchend', function(event){ 73 | event.preventDefault(); 74 | jump = false; 75 | }); 76 | 77 | $('#fire').on('touchstart', function(event){ 78 | event.preventDefault(); 79 | fire = true; 80 | }); 81 | 82 | $('#fire').on('touchend', function(event){ 83 | event.preventDefault(); 84 | fire = false; 85 | }); 86 | 87 | $('#firePowerUp').on('touchstart', function(event){ 88 | event.preventDefault(); 89 | firePowerUp = true; 90 | }); 91 | 92 | $('#firePowerUp').on('touchend', function(event){ 93 | event.preventDefault() 94 | firePowerUp = false; 95 | }); 96 | 97 | function updateGame() { 98 | // sends game-update to server with the players input and player number 99 | socket.emit('game-update', {right: right, left: left, jump: jump, fire: fire, player: player, firePowerUp: firePowerUp}); 100 | } 101 | }); 102 | -------------------------------------------------------------------------------- /src/client/states/splash.js: -------------------------------------------------------------------------------- 1 | function Splash() {}; 2 | // console.log("splash"); 3 | 4 | Splash.prototype = { 5 | loadScripts: function () { 6 | game.load.script('WebFont', 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.16/webfont.js'); 7 | game.load.script('menu', 'states/menu.js'); 8 | game.load.script('game', 'states/game.js'); 9 | game.load.script('gameover', 'states/gameover.js'); 10 | }, 11 | loadAssets: function () { 12 | // Map assets 13 | game.load.image('sky', 'assets/marioLevel/MarioLevelBackground.png'); 14 | game.load.image('ground', 'assets/marioLevel/ground.png'); 15 | game.load.image('move-box', 'assets/marioLevel/box.png'); 16 | game.load.image('box', 'assets/marioLevel/ledge2.png'); 17 | game.load.image('littlebox', 'assets/marioLevel/box.png'); 18 | game.load.image('pipe', 'assets/marioLevel/pipe2.png'); 19 | 20 | // Menu Assets 21 | game.load.image('menu', 'assets/main_background.png'); 22 | game.load.image('player-selection', 'assets/player_selection2.png'); 23 | 24 | //Character Pictures for Player Selection 25 | game.load.image('select0', 'assets/megamanSplash.png'); 26 | game.load.image('select1', 'assets/kirbySplash.png'); 27 | game.load.image('select2', 'assets/pikachuSplash.png'); 28 | game.load.image('select3', 'assets/marioSplash.png'); 29 | 30 | // Sprite Bullets 31 | game.load.image('bullet0', 'assets/weapons/bullet0.png'); 32 | game.load.image('bullet1', 'assets/weapons/bullet1.png'); 33 | game.load.image('bullet2', 'assets/weapons/bullet2.png'); 34 | game.load.image('bullet3', 'assets/weapons/bullet3.png'); 35 | 36 | // Sprites 37 | game.load.spritesheet('megaman0', 'assets/sprites/megamanNew1.png', 50, 48); 38 | game.load.spritesheet('kirby1', 'assets/sprites/kirbySprite2.png', 23, 22); 39 | game.load.spritesheet('pikachu2', 'assets/sprites/pikachuSprite.png', 30, 30); 40 | game.load.spritesheet('mario3', 'assets/sprites/mario2.png', 24, 38); 41 | 42 | //Audio 43 | game.load.audio('soundDie', 'assets/sounds/Pacman-death-sound.mp3'); 44 | game.load.audio('mainSound', 'assets/sounds/SuperMarioBros.mp3') 45 | 46 | }, 47 | loadFonts: function () { 48 | WebFontConfig = { 49 | custom: { 50 | families: ['PressStart2P', 'Mario', 'PipeDream'], 51 | urls: ['assets/css/fonts.css'] 52 | } 53 | }; 54 | }, 55 | init: function() { 56 | this.status = game.make.text(game.world.centerX, 380, 'Loading...', { 57 | fill: 'blue', 58 | font: '40px Mario'}); 59 | this.status.anchor.setTo(0.5); 60 | }, 61 | preload: function() { 62 | 63 | game.add.sprite(0, 0, 'load-bg'); 64 | game.add.existing(this.status); 65 | 66 | this.loadScripts(); 67 | this.loadAssets(); 68 | this.loadFonts(); 69 | }, 70 | addGameStates: function() { 71 | game.state.add('Menu', Menu); 72 | game.state.add('Game', Game); 73 | game.state.add('GameOver', GameOver); 74 | }, 75 | create: function () { 76 | this.addGameStates(); 77 | this.status.setText('Loading...'); 78 | 79 | setTimeout(function() { 80 | game.state.start('Menu'); 81 | }, 1000); 82 | } 83 | }; 84 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Module Dependencies 3 | */ 4 | 5 | var gulp = require('gulp'); 6 | var jshint = require('gulp-jshint'); 7 | var browserSync = require('browser-sync'); 8 | var reload = browserSync.reload; 9 | var nodemon = require('gulp-nodemon'); 10 | var connect = require('gulp-connect'); 11 | var uglify = require('gulp-uglify'); 12 | var minifyCSS = require('gulp-minify-css'); 13 | var clean = require('gulp-clean'); 14 | var concat = require('gulp-concat'); 15 | var runSequence = require('run-sequence'); 16 | 17 | 18 | /** 19 | * Config 20 | */ 21 | 22 | var paths = { 23 | styles: [ 24 | './src/client/css/*.css', 25 | ], 26 | scripts: [ 27 | './src/client/js/*.js', 28 | ], 29 | server: 30 | './src/server/app.js', 31 | distServer: [ 32 | './dist/server/bin/www' 33 | ] 34 | }; 35 | 36 | var nodemonConfig = { 37 | script: paths.server, 38 | ext: 'html js css', 39 | ignore: ['node_modules'] 40 | }; 41 | 42 | var nodemonDistConfig = { 43 | script: paths.distServer, 44 | ext: 'html js css', 45 | ignore: ['node_modules'] 46 | }; 47 | 48 | 49 | /** 50 | * Gulp Tasks 51 | */ 52 | 53 | gulp.task('lint', function() { 54 | return gulp.src(paths.scripts) 55 | .pipe(jshint()) 56 | .pipe(jshint.reporter('jshint-stylish')); 57 | }); 58 | 59 | gulp.task('browser-sync', ['nodemon'], function(done) { 60 | browserSync({ 61 | proxy: "localhost:3000", // local node app address 62 | port: 5000, // use *different* port than above 63 | notify: true 64 | }, done); 65 | }); 66 | 67 | gulp.task('nodemon', function (cb) { 68 | var called = false; 69 | return nodemon(nodemonConfig) 70 | .on('start', function () { 71 | if (!called) { 72 | called = true; 73 | cb(); 74 | } 75 | }) 76 | .on('restart', function () { 77 | setTimeout(function () { 78 | reload({ stream: false }); 79 | }, 1000); 80 | }); 81 | }); 82 | 83 | gulp.task('watch', function() { 84 | gulp.watch(paths.scripts, ['lint']); 85 | }); 86 | 87 | gulp.task('clean', function() { 88 | gulp.src('./dist/*') 89 | .pipe(clean({force: true})); 90 | }); 91 | 92 | gulp.task('minify-css', function() { 93 | var opts = {comments:true, spare:true}; 94 | gulp.src(paths.styles) 95 | .pipe(minifyCSS(opts)) 96 | .pipe(gulp.dest('./dist/client/css/')); 97 | }); 98 | 99 | gulp.task('minify-js', function() { 100 | gulp.src(paths.scripts) 101 | .pipe(uglify()) 102 | .pipe(gulp.dest('./dist/client/js/')); 103 | }); 104 | 105 | gulp.task('copy-server-files', function () { 106 | gulp.src('./src/server/**/*') 107 | .pipe(gulp.dest('./dist/server/')); 108 | }); 109 | 110 | 111 | gulp.task('connectDist', function (cb) { 112 | var called = false; 113 | return nodemon(nodemonDistConfig) 114 | .on('start', function () { 115 | if (!called) { 116 | called = true; 117 | cb(); 118 | } 119 | }) 120 | .on('restart', function () { 121 | setTimeout(function () { 122 | reload({ stream: false }); 123 | }, 1000); 124 | }); 125 | }); 126 | 127 | 128 | // *** default task *** // 129 | gulp.task('default', ['browser-sync', 'watch'], function(){}); 130 | 131 | // *** build task *** // 132 | gulp.task('build', function() { 133 | runSequence( 134 | ['clean'], 135 | ['lint', 'minify-css', 'minify-js', 'copy-server-files', 'connectDist'] 136 | ); 137 | }); 138 | -------------------------------------------------------------------------------- /src/client/states/gameover.js: -------------------------------------------------------------------------------- 1 | var characters = ['select0', 'select1', 'select2', 'select3']; 2 | var winningPlayer; 3 | var count = 0; 4 | this.winnerText; 5 | 6 | function GameOver () {}; 7 | 8 | GameOver.prototype = { 9 | init: function(winner, playerCount) { 10 | 11 | this.winner = winner; 12 | this.playerCount = playerCount; 13 | 14 | for (var i=0; i < characters.length; i++) { 15 | if (i === winner) { 16 | winningPlayer = characters[i]; 17 | } 18 | } 19 | 20 | this.titleText = game.make.text(game.world.centerX, 90, 'Not-So-Super\n Smash Bros.', { 21 | font: '60px PipeDream', 22 | align: 'center', 23 | }); 24 | this.titleText.addColor('blue', 0); 25 | this.titleText.addColor('black', 3); 26 | this.titleText.addColor('#fbcf08', 4); 27 | this.titleText.addColor('black', 6); 28 | this.titleText.addColor('#E42926', 7); 29 | this.titleText.addColor('#00c600', 12); 30 | this.titleText.addColor('#fbcf08', 18); 31 | this.titleText.anchor.setTo(0.5); 32 | this.titleText.setShadow(5, 5, 'rgba(0, 0, 0, 0.5)', 0); 33 | this.titleText.anchor.setTo(0.5); 34 | 35 | this.winnerText = game.make.text(game.world.centerX, 200, 'The winner is: ' , { 36 | font: '50px PipeDream', 37 | align: 'center', 38 | }); 39 | this.winnerText.anchor.setTo(0.5); 40 | 41 | }, 42 | create: function () { 43 | game.add.sprite(0, 0, 'menu'); 44 | game.add.existing(this.titleText); 45 | game.add.existing(this.winnerText); 46 | // Make sprite dynamic 47 | this.sprite = game.add.sprite(game.world.centerX, game.world.centerY, winningPlayer); 48 | this.sprite.scale.setTo(0.5); 49 | this.sprite.anchor.setTo(0.5); 50 | this.restartGame(); 51 | setInterval(timer, 800); 52 | }, 53 | restartGame: function () { 54 | var text = game.add.text(game.world.centerX, game.world.height * 0.7, 'Rematch?', { 55 | font: '50px PipeDream', 56 | align: 'center', 57 | fill: 'red' 58 | }); 59 | text.anchor.setTo(0.5); 60 | var hoverTrue = function (button) { 61 | button.fill = "#30DEF8"; 62 | button.stroke = "rgba(200, 200, 200, 0.5)"; 63 | }; 64 | var hoverFalse = function (button) { 65 | button.fill = 'red'; 66 | button.stroke = "rgba(0,0,0,0)"; 67 | }; 68 | var onClick = function () { 69 | mainSound.stop(); 70 | game.state.start('Game', true, false, this.playerCount); 71 | }.bind(this); 72 | 73 | text.stroke = "rgba(0,0,0,0)"; 74 | text.strokeThickness = 4; 75 | text.inputEnabled = true; 76 | text.events.onInputUp.add(onClick); 77 | text.events.onInputOver.add(hoverTrue); 78 | text.events.onInputOut.add(hoverFalse); 79 | }, 80 | preload: function () { 81 | 82 | }, 83 | update: function() { 84 | if (count === 0){ 85 | this.winnerText.addColor('red', 0); 86 | } 87 | if (count === 1) { 88 | this.winnerText.addColor('#fbcf08', 0); 89 | } 90 | if (count === 2) { 91 | this.winnerText.addColor('blue', 0); 92 | } 93 | if (count === 3) { 94 | this.winnerText.addColor('#E42926', 0); 95 | } 96 | if (count === 4){ 97 | this.winnerText.addColor('#00c600', 0); 98 | } 99 | } 100 | }; 101 | 102 | function timer () { 103 | if (count === 4) { 104 | count = 0; 105 | } 106 | count += 1; 107 | } 108 | -------------------------------------------------------------------------------- /src/server/app.js: -------------------------------------------------------------------------------- 1 | // *** main dependencies *** // 2 | var express = require('express'); 3 | var path = require('path'); 4 | var favicon = require('serve-favicon'); 5 | var logger = require('morgan'); 6 | var cookieParser = require('cookie-parser'); 7 | var bodyParser = require('body-parser'); 8 | 9 | // *** routes *** // 10 | var routes = require('./routes/index.js'); 11 | 12 | 13 | // *** express instance *** // 14 | var app = express(); 15 | 16 | app.set('port', process.env.PORT || 3000); 17 | 18 | var server = app.listen(app.get('port'), function() { 19 | console.log('Express server listening on port ' + server.address().port); 20 | }); 21 | // *** config middleware *** // 22 | app.use(logger('dev')); 23 | app.use(bodyParser.json()); 24 | app.use(bodyParser.urlencoded({ extended: false })); 25 | app.use(cookieParser()); 26 | app.use(express.static(path.join(__dirname, '../client'))); 27 | 28 | 29 | // *** main routes *** // 30 | app.get('/', function(req, res, next) { 31 | res.sendFile(path.join(__dirname, '../client/', 'layout.html')); 32 | }); 33 | 34 | app.get('/controller', function(req, res) { 35 | //Serve up phone page here. 36 | res.sendFile(path.join(__dirname, '../client', 'controller.html')); 37 | }); 38 | 39 | 40 | // *** SOCKET.IO *** // 41 | var io = require('socket.io').listen(server); 42 | var rooms = {}; 43 | 44 | io.on('connect', function(socket){ 45 | console.log('a user connected'); 46 | 47 | //connect new player to the room 48 | socket.on('new-player', function(data){ 49 | 50 | if (!rooms[data.gameRoom] || rooms[data.gameRoom].started) { 51 | console.log('invalid room'); 52 | socket.emit('invalid-room'); 53 | } else { 54 | console.log("Joined",data.gameRoom) 55 | socket.room = data.gameRoom; 56 | 57 | if (rooms[data.gameRoom].players) { 58 | rooms[data.gameRoom].players++; 59 | console.log("Players:",rooms[data.gameRoom].players) 60 | } else { 61 | rooms[data.gameRoom].players = 1; 62 | console.log("Players:",rooms[data.gameRoom].players) 63 | } 64 | console.log("Phone:", data.gameRoom); 65 | if(rooms[data.gameRoom].players < 5) { 66 | io.sockets.in(rooms[socket.room].id).emit('player-joined', rooms[data.gameRoom].players); 67 | 68 | var playerId = rooms[data.gameRoom].players - 1; 69 | socket.emit('success-join', playerId); 70 | } 71 | else { 72 | socket.emit('fail-join'); 73 | } 74 | if (rooms[data.gameRoom].players >= 1 && rooms[data.gameRoom].players < 5 ) { 75 | io.sockets.in(rooms[socket.room].id).emit('start-game'); 76 | } 77 | else { 78 | console.log('Error'); 79 | } 80 | } 81 | }); 82 | 83 | //updates game while being played 84 | socket.on('game-update', function(data) { 85 | if (rooms[socket.room]) { 86 | io.sockets.in(rooms[socket.room].id).emit('game-update', data); 87 | } 88 | // io.sockets.emit('game-update', data); 89 | }) 90 | 91 | // Check for 'create-game' emit 92 | socket.on('create-game', function(data) { 93 | if(!rooms[data.gameRoom]) { 94 | console.log('Creating game... GameRoom:', data.gameRoom) 95 | rooms[data.gameRoom] = {id: data.viewId}; 96 | rooms[data.gameRoom].started = false; 97 | socket.join(data.viewId); 98 | socket.emit('success-create', data); 99 | } else { 100 | console.log("Shit's broke server-side"); 101 | } 102 | }) 103 | 104 | // Check for 'start-game' emit 105 | socket.on('game-start', function(data) { 106 | console.log('GameRoom:', data.gameRoom); 107 | rooms[data.gameRoom].started = true; 108 | }) 109 | 110 | // Check for 'disconnect emit' 111 | socket.on('disconnect', function(){ 112 | console.log('user disconnected'); 113 | }); 114 | }); 115 | 116 | 117 | module.exports = server; 118 | -------------------------------------------------------------------------------- /src/client/states/game.js: -------------------------------------------------------------------------------- 1 | var players = []; 2 | var inputs = []; 3 | var ground; 4 | var platforms; 5 | var bullets; 6 | var dieSound; 7 | var mainSound; 8 | 9 | function Game () { 10 | this.playerCount; 11 | this.platforms; 12 | } 13 | 14 | 15 | function powerUp () { 16 | for (var i=0; i