Hacker News new | ask | show | jobs
by nonethewiser 1150 days ago
> This is such an interesting aspect of web games: HTML-based UIs.

I am neither a web dev nor (especially) game dev expert , but I recently came across this crossroads when building a small js canvas game. Should I use html elements styled with css for my game UI?

After a very short time thinking about it I decided not to implement the UI this way. It seems like a good idea because html and css are easy to use. Much easier to style a button and assign it a js function than draw buttons on the canvas and check if they’ve been clicked. But I felt like it spanned a boundary that might prove hard to reconcile in some scenarios, but that was more of an instinct than a well reasoned conclusion. I’m curious what others think about it.

2 comments

Personally I went with HTML for my web game UI and I've not had any reason to regret it. I mean game UIs are thorny and annoying, but it would be a lot worse working inside the canvas.

My biggest surprise was, before I jumped in I figured there would probably be some existing "RPG inventory" libraries I could build from, that handled dragging icons around between icon slots etc. But I never found any game-oriented UI projects I could use, and ended up building entirely from scratch.

Not a game but I once worked on a Miro clone. We used canvas for the... canvas part... but plain old HTML for all the UI elements as those don't need to be redrawn every time you blink.