Skip to content

Instantly share code, notes, and snippets.

@dlivingstone
dlivingstone / Dead Man.py
Created January 27, 2013 01:41
Dead Man
# by daniel livingstone for global game jam 2013
# very hacky with all sorts of bad code...
# maybe I'll fix this one day, but don't bet on it...
# art resources will be shared also
# check project home page at
# http://globalgamejam.org/2013/dead-man
#
# enjoy, but be careful not to drop your iPad
# i am not responsible for any breakages!
from scene import *
@dlivingstone
dlivingstone / main.cpp
Created August 4, 2012 13:37
GED: SDL base code. Requires glew, SDL and SDL_ttf. This base project code is in need of substantial re-writing and improvement - see comments for more details. The MavenPro font required is a free Google Webfont.
// Game Engine Design - SDL base code
// This sample project has a complete lack of OO design and makes use of
// a very large number of global variables. What it does do, is demonstrate
// use of SDL for window/event management with OpenGL for graphics rendering
// This project requires the following 3rd party libraries:
// - glew (GL extension wrangler, for access to OpenGL past 1.1 on Windows)
// - SDL (base libraries)
// - SDL_ttf (to render text to a surface/texture for display in OpenGL)
//
// There are MANY ways to improve this code, some of which are identified in
@dlivingstone
dlivingstone / main.cpp
Created July 6, 2012 22:18
OpenGL demo project: A project that needs lots of fixing and restructuring
// main.cpp
// A very basic OpenGL/GLUT application using the deprecated OpenGL 1.x
// (c) Daniel Livingstone, 2012
// The structure of this program is typical of many simple OpenGL demonstration
// programs, but is unsuitable for larger projects: The very basic structure
// is useful when learning OpenGL, but very poor for building large, complex
// systems such as modern games
@dlivingstone
dlivingstone / DecoratorMain.cpp
Created June 27, 2012 19:43
Simple C++ Decorator Pattern example
// Simple decorator pattern example
// (c) Daniel Livingstone 2012
// CC-BY-SA
#include <string>
#include <iostream>
using namespace std;
class AbstractNPC {
public:
@dlivingstone
dlivingstone / bits-main.cpp
Created November 8, 2011 10:37
Bitshifts and bitfields: A simple demo program to illustrate bitshifting and the use of bitfields in C++
// Annotated C++ program to illustrate use of bitshift
// operators and bitfields
// CC-BY-SA Daniel Livingstone
// University of the West of Scotland
// Preprocessor directive to include the i/o library:
#include <iostream>
// i/o functions are part of the standard library
// & we are using the standard library 'namespace' in this program
@dlivingstone
dlivingstone / main.cpp
Created November 7, 2011 21:42
OpenGL with GLM & SDL: A simple program to demonstrate modern OpenGL programming (compatible with OpenGL 3.0 and later) CC-BY-SA Daniel Livingstone
#include <iostream>
#include <fstream>
// Windows specific: Uncomment the following line to open a console window for debug output
#if _DEBUG
#pragma comment(linker, "/subsystem:\"console\" /entry:\"WinMainCRTStartup\"")
#endif
// Simple OpenGL GLM/SDL demo
// Renders a rotating pyramid, showing 3 of 4 sides (allowing back faces to be seen)
@dlivingstone
dlivingstone / BASS-test.cpp
Created November 2, 2011 11:22
BASS audio test
// BASS demo test
// A very basic OpenGL/GLUT application
// Create a window, load some sounds and play them.
// A test program for BASS - available from http://www.un4seen.com/
// This program uses two sound effects - available from http://www.freesound.org/
// To test this program you will need two wav sound effect files!
#include "bass.h"
#include <iostream>
#include <GL/glut.h>
@dlivingstone
dlivingstone / blocks.uwsm
Created November 1, 2010 07:17
This sample code will load and display a rotating 3D model. Uses OpenGL and the GLTools library from the OpenGL SuperBible. More details on the UWSM model format used (and sample model data) available at http://3dgamedev.wordpress.com
uwsm0_2
378
48.4251968503937 0 0 0 -38.18897637795276 0 0 0 0 48.4251968503937 -38.18897637795276 0 0 0 11.81102362204724 0 -38.18897637795276 0 0 -38.18897637795276 11.81102362204724 0 0 0 0 0 11.81102362204724 48.4251968503937 0 0 0 0 0 48.4251968503937 0 11.81102362204724 48.4251968503937 0 0 48.4251968503937 -38.18897637795276 11.81102362204724 48.4251968503937 -38.18897637795276 0 48.4251968503937 -26.57597781267043 11.81102362204724 48.4251968503937 0 11.81102362204724 48.4251968503937 -38.18897637795276 11.81102362204724 0 -38.18897637795276 0 48.4251968503937 -38.18897637795276 0 0 -38.18897637795276 11.81102362204724 40.11978340741202 -38.18897637795276 11.81102362204724 31.92395467371481 -38.18897637795276 11.81102362204724 0 -38.18897637795276 11.81102362204724 27.25139183695274 -35.34645501628111 11.81102362204724 0 0 11.81102362204724 29.82020513564828 -37.31757478744946 11.81102362204724 31.92395467371481 -38.18897637795276 11.81102362204724 25.28027206578439 -32.77764171758558 11.81102362204724
@dlivingstone
dlivingstone / defaultLight.vert
Created October 19, 2010 00:22
A loaddata program for OpenGL that will load and render a model stored in a particular matching format. Example model data and fragment shader available here: http://gist.github.com/629763 . This gist includes the main cpp file and the vertex shader only.
// Vertex Shader – default light
// This is based (very closely!) on code extracted from the GLShaderManager provided
// by Richard Wright for the OpenGL SuperBible, 5th Edition
// The SuperBible source code is available http://www.starstonesoftware.com/OpenGL/
///* GLShaderManager.h
//
//Copyright (c) 2009, Richard S. Wright Jr.
//All rights reserved.
//
@dlivingstone
dlivingstone / LoadModel-GLTools.cpp
Created October 16, 2010 13:07
An example model loader/viewer for OpenGL core profile. This code uses the GLTools library. Model details on the model format will be available at 3dgamedev.wordpress.com ...
// loadModelDataTest-GLTools
// A simple app that loads model data from a custom data format
// the format is a (relatively) simple one based on how an individual
// mesh may be saved in a Collada file - currently the easiest way
// to make models, is with Google Sketchup, export to Collada, then
// manually hack the data and save.
//
// A version of this code which only requires GLEW and freeglut is to
// follow
// Daniel Livingstone, Oct 2010