-
Notifications
You must be signed in to change notification settings - Fork 130
/
build.sh
executable file
·124 lines (108 loc) · 3.07 KB
/
build.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
set -e
# Compile the pack_map
gcc -std=c99 pack_map.c -lm -o pack_map
# Pack maps
./pack_map assets/maps/m1.map build/m1.plb
./pack_map assets/maps/m2.map build/m2.plb
# Concat all maps into one file
cat \
build/m1.plb \
build/m2.plb \
> build/l
# Pack models
php pack_model.php assets/models/boulder.obj build/boulder.rmf
php pack_model.php assets/models/q.obj build/q.rmf
php pack_model.php assets/models/grenade.obj build/grenade.rmf
php pack_model.php \
assets/models/hound_run_1.obj \
assets/models/hound_run_2.obj \
build/hound.rmf
php pack_model.php \
assets/models/unit_idle.obj \
assets/models/unit_run_1.obj \
assets/models/unit_run_2.obj \
assets/models/unit_run_3.obj \
assets/models/unit_run_4.obj \
assets/models/unit_fire.obj \
build/unit.rmf
php pack_model.php assets/models/box.obj build/box.rmf
php pack_model.php assets/models/nailgun.obj build/nailgun.rmf
php pack_model.php \
assets/models/torch_1.obj \
assets/models/torch_2.obj \
assets/models/torch_3.obj \
build/torch.rmf
# Concat all models into one file
cat \
build/boulder.rmf \
build/unit.rmf \
build/grenade.rmf \
build/q.rmf \
build/hound.rmf \
build/box.rmf \
build/nailgun.rmf \
build/torch.rmf \
> build/m
# Concat js Source
cat \
source/wrap_pre.js \
source/document.js \
source/textures.js \
source/music.js \
source/audio.js \
source/input.js \
source/ttt.js \
source/math_utils.js \
source/renderer.js \
source/model.js \
source/map.js \
source/entity.js \
source/entity_player.js \
source/entity_door.js \
source/entity_light.js \
source/entity_torch.js \
source/entity_barrel.js \
source/entity_particle.js \
source/entity_projectile_grenade.js \
source/entity_projectile_nail.js \
source/entity_projectile_plasma.js \
source/entity_projectile_gib.js \
source/entity_projectile_shell.js \
source/entity_enemy.js \
source/entity_enemy_grunt.js \
source/entity_enemy_enforcer.js \
source/entity_enemy_ogre.js \
source/entity_enemy_zombie.js \
source/entity_enemy_hound.js \
source/entity_pickup.js \
source/entity_pickup_key.js \
source/entity_pickup_nailgun.js \
source/entity_pickup_grenadelauncher.js \
source/entity_pickup_health.js \
source/entity_pickup_nails.js \
source/entity_pickup_grenades.js \
source/entity_trigger_level.js \
source/weapons.js \
source/game.js \
source/main.js \
source/wrap_post.js \
> build/game.js
# Compress WebGL calls, remove DEBUG[...]
php pack_js.php build/game.js > build/game.packed.js
# Uglify JS
npx uglify-js build/game.packed.js \
--compress --mangle toplevel -c --beautify --mangle-props regex=/^_/ \
-o build/game.min.beauty.js
npx uglify-js build/game.packed.js \
--compress --mangle toplevel --mangle-props regex=/^_/ \
-o build/game.min.js
npx roadroller -Zab14 -Zlr930 -Zmd19 -Zpr14 -S0,1,2,3,7,13,14,19,58,97,305,422 build/game.min.js -o build/game.roadrolled.js
# Embed source into HTML
sed -e '/GAME_SOURCE/{r build/game.roadrolled.js' -e 'd;}' source/html_template.html > build/index.html
# Build ZIP
rm -f -- build/game.zip
cd build
zip game.zip index.html l m
cd ..
advzip -z -4 build/game.zip
ls -la build/