Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New demo: generates flats and textures for each Palette entry #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions demo/blocky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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

iwad = WAD('doom2.wad')
out = WAD()
editor = omg.txdef.Textures(iwad.txdefs)

for i in range(0,256):

# generate raw patch data for palette index i
topdelta = 0
length = 128
unused = 0
data = i
post = struct.pack('<BBB{}sB'.format(length), topdelta, length, unused, bytes([data])*length, unused)
width = 64
height = 128
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

# fix flats in vanilla
out.flats.prefix='FF*_START'

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