<file_sep># TowerDefense for BlackBerry10!

The scope is to create a simple and easy game for all those Tower defense lovers. 
--

Why do this?
Because we though it would be fun to make our own tower defense game while learning to increase our skills as a group.

I'm using the following to develop this :

  * Phaser.io
  * Blackberry Webworks
  * TypeScript
  * HTML5
  * CSS3

Learn Phaser!
https://phaser.io/learn

It is recommended you download, install and run webworks to run this. However, you can go into the www/ folder and run that however way you'd like.

What's a BlackBerry WebWorks app? Follow this link to BlackBerry's Dev page to find out! 
http://developer.blackberry.com/html5/documentation/v2_2/what_is_a_webworks_app.html
<file_sep>//new Game(width, height, renderer, parent, state, transparent, antialias, physicsConfig)
//var game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO, '', {preload: preload, create: create, update: update});
var game = new Phaser.Game(1350, 1080, Phaser.AUTO, '', {preload: preload, create: create, update: update});

//for future purposes, to scale game based on pixel ratio
var scaleRatio = window.devicePixelRatio / 3;
//var logo;
var background;
var creep;


function preload(){
	//game.load.type('assetName', 'location/in/filesystem', width, height);
	//game.load.image('logo', 'assets/phaser-logo-small.png');
	game.load.spritesheet('creep', 'assets/creeps/creep_noWeapon.png', 200, 163);
	game.load.image('background1', 'assets/maps/Maps1.png', 1080, 1350);
}

function create(){
	
	//Arcade Physics - i.e. It enables motion
	game.physics.startSystem(Phaser.Physics.ARCADE);

	//Sets Background at 0x0(Top Left Corner)
	game.add.sprite(0, 0, 'background1');

	//Logo
	//logo = game.add.sprite(game.world.centerX, game.world.centerY, 'logo');
	//logo.scale.setTo(scaleRatio, scaleRatio);

	//creeep
	creep = game.add.sprite(game.world.centerX, game.world.centerY, 'creep');
	//creep.scale.setTo(scaleRatio, scaleRatio);

	//Gives Creep ability to Move and other physics related qualities
	game.physics.arcade.enable(creep);
	
	//Sets the Animation sequence for the creep
	//assetName.animations.add('animationName', [Frames], fps, loop?)
	creep.animations.add('left', [0, 1], 5, true);
	creep.animations.add('right', [3, 4], 5, true);

	//Add Keyboard Manager
	cursors = game.input.keyboard.createCursorKeys();
}	

function update(){
	//Stops creep motion on the x axis
	creep.body.velocity.x = 0;


	//Checks for arrow presses and acts accordingly
	if(cursors.left.isDown)
	{
		creep.body.velocity.x = -150;
		creep.animations.play('left');
	} 
	else if (cursors.right.isDown)
	{
		creep.body.velocity.x = 150;
		creep.animations.play('right');
	} 
	else 
	{
		creep.animations.stop();
		creep.frame = 2;
	}
}