Skip to content

Instantly share code, notes, and snippets.

View edbartley's full-sized avatar

Ed Bartley edbartley

View GitHub Profile
@edbartley
edbartley / intToStr.cpp
Created October 4, 2012 15:21
C++ functions to convert an int to a C string and back again
char* intToStr(int value)
{
int divisor = 1;
int bufferLength = 1;
int isNegative = 0;
int bufferIndex = 0;
// Handle the negative value case by remebering that the number is negative
// and then setting it positive
if(value < 0)
@edbartley
edbartley / fibIt.cpp
Created October 4, 2012 17:10
Two specialized implementations of the Fibonacci sequence
// NOTE: These functions are for a specific seed case of the Fibonacci sequence where fib(0) must equal 1 as
// follows:
// Fib(0) = 1
// Fib(1) = 1
// Fib(n) = Fib(n-1) + Fib(n-2), where n > 1
// Seed values are F0 = 1, F1 = 1
// So the sequence that should be produced by incrementing n (starting at 0) is as follows:
// 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
long long unsigned fibIt(unsigned target)
@edbartley
edbartley / FPGParallacEntity.java
Created December 3, 2012 21:42
A Parallax entity for AndEngine that works in both X and Y directions.
import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.background.ParallaxBackground.ParallaxEntity;
import org.andengine.entity.shape.IAreaShape;
import org.andengine.opengl.util.GLState;
public class FPGParallaxEntity extends ParallaxEntity
{
// ===========================================================
// Constants