Skip to content

Instantly share code, notes, and snippets.

View mohiji's full-sized avatar

Jonathan Fischer mohiji

View GitHub Profile
@mohiji
mohiji / gist:580235
Created September 15, 2010 04:25
Comparing my menu.c from 2007 with the one currently in Egoboo
#include "egoboo.h"
#include "Ui.h"
#include "Menu.h"
#include "Log.h"
// TEMPORARY!
#define NET_DONE_SENDING_FILES 10009
#define NET_NUM_FILES_TO_SEND 10010
//--------------------------------------------------------------------------------------------
@mohiji
mohiji / Ui.c
Created March 19, 2011 03:47
Egoboo's main menu implementation from Summer 2005
// Egoboo - Ui.c
#include "Ui.h"
#include <string.h>
#include <SDL_opengl.h>
struct UiContext
{
// Tracking control focus stuff
UI_ID active;
@mohiji
mohiji / 1VectorTest.cpp
Created August 5, 2011 17:57
C++ vectors do a lot under the hood.
#include <vector>
#include <cstdio>
using namespace std;
class Test
{
public:
Test()
{
printf(" Test being created!\n");
@mohiji
mohiji / gist:1203900
Created September 8, 2011 16:55
Pre-processor abuse
#ifdef WIN32
WSADATA g_wsadata;
#define StartSocketLib WSAStartup( MAKEWORD(2, 2), &g_wsadata);
#define CloseSocketLib WSACleanup();
#else
#define StartSocketLib {}
#define CloseSocketLib {}
@mohiji
mohiji / gist:1367565
Created November 15, 2011 16:46
Very early beginnings of a Legend of the Red Dragon style game.
(defparameter *locations* (make-hash-table :test 'eq))
(defclass location ()
((name :accessor location-name :initarg :name)
(description :accessor location-description :initarg :description)
(exits :accessor location-exits :initarg :exits)))
(defmacro define-location (symbol-name &key name description exits)
`(setf (gethash ',symbol-name *locations*)
(make-instance 'location
@mohiji
mohiji / CollisionMap.h
Created April 17, 2012 21:14
A* Implementation
//
// CollisionMap.h
// MazeGame
//
// Created by Jonathan Fischer on 2/25/12.
//
#import <Foundation/Foundation.h>
#include "MapCommon.h"
@class Path;
@mohiji
mohiji / gist:2784905
Created May 24, 2012 23:42
Player character classes make things sound kind of silly.
_stationaryMaria = [[Maria alloc] init];
_stationaryMaria.x = 7.0f * 24.0f;
_stationaryMaria.y = 5.0f * 24.0f;
@mohiji
mohiji / gist:3086990
Created July 10, 2012 23:45
Handy Common Lisp + cl-pdf Snippet
(pdf:with-document ()
(pdf:with-page (:bounds pdf:*letter-portrait-page-bounds*)
(let ((width (elt pdf:*letter-portrait-page-bounds* 2))
(height (elt pdf:*letter-portrait-page-bounds* 3))
(helvetica (make-instance 'pdf:font)))
(loop for y from 20 to height by 20 do
(pdf:move-to 0 y)
(pdf:line-to width y))
(loop for x from 20 to width by 20 do
@mohiji
mohiji / TextureAtlas.h
Created August 11, 2012 04:56
My texture atlas tool and sample code
//
// TextureAtlas.h
//
// Created by Jonathan Fischer on 8/10/12.
// Copyright (c) 2012 Jonathan Fischer. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AtlasFrame : NSObject
@mohiji
mohiji / texture-generators.lisp
Created December 4, 2012 18:19
Using a cond in a let form makes me feel a little greasy
(defvar *grass-base-color* (list 64 137 44))
(defvar *grass-medium-color* (mapcar (lambda (x) (round (* x 0.9))) *grass-base-color*))
(defvar *grass-dark-color* (mapcar (lambda (x) (round (* x 0.8))) *grass-base-color*))
(defun generate-grass-texture2 (file width height)
(let* ((png (make-instance 'zpng:png
:color-type :truecolor-alpha
:width width
:height height))
(image (zpng:data-array png)))