Skip to content

Instantly share code, notes, and snippets.

LoadPalette("test32.pcx");
var bmp1 = LoadBitmap("test32.pcx");
var bmp2 = CreateBitmap(bmp1.w * 2, bmp1.h * 2);
var bmp3 = CreateBitmap(bmp2.w * 2, bmp2.h * 2);
ClearToColor(bmp2, 0);
ClearToColor(bmp3, 0);
var ttt = 0.0;
var c = 1;
var a = 0;
function DrawB(b1, b2, t, x, y)
@kdrnic
kdrnic / sprite.js
Last active September 10, 2017 20:20
/*
Problem: Defining an API for sprite drawing calls
Some parameters of sprites:
- The bitmap with the sprite sheet
- Width and height
- Position X, Y
- Scale
- Rotation angle
- Flips (vertical, horizontal)
@kdrnic
kdrnic / main.js
Created September 10, 2017 08:33
var spriteFile = "sprites\\link.pcx";
var spriteW = 16;
var spriteH = 24;
var spriteBmp = LoadBitmap(spriteFile);
var spritePalette = LoadPalette(spriteFile);
SetPalette(spritePalette);
var spriteSheet = CreateSpriteSheet(spriteBmp, spriteW, spriteH);
var bgColour = 7;
Cout(JSON.stringify(spriteSheet));
var spriteX = (screen.w - spriteW) * 0.5;
@kdrnic
kdrnic / rules.md
Last active September 10, 2017 19:27

Assets allowed in the ranked jams

  • You are allowed to use/reuse any outside library or personal code made prior to the event, or code bits found from sources like StackOverflow or blogs (mind the note below about licensing though). You can also prepare your project by initializing the sources in advance. However, you cannot work on a game you started before the event
  • Fonts are allowed, as are your engine's default appearance for UI elements
  • Pre-made game author & engine splash screens
  • Photos and videos as long as taken during the event
  • Drums, sampled instruments in formats like Soundfont (.sf2), as well as DAW plugins like VSTs and their presets
  • In the same vein, speech synthesis may be used to create narration for your game
  • Brushes for painting with GIMP or other image editing software
  • Procedurally generated assets, such as sfxr sound effects or textures made using GIMP's filters
@kdrnic
kdrnic / main.js
Created September 10, 2017 22:50
var spriteFile = "sprites\\link.pcx";
var spriteW = 16;
var spriteH = 24;
var spriteBmp = LoadBitmap(spriteFile);
var spritePalette = LoadPalette(spriteFile);
SetPalette(spritePalette);
var spriteSheet = CreateSpriteSheet(spriteBmp, spriteW, spriteH);
var bgColour = 11;
var spriteX = (screen.w - spriteW) * 0.5;
var spriteY = (screen.h - spriteH) * 0.5;
*.c
*.cfg
*.js
*.json
*.bat
*.h
*.md
samples/*
sprites/*
function LoadStage(filename){
var json = ReadTextFile(filename);
if(json) json = JSON.parse(json);
else return false;
function CreateFilter(name){
return function(l){
return l.name == name;
}
}
#define A(N) C_ ## N
#define C_1 "a"
#define C_2 "b"
#define C_3 "c"
#define C_4 "d"
#define C_5 "e"
A(5)
#define JS_DRAWPRIM_GET1ARG(n) int arg ## n = duk_get_int(ctx, n);
@kdrnic
kdrnic / 8.js
Created December 8, 2017 22:50
fs = require("fs");
inp = fs.readFileSync("input8.txt").toString();
inp = inp.split("\n");
regs = {};
comps = new Map(["==", "<", ">", "<=", ">=", "!="].map(e=>[e, new Function("a", "b", "return a" + e + "b")]));
ops = new Map([["inc", function(a,b){return a + b}], ["dec", function(a,b){return a - b}]]);
vals = [];
for(var i = 0; i < inp.length; i++){
var lin = inp[i].split(" ");
if(lin.length < 6) break;
@kdrnic
kdrnic / 7.js
Created December 9, 2017 00:04
fs = require("fs");
inp = fs.readFileSync("input7.txt").toString();
inp = inp.split("\n");
inp = inp.map(line => line.split(/\s+|->|\)|\(|,/).filter(w => w.length));
progs = new Map();
for(var i = 0; i < inp.length; i++){
var line = inp[i];
if(line.length < 2) continue;
progs.set(line[0], {w: parseInt(line[1]), children: line.slice(2).map(n => progs.has(n) ? progs.get(n) : n), TotalWeight: function(){
return (this.totalW = this.w + this.children.reduce((acc, cv) => acc + cv.TotalWeight(), 0));