Skip to content

Instantly share code, notes, and snippets.

// fall, cap at maxFallSpeed
velocity.y += MIN(gravity * Monocle::deltaTime, maxFallSpeed);
position += velocity * Monocle::deltaTime;
float useSpeed = isWalking?walkSpeed:runSpeed;
const float turnThresh = 0.25f;
if (moveDir.x > turnThresh)
scale.x = 1;
void Player::Update()
{
Entity::Update();
Vector2 lastPosition = position;
const float walkSpeed = 150;
const float runSpeed = 220;
const float maxFallSpeed = 50.0f;
const float gravity = 980.0f;
int y = 0;
int max = 16;
for (y = 0; y < max; y++)
{
CollisionData collisionData;
if (!Collide("Obstruction", &collisionData))
{
break;
}
printf("normal %f, %f\n", collisionData.normal.x, collisionData.normal.y);
@zaphire
zaphire / Puppet.xml
Created April 6, 2011 08:23
XML: Puppet File Structure
<TextureAtlas image="graphics/monocleman.png" width="512" height="512">
<TextureAtlasEntry name="torso" coords="262 2 90 118"/>
<TextureAtlasEntry name="tortilla" coords="2 2 258 183"/>
<TextureAtlasEntry name="mustache" coords="262 122 109 43"/>
<TextureAtlasEntry name="nose" coords="354 2 40 81"/>
<TextureAtlasEntry name="hat" coords="396 2 86 69"/>
<TextureAtlasEntry name="eye-left" coords="62 249 12 15"/>
<TextureAtlasEntry name="eye-right" coords="76 249 12 14"/>
<TextureAtlasEntry name="eyeunderline-left" coords="396 73 28 10"/>
<TextureAtlasEntry name="eyebrow" coords="46 281 42 16"/>
@zaphire
zaphire / exportSprites.js
Created April 7, 2011 04:42
Exports photoshop layers as individual sprites, by Tuba
/*Maximum spriteSheet width -> FIXED*/
var maxWidth = 256;
var filename = activeDocument.name.replace(".psd","");
var file = new File(activeDocument.fullName.path+"/"+filename+".xml");
var AD = activeDocument;
var output = new File(activeDocument.fullName.path+"/"+filename+".png");
var pngOptions = new PNGSaveOptions();
@zaphire
zaphire / TextureAtlasGenerator.txt
Created April 7, 2011 09:42
Pseudocode: Texture Atlasing
struct Node
{
Node* child[2]
Rectangle rc
int imageID
}
Node* Node::Insert(const Image& img)
if we're not a leaf then
@zaphire
zaphire / WinnitronStartup.ahk
Created April 9, 2011 09:02
AutoHotKey: Winnitron Launcher Startup Script
; waits for 45 seconds (Sleep uses milliseconds)
; starts Winnitron launcher
Sleep 45000
Run c:\winnitron\winnitron.exe
class MarianGame : public Game
{
public:
MarianGame();
void Update();
private:
Continuity continuity;
Values values;
Moods moods;