I'm writing a browser game and need help with sass and background images.
I have a world with terrain (grass, water) and entities (player, monster). This is rendered in a big html table and each td
gets data-attributes assigned.
<td data-y="5" data-x="23" data-terr="1" class=""></td>
<td data-y="5" data-x="24" data-terr="0" class="player"></td>
Based on those attributes the css then applies the correct images.
table td {
padding: 0;
background-size: 100% 100%;
image-rendering: pixelated;
&[data-terr="0"] {
background-color: #060;
background-image: url(#{$spritedir}/grass.png);
}
&[data-terr="1"] {
background-color: #666;
background-image: url(#{$spritedir}/water.png);
}
&.player {
background-image: url(#{$spritedir}/hero.png);
}
}
Now the problem is that the field where the player
class is applied, the player overrides the background-image
and the terrain vanishes.
But i want to stack the images. Like this:
background-image: url(#{$spritedir}/grass.png),
url(#{$spritedir}/hero.png);
Is this possible with css/sass? I mean without listing every terrain/entity combination.