Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh pages #5

Open
wants to merge 9 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# GMU CS325 Introduction to Game Design

This repository is a simple "hello, world!" template for a game made with Phaser.
All the code lives in the `gh-pages` branch. This lets you run your games directly from github!
Check it out: http://gmu-cs325.github.io/digital-template/
Fork this repository, checkout the `gh-pages` branch, and start making your own game!

You can't run the `index.html` directly from your local machine without a local webserver.
If you try, the images won't load (your browser will prevent it, thinking it is malicious).
To get around this, use python (enter the directory and type `python -m SimpleHTTPServer`)
or install [`node.js`](http://nodejs.org/) and the `http-server` package,
and then type `http-server` from inside the directory.
Binary file added assets/Facts.mp3
Binary file not shown.
Binary file added assets/GitHubSetup.exe
Binary file not shown.
20 changes: 20 additions & 0 deletions assets/Ichigo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{"frames": {

"Ichigo.png":
{
"frame": {"x":1,"y":1,"w":1386,"h":58},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":5,"y":0,"w":1386,"h":58},
"sourceSize": {"w":1395,"h":58}
}},
"meta": {
"app": "http://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "Ichigo.png",
"format": "RGBA8888",
"size": {"w":1388,"h":60},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:c1869e39c6b58f14c88847cdbc392133:e3bde8ac994427e2dbb4cbc60faaf694:02693341a6a7d8de9acea0dd2bc91d75$"
}
}
Binary file added assets/Ichigo.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 assets/collected.mp3
Binary file not shown.
Binary file added assets/dude.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 removed assets/phaser.png
Binary file not shown.
Binary file added assets/platform.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 assets/seireitei.jpg
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 assets/skull.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 assets/soul.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 assets/terminated.wav
Binary file not shown.
28 changes: 14 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Hello! Wow!</title>
<title>Souls</title>
<script src="js/phaser.js"></script>
<script src="js/main.js"></script>

Expand All @@ -20,33 +20,33 @@

</head>
<body>
<div id="game"></div>
<div id="Souls"></div>
<div id="readme">
<h2>Your game title</h2>
<h2>Souls</h2>
<ul>

<li><strong>High Concept:</strong>
A one-sentence summary of your game.
You are a soul reaper who is gathering souls
</li>

<li><strong>Player Experience Goals:</strong>
What experience do you want players to have when playing your game?
I want players to expierence a puzzle type of platformer
</li>

<li><strong>Genre:</strong>
A single sentence that places the game within a game genre or a hybrid of genres.
This game would be categorized under platformer
</li>

<li><strong>Game play:</strong>
A paragraph describing the actions the player can perform, the system dynamics, and the core mechanic. Include a concise explanation of the prototype’s inputs and their expected effects (how to play). You can also describe game play that is not in the prototype. You may include mock-up images for parts of the game not in the prototype.
In this game the player will use arrow keys to control the character. You must collect the blue souls. If you touch a skull, you will die and the game is over. You must also collect all souls before the time is up.
</li>

<li><strong>Prototype goal:</strong>
What game mechanic is this prototype evaluating?
This prototype is evaluating the ability to move around the surroundings of the map.
</li>

<li><strong>Features:</strong>
What are the unique aspects of your game that set it apart?
This game takes an element from mario where you have to collect coins. The coins are flying around the map along with the skulls.
</li>

<li><strong>Setting/Premise:</strong>
Expand All @@ -62,22 +62,22 @@ <h2>Your game title</h2>
</li>

<li><strong>Play time:</strong>
How long does your game take to play?
This game can be completed within 90 seconds
</li>

<li><strong>Strategies:</strong>
What player strategies do you expect will be effective at playing this game?
I suggest the player to jump to the side of the map that doesnt have the giant skulls and collect the souls there and jump over the skulls if you have to get the rest. Try not to go to a corner of the map when a skull is going toward you.
</li>

<li><strong>Prototype Assets:</strong>
Did you make your prototype assets from scratch? Did you borrow them? Cite your sources here.
I used the getting started example from phaser to get started
</li>

<li><strong>Prototype Closest Other Game:</strong>
Which other game most closely resembles your game? If you are borrowing from a Phaser Example, you must say so here.
The Getting started example is close to this game except that the object to collect flies all over the map.
</li>

</ul>
</div>
</body>
</html>
</html>
222 changes: 178 additions & 44 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,186 @@
window.onload = function() {
// You might want to start with a template that uses GameStates:
// https://github.com/photonstorm/phaser/tree/master/resources/Project%20Templates/Basic
"use strict";
var game = new Phaser.Game( 800, 600, Phaser.AUTO, 'Souls', { preload: preload, create: create, update: update } )
function preload() {
game.load.image('seireitei', 'assets/seireitei.jpg');
game.load.image('ground', 'assets/platform.png');
game.load.image('star', 'assets/soul.png');
game.load.spritesheet('Ichigo', 'assets/Ichigo.png',45,56);
game.load.image('skull',"assets/skull.png");
game.load.audio('terminated',"assets/terminated.wav");
game.load.audio('collected',"assets/collected.mp3");
game.load.audio('facts',"assets/facts.mp3");
}
var player;
var platforms;
var cursors;
var background;
var gameover;
var win;
var stars;
var score = 0;
var scoreText;
var timer;
var currentTime;
var timerEvent;
var Event;
var skulls;

// You can copy-and-paste the code from any of the examples at http://examples.phaser.io here.
// You will need to change the fourth parameter to "new Phaser.Game()" from
// 'phaser-example' to 'game', which is the id of the HTML element where we
// want the game to go.
// The assets (and code) can be found at: https://github.com/photonstorm/phaser/tree/master/examples/assets
// You will need to change the paths you pass to "game.load.image()" or any other
// loading functions to reflect where you are putting the assets.
// All loading functions will typically all be found inside "preload()".

"use strict";

var game = new Phaser.Game( 800, 600, Phaser.AUTO, 'game', { preload: preload, create: create, update: update } );

function preload() {
// Load an image and call it 'logo'.
game.load.image( 'logo', 'assets/phaser.png' );
function create() {
// We're going to be using physics, so enable the Arcade Physics system
game.physics.startSystem(Phaser.Physics.ARCADE);
var facts =game.add.audio('facts');
facts.play();
// A simple background for our game
background=game.add.sprite(0, 0, 'seireitei');
background.height=game.height;
background.width=game.width;
// The platforms group contains the ground and the 2 ledges we can jump on
platforms = game.add.group();
// We will enable physics for any object that is created in this group
platforms.enableBody = true;
// Here we create the ground.
var ground = platforms.create(0, game.world.height - 64, 'ground');
//var ceiling = platforms.create(0,-50,'ground');
// Scale it to fit the width of the game (the original sprite is 400x32 in size)
ground.scale.setTo(2, 2);
//ceiling.scale.setTo(2,2);
// This stops it from falling away when you jump on it
ground.body.immovable = true;
// ceiling.body.immovable =true;
// Now let's create two ledges
var ledge = platforms.create(400, 400, 'ground');
ledge.body.immovable = true;
ledge = platforms.create(-150, 250, 'ground');
ledge.body.immovable = true;
// The player and its settings
player = game.add.sprite(0, game.world.height - 150, 'Ichigo');
// We need to enable physics on the player
game.physics.arcade.enable(player);
// Player physics properties. Give the little guy a slight bounce.
player.body.bounce.y = 0.2;
player.body.gravity.y = 300;
player.body.collideWorldBounds = true;
// Our two animations, walking left and right.
player.animations.add('idle', [0,1,2,3],10,true);

player.animations.add('left', [13, 12], 10, false);
player.animations.add('right', [12, 13], 10, true);
// Finally some stars to collect
stars = game.add.group();
// We will enable physics for any star that is created in this group
stars.enableBody = true;
// Here we'll create 20 of them evenly spaced apart
for (i = 0; i < 20; i++)
{
// Create a star inside of the 'stars' group
var star = stars.create(i * 70, 1, 'star');
star.body.velocity.setTo(200,200);
star.body.collideWorldBounds=true;
star.body.bounce.y = 0.7 + Math.random() * 0.2;
star.body.bounce.x= 0.7 + Math.random() * 0.2;
}
skulls=game.add.group();
skulls.enableBody=true;
var i;
for (i = 0; i < 2; i++)
{
// Create a star inside of the 'stars' group
var skull = skulls.create(i * 150, 1, 'skull');
skull.body.velocity.setTo(200,200);
skull.body.collideWorldBounds=true;
skull.body.bounce.y = 0.7 + Math.random() * 0.2;
skull.body.bounce.x= 0.7 + Math.random() * 0.2;
}
// The score
scoreText = game.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#000' });
timer= game.time.create();
timerEvent= timer.add(Phaser.Timer.MINUTE*1+ Phaser.Timer.SECOND *30, this.endTimer,this);
timer.start();
// timer = game.add.text(game.world.centerX+250, 16, '00:00:00', { fontSize: '32px', fill: '#000' });
// Our controls.
cursors = game.input.keyboard.createCursorKeys();

var bouncy;

function create() {
// Create a sprite at the center of the screen using the 'logo' image.
bouncy = game.add.sprite( game.world.centerX, game.world.centerY, 'logo' );
// Anchor the sprite at its center, as opposed to its top-left corner.
// so it will be truly centered.
bouncy.anchor.setTo( 0.5, 0.5 );

// Turn on the arcade physics engine for this sprite.
game.physics.enable( bouncy, Phaser.Physics.ARCADE );
// Make it bounce off of the world bounds.
bouncy.body.collideWorldBounds = true;

// Add some text using a CSS style.
// Center it in X, and position its top 15 pixels from the top of the world.
var style = { font: "25px Verdana", fill: "#9999ff", align: "center" };
var text = game.add.text( game.world.centerX, 15, "Build something awesome.", style );
text.anchor.setTo( 0.5, 0.0 );
}
function update() {
// Collide the player and the stars with the platforms
game.physics.arcade.collide(player, platforms);
game.physics.arcade.collide(stars, platforms);
// Checks to see if the player overlaps with any of the stars, if he does call the collectStar function
game.physics.arcade.overlap(player, stars, collectStar, null, this);
game.physics.arcade.overlap(player,skulls,explode,null,this);
// Reset the players velocity (movement)
player.body.velocity.x = 0;
if (cursors.left.isDown)
{
// Move to the left
player.body.velocity.x = -150;
player.scale.x=-1;
player.animations.play('left');
}
else if (cursors.right.isDown)
{
// Move to the right
player.body.velocity.x = 150;
player.scale.x=1;
player.animations.play('right');
}
else
{
// Stand still
player.animations.play('idle');
//player.frame =4;
}

function update() {
// Accelerate the 'logo' sprite towards the cursor,
// accelerating at 500 pixels/second and moving no faster than 500 pixels/second
// in X or Y.
// This function returns the rotation angle that makes it visually match its
// new trajectory.
bouncy.rotation = game.physics.arcade.accelerateToPointer( bouncy, this.game.input.activePointer, 500, 500, 500 );
// Allow the player to jump if they are touching the ground.
if (cursors.up.isDown && player.body.touching.down)
{
player.body.velocity.y = -350;
}
if(stars.countLiving()==0 || timer.running()==false)
{
timer.stop();
goText = this.game.add.text(game.world.centerX-100,game.world.centerY,' ', { font: '40px Arial', fill: '#D80000', align: 'center' });
goText.text="You Win!!";
goText.visible=true;
player.kill();
timer.stop();
}
render();
}
function render()
{
if (timer.running) {
currentTime=game.debug.text(this.formatTime(Math.round((timerEvent.delay - timer.ms) / 1000)), game.world.centerX+300, 32,'#000');
}
}
function formatTime (s) {
// Convert seconds (s) to a nicely formatted and padded time string
var minutes = "0" + Math.floor(s / 60);
var seconds = "0" + (s - minutes * 60);
return minutes.substr(-2) + ":" + seconds.substr(-2);
}
function explode(player,skull)
{
player.kill();
var terminated =game.add.audio('terminated');
terminated.play();
goText = this.game.add.text(game.world.centerX-100,game.world.centerY,' ', { font: '40px Arial', fill: '#D80000', align: 'center' });
goText.text="Game Over\n You Died!!";
goText.visible=true;
timer.stop();
// game.input.onTap.addOnce(restart,this);
}
function collectStar (player, star) {

// Removes the star from the screen
star.kill();
var collected =game.add.audio('collected');
collected.play();
// Add and update the score
score += 10;
scoreText.text = 'Score: ' + score;


}
};
45 changes: 20 additions & 25 deletions js/phaser.min.js

Large diffs are not rendered by default.