Skip to content

Instantly share code, notes, and snippets.

quantumpotato

Block or report user

Report or block quantumpotato

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gamepad
loopGamepadInput() {
var pads = navigator.getGamepads();
if (pads) {
for (var i = 0; i < pads.length; i++) {
var gp = pads[i];
if (!gp) {
break;
}
var x = gp.axes[0];
View Turbo
class TurboMover extends Component {
registrationNames() {
return ['velocity'];
}
getValue(name, hash) {
if (name == 'velocity') {
hash.vx = hash.vx * 20; //times speed
hash.vy = hash.vy * 20;
}
View gist:19788003148b47ea423d
loop() {
this.now = Date.now();
var delta = this.now - this.last;
this.last = this.now;
this.dt = this.dt + delta;
if (this.dt < this.rate) {
window.requestAnimationFrame(this.loop.bind(this));
return;
View gist:49bb52da8eea3ff3e0c6
stage = 1
def show_prompt():
if stage == 1:
print "You are between a volcano and a supernova."
print "1 for volcano, 2 for supernova."
def restart_input():
print "Nice try."
input_loop()
View gist:4736250
[self.button1 setImage:[UIImage imageNamed:@"image_up.png"] forState:UIControlStateNormal];
[self.button1 setImage:[UIImage imageNamed:@"image_down.png"] forState:UIControlStateSelected];
@quantumpotato
quantumpotato / gist:3709551
Created Sep 12, 2012
Avoiding multiple #import .h when using @Class forward declaration
View gist:3709551
//QPBattlefield.h
#import "ClonePilotBattlefield.h"
#import "QPBFState.h"
#import "QPBFTitleState.h"
#import "QPBFDrawingState.h"
#import "QPBFInputConstants.h"
@interface QPBattlefield : ClonePilotBattlefield
@quantumpotato
quantumpotato / BlockHacking
Created Feb 17, 2012
For X in Y with C do {}
View BlockHacking
#import "BlockHacking.h"
typedef void (^twoObjectBlock)(id a, id b);
typedef void (^XYZBlock)(Class x, NSArray *y, id c, twoObjectBlock b);
XYZBlock arrayDoBlock = ^(Class x, NSArray *y, id c, twoObjectBlock b) {
for (x in y) {
b(c,x);
}
};
@quantumpotato
quantumpotato / NSNotificationCenter+CHAdditions
Created Jan 3, 2012
NSNotification observing with blocks
View NSNotificationCenter+CHAdditions
#import <Foundation/Foundation.h>
@interface NSNotificationCenter (CHAdditions)
+ (void)addObserver:(id)observer forNotificationNamed:(NSString *)notificationName withBlock:(void (^)(NSNotification *note))block;
@end
#import "NSNotificationCenter+CHAdditions.h"
@quantumpotato
quantumpotato / StreamHandler.js
Created Sep 6, 2011
Adding, sending and writing messages from a queue on a player(client).
View StreamHandler.js
//We store chat messages for the player until they send us their input
//Otherwise the message will get sent and terminal writes it *next to* whatever they are typing!
function StreamHandler() {
this.addMessage = function(player, message) {
player.messages.push(message);
}
this.writeMessage = function(player, cb) {
if (player.messages.length > 0) {
You can’t perform that action at this time.