Skip to content

Instantly share code, notes, and snippets.

View hex13's full-sized avatar
💭
slavic code master

Łukasz Lityński hex13

💭
slavic code master
  • JavaScript developer
  • Warsaw/Poland
View GitHub Profile
{
"images": [
["zolnierz", "/img/bandzior.png"],
["bandzior", "/img/bandzior.png"],
["czolg", "/img/czolg.png"],
["ulica", "/img/ulica.png"]
],
"levels": [
{
"objects": [
game.load.image('zolnierz', 'img/zolnierz.png');
game.load.image('bandzior', 'img/bandzior.png');
game.load.image('czolg', 'img/czolg.png');
game.load.image('ulica', 'img/ulica.png');
...
game.add.sprite(10, 100, 'zolnierz');
game.add.sprite(10, 150, 'zolnierz');
game.add.sprite(10, 200, 'zolnierz');
game.add.sprite(0, 0, 'ulica');
game.add.sprite(10, 100, 'jednostka_1');
// kod inicjalizujacy jednostke 1...
game.add.sprite(10, 100, 'jednostka_2');
// kod inicjalizujacy jednostke 2...
game.add.sprite(10, 100, 'jednostka_3');
// kod inicjalizujacy jednostke 3...
...
game.add.sprite(10, 100, 'jednostka_n');
// kod inicjalizujacy jednostke n...
@hex13
hex13 / gist:a422396fbc83507827e9
Last active August 29, 2015 14:10
instead of console.log: just assign to global variable debug and it will log automagically.
Object.defineProperty(window, 'debug', {
set: console.log.bind(console)
});
debug = 'HelloWorld';
debug = 'twelve: ' + (2+10);
const speck = require('speckjs');
const fs = require('fs');
const name = './src/index.js';
speck.build({name: name, content: fs.readFileSync(name, 'utf8')}, {ecmaVersion: 6, sourceType: 'module'});
function foo() {
return <div>{'{ss'}</div>;
}
console.log(1);
@hex13
hex13 / gist:6795950
Last active December 24, 2015 12:09
spaceshooter, tutorial, step 0, index.html
<!DOCTYPE html>
<html>
<head>
<title>space shooter - tutorial - 13zmiennych.blogspot.com </title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="index.js"></script>
</head>
<body>
@hex13
hex13 / gist:6800626
Last active December 24, 2015 12:49
spaceshooter, tutorial, step 1, basic structure
function loadImages(directory, fileNames, onComplete) {
};
function initialize() {
// tu bedzie kod inicjalizujacy gre...
};
$(document).ready(function() {
@hex13
hex13 / gist:6800760
Last active December 24, 2015 12:49
spaceshooter, tutorial, step1, loadImages
function loadImages(directory, fileNames, onComplete) {
var imagesLeft = fileNames.length;
fileNames.forEach(function(fileName) {
var img = new Image();
img.onload = function() {
imagesLeft--; // tu zliczamy ile obrazkow się zaladowalo
if (imagesLeft <= 0) // jesli wszystkie obrazki sie zaladowaly...
onComplete(); // uruchamiamy funkcje onComplete (podana jako argument funkcji)
};
@hex13
hex13 / gist:6800682
Last active December 24, 2015 12:49
spaceshooter, tutorial, step 1, loadImages-a
function loadImages(directory, fileNames, onComplete) {
fileNames.forEach(function(fileName) {
var img = new Image();
img.src = directory + '/' + fileName; // here!!! magic happens
});
};