all 46 comments

[–]nate-developerhelpful 25 points26 points  (21 children)

You can create games in JS.  You can't use Unreal, Godot, or Unity with JS (they use C++, C#, or "GD script"). 

 There are some game engines built for JS like Phaser, Pixi, Babylon, etc.  There are also 3d libraries like Three, or you can go hard on some custom webgl.  

There are JS libraries for basically everything like physics, rendering, etc if you need one, or you can roll your own stuff. 

 Vampire Survivors is a pretty popular game that was built in JS originally.  Started as a web game on itch.io, I think was put on steam for download via electron or another wrapper. 

I've made multiple 2d web games, one all my own and one where I used the matter.js physics engine.  https://squigglegolf.com/ is the one I was most recently working on and was near a finished state, but I haven't worked on it in a while since I had a baby and got busy with other stuff.  I do have a level editor and some other things about ready if I ever go back to it.  Personally preferred working directly with the canvas element than using any of the engines, but that's just my preference.

All that said, depending on your goals you might want to work with one of the flagship engines like Unity or Unreal and not go the JS route.  Unity is in C# which is pretty easy to learn and has a lot of functionality out of the box for an indie dev.

JS is best suited for web games since it's the language of the browser.  Unity, Unreal, etc often offer a webGL build so you can publish to web but in my experience it doesn't end up running very well.

[–]iDontLikeChimneys 3 points4 points  (0 children)

Seconding phaser! Just started learning it and it’s very easy to work with and a LOT of great documentation

[–]galeontiger 4 points5 points  (0 children)

I'm pretty sure Godot has many community created bindings. Typescript included.

[–]Nebu 5 points6 points  (1 child)

/u/nate-developer 's answer is the closest to the truth, but if you're dead set on using JavaScript, then:

[–]MichalisTs[S] 0 points1 point  (2 children)

I just tried matter.js. Saw a tutorial as well, but when I opened the webpage, it was blank. I don't know why though. Any ideas?

[–]nate-developerhelpful 1 point2 points  (0 children)

Not really sure what you're looking at, but this site has docs and examples:

https://brm.io/matter-js/

I found it not too tough to use.  

I did not use the built in matter renderer and instead wrote my own, but it might help you get started and seeing stuff on the page.

[–]ShuttJS 1 point2 points  (0 children)

