var Game = {
configuracion:{
bgcolor:'#4287f5',
width:600,
height:100,
spriteSize:32,
screenUsers:{
w:5,
h:5
}
},
widthPixels:function(){
return this.configuracion.width;
},
heightPixels:function(){
return this.configuracion.height;
},
// The total width of the game screen. Since our grid takes up the entire screen
// this is just the width of a tile times the width of the grid
width: function() {
//return this.map_grid.width * this.map_grid.tile.width;
return Math.floor(this.configuracion.width/this.configuracion.spriteSize);
},
// The total height of the game screen. Since our grid takes up the entire screen
// this is just the height of a tile times the height of the grid
height: function() {
//return this.map_grid.height * this.map_grid.tile.height;
return Math.floor(this.configuracion.height/this.configuracion.spriteSize);
},
// Initialize and start our game
start: function() {
// Start crafty and set a background color so that we can see it's working
Crafty.init(Game.configuracion.width, Game.configuracion.height);
Crafty.background(Game.configuracion.bgcolor);
// Simply start the "Loading" scene to get things going
Crafty.scene('Scene_Load');
}
}
$text_css = { 'font-size': '24px', 'font-family': 'Arial', 'color': 'white', 'text-align': 'center' }
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//COMPONENTES
// The Grid component allows an element to be located
// on a grid of tiles
Crafty.c('Grid', {
init: function() {
this.attr({
w: Game.configuracion.width,
h: Game.configuracion.height
});
},
// Locate this entity at the given position on the grid
at: function(x, y) {
if (x === undefined && y === undefined) {
// console.log(this.x/Game.width(),this.y/Game.height());
return { x: this.x, y: this.y }
}else{
// console.log(x , y );
this.attr({ x: x, y: y });
return this;
}
}
});
// An "Actor"...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.