Skip to content

Instantly share code, notes, and snippets.

View ngscheurich's full-sized avatar
🛠️
Making video games and web things

N. G. Scheurich ngscheurich

🛠️
Making video games and web things
View GitHub Profile
@ngscheurich
ngscheurich / sfml-draw-2d.cpp
Created July 14, 2012 20:34
Display a 2D graphic using SFML
// @library SFML 2.0 RC
// Load the texture for the sprite
sf::Texture texture;
if (!texture.loadFromFile("file.png")) {
return EXIT_FAILURE;
}
// Make drawable sprite using texture
sf::Sprite sprite(texture);
@ngscheurich
ngscheurich / sfml-keyboard-input.cpp
Created July 14, 2012 20:46
Detect keyboard input using SFML
// @library SFML 2.0 RC
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::KeyPressed:
cout << event.key.code;
break;
}
@ngscheurich
ngscheurich / sfml-mouse-clicks.cpp
Created July 14, 2012 21:02
Detect mouse clicks using SFML
// @library SFML 2.0 RC
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::MouseButtonPressed:
cout << event.mouseButton.button << " button was clicked";
break;
}
@ngscheurich
ngscheurich / sfml-mouse-position.cpp
Created July 14, 2012 21:06
Detect mouse position using SFML
// @library SFML 2.0 RC
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::MouseButtonPressed:
cout << "Button " << event.mouseButton.button << " @ "
<< sf::Mouse::getPosition(window).x << ", "
<< sf::Mouse::getPosition(window).y << "\n";
@ngscheurich
ngscheurich / sfml-play-audio.cpp
Created July 14, 2012 21:16
Play audio using SFML
// @library SFML 2.0 RC
// Load the sound file
sf::Music sound;
if (!sound.openFromFile("soundfile.ogg")) {
return EXIT_FAILURE;
}
// Play the sound
sound.play();
@ngscheurich
ngscheurich / gist:8408519
Created January 13, 2014 21:28
Delete all items displayed on a "Manage Your Kindle" page
jQuery('.headerStatus[id^=Row]').each(function() { Fion.deleteItem(jQuery(this).attr('id').replace(/Row.*_/, 'deleteItem_')) })
@ngscheurich
ngscheurich / gist:9494402
Last active August 29, 2015 13:57
Starbound ❤ Dropbox (Windows PowerShell)
PS > cmd /c mklink /d "C:\Program Files (x86)\Steam\SteamApps\common\Starbound\player" "C:\Users\{your_username}\Dropbox\Starbound\player"
PS > cmd /c mklink /d "C:\Program Files (x86)\Steam\SteamApps\common\Starbound\universe" "C:\Users\{your_username}\Dropbox\Starbound\universe"
@ngscheurich
ngscheurich / gist:9494490
Created March 11, 2014 20:37
Starbound ❤ Dropbox (Mac OS X Terminal)
$ ln -s ~/Dropbox/Starbound/player ~/Library/Application\ Support/Steam/SteamApps/common/Starbound/player
$ ln -s ~/Dropbox/Starbound/player ~/Library/Application\ Support/Steam/SteamApps/common/Starbound/universe
@ngscheurich
ngscheurich / ListOps.hs
Created March 15, 2016 20:09
Reimplementation of Haskell’s `head`, `tail`, `init`, and `last` functions
-- http://www.codewars.com/kata/54592a5052756d5c5d0009c3/train/haskell
module ListOps where
import Prelude hiding (head, tail, init, last)
head :: [a] -> a
head (x:_) = x
tail :: [a] -> [a]
tail (_:xs) = xs
const glitch = require('glitch-canvas');
const canvasCover = require('./lib/canvas-cover.js');
const canvas = document.getElementById('canvas');
sizeCanvas();
const ctx = canvas.getContext('2d');
const image = new Image();
image.src = '/assets/images/stock.jpg';