Skip to content

Commit c524b39

Browse files
authored
Merge pull request #264 from oskarrough/feat/map-border-anims
Feat/map border anims
2 parents c20b271 + cf9e8b1 commit c524b39

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

src/game/dungeon.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,16 @@ export const MapNodeTypes = {
326326
boss: '🌋',
327327
}
328328

329+
export function nodeTypeToName(nodeType) {
330+
return {
331+
start: 'Start room',
332+
C: 'Campfire',
333+
M: 'Monster',
334+
E: 'Elite monster',
335+
boss: 'Boss',
336+
}[nodeType]
337+
}
338+
329339
/**
330340
* A node in the dungeon map graph
331341
* @param {MapNodeTypes} [type] - a string key to represent the type of room

src/ui/components/slay-map.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component, html} from '../lib.js'
22
import {debounce, random as randomBetween} from '../../utils.js'
33
import {isRoomCompleted} from '../../game/utils-state.js'
4-
import {emojiFromNodeType, generatePaths} from '../../game/dungeon.js'
4+
import {emojiFromNodeType, nodeTypeToName, generatePaths} from '../../game/dungeon.js'
55

66
/**
77
* Renders a map of the dungeon.
@@ -175,6 +175,7 @@ export class SlayMap extends Component {
175175
can-visit=${Boolean(canVisit)}
176176
did-visit=${node.didVisit}
177177
onClick=${() => this.nodeSelect({x: nodeIndex, y: rowIndex})}
178+
title=${nodeTypeToName(node.type)}
178179
>
179180
<span>${emojiFromNodeType(node.type)}</span>
180181
</slay-map-node>`

src/ui/pages/map-demo.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import '../styles/index.css'
1111
<div class="Container">
1212
<p><a class="Button" href="/">&larr; Menu</a></p>
1313
<p>Here you can play around with the function used to generate the map in Slay the Web.</p>
14-
<slay-map-demo></slay-map-demo>
1514
</div>
15+
<slay-map-demo></slay-map-demo>
1616
</Layout>
1717

1818
<style>

src/ui/styles/map.css

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,32 @@
1515
slay-map {
1616
--rows: 12;
1717
--columns: 6;
18-
--pathColor: white;
18+
--pathColor: chocolate;
1919
--pathWidth: 1px;
2020
--highlight: gold;
2121
--nodeSize: 1.5em;
2222

2323
box-sizing: border-box;
2424
display: grid;
25-
width: 100%;
26-
margin: auto;
25+
margin: 0;
2726
min-height: 125vh;
2827
padding: 1em;
2928
position: relative;
30-
background: hsl(120, 17.5%, 19%);
3129
border-radius: 0.75rem;
30+
background: hsl(120, 17.5%, 19%);
31+
32+
border: 2px groove var(--highlight);
33+
outline: 1px solid var(--highlight);
34+
outline-offset: -0.5rem;
3235
}
3336

3437
slay-map-row {
3538
display: grid;
3639
grid-template-columns: repeat(var(--columns), 1fr);
3740
/* grid-gap: 0.5em; */
41+
align-items: center;
42+
justify-items: center;
43+
min-height: 20dvh;
3844
}
3945

4046
slay-map-node {
@@ -46,7 +52,9 @@ slay-map-node {
4652
position: relative;
4753
z-index: 2;
4854
border-radius: 50%;
49-
transition: opacity 250ms, border-color 250ms;
55+
transition:
56+
opacity 250ms,
57+
border-color 250ms;
5058
}
5159

5260
slay-map-row:first-of-type,
@@ -65,6 +73,12 @@ slay-map-node {
6573
/* All nodes are disabled by default */
6674
pointer-events: none;
6775
visibility: hidden;
76+
width: 4rem;
77+
height: 4rem;
78+
background-color: var(--bg);
79+
}
80+
slay-map-node:hover {
81+
border-color: var(--highlight);
6882
}
6983
slay-map-node[linked] {
7084
visibility: visible;
@@ -89,7 +103,9 @@ slay-map-node[can-visit] {
89103
slay-map-node[type]:hover {
90104
/* border-color: hsla(0, 0%, 0%, 0.9); */
91105
cursor: pointer;
92-
cursor: url(/images/cursors/point.png) 10 0, auto;
106+
cursor:
107+
url(/images/cursors/point.png) 10 0,
108+
auto;
93109
}
94110
slay-map-node > span {
95111
transition: transform 300ms ease-in-out;
@@ -119,6 +135,8 @@ slay-map-node[node-type='start'][current] span {
119135
slay-map-node[node-type='start'],
120136
slay-map-node[node-type='boss'] {
121137
/* font-size: 3rem; */
138+
width: 10rem;
139+
height: 10rem;
122140
}
123141
/* "Camp" */
124142
slay-map-node[node-type='C'] {
@@ -162,8 +180,19 @@ slay-map svg.paths {
162180
slay-map svg.paths line {
163181
stroke: var(--pathColor);
164182
stroke-width: var(--pathWidth);
165-
stroke-dasharray: 0.5em;
183+
stroke-dasharray: 0.2em;
184+
stroke-dashoffset: 0;
166185
/* opacity: 0.3; */
186+
/* animation: mapLines 10s linear infinite; */
187+
}
188+
189+
@keyframes mapLines {
190+
from {
191+
stroke-dashoffset: 0;
192+
}
193+
to {
194+
stroke-dashoffset: -10%;
195+
}
167196
}
168197

169198
/* map animations */
@@ -187,7 +216,10 @@ slay-map svg.paths line {
187216
}
188217

189218
/* slay-map.debug slay-map-row { border-bottom: 1px solid rgba(0,0,0,0.2); } */
190-
slay-map.debug slay-map-node { outline: 1px solid cyan; border-radius: 0;}
219+
slay-map.debug slay-map-node {
220+
outline: 1px solid cyan;
221+
border-radius: 0;
222+
}
191223
/* slay-map.debug slay-map-node span { outline: 1px solid white; } */
192224
/* slay-map.debug slay-map-node[type] span { outline: 1px solid red; } */
193225
/* slay-map.debug slay-map-node[linked] span { outline: 1px solid red; } */

0 commit comments

Comments
 (0)