Show HN: 3D first person game rendered in CSS/HTML
pantel.is
pantel.is
This is meant to be an experiment of rendering a full 3D scene in html/css. Of course there is a ton of (vanilla) JS to handle pretty much everything - but the main point is to explore what good ol' divs can do in a 3D context.
It might seem a bit off, because I am not a good artist/world builder, but it contains various features such as lights and shadows calculation (rendered on divs though background images + blend modes -- try clicking on the candle). Billboarding and sprite effects, geometry culling etc, as well as scalene triangle computation (which allows us to convert actual 3d models to html elements - https://pantelis.s3-us-west-2.amazonaws.com/0/css3d/readme/t...)
-----
If this interests you, I am giving a presentation on how it is built and lessons learnt this coming Wednesday (2nd of September) at CascadiaJS 2020 ( https://2020.cascadiajs.com/ ), among a line up of awesome speakers!
- Audio on/off switch [y]
- Mouse axis inversion switch [x]
My brain hursts using the mouse to look around that way, I'm too old to learn new tricks!
Great game and proof of concept w/ CSS/HTML, you get 10/10 xD
I also experimented with 3d rendering with just CSS a few years ago. The result came out pretty nice (desktop only I'm afraid): https://www.michaelbromley.co.uk/experiments/css-space-shoot...
Love that the layout is responsive and has mobile, tablet and desktop versions in good web UI style. (FYI, if you close the sidebar and resize to desktop, it's missing.)
That said, please please, no "WASD". This is very uncomfortable on non-QWERTY keyboard layouts.
There are two solutions to this.
# Best solution
Game programmer always mean "the group of physically-positioned keys that happen to be labelled WASD on the programmer's keyboard", not "whatever keys that are actually labelled WASD on the player's keyboard".
So, wherever possible, use an API that refers to key position, not key symbol. This is possible in most programming environments, e.g. in Javascript using https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEve...
# Alternative solution
Alternatively, use keys that are stable across most common Latin keyboards layout, which means no AMQWYZ.
ESDF is fine, as are RDFG, TFGH, or the traditional IJKL (see https://en.wikipedia.org/wiki/Arrow_keys for more).
If you want to be kind to Dvorak, Bepo, Colemak and other users, prefer the first solution!
https://en.wikipedia.org/wiki/Keyboard_layout#QWERTY-based_L...
So to be clear, the ideal thing to do is to allow the player to define in-game which keys should do what. But realistically speaking, I’m not going to complain because I brought this on myself when I chose to use a hardware controlled Dvorak layout. Still worth it btw ^^
I do note however, that the project is open source on GitHub, so if any of my fellow hardware controlled alternate keyboard layout peoples want to take a stab at submitting a PR for a keyboard binding config menu for the game I say go for it :)
Ugh, no. FPS has standardized on WASD over the last 20 years and people trying to reinterpret this are the bane of a positive experience.
Positional keys? Sure. Whatever's in WASD's place is fine. But splitting hairs for the <1% of users using nonstandard stuff (like a dvorak keyboard, which after a lifetime of computer nerditry I still have never seen in-the-wild) will lose you a huge chunk of your audience.
WASD or die
No no no no no this is a terrible idea. Don't make 99% of peoples experience non standard just so that people with non qwerty keyboards (who are probably expecting to need to remap controls anyway) have automagic defaults. Just default to the most common thing (WASD) and let people remap keybinds to whatever they want in case that doesn't fit.
I'm a pretty avid gamer and I've literally never opened a PC first person/third person shooter (or other real time genres with a similar perspective) released in the last 15 years or so that didn't have movement mapped to WASD by default. Not doing so would make your game feel very unpolished.
If you care about accessibility at all you need to allow button remapping anyway, even if you go with positional keybinding.
I would probably give up if the game had OSHA approved flood lightning in a medieval dungeon prison cell.
So... webgl is still the way! This is meant to be an experiment to show what css/html is capable of!
Wait until you learn what a camera is :)
In reality, this is how the concept of the transform stack works in most game engines, too.
Overall great job! Agree with the comments about it being a little dark.. am on a laptop in daylight and it was hard to see with everyting maxed. Looking forward to more.
I think it'd be way better user experience if this window wasn't that small
is the size performance related?
Also when viewing videos (such as the candle) I get a picture-in-picture icon.
Quiet enjoyed the game though.
The game gets stuck on Firefox, Linux, at the scene "Suddenly, a devilish creature appears...". Nothing appears, and I can no longer look around, just walk.
It's billboarding! (and the css lightsources are duplicated in the webgl world, so that the worm is properly shaded)
Holding the mouse button to look around is awkward, but it was fun!
rkgvathvfu pnaqyr
rng sbbq
trg obar
hfr obar ba frjre tengr
tb vagb frjre
Cneg 2
fgnl fgvyy gjvpr ng yrrpu
teno gbepu ba tebhaq
hfr gbepu gb trg guvatl sebz fxryyrgba
hfr gbepu ba qbbe
By coincidence I read up on WebRender on Firefox today and decided to force it turned on - suddenly the game looks nice (only glitch when looking down below the candle one of the wall segments still vanishes).
But it runs a lot better with WebRender (which uses the Graphics card to composite) than without on my machine.
I'd enjoy it a whole lot more if the descriptive text simply appeared and didn't halt the gameplay.