Created
November 20, 2015 08:49
-
-
Save highfestiva/6716d50222b6551bccd9 to your computer and use it in GitHub Desktop.
Crushing some letters in Trabant, http://pixeldoctrine.com/trabant.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
x x x x xx xxx''' | |
gravity((0,0,0)) | |
cam(distance=30) | |
pos = [(x-10,0,-y) for y,l in enumerate(text.split('\n')) for x,ch in enumerate(l) if ch!=' '] | |
objs = create_clones(create_box((0,-100,-100)), zip(pos,[quat()]*len(pos))) | |
for o in objs: waitload(o.id) | |
create_sphere((70,-40,-12), vel=(-43,27,7), mass=50) | |
rec = {o:[] for o in objs} | |
fwd = True | |
while loop(): | |
if timeout(5): | |
fwd = False | |
setvar('Physics.NoClip', True) | |
for o in objs: | |
if fwd: | |
v = o.vel() | |
rec[o] += [(o.pos(),v,o.avel(),o.orientation())] | |
if v.length2(): | |
o.vel(v-vec3(0,0,0.2)) | |
elif rec[o]: | |
p,v,av,ori = rec[o][-1] | |
del rec[o][-1] | |
o.pos(p, orientation=ori) | |
o.vel(-v, avel=-av) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment