c++ Archive
-
Linear Algebra, Analytic Geometry and other stuff you never saw the point of
Posted on September 22, 2011 | No CommentsThere will be a less predictable image in a future post, once I produce something worth looking at that makes sense to you. I’ve been spending the past few weeks... -
Find opposite angle in radians
Posted on April 18, 2011 | No Comments// Finds the angle that is 180 degrees from the given angle, but in radians fmodf((angle + M_PI), (M_PI * 2)) -
Static class variable initialisation in C++
Posted on March 31, 2011 | No CommentsI’ve been trying to make a simple Service Locator class work but had a problem with bizarre linker errors, where the static member variable couldn’t be resolved. After a lot... -
LERP between angles in radians
Posted on March 16, 2011 | No Comments#include < stdio.h > #include < math.h > #define M_PI 3.141 #define PI180 (M_PI/180) #define DEG2RAD(x) (x * PI180) float getShortAngle(float a1, float a2) { float angle =... -
LERP
Posted on March 16, 2011 | No Comments// Between a and b, using steps of 'f' size float lerp(float a, float b, float f) { return a + f * (b - a); } // From http://stackoverflow.com/questions/4353525/floating-point-linear-interpolation -
Shortest distance between two angles
Posted on March 16, 2011 | No Commentsfloat getShortAngle(float a1, float a2) { float angle = abs(a1 - a2)%360; if(angle > 180) angle = 360 - angle; return angle; }; printf ("%f", getShortAngle(360, 720)); -
Random numbers between -1 and 1
Posted on March 10, 2011 | No Comments#include <stdio.h> #include <time.h> #include <stdlib.h> int main() { srand(time(NULL)); for (int i = 0; i < 100; i++) { float val = (2.0*((float)rand()/RAND_MAX))-1.0; printf ("%f\n", val); } } -
2010 Review
Posted on December 31, 2010 | No CommentsInspired by a post over on the Beercave, here’s a summary of the goings on this year… -
Scrolling Tilemaps
Posted on December 15, 2009 | No CommentsMy game engine now has scrolling tilemaps in it. I have arbitrarily chosen each tile to be 32×32 pixels, and the maps to contain 256×256 tiles. This gives me a virtual display... -
Adding Lua to my software
Posted on October 30, 2009 | 2 CommentsWell, this is a bit fun! One of the main points of my game environment is that I should be able to easily modify entity behaviour without having to hard...





