Skip to content

Instantly share code, notes, and snippets.

View highfestiva's full-sized avatar

highfestiva highfestiva

View GitHub Profile
import Graphics.Gloss
main = animate (InWindow "Tree" (500, 650) (20, 20))
black (picture 4)
picture :: Int -> Float -> Picture
picture degree time
= Translate 0 (-300)
$ tree degree time (dim $ dim brown)
stump :: Color -> Picture
stump color
= Color color
@highfestiva
highfestiva / tv3d_debug.py
Last active August 29, 2015 14:10
tv3d debugging example
from functools import partial
from math import pi
import tv3d
tv3d.open(camdist=80,camangle=(pi/2,0,0),camrotspeed=(0,0.4,0),fov=15,addr='localhost:2541')
def draw(f,v,i):
r = f(v,i)
tv3d.releaseobjects()
tv3d.createmeshobject([f for xyz in v for f in xyz],i)
tv3d.sleep(0.2)
return r
@highfestiva
highfestiva / breakout.py
Created December 19, 2014 13:48
Simple game mechanic prototyping
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# An RC car sim prototype using physical motors for control.
from trabant import *
# ASCII geometry.
paddle = r'''
^ ^
<XXXXXXXXXXX>
@highfestiva
highfestiva / irony.py
Created May 17, 2015 19:41
Your first 3D "game" irony
from trabant import *
create_box(side=(6,1,1), mat='flat', static=True)
create_box((0,0,-.5), side=(1.5,1,6), mat='flat', static=True)
while loop(): taps()
@highfestiva
highfestiva / quickcraft.py
Last active August 28, 2015 12:13
22 LoC Minecraft prototype. Written for Trabant game prototyping IDE, pixeldoctrine.com/trabant.html.
# A minimal 22 LoC Minecraft imitation for the Trabant API (pixeldoctrine.com/trabant.html).
# Note that this is made for computers and no touch controls are included.
from trabant import *
# draw all shapes filled
fg(outline=False)
# floor
for y in range(5):
#!/usr/bin/env python3
from progwar.client import my_tanks,join_game
from math import atan2,atan
def closest_tank(pos, tanks):
return min(tanks, default=None, key=lambda t:(t.pos-pos).length())
def update(blips):
@highfestiva
highfestiva / dungeon_psi_master.py
Created September 29, 2015 20:43
Trabant prototype for testing precognition using PRNG. Not sure if odds calculation is correct.
#!/usr/bin/env python3
'''A simple precognition PRNG game. Press left or right on the keyboard and try to predict the next turn.'''
from math import factorial
from random import choice
from trabant import *
houses = {}
moving = True
@highfestiva
highfestiva / letters.py
Created November 20, 2015 08:49
Crushing some letters in Trabant, http://pixeldoctrine.com/trabant.html
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from trabant import *
from trabant.gameapi import setvar,waitload
text = '''
xxx
x x xx xx xxx
x x x x x x x x x
@highfestiva
highfestiva / doom.py
Last active February 22, 2016 19:44
Doom 1 E1M1 reimplementation in Trabant IDE in 152 LoC.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Doom prototype.
from trabant import *
import trabant
from trabant.packstr import unpack
from math import sin,fmod
from time import time
@highfestiva
highfestiva / packstr.py
Last active February 17, 2016 20:43
A nifty little utility to compress arbitrary data or text into a string.
#!/usr/bin/env python3
from sys import byteorder
from zlib import compress,decompress
def stringify(b):
i = int().from_bytes(b, byteorder)
s = ''
while i: