Skip to content

Commit 304d57f

Browse files
committed
replaced quake sky with custom sky
1 parent 16f9c1f commit 304d57f

File tree

9 files changed

+76
-7
lines changed

9 files changed

+76
-7
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ andvaranaut
55
andvaranaut.exe
66
SDL2.dll
77
*.db
8-
art/art.cfg
9-
*.py
10-
noise

art/tiles/cloud.bmp

0 Bytes
Binary file not shown.

art/tiles/cloud2.bmp

31 KB
Binary file not shown.

aux/noise.png

17 KB
Loading

aux/sky.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This Python2 script generates two Quake-like cloud textures
2+
# (cloud.bmp and cloud2.bmp) using Tileable Perlin Noise.
3+
4+
# cloud.bmp is the back cloud layer and cloud2.bmp
5+
# is the front cloud layer with a transperancy alpha.
6+
7+
import random, copy, math
8+
from PIL import Image, ImageOps
9+
10+
def noise(x, y, per, perm, dirs):
11+
12+
def surflet(gridX, gridY):
13+
distX, distY = abs(x - gridX), abs(y - gridY)
14+
polyX = 1 - 6 * distX ** 5 + 15 * distX ** 4 - 10 * distX ** 3
15+
polyY = 1 - 6 * distY ** 5 + 15 * distY ** 4 - 10 * distY ** 3
16+
hashed = perm[perm[int(gridX) % per] + int(gridY) % per]
17+
grad = (x - gridX) * dirs[hashed][0] + (y - gridY) * dirs[hashed][1]
18+
return polyX * polyY * grad
19+
20+
intX, intY = int(x), int(y)
21+
22+
return (surflet(intX + 0, intY + 0) + surflet(intX + 1, intY + 0) +
23+
surflet(intX + 0, intY + 1) + surflet(intX + 1, intY + 1))
24+
25+
def fbm(x, y, per, octs, perm, dirs):
26+
27+
val = 0
28+
for o in range(octs):
29+
val += 0.5 ** o * noise(x * 2 ** o, y * 2 ** o, per * 2 ** o, perm, dirs)
30+
return val
31+
32+
def gen(size, perm, dirs):
33+
34+
freq = 1 / 32.0
35+
octs = 5
36+
data = []
37+
for y in range(size):
38+
for x in range(size):
39+
now = fbm(x * freq, y * freq, int(size * freq), octs, perm, dirs)
40+
data.append(now)
41+
return data
42+
43+
def go(path, clamped, size):
44+
45+
perm = range(256)
46+
random.shuffle(perm)
47+
perm += perm
48+
dirs = [(math.cos(a * 2.0 * math.pi / 256), math.sin(a * 2.0 * math.pi / 256)) for a in range(256)]
49+
50+
grey = Image.new("L", (size, size))
51+
52+
grey.putdata(gen(size, perm, dirs), 128, 128)
53+
54+
color = ImageOps.colorize(grey, (0, 0, 0), (211, 69, 73))
55+
56+
if clamped:
57+
for x in range(size):
58+
for y in range(size):
59+
if grey.getpixel((x, y)) < 128:
60+
key = 0xFFFF00
61+
color.putpixel((x, y), key)
62+
63+
color.save(path)
64+
65+
def main():
66+
size = 128
67+
go("cloud.bmp", False, size)
68+
go("cloud2.bmp", True, size)
69+
70+
if __name__ == "__main__":
71+
main()

src/Overview.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ Overview xbackpan(Overview ov, const Point where, const int xres, const int yres
3939
return ov;
4040
}
4141

42-
Overview xupdate(Overview ov, const Input input, const int xres, const int textures)
42+
Overview xupdate(Overview ov, const Input input, const int xres)
4343
{
44+
const int textures = '~' - ' ' + 1;
4445
// Selecting either 1, 2, or 3 will change the overview party to either the flooring, walling, or ceiling tiles.
4546
if(input.key[SDL_SCANCODE_1]) ov.party = FLORING;
4647
if(input.key[SDL_SCANCODE_2]) ov.party = WALLING;

src/Overview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ Overview xzov();
3131

3232
Overview xinit();
3333

34-
Overview xupdate(Overview, const Input, const int xres, const int textures);
34+
Overview xupdate(Overview, const Input, const int xres);
3535

3636
Overview xbackpan(Overview ov, const Point where, const int xres, const int yres);

src/Sdl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void dgridl(const Sdl sdl, const Overview ov, const Sprites sprites, cons
327327
// Draw the selection panel.
328328
static void dpanel(const Sdl sdl, const Overview ov, const int ticks)
329329
{
330-
for(int i = ov.wheel; i < sdl.textures.count; i++)
330+
for(int i = ov.wheel; i <= '~' - ' '; i++)
331331
{
332332
const SDL_Rect to = { ov.w * (i - ov.wheel), 0, ov.w, ov.h };
333333
// Sprites.

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(int argc, char* argv[])
3131
if(in.key[SDL_SCANCODE_TAB])
3232
{
3333
SDL_SetRelativeMouseMode(SDL_FALSE);
34-
ov = xupdate(ov, in, sdl.xres, sdl.textures.count);
34+
ov = xupdate(ov, in, sdl.xres);
3535
xmedit(wd.map[me.floor], ov);
3636
wd.sprites[me.floor] = xlay(wd.sprites[me.floor], wd.map[me.floor], ov);
3737
xview(sdl, ov, wd.sprites[me.floor], wd.map[me.floor], ticks);

0 commit comments

Comments
 (0)