-
-
Save Babsobar/d8dc8eaf0d42108e323f268eeedd0093 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//terrain Variables | |
var terrain; | |
var terrainLayer; | |
var terrainPop; | |
var terrainLimbo | |
var currentLayer; | |
//First iteration of unit architecture, prototype for now | |
var biffinRed; | |
var army; | |
var corps; | |
//Keys | |
var marker; | |
var updateInput = true; | |
//default Tile on selector: water(0) | |
var currentTile = 0; | |
//Size of map; in tiles amount | |
var gameWorldX = 120; | |
var gameWorldY = 120; | |
// which tiles to use as a tileset (can be changed for skins) | |
var tileSetImage = 'terrain2' | |
//GUI variables | |
var tileSelector; | |
var menuX = 64; | |
var menuY = 512; | |
var menuIncrementX = menuX | |
var menuIncrementY = menuY; | |
var zooming = false; | |
var zoomAmount = 0; | |
//activates keyboard input. | |
var keyboardInput; | |
BasicGame.Game = function (game) { | |
// When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: | |
this.game; // a reference to the currently running game | |
this.add; // used to add sprites, text, groups, etc | |
this.camera; // a reference to the game camera | |
this.cache; // the game cache | |
this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) | |
this.load; // for preloading assets | |
this.math; // lots of useful common math operations | |
this.sound; // the sound manager - add a sound, play one, set-up markers, etc | |
this.stage; // the game stage | |
this.time; // the clock | |
this.tweens; // the tween manager | |
this.state; // the state manager | |
this.world; // the game world | |
this.particles; // the particle manager | |
this.physics; // the physics manager | |
this.rnd; // the repeatable random number generator | |
// You can use any of these from any function within this State. | |
// But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference. | |
}; | |
BasicGame.Game.prototype = { | |
create: function () { | |
keyboardInput = this.input.keyboard.createCursorKeys(); | |
//========================== WORLD CREATOIN | |
//Make our game world and set it bounds | |
this.world.setBounds(0, 0, gameWorldX*32, gameWorldY*32); | |
// ========================== TERRAIN CREATION | |
//create Blank tilemap | |
terrainLayer = this.add.tilemap(); | |
// add a tileset Image to the map | |
terrainLayer.addTilesetImage(tileSetImage); | |
//create the world as a layer | |
terrain = terrainLayer.create('level1', gameWorldX, gameWorldY, 32, 32); | |
terrainPop = terrainLayer.createBlankLayer('level2', gameWorldX,gameWorldY,32,32) | |
terrainLimbo = terrainLayer.createBlankLayer('limbo', gameWorldX,gameWorldY,32,32) | |
// Fills tilemap layer with default tile:HOLY WATER (6) | |
terrainLayer.fill(0, 0,0,gameWorldX,gameWorldY, 'level1'); | |
//allows camera to move around | |
terrainLayer.fixedToCamera = false; | |
currentLayer = terrain; | |
//creates editor menu (prototype to be eliminated) | |
//createTileSelector(); | |
//sends callback | |
//this.input.addMoveCallback(updateMarker, this); | |
///////////////////////// UNIT PROPERTIES AND CREATION. To be changed and tested most likely | |
// Adds basic background color for testin | |
this.stage.backgroundColor = '#2d2d2d'; | |
// Some text for fun | |
var text = this.add.text(this.world.centerX - 150, 370,"Buttons for brushtype"); | |
text.fixedToCamera = true; | |
createButtons(); | |
},// End of Create | |
update: function () { | |
//for each direction, moves camera in world. | |
if (keyboardInput.up.isDown) | |
{ | |
this.camera.y -= 4; | |
menuIncrementY -= 4; | |
} | |
else if (keyboardInput.down.isDown) | |
{ | |
this.camera.y += 4; | |
menuIncrementY += 4; | |
} | |
if (keyboardInput.left.isDown) | |
{ | |
this.camera.x -= 4; | |
menuIncrementX -= 4; | |
} | |
else if (keyboardInput.right.isDown) | |
{ | |
this.camera.x += 4; | |
menuIncrementX += 4; | |
} | |
}, | |
quitGame: function (pointer) { | |
this.state.start('MainMenu'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment