File: llevels.wl

package info (click to toggle)
wadc 2.1%2Bgit3aac3015-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,312 kB
  • ctags: 643
  • sloc: java: 2,771; ansic: 1,526; xml: 125; makefile: 33; sh: 13
file content (56 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#"standard.h"

-- generates a corridor with every possible doom light level
-- each segment has a custom texture with a number on it corresponding
-- to the light level

-- units/tens/hundreds: given a number (light level), calculate patch
-- name and offset for each decimal number column

units(num) {
    addpatch(cat("WINUM", num), 24, 0)
}

tens(num) {
    addpatch(cat("WINUM", div(num, 10)), 12, 0)
    units(sub(num, mul(10, div(num, 10))))
}

hundreds(num) {
    addpatch(cat("WINUM", div(num, 100)), 0, 0)
    tens(sub(num, mul(100, div(num, 100))))
}

maketex(num) {
  texture(cat("LLEVL", num), 64, 128)
  addpatch("RW24_2", 0, 0)
  hundreds(num)
  mid(cat("LLEVL", num))
}

-- a basic box segment
mybox(floor,ceil,light,x,y) {
  maketex(get("llevel"))
  straight(x)
  mid("BRICK7")
  right(y)
  right(x)
  right(y)
  rightsector(floor,ceil,light)
  rotright
}

main {
  pushpop(
    movestep(32,32)
    thing
  )

  -- 32 possible light levels, 0-255, 0-7 = 1, etc.
  set("llevel", 0)
  for(1, 32,
    mybox(0, 128, get("llevel"), 64, 256)
    move(64)
    set ("llevel", add(get("llevel") , 8))
  )
}