Skip to content

Commit

Permalink
Merge pull request #150 from left23/master
Browse files Browse the repository at this point in the history
refactor plates 001, 013, 020
  • Loading branch information
left23 authored Jun 19, 2016
2 parents f373b04 + 6ff8154 commit b8dfcfc
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 189 deletions.
127 changes: 0 additions & 127 deletions components/com_battle/views/plate/tmpl/001_consumer/-script.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
</body>
</html>


13 changes: 12 additions & 1 deletion components/com_battle/views/plate/tmpl/001_consumer/state001.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ function killTooltip(thing) {
text.destroy();
//bar.destroy();

}
}


// defining a single global object (are_you_insane) and adding some functions in to its prototype (eg preload, create functions)

var are_you_insane = {};


are_you_insane.State001 = function (game) {


};
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<html>
<head>
<!-- Phaser -->
<script src="/components/com_battle/views/phaser/tmpl/_site/js/phaser.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="world">
</div>
<script src='http://eclecticmeme.com/components/com_battle/views/plate/tmpl/013_are_you_insane/script.js'></script>
</body>
<head>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<div id="world">
</div>
<script src='state001.js'></script>
<script src='script.js'></script>
</body>
</html>




Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
var game = new Phaser.Game(640, 480, Phaser.CANVAS, 'world', { preload: preload, create: create });
// we create the global game object, an instance of Phaser.Game

function preload () {
var game = new Phaser.Game(800, 500, Phaser.AUTO, 'world');

// You can fill the preloader with as many assets as your game requires
// the first parameter is the key you use to jump between stated
// the key must be unique within the state manager
// the second parameter is the object that contains the state code
// these come from the js files we included in the head tag in the html file
game.state.add('State001', are_you_insane.State001);

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
game.load.image('plate', 'are_you_insane.jpg');

}

function create() {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
}
game.state.start('State001');
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// defining a single global object (are_you_insane) and adding some functions in to its prototype (eg preload, create functions)

var are_you_insane = {};


are_you_insane.State001 = function (game) {


};

are_you_insane.State001.prototype = {

preload: function () {

// You can fill the preloader with as many assets as your game requires

// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.

// The second parameter is the URL of the image (relative)
this.load.image('plate', 'are_you_insane.jpg');

},
create: function () {

// This creates a simple sprite that is using our loaded image and
// displays it on-screen and assign it to a variable
var image = this.add.sprite(game.world.centerX, game.world.centerY, 'plate');

// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<html>
<head>
<script src="/components/com_battle/includes/jquery-2.0.3.min.js"></script>
<!-- Phaser -->
<script src="/components/com_battle/includes/phaser.js"></script>
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var game = new Phaser.Game(800, 500, Phaser.AUTO, 'world');
// the key must be unique within the state manager
// the second parameter is the object that contains the state code
// these come from the js files we included in the head tag in the html file
game.state.add('State001', zombies_from_outer_space.State001);
game.state.add('State001', zombies_from_space.State001);

game.state.start('State001');

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// defining a single global object (zombies_from_outer_space) and adding some functions in to its prototype (eg preload, create functions)
// defining a single global object (zombies_from_space) and adding some functions in to its prototype (eg preload, create functions)

var zombies_from_space = {};

var zombies_from_outer_space = {};
var cursors;
var player;
var fire;
Expand All @@ -15,12 +16,11 @@ var result = 'Click a body';
var title;
var arm;

zombies_from_outer_space.State001 = function (game) {

zombies_from_space.State001 = function (game) {

};

zombies_from_outer_space.State001.prototype = {
zombies_from_space.State001.prototype = {

preload: function () {
// The second parameter is the URL of the image (relative)
Expand Down Expand Up @@ -147,11 +147,6 @@ zombies_from_outer_space.State001.prototype = {
player.animations.stop();
}
}
/*
var game = new Phaser.Game(640, 480, Phaser.CANVAS, 'world', {
preload: preload, create: create , update:update, render:render
});
*/

function listener () {

Expand All @@ -174,26 +169,22 @@ function click(pointer) {
// You can hitTest against an array of Sprites, an array of Phaser.Physics.P2.Body objects, or don't give anything
// in which case it will check every Body in the whole world.

var bodies = game.physics.p2.hitTest(pointer.position, [ bobhead, bobbody, player ]);
var bodies = game.physics.p2.hitTest(pointer.position, [bobhead, bobbody, player]);

if (bodies.length === 0)
{
if (bodies.length === 0) {
result = "You didn't click a Body";
}
else
{
else {
result = "You clicked: ";

for (var i = 0; i < bodies.length; i++)
{
for (var i = 0; i < bodies.length; i++) {
// The bodies that come back are p2.Body objects.
// The parent property is a Phaser.Physics.P2.Body which has a property called 'sprite'
// This relates to the sprites we created earlier.
// The 'key' property is just the texture name, which works well for this demo but you probably need something more robust for an actual game.
result = result + bodies[i].parent.sprite.key;

if (i < bodies.length - 1)
{
if (i < bodies.length - 1) {
result = result + ', ';
}
}
Expand Down

0 comments on commit b8dfcfc

Please sign in to comment.