Skip to content

Instantly share code, notes, and snippets.

View highfestiva's full-sized avatar

highfestiva highfestiva

View GitHub Profile
@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()
#!/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 / translate_stdout
Created September 20, 2013 08:31
Why not translate everything you print into Swedish? Translator stolen from this guy: https://github.com/terryyin/google-translate-python/blob/master/translate.py
import re
from urllib import request
from urllib.parse import quote
string_pattern = r"\"(([^\"\\]|\\.)*)\""
match_string = re.compile(
r"\,?\["
+ string_pattern + r"\,"
+ string_pattern + r"\,"
+ string_pattern + r"\,"
@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:
@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 / fern.py
Created June 4, 2016 18:02
Recursive furn generator
#!/usr/bin/env python3
from trabant import *
import trabant
trabant.wait_until_loaded = False
fg(outline=False)
def gen_branch(pos, ang, d_ang, l):