Tower Defense with a twist: all towers must be positioned with CSS Flexbox
flexboxdefense.com
flexboxdefense.com
1) When roads twist around on themselves, draw a bridge or some other kind of hint to indicate the path invaders will follow (e.g. https://i.imgur.com/t3fuboT.png). In Wave 9 it wasn't clear they'd take the long way through the loop.
2) When the tab goes into the background, pause the game instead of erasing the user's entire tower layout and progress.
Also a general observation / opinion: Does anyone else feel like flexbox syntax is unintuitive? I feel like you could achieve the same thing without rotating axes, and with more consistent naming conventions.
Definitely think the second one is a must -- there were a handful of times where I tabbed out and lost progress towards the end of a wave.
I would say flexbox syntax is one of the least intuitive additions to CSS of late. The combination between some properties and values having `flex-` prefixed and some not is always a bit of pain when using it.
Overall though, a great game and a bit of good fun for a Sunday morning!
Is there some universal Tower Defense rule for how they should walk? In the TDs I've played they always take the shortest possible route.
1) Large lanes to build in; mobs will take the shortest route from spawn to end point. You often end up making mazes with your buildings in these.
2) Single lanes to build around; mobs must walk the path laid out and these will often include loops where you've got opportunity to build in the centre of. You often end up building close to turns and loops to maximise opportunity for your tower to hit any given mob more than once.
Then some TDs will allow users to "block" the path -- usually in these instances a blocked path will result in mobs actively attacking the structures in the way.
I also think it is unintuitive. However, I'm pretty sure it was a conscious decision to not leave out non-left-to-right languages.
Notice that "flex-direction" depends on "dir" html attribute [1] and/or the "direction" CSS property. Hence, given the same flex definitions, the layout gets "mirrored" when you translate the page to a right-to-left language (such as arabic), which should work better for that language.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...
The forced need to use these rules for purposes of the game really helped drill the concepts home and I think I can confidently say that I'm now more comfortable with using flexbox for things without needing to open up documentation or alignment cheatsheets anymore. Nice work! I really appreciate the value this has and will definitely be sharing it with anyone else I know who uses flexbox on a day to day basis.
I think it'd be awesome if you expanded more levels to incorporate concepts like flex-grow/flex-basis and whatnot.
And I'll come here and repost the article, but with the title: In Defense of Flexbox.
Some layouts are impossible with Grid but a perfect fit for Flexbox and vice versa.
Do you have any links to demonstrate this? I’m starting to use grid more and more, so I’d like to have a little advance knowledge of when I shouldn’t apply it.
https://codepen.io/willem-aart/pen/oNxwRXY?editors=1100
This is impossible to achieve with CSS Grid.
One might alternatively approach this 'cluster layout' using inline-block elements. However, these elements would then be separated by space characters and the width of the space would be added to any applied margins. These issues could possibly be resolved by resorting to hacks such as setting font-size: 0 on the parent. Not pretty.
On the other hand, when using flexbox, space characters between flex childs are ignored which makes it a good fit for this kind of layout.
I would prefer a more boring but simpler to code world of CSS. However I am going to look into flexbox more. Thanks for your pen!
On the other hand, that layout hardly needs flexbox, since inline block elements will wrap in much the same way. The vertical equivalent of that layout however would very much require flexbox. However, I'm not sure of the use cases for that.
.tower-group-1 {display: flex;}
.tower-1-1 {}
.tower-1-2 {}
.tower-1-3 {align-self: center;}
.tower-1-4 {order: -1;}
.tower-1-5 {order: -1;}It's rather cute, I like it.
- Get rid of google-analytics.com
- When there is a syntax error do not shake the box, as you have to wait until it is done in order to fix it. (it also shakes the box when you close the help dialog if there is a syntax error)
The real braintwisters start when you introduce flex-wrap, flex-grow, and flex-shrink.
Flexbox is a little bit muscle memory but always so confusing and offputting to me at first!
Not currently up for the challenge but very fascinating!
Not Tower Defense and maybe less game-y, but it's nice anyway.