phaser/examples/consoleBanner.php

84 lines
2.1 KiB
PHP
Raw Normal View History

2013-09-05 02:35:12 +00:00
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<textarea id="output" style="width: 800px; height: 400px">xxx</textarea>
<script type="text/javascript">
(function () {
2013-09-05 20:07:44 +00:00
var game = new Phaser.Game(50, 50, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
2013-09-05 02:35:12 +00:00
function preload() {
2013-09-05 20:07:44 +00:00
game.load.image('piccie', 'assets/sprites/phaser_tiny.png');
2013-09-05 02:35:12 +00:00
// game.load.image('piccie', 'assets/sprites/carrot.png');
// game.load.image('piccie', 'assets/sprites/phaser-dude.png');
2013-09-05 20:07:44 +00:00
// game.load.image('piccie', 'assets/pics/atari_fujilogo.png');
2013-09-05 02:35:12 +00:00
}
var canvas;
var context;
2013-09-05 20:07:44 +00:00
var logo;
2013-09-05 02:35:12 +00:00
function create() {
2013-09-05 20:07:44 +00:00
logo = game.add.sprite(0, 0, 'piccie');
2013-09-05 02:35:12 +00:00
2013-09-05 20:07:44 +00:00
logo.body.velocity = 10;
2013-09-05 02:35:12 +00:00
2013-09-05 20:07:44 +00:00
}
function colorToHex(color) {
return "0123456789ABCDEF".charAt((color - (color % 16)) / 16) + "0123456789ABCDEF".charAt(color % 16);
}
function canvasToConsole() {
2013-09-05 02:35:12 +00:00
2013-09-05 20:07:44 +00:00
console.clear();
2013-09-05 02:35:12 +00:00
2013-09-05 20:07:44 +00:00
for (var y = 0; y < game.height; y++)
2013-09-05 02:35:12 +00:00
{
2013-09-05 20:07:44 +00:00
// var line = '';
var c = [];
2013-09-05 02:35:12 +00:00
var previousColor = '';
2013-09-05 20:07:44 +00:00
for (var x = 0; x < game.width; x++)
2013-09-05 02:35:12 +00:00
{
2013-09-05 20:07:44 +00:00
var rgb = game.renderer.context.getImageData(x, y, 1, 1);
var s = "#" + colorToHex(rgb.data[0]) + colorToHex(rgb.data[1]) + colorToHex(rgb.data[2]);
c.push("'background: " + s + "'");
2013-09-05 02:35:12 +00:00
}
2013-09-05 20:07:44 +00:00
console.log('%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c ',
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9],
c[10], c[11], c[12], c[13], c[14], c[15], c[16], c[17], c[18], c[19],
c[20], c[21], c[22], c[23], c[24], c[25], c[26], c[27], c[28], c[29],
c[30], c[31], c[32], c[33], c[34], c[35], c[36], c[37], c[38], c[39],
c[40], c[41], c[42], c[43], c[44], c[45], c[46], c[47], c[48], c[49],
c[50]);
2013-09-05 02:35:12 +00:00
}
}
function update() {
2013-09-05 20:07:44 +00:00
canvasToConsole();
2013-09-05 02:35:12 +00:00
}
function render() {
}
})();
</script>
</body>
</html>