Skip to content

Instantly share code, notes, and snippets.

View sergebat's full-sized avatar

Sergey Batishchev sergebat

  • Vancouver, BC, Canada
View GitHub Profile
@sergebat
sergebat / Gruntfile.js
Created September 9, 2013 20:40
My grunt file for HTML5 game build: TypeScript, copy, tag, uglify, upload to demo server (SFTP)
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ["deploy"],
typescript: {
base: {
src: ['src/main.ts'],
dest: 'js/game.min.js',
@sergebat
sergebat / convert-screenshot.cmd
Last active December 31, 2015 11:09
ImageMagick: Convert test.png of any size to the 768x1024 image, cropping it vertically, or extending vertically if image is too small (filling with specified color)
convert test.png -background "#ff0000" -resize 768x4096^ -gravity center -extent 768x1024 test-out.png
@sergebat
sergebat / convert-all-screenshots.cmd
Created December 15, 2013 21:08
ImageMagick: Convert all PNG files from "input" sub-directory of any size to the 768x1024 images in output directory, cropping it vertically, or extending vertically if image is too small (filling with specified color), converting to JPG
mogrify -path "output" -background "#ff0000" -format jpg -resize 768x4096^ -gravity center -extent 768x1024 input/*.png
@sergebat
sergebat / game.csproj
Created December 20, 2013 18:34
My VS project file for typescript compilation
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProjectGuid>{2CC2CEE3-2A51-4C0C-811F-1096A488E1C2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugType>full</DebugType>
@sergebat
sergebat / gist:9134951
Created February 21, 2014 14:12
visibilitychange example
(function() {
var hidden = "hidden";
// Standards:
if (hidden in document)
document.addEventListener("visibilitychange", onchange);
else if ((hidden = "mozHidden") in document)
document.addEventListener("mozvisibilitychange", onchange);
else if ((hidden = "webkitHidden") in document)
document.addEventListener("webkitvisibilitychange", onchange);
@sergebat
sergebat / .hgignore
Created August 11, 2014 12:46
sbat .hgrc/.hgignore for Mac
.DS_Store
class MuteTrigger {
private count: number = 0;
private inputSet = {};
mute(reason: string) {
if (this.inputSet[reason]) {
return;
}
this.inputSet[reason] = true;
@sergebat
sergebat / index.html
Last active August 29, 2015 14:05
Test Ludei Screen Canvas
<html>
<body>
<canvas></canvas>
<script>
var devicePixelRatio = window.devicePixelRatio;
var windowWidth = window.innerWidth * devicePixelRatio;
var windowHeight = window.innerHeight * devicePixelRatio;
canvas.width = windowWidth;
canvas.height = windowHeight;
window.requestAnimationFrame(step);
@sergebat
sergebat / hardware.ts
Created August 19, 2014 10:39
Example on handling "Back" button in Ludei/easeljs/typescript game
declare var CocoonJS;
module hardware {
var backButtonHandler: () => void = null;
var backButtonDisplayObject: createjs.DisplayObject = null;
/**
* Call hardware.captureBackButton just before showing the screen, where you want to support "back" functionality,
* pass your own handler (typically screen onQuit handler).
*
* It assumes that only one screen is shown at a time.
@sergebat
sergebat / Gruntfile-colorizefla.js
Last active October 4, 2015 13:59
Grunt target to find and replace in bulk colors of the uncompressed fla file (xfl)
var path = require('path');
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
colorizefla: {
blacknwhite: {
colors: [
{name: "Color1", from: "#A8B89D", to: "#666666"},
{name: "Color2", from: "#C2D1B6", to: "#999999"}
]