Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Fixed ctypes error and load directly from PNG | 6e7f962125cc0f50351c5892620561433b6435fe | blain maguire | 2013-03-05 17:03:41 |
added LICENSE | 92356317b25c36c0fd73929ccb6b9e665d02a260 | Michael Fogleman | 2013-02-03 20:25:19 |
Jump height and mouse sensitivity in main.py | a81e11aaa49aac578b572935a19938fd2e4af48c | H34l0r | 2012-10-23 09:23:10 |
Update README | 886f7722506103b1ac120b268544cd9c20577556 | Michael Fogleman | 2012-02-15 02:20:16 |
reticle performance, time-based queue handling, terrain generation tweaks | d28386fcd85f04a3ce2ec6843b33ad1a4bfe357d | Michael Fogleman | 2012-01-30 19:07:58 |
first commit | 9ad9b952348ec7fc424ab056fe2c776c69cf9741 | Michael Fogleman | 2012-01-30 15:31:51 |
File | Lines added | Lines deleted |
---|---|---|
encode.py | 0 | 33 |
main.py | 2 | 4 |
File encode.py deleted (index 96811c5..0000000) | |||
1 | import os | ||
2 | import base64 | ||
3 | |||
4 | EXTENSIONS = [ | ||
5 | '.png', | ||
6 | ] | ||
7 | |||
8 | def print_data(data): | ||
9 | size = 72 | ||
10 | offset = 0 | ||
11 | length = len(data) | ||
12 | while offset < length: | ||
13 | print ' "%s"' % data[offset:offset+size] | ||
14 | offset += size | ||
15 | |||
16 | def generate(folder): | ||
17 | print '# Automatically generated file!' | ||
18 | print 'from wx.lib.embeddedimage import PyEmbeddedImage' | ||
19 | |||
20 | for name in os.listdir(folder): | ||
21 | if name[-4:] not in EXTENSIONS: | ||
22 | continue | ||
23 | path = os.path.join(folder, name) | ||
24 | base = name[:-4] | ||
25 | with open(path, 'rb') as f: | ||
26 | encoded = base64.b64encode(f.read()) | ||
27 | print '%s = PyEmbeddedImage(' % base | ||
28 | print_data(encoded) | ||
29 | print ')' | ||
30 | |||
31 | |||
32 | if __name__ == '__main__': | ||
33 | generate('.') |
File main.py changed (mode: 100644) (index e36fa87..271abc5) | |||
1 | 1 | from pyglet.gl import * | from pyglet.gl import * |
2 | 2 | from pyglet.window import key | from pyglet.window import key |
3 | import StringIO | ||
4 | import base64 | ||
5 | 3 | import math | import math |
6 | 4 | import random | import random |
7 | 5 | import time | import time |
6 | from ctypes import c_float | ||
8 | 7 | ||
9 | 8 | SECTOR_SIZE = 16 | SECTOR_SIZE = 16 |
10 | 9 | ||
... | ... | FACES = [ | |
51 | 50 | class TextureGroup(pyglet.graphics.Group): | class TextureGroup(pyglet.graphics.Group): |
52 | 51 | def __init__(self, data): | def __init__(self, data): |
53 | 52 | super(TextureGroup, self).__init__() | super(TextureGroup, self).__init__() |
54 | fp = StringIO.StringIO(base64.b64decode(data)) | ||
55 | self.texture = pyglet.image.load('__file__.png', file=fp).get_texture() | ||
53 | self.texture = pyglet.image.load('texture.png').get_texture() | ||
56 | 54 | def set_state(self): | def set_state(self): |
57 | 55 | glEnable(self.texture.target) | glEnable(self.texture.target) |
58 | 56 | glBindTexture(self.texture.target, self.texture.id) | glBindTexture(self.texture.target, self.texture.id) |