PkAlerts

Alertas para tu stream

by Edgar Martinez

HTML

<script src="https://github.com/craftyjs/Crafty/releases/download/0.9.0/crafty.js"></script>
<div id="cr-stage"></div>

CSS

body {
      background: black;
      text-align: center;
      color: #DDD;
      font-family: Arial;
    }

JavaScript

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"...