Skip to content

Commit

Permalink
blocky: generates flat color patches and textures
Browse files Browse the repository at this point in the history
  • Loading branch information
jmtd committed Mar 6, 2021
1 parent 33866ee commit 4f81732
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions demo/blocky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/python
# generates a PWAD with 256 64x64-sized flat color patches and textures named
# COLORXXX and 256 flats named FOLORXXX where XXX is a decimal index into the
# palette

from omg import *
from omg.txdef import *
import struct

out = WAD()
editor = omg.txdef.Textures()

for i in range(0,256):

# generate raw patch data for palette index i
topdelta = 0
length = 64
unused = 0
data = i
post = struct.pack('<BBB64sB', topdelta, length, unused, bytes([data])*64, unused)
width = height = 64
leftoffs = topoffs = 0
postoffs = 264
patch = struct.pack('<HHhh', width, height, leftoffs, topoffs) \
+ struct.pack('<L', postoffs) * 64 \
+ post
gr = Graphic()
gr.data = patch
name = "COLOR{:03d}".format(i)
out.patches[name] = gr

# generate a texture entry
editor.simple(name, out.patches[name])

# generate a flat
name = "FOLOR{:03d}".format(i)
flat = Flat()
flat.load_raw(bytes([i])*4096)
out.flats[name] = flat

out.txdefs = editor.to_lumps()
out.to_file('out.wad')

0 comments on commit 4f81732

Please sign in to comment.