Skip to content

Instantly share code, notes, and snippets.

View AlexBezuska's full-sized avatar

Alex Bezuska AlexBezuska

  • Louisville, Kentucky (KY)
View GitHub Profile
<style>
.itch-like-btn{
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
box-sizing: border-box;
-moz-box-sizing: border-box;
display: block;
background: #FA5C5C;
color: white !important;
function wrapText(context, text, x, y, maxWidth, lineHeight) {
var words = text.split(" ");
var line = "";
for (var i = 0; i < words.length; i++) {
var testLine = line + words[i] + " ";
var metrics = context.measureText(testLine);
var testWidth = metrics.width;
if (testWidth > maxWidth && i > 0) {
context.fillText(line, x, y);
@AlexBezuska
AlexBezuska / scatter-trees.ts
Created December 1, 2016 12:54
prefab scattering system for SuperPowers-html5
class ScatterStars extends Sup.Behavior {
trees = [];
treeCount = 20;
start() {
for (var i = 0; i < this.treeCount; i++){
Sup.appendScene("Plants")[0]
.arcadeBody2D.warpPosition(Sup.Math.Random.float(-5, 5),Sup.Math.Random.float(-5, 5));
}
}
@AlexBezuska
AlexBezuska / responsive vs non svg
Created August 24, 2016 21:42
responsive vs non svg
responsive:
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25.51 218.96"><defs><style>.cls-1{fill:#b5b5b6;stroke-width:1.44px;}.cls-1,.cls-3{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#d33f27;}.cls-3{fill:#d4d4d6;stroke-width:0.72px;}</style></defs><title>barge-radar-responsive</title><path class="cls-1" d="M0.88,206.32s1.49,11.92,13.41,11.92,10.43-13.41,10.43-13.41L24.56,14.13S26.05,0.72,14.13.72,0.72,12.64.72,12.64Z"/><ellipse class="cls-2" cx="5.81" cy="17.59" rx="2.89" ry="8.44"/><ellipse class="cls-2" cx="5.81" cy="200.88" rx="2.89" ry="8.44"/><rect class="cls-3" x="5.11" y="103.18" width="14.9" height="10.34"/></svg>
not responsive:
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="0.35in" height="3.04in" viewBox="0 0 25.51 218.96"><defs><style>.cls-1{fill:#b5b5b6;stroke-width:1.44px;}.cls-1,.cls-3{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#d33f27;}.cls-3{fill:#d4d4d6;stroke-width:0.72px;}</style></defs><title>barge-radar</ti
"use strict";
module.exports = function(ecs, game) { // eslint-disable-line no-unused-vars
ecs.addEach(function(entity, context) { // eslint-disable-line no-unused-vars
var viewportPosition = game.entities.get(entity, "position");
var viewportSize = game.entities.get(entity, "size");
var cameraPosition = game.entities.get(0, "position");
var cameraSize = game.entities.get(0, "size");
@AlexBezuska
AlexBezuska / crop-game.js
Created March 29, 2016 14:40
Splat-ecs crop game render system, (letterboxing both directions)
"use strict";
module.exports = function(ecs, game) { // eslint-disable-line no-unused-vars
ecs.addEach(function(entity, context) { // eslint-disable-line no-unused-vars
var viewportPosition = game.entities.get(entity, "position");
var viewportSize = game.entities.get(entity, "size");
var cameraPosition = game.entities.get(0, "position");
var cameraSize = game.entities.get(0, "size");
@AlexBezuska
AlexBezuska / Tiled Map Editor json export example
Created May 19, 2015 18:55
Tiled Map Editor json export example
{ "height":10,
"layers":[
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 3, 3, 3, 3, 3, 0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":10,
"name":"Tile Layer 1",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":18,
@AlexBezuska
AlexBezuska / post-jamLD32.md
Last active August 29, 2015 14:19
Post LD32 jam checklist