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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@hakelimopu
hakelimopu / EngineExtensionMethods.cs
Created January 12, 2017 11:59
Some of the classes for extending GameChips for PixelVision8 (and making their use more attribute-y and generic-y/reflect-y)
using PixelVisionSDK.Engine;
using PixelVisionSDK.Engine.Chips.Game;
using System;
using System.Linq;
namespace PixelVisionSDK.Extensions
{
public static class EngineExtensionMethods
{
public static void LoadExtendedGameChip<T>(this IEngine engine, T gameChip) where T:GameChip
@hakelimopu
hakelimopu / SDLRunner.cs
Last active January 11, 2017 11:48
Gotta get an asset loader and color cache going, but these are the bones of an SDL Runner.
using System;
using SDL2;
using PixelVisionSDK.Engine;
using PixelVisionSDK.Engine.Chips.Graphics.Sprites;
using PixelVisionSDK.Engine.Chips.Graphics.Colors;
using PixelVisionSDK.Engine.Chips.Graphics.Display;
using PixelVisionSDK.Engine.Chips.IO.Controller;
using PixelVisionSDK.Engine.Chips.Game;
using PixelVisionSDK.Engine.Utils;
using System.Runtime.InteropServices;
@hakelimopu
hakelimopu / GuessMyNumber.fs
Created March 30, 2016 03:42
Quick Shot #1: Guess My Number
open Microsoft.SmallBasic.Library
//Guess My Number
//1. Computer picks a number between 1 and 100
//2. Player makes a guess
//3. Computer tells player if guess was too high or too low
//4. If the guess is not correct, go back to 2
//5. When the guess is correct, report how many guesses it took.
type GameState = {
type Country = string
type Chart = Set<Country*Country>
type Colour = Set<Country>
type Colouring = Set<Colour>
let areNeighbours (chart:Chart) (firstCountry:Country) (secondCountry:Country) :bool =
chart.Contains((firstCountry,secondCountry)) || chart.Contains((secondCountry,firstCountry))
let canBeExtBy (chart:Chart) (colour:Colour) (country:Country) :bool =
colour
module MyGame
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
type MyGame () as this =
inherit Game()
let graphics = new GraphicsDeviceManager(this)
let mutable spriteBatch: SpriteBatch = null
override this.Initialize() =
@hakelimopu
hakelimopu / Cardinal.fs
Created December 15, 2015 21:53
A Second, Better Approach to Immutable Maze Generation
module Cardinal
open Location
type Direction = North | East | South | West
let Walk (location:Location) (direction:Direction) : Location =
match direction with
| North -> {location with Row=location.Row-1}
| East -> {location with Column=location.Column+1 }
@hakelimopu
hakelimopu / MazeGen.fs
Last active November 18, 2015 14:15
A lot of gyrations and convolutions on the way here, but I got it to generate a maze via Prim's algorithm.
type Direction = North | East | South | West
let DirectionDelta = function
| North -> 0, -1
| East -> 1, 0
| South -> 0, 1
| West -> -1, 0
let DirectionOpposite = function
| North -> South
@hakelimopu
hakelimopu / JetLag.cs
Last active November 7, 2015 15:05
C# and F# versions of the same game
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
namespace csharpversion
{
class Program
@hakelimopu
hakelimopu / Sokoban.fs
Last active February 10, 2024 23:40
A sokoban player in F# (.NET, console-based)
let exampleLevel = [" #####";
" # #";
" #$ #";
" ### $##";
" # $ $ #";
"### # ## # ######";
"# # ## ##### ..#";
"# $ $ ..#";
"##### ### #@## ..#";
" # #########";