Skip to content

Commit

Permalink
Phaser template
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Sep 19, 2015
1 parent 0586829 commit 77be8fc
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# jonga
Physics based kung fu boss battle game for mini LD 62
# Jonga

<!--
![](logo.png)
-->
Physics based kung fu boss battle game!

<!--
Jonga is open source and made for [Mini LD 62](insert link here)
[Play online now](insert link here)
-->

### Licenses

Code is under MIT (see `LICENSE`);
<!--
all assets are under [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
-->
Binary file added images/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bar_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE HTML>
<title>Jonga</title>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body{
margin: 0;
padding: 0;
font-family: monospace;
background-color: #12B2AD;
}
canvas {
width: 100%;
height: 100%;
}
</style>
<script src="scripts/phaser.min.js"></script>
<script src="scripts/graphics.js"></script>
<script src="scripts/main.js"></script>
<script src="scripts/preload.js"></script>
<script src="scripts/boot.js"></script>
</head>
<body>
<div id="gameContainer"></div>
<div id="fontLoader">Coconuts</div>
<script src="scripts/index.js"></script>
</body>
</html>
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions manifest.webapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Jonga",
"description": "Physics based kung fu boss battle game for mini LD 62",
"launch_path": "/index.html",
"icons": {
"512": "images/icon-512.png",
"128": "images/icon-128.png"
},
"developer": {
"name": "congusbongus",
"url": "http://cxong.github.io"
},
"default_locale": "en",
"type": "web",
"version": "1.0"
}
17 changes: 17 additions & 0 deletions scripts/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BasicGame.Boot = function (game) {
};

BasicGame.Boot.prototype = {

preload: function () {
this.game.load.image('bar_back', 'images/bar_back.png');
this.game.load.image('bar', 'images/bar.png');
},

create: function () {
this.game.stage.backgroundColor = 0x00FFF6;
this.input.maxPointers = 1;

this.state.start('preload');
}
};
6 changes: 6 additions & 0 deletions scripts/graphics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var SCREEN_WIDTH = 800;
var SCREEN_HEIGHT = 480;

var GROUND_Y = SCREEN_HEIGHT - 80;

var GRAVITY = 990;
10 changes: 10 additions & 0 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
window.onload = function() { setTimeout(function () {
document.getElementById('fontLoader').style.display = 'none';
var game = new Phaser.Game(SCREEN_WIDTH, SCREEN_HEIGHT, Phaser.AUTO,
'gameContainer', null, false,
false);
game.state.add('boot', BasicGame.Boot);
game.state.add('preload', BasicGame.Preload);
game.state.add('game', GameState);
game.state.start('boot');
}, 1000); };
99 changes: 99 additions & 0 deletions scripts/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
var GameState = function(game){};

GameState.prototype.preload = function() {
};

GameState.prototype.create = function() {
this.game.stage.backgroundColor = 0x00FFF6;
this.game.physics.arcade.gravity.y = GRAVITY;

this.sounds = {
//hit: this.game.add.sound('hit'),
};

this.groups = {
bg: this.game.add.group(),
enemies: this.game.add.group(),
player: this.game.add.group(),
enemyFists: this.game.add.group(),
playerFists: this.game.add.group(),
title: this.game.add.group()
};

this.groups.bg.add(this.game.add.sprite(0, 0, 'bg'));
//var sand = this.game.add.sprite(0, SCREEN_HEIGHT, 'sand');
//sand.anchor.y = 1;
//this.groups.sand.add(sand);

/*
this.player = new Player(
this.game, this.groups.tree, this.groups.coconuts, this.sounds,
SCREEN_WIDTH / 2, SAND_Y, 'tree');
this.game.input.onDown.add(function() {
this.attack();
}, this);
this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR).onDown.add(function() {
this.attack();
}, this);
*/

//this.music = this.game.add.audio('music');
/*
this.bigTextStyle = {
font: "36px Courier New, monospace",
fill: "#000",
fontWeight: "bold"
};
this.highStyle = {
font: "36px Courier New, monospace",
fill: "#f00",
fontWeight: "bold"
};
*/

this.title = this.game.add.sprite(
SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 'title');
this.title.anchor.setTo(0.5);

this.started = false;

this.readyTime = this.game.time.now + 1000;
};

GameState.prototype.start = function() {
//this.groups.tourists.removeAll();

this.timeLast = this.game.time.now;
this.timeLastHalf = this.timeLast;
//this.music.play('', 0, 1, true);

this.title.alpha = 0;

this.started = true;
};

GameState.prototype.stop = function() {
this.music.stop();

this.title.alpha = 1;

this.started = false;

this.readyTime = this.game.time.now + 1000;
};

GameState.prototype.attack = function() {
if (!this.started) {
if (this.readyTime < this.game.time.now) {
this.start();
}
} else {
//this.tree.attack();
}
};

GameState.prototype.update = function() {
/*this.game.physics.arcade.overlap(
this.groups.coconuts, this.groups.tourists, function(coconut, tourist) {
}, null, this);*/
};
27 changes: 27 additions & 0 deletions scripts/phaser.min.js

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions scripts/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var BasicGame = {};
BasicGame.Preload = function (game) {
this.preloadBar = null;
};

BasicGame.Preload.prototype = {
preload: function () {
var barBack = this.add.sprite(SCREEN_WIDTH / 2,
SCREEN_HEIGHT / 2,
'bar_back');
barBack.anchor.setTo(0.5, 0.5);
this.preloadBar = this.add.sprite(SCREEN_WIDTH / 2,
SCREEN_HEIGHT / 2,
'bar');
this.preloadBar.anchor.setTo(0, 0.5);
this.preloadBar.x -= this.preloadBar.width / 2;
this.load.setPreloadSprite(this.preloadBar);

this.game.load.image('title', 'images/title.png');
this.game.load.image('bg', 'images/bg.png');

//this.game.load.audio('hit', 'sounds/hit.wav');
//this.game.load.audio('music', 'sounds/headinthesand.ogg');
},

create: function () {
this.state.start('game');
}
};

0 comments on commit 77be8fc

Please sign in to comment.