Skip to content

Instantly share code, notes, and snippets.

View simonlc's full-sized avatar
🧩
Clearing lines

Simon L simonlc

🧩
Clearing lines
  • Canada
View GitHub Profile
@simonlc
simonlc / snake.js
Created October 13, 2012 02:49
HTML5 Snake Game
var FPS = 10;
var gLoop;
var lastX;
var lastY;
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var info = document.getElementById('i');
var wrapper = document.getElementById('w');
var classic = document.getElementById('classic');
#include <webassembly.h>
struct rng_state {
unsigned int seed;
};
export unsigned short type0_rand(struct rng_state *r) {
unsigned int t;
t = 0x41C64E6DUL * r->seed + 12345;
import React from 'react';
import { Link } from 'react-router-dom';
import Table from 'table.js';
function profileUrl(props, item) {
return {
to: `/admin/users/${item.id}`,
};
}
#import <React/RCTBridgeModule.h>
#import <MapKit/MapKit.h>
@interface MapKitAutocomplete : NSObject <RCTBridgeModule,MKLocalSearchCompleterDelegate>
@property (strong, nonatomic) MKLocalSearchCompleter *completer;
@end
@simonlc
simonlc / private-methods.js
Created February 19, 2017 15:25
private fields using closuers
function Registry(defaultValue){
const defaultValue = defaultValue;
const values = Object.create(null);
// These functions will always have access to the above variables. Javascript creates
// a closure when functions are created, so the outer scope is available to it.
// These first two functions are public
this.register = function(name, value){
values[name] = value;
};
@simonlc
simonlc / js-sound-example.js
Created December 10, 2016 07:01
A really quick example on how to use sound buffers.
'use strict';
// TODO Group audio files so we can control volume seperately
const context = new AudioContext();
const soundDatas = {};
const soundFiles = {
clear: '/audio/clear.wav',
fall: '/audio/fall.wav',
land: '/audio/land.wav',
@simonlc
simonlc / life.js
Created October 14, 2012 16:01
HTML5 Conway's Game of Life
// Conway's Game of Life for HTML5 Canvas
// By Simon Laroche
var FPS = 5;
var paused = true;
var gameStarted = false;
var gLoop;
var generations = 0;
var population = 0;
@simonlc
simonlc / tictactoe.js
Created September 26, 2012 22:44
HTML5 Tic-Tac-Toe
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
canvas.addEventListener('click', on_canvas_click, false);
var grid = [['', '', ''], ['', '', ''], ['', '', '']];
var turn = 'X';
var cord_x;
var cord_y;
var reset = false;