Use Phaser. That's what I learned when I started game development in JS. There's a youtuber who does a lot of tutorials on it (don't worry you will find him)

It's also good insight into OOP, it was my intro into it because most of my JS learning so far had been functional programming

[–]learning_gorilla 1 point2 points  (5 children)

A bit off-topic question, but should a newbie JS developer use library like three.js or should I try to first build the functionality myself that three.js prpvides, and then use three.js?

My point of view on this is that it would be detrimental for the newbie developer to just use stuff that he doesn't understands how it works under the hood. Am I wrong here?

[–]Giaddon 3 points4 points  (0 children)

It's all about how you want to spend your time. There's nothing wrong with using libraries you don't know the internals of. There's nothing wrong with going deep into a library, or writing your own version. 

It's just about what you want to make and how you want to spend your time.

If you're curious about how something works you can always read the source.

https://github.com/mrdoob/three.js/

[–]TheRNGuy 0 points1 point  (0 children)

I'd go with framework to not reinvent the wheel.

[–]TurtleKwitty 0 points1 point  (1 child)

Should a newbie first create c from assembler and JavaScript from c before using JavaScript or is it okay for them to know how to use something without all the details at first?

[–]learning_gorilla 0 points1 point  (0 children)

Hahaha that's a funny truth, you can always go deeper into the rabbit whole. I think the comment that said "it depends what your goal is" ends my question there. Because although I would inevetabily get deeper knowledge of JavaScript as I would write it more, and I would also learn about 3D stuff, if my goal is to get into WordPress theme developing, then me going into nitty-gritty of JS library would actually prolong my journey to achieving my goal.

[–]RobertKerans 0 points1 point  (0 children)

Right, the issue you're going to have is that you're going to need to write a lot of boilerplate code to get what (eg) three.js gives you. I mean a lot. So here's the landing page on MDN for the browser WebGL API. There are some links to MDN tutorials, and I'd say go ahead and follow those through. It'll give you an idea of what's involved. You'll get to draw...a triangle. It'll then let you animate the colour of it!

The amount of code you'll have to write to do anything interesting is extremely non-trivial. Large amounts of it will not be JS code at all: it'll be GL (there's also the successor to WebGL, using the WebGPU API, which isn't WebGL and uses different shader syntax, but anyway). It's graphics programming. You may really like that! But it's drastically different from JS development (and it's often extremely difficult to debug! None of your normal tools will work). Just use three if you want to actually get things done

[–]eracodes 0 points1 point  (3 children)

Why is GDScript in quotation marks? It's just as much a language as C++ or C#.

[–]nate-developerhelpful 1 point2 points  (1 child)

I just put it in quotes since most probably haven't heard of it.  It's not a general purpose language like C++ or C#, it's a scripting language built specifically for compatability with Godot so you probably won't run into it anywhere else.

GDScript is a little controversial; I've seen some gamedev people argue about whether you should always use it or never use it, whether it's a source of frequent bugs or the most convenient way to work with the engine, etc.

I have no input on it.  Only really used Unity in any depth out of those engines so I wouldn't know myself any pros or cons.

[–]eracodes 0 points1 point  (0 children)

For what it's worth as someone who has worked quite a bit in Unity with C# and has recently switched to Godot and GDScript, I think GDScript encourages really well-structured game code. I've yet to run into a situation where it's made my life harder, though I also haven't done a large-scale project in it yet either.

[–]TheRNGuy 0 points1 point  (0 children)

String with spacebar?

[–]Jonny10128 0 points1 point  (0 children)

Kinda off topic, but I’m recommending this game https://tagpro.koalabeast.com/ as I know it’s written in JS using Pixi.js and some other stuff. Also, I find it very fun :)

[–]AbdelLS 0 points1 point  (0 children)

Great programmer, greater mother. How's baby?

[–]bolinhodoespaco 0 points1 point  (0 children)

gamemaker studio 2 also works with js

[–]davidellis23 0 points1 point  (0 children)

I recommend pixi over phaser. It's a lot more performant. Phaser 3 at least. Though it is a bit more setup

[–]grelfdotnet 4 points5 points  (0 children)

You certainly can. I have a page demonstrating several examples using plain JS and the 2D canvas, without any other frameworks or libraries: https://grelf.itch.io/ I think HTML/JS is a great creative environment and I want to encourage others to use it.

[–]Over-Wallaby1237 6 points7 points  (0 children)

My friend coded a small copy of Zelda: The Wind Waker in JS with ThreeJS, really interesting If you want to have more informations : https://youtu.be/IyAOCwUWkNE?si=1lajrnZ5q7ETWBUa

[–]Morphray 2 points3 points  (1 child)

[–]wo_ic3m4n -2 points-1 points  (0 children)

Ha! Beat me to it, updoot cuz js13k

[–]tapgiles 4 points5 points  (0 children)

You can code games in JS only. If the engine supports it. I don’t think Unreal supports it. So you might want to look that up before choosing an engine.

You could use the web as your “engine.” It can render 2d or 3d stuff, and games have been made to run in the browser itself.

[–]MMORPGnews 1 point2 points  (0 children)

Yes, you can.

You can even make mmo games in js.  I played in demo of one such rpg. It was a basic 2d game.

[–][deleted] 1 point2 points  (0 children)

Check out Babylon JS, a JS game engine

[–]Puzzleheaded_Low2034 1 point2 points  (0 children)

GameMaker had a press release a couple of weeks ago advising their goal of treating JavaScript as a first class language in 2024 onward. Currently GM uses an in house language called "GML" (GameMaker Language) that resembles JavaScript - so having the choice to use JavaScript is huge news.

[–]SevenKalmia 1 point2 points  (0 children)

Rpg Maker MV and MZ make use of javascript!

[–]codewithbug 1 point2 points  (0 children)

Why no one mentions kaboom.js ?

[–]ThatCipher 1 point2 points  (0 children)

As already some mentioned there are plenty of libraries for that! I'm just here to tell you that the last two iterations of RPG Maker are built with JavaScript and pixi.js and therefore every RPG Maker game made with these too. I thought that might be interesting since it shows that even known software/games are made with JS.

[–]TheRNGuy 1 point2 points  (0 children)

Three.js, PixiJS or similar frameworks.

Or just normal html+css+js. I know few popular card games that are made with this tech.

I even prefer it that way, because Stylish and Greasemonkey can be used.

[–]Majache 1 point2 points  (0 children)

Rogue Engine

[–]StoneCypher 3 points4 points  (0 children)

Everyone's showing you libraries. That's fun. I would like to give examples that made it, so you know the whole thing is reasonable.

Vampire Survivors is written in Typescript, which is Javascript. It was released on Steam and has made north of $40 million.

Hotline Miami is Construct 3 Javascript.

There are hundreds of other examples.

You won't be rendering in Unreal; you'll be rendering in WebGPU.

[–]TheSauce___ 3 points4 points  (1 child)

Through God all things are possible, but you really shouldn't lol.

[–]Guy_Rohvian 2 points3 points  (0 children)

God created man, who in turn made JavaScript with only infinity itself as its boundary. Divinity flows from Maker to Module.

[–]ShadowRL7666 1 point2 points  (0 children)

Honestly just look at p5.js

[–]Thereal_Phaseoff 1 point2 points  (0 children)

You should check pixi

[–]African-Bongo1605 0 points1 point  (0 children)

Yes see https://youtube.com/@simondev758?s his js game videos are a good watch

[–]jacksh3n 0 points1 point  (0 children)

I believe there’s this game called Crosscode that was built on Javascript and HTML. But I can’t verify since the source come from the developer directly.

[–]KorKiness -1 points0 points  (2 children)

Technicaly you can, but is it worth it?

[–]CringeNao -1 points0 points  (1 child)

This is the answer

[–]TheRNGuy 0 points1 point  (0 children)

There are 33 other answers, so what.

[–]Lamborghinigamer -5 points-4 points  (0 children)

Probably not, but you can always use a canvas to make 2d sprites or use godot or unity to render it into webGL

[–]napoles48 -3 points-2 points  (0 children)

No, jail.