Skip to content

Instantly share code, notes, and snippets.

View RichardMarks's full-sized avatar

Richard Marks RichardMarks

View GitHub Profile
@RichardMarks
RichardMarks / gist:767590
Created January 6, 2011 06:02 — forked from jakevsrobots/gist:460662
Python script for compiling OGMO tile layers into CSV
#!/usr/bin/python
import os, sys
from xml.dom import minidom
#--------------------------------------
BASE_PATH = os.path.dirname(__file__)
MAP_SRC_DIR = os.path.join(BASE_PATH, 'data/maps')
MAP_COMPILED_DIR = os.path.join(BASE_PATH, 'data/maps/compiled')
@RichardMarks
RichardMarks / FPDemo.as
Created January 7, 2011 01:13
FlashPunk and AIR - How to obtain the Window Dimensions
package
{
import flash.desktop.NativeApplication;
import flash.events.Event;
import flash.events.NativeWindowBoundsEvent;
import net.flashpunk.Engine;
import net.flashpunk.FP;
import net.flashpunk.Screen;
/**
* ...
@RichardMarks
RichardMarks / Screen.as
Created January 8, 2011 04:04
Allow resizing of screen. Patch for FlashPunk Screen.as -- This is NOT the entire Screen.as, just a patch
// Screen.as PATCH Richard Marks <[email protected]> - Jan 07, 2011
/**
* resizes the screen - updates FP dimension variables
* you should not do this a lot, there will be lag.
* @param width new width of the screen
* @param height new height of the screen
*/
public function resize(width:uint, height:uint):void
{
// tell FP the screen size has changed
@RichardMarks
RichardMarks / hello.ecpua
Created January 12, 2011 12:50
Hello World in ECPU Assembly
; hello.ecpua
inc 0x0A
print ; newline
inc 0x3E
print ; H
inc 0x1D
print ; e
inc 0x07
print ; l
print ; l
@RichardMarks
RichardMarks / MapEntity.as
Created January 15, 2011 12:30
changes for warpin project
// Add to MapEntity.as - this is not the full MapEntity.as file.
/**
* checks if there is a warp that collides with the specified entity
* @param e - the entity to test collision against
* @return null if no warp is found, and the WarpPoint object if there is one
*/
public function CheckWarpCollidesWith(e:Entity):WarpPoint
{
// loop through each warp in the warps container
// sprites.png is 640x240 with the left 320x240 holding player sprite frames
// and the right 320x240 holding the enemy frames
[Embed(source="../assets/sprites.png")] private const SPRITES_PNG:Class;
var sprites:BitmapData = (new SPRITES_PNG).bitmapData;
var playerSprites:BitmapData = new BitmapData(320, 240);
var enemySprites:BitmapData = new BitmapData(320, 240);
playerSprites.copyPixels(sprites, new Rectangle(0,0, 320, 240), new Point);
private function CreateMinimap():void
{
// create a buffer the same size as your game world
// fill it with nothing (0% alpha and no pixels drawn on it)
minimapDisplay = new BitmapData(WORLD_WIDTH, WORLD_HEIGHT, true, 0x00000000);
// loop over the game world exploration grid
var gh:Number = Global.exploredMap.rows;
var gw:Number = Global.exploredMap.columns;
@RichardMarks
RichardMarks / K.as
Created February 1, 2011 21:22
Simple Kongregate API - see KUsage.as for usage
package
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
/**
* kongregate API
* @author Richard Marks
*/
@RichardMarks
RichardMarks / SpriteLoader.as
Created February 3, 2011 01:13
FlashPunk utility class for loading sprite definitions from an XML file
package net.flashpunk.utils
{
import net.flashpunk.graphics.Spritemap;
/**
* Utility class for loading sprite definitions from an XML file
*
* A Sprite Definition XML Document containing two sprite definitions is shown below:
*
* <sprites>
* <sprite name="player" width="32" height="32">
/*
RoomPather.java
By: Kevin Hulin
Upon reading the challenge problem, I immediately thought of a math problem
that I had read an article about. The NP-C salesman problem, or "Given
a set of houses to visit, give the shortest path that touches each
house only once." This idea being set in my head and a little more research
on the problem led me to design a program that takes a set of coordinates
and returns an "almost shortest" path that touches each point exactly once.