Skip to content

Commit 1edcf2e

Browse files
committed
blocky: generates flat color patches and textures
1 parent c1c8030 commit 1edcf2e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

demo/blocky.py

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/python
2+
# generates a PWAD with 256 64x64-sized flat color patches and textures named
3+
# COLORXXX and 256 flats named FOLORXXX where XXX is a decimal index into the
4+
# palette
5+
6+
from omg import *
7+
from omg.txdef import *
8+
import struct
9+
10+
out = WAD()
11+
editor = omg.txdef.Textures()
12+
13+
for i in range(0,256):
14+
15+
# generate raw patch data for palette index i
16+
topdelta = 0
17+
length = 64
18+
unused = 0
19+
data = i
20+
post = struct.pack('<BBB64sB', topdelta, length, unused, bytes([data])*64, unused)
21+
width = height = 64
22+
leftoffs = topoffs = 0
23+
postoffs = 264
24+
patch = struct.pack('<HHhh', width, height, leftoffs, topoffs) \
25+
+ struct.pack('<L', postoffs) * 64 \
26+
+ post
27+
gr = Graphic()
28+
gr.data = patch
29+
name = "COLOR{:03d}".format(i)
30+
out.patches[name] = gr
31+
32+
# generate a texture entry
33+
editor.simple(name, out.patches[name])
34+
35+
# generate a flat
36+
name = "FOLOR{:03d}".format(i)
37+
flat = Flat()
38+
flat.load_raw(bytes([i])*4096)
39+
out.flats[name] = flat
40+
41+
out.txdefs = editor.to_lumps()
42+
out.to_file('out.wad')

0 commit comments

Comments
 (0)