-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (81 loc) · 2.05 KB
/
index.html
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
<!DOCTYPE html>
<title>Awesome Broughlike</title>
<style>
canvas {
outline: 1px solid white;
}
body {
background-color: indigo;
text-align: center;
margin-top: 20px;
}
h5 {
color: white;
}
</style>
<canvas></canvas>
<script src="js/game.js"></script>
<script src="js/map.js"></script>
<script src="js/monster.js"></script>
<script src="js/spell.js"></script>
<script src="js/tile.js"></script>
<script src="js/util.js"></script>
<script>
// gameplay
num_tiles = 11;
max_hp = 6;
num_levels = 7;
starting_hp = 3;
blindness_radius = 2;
game_state = "loading";
shake_amount = 0;
shake_x = 0;
shake_y = 0;
n_loop = 0;
wall_density = 0.2;
// ui
tile_size = 64;
ui_width = 4; // Should be 4 when ui is added
SPRITE_PLAYER = 0;
SPRITE_PLAYER_DEAD = 1;
SPRITE_FLOOR = 2;
SPRITE_WALL = 3;
SPRITE_DODO = 4;
SPRITE_LIZARD = 5;
SPRITE_ECTO = 6;
SPRITE_SNAKE = 7;
SPRITE_JESTER = 8;
SPRITE_JELLY = 18;
SPRITE_VORTEX = 19;
SPRITE_HEALTH = 9;
SPRITE_PORTAL = 10;
SPRITE_EXIT = 11;
SPRITE_GEM = 12;
SPRITE_AURA = 13;
SPRITE_FIREBALL = 14;
SPRITE_BOLT_H = 15;
SPRITE_BOLT_V = 16;
SPRITE_SHIELD = 17;
SPRITE_DARKNESS = 20;
starting = true;
spritesheet = new Image();
spritesheet.src = 'spritesheet.png';
spritesheet.onload = showTitle;
document.querySelector("html").onkeypress = function(e) {
if (game_state == "title") {
startGame();
} else if (game_state == "dead") {
showTitle();
} else if (game_state == "running") {
if (e.key == "w") player.tryMove(0, -1);
if (e.key == "s") player.tryMove(0, 1);
if (e.key == "a") player.tryMove(-1, 0);
if (e.key == "d") player.tryMove(1, 0);
if (e.key >= 1 && e.key <= 9) player.castSpell(e.key-1);
}
};
// Complete initialization
initSounds();
setInterval(draw, 15);
setupCanvas();
</script>