What to use for game development with javascript for android and ios

Alright, i learnt html, css and js. I know these 3 things. I want to develop both 2d and 3d complex games, i want to go into game development with javascript. What should i do or learn next?
What is the best thing to do next? Please guide me. i want to create android and ios apps both

1 Like

So for web-browser-based games, 2D or 3D, JS is native, so JS is a natural fit. For iOS/Android, it’s not, but there are a load of frameworks for 2D games that will build for native. For 3D, using JS, building to native: no.

But before you think about that. You could not use JS and start learning to build games using a different language, but it would make sense to start with browser games and work from there:

This sounds like silly advice, but just build some games using JS for the browser. Like, lots of games, little games. This is a similar story for any type of development, but I think with games it’s even more critical to do this. You’ll make loads of mistakes, your first 10 or 20 or whatever games will be garbage. But you will know where your knowledge is lacking, what you want to focus on, what is hard and what is easy. Just make them then throw them away. If you know some JS, then you can start making some basic games now. Then you can pick up a framework like Kaboom or Phaser or whatever when it starts getting onerous to write game loops or get images or whatever. and make some more complex games. And so on.

Just don’t start out trying to make something complex. This will be incredibly tempting: you have some great idea, some grand plan, you carefully review engines that you’d use, you find some Udemy course on it etc etc. But you will get bogged down, you will get bored, it will drag on, you won’t learn anything, you won’t have the foundation to execute the plan.

There isn’t one best way to make a game, there are millions of ways, and I think where you are atm you can use what you know about JS to make a good start on basic things. Most games use a game loop to work. You have function which runs (say) 60 times a second and updates everything in your game that needs updating. User holds a “left” button, the sprite moves left a little bit, loop runs, sprite moves left a little bit, loops runs, sprite moves left a little bit, and so on.

Use Google, use GitHub, search for introductions to building games. There are lots and lots and lots and lots. I’ve got some stuff in old bookmarks, bit random but might give you a start:

It’s such a broad subject that needs such a range of skills that your best bet is to just dive in. You can do this with HTML/CSS (by all means start by doing that!), but the DOM is very slow and if your game needs stuff to move around, it will be extremely janky. So you use canvas, which is an HTML element you can draw pixels to. When it updates, canvas gets redrawn. Game loop runs, canvas gets redrawn. So look at how canvas works, make stuff clicky in the canvas, make stuff move around the canvas. Then go from there.

Relatively, between 2D and 3D, 2D is not too difficult. For web, you can write this all yourself by programming the <canvas> element, but there are lots and lots and lots and lots of frameworks that can help to build out 2D browser-based games. And those frameworks often export to native code. A framework is going to mean you don’t have to write the logic to do things like importing sprites or configuring the game loop or letting you use WebGL without having to write the lengthy boilerplate needed to get it running, or having a common API that builds to whatever graphics API is used on a mobile device. Depending on the type of game, you will quite possibly need to know some basic maths, trigonometry being the most obvious need if you’re doing any kind of action game.

For 3D you are definitely going to need some maths. You’re also definitely going to want to use a framework. There are only two 3D game engines in JS that have any real traction: PlayCanvas and Babylon.js, and even then… PlayCanvas is the more polished of the two, and Babylon is backed by Microsoft, ish. There are also quite a few 3D libraries (Three.js being by far and away the most popular). But they’re just libraries, they don’t give you anything specifically game-related.

They don’t build to native. Games built with them may work as browser-based games on a mobile device, but if you want to build native, at that point you quite possibly want to look at another game engine. Mostly these will not have JS scripting (off the top of my head, I can’t think of any examples of 3D engines that use JS as the scripting layer).

1 Like

so, that technically means that i can’t build games for android and ios with javascript? i need to learn a different language after i learnt all this? that’s sad when i learnt javascript, i was told you can build games, sigh, btw you got any recommendation for a programming language? BY WHICH I CAN DEVELOP GAMES FOR ANDROID AND IOS

and even i made the browser games, what would i do with it? Where can i publish it? nowhere.

You get that mobile phones have browsers? They’re not different to the browsers on a desktop.

I never said you couldn’t. You can build 2D games just fine and export them as native apps. You can wrap browser apps to be mobile apps using things like Cordova, they could be 3D, they’re just using the mobile browser to run. There’s nothing I said that means you can’t use JS to build games.

The issue is that most game engines (of which it is probable you would be using one of) are not normally written in JavaScript. The ones that are written in JavaScript are designed to help produce browser-based games. Otherwise, engines are, as rule, commonly written in C++: 3D games are complex graphically, they are highly resource intensive, JS is just not designed to handle the stresses of heavy computation. Most then allow you to use a scripting language to program the games with. For example, Unity allows use C# as a scripting language, Unreal allows use of C++ as a scripting language, Godot allows use of its own GDScript language, Defold uses Lua, Panda3D uses Python, and so on. So you program in that language, then when you want to build the game, you press the “package my game for Android” button and off you go [simplifying there, but you get the idea].

You can continue to build games in JS: there is no issue with that. If you are only starting out, you aren’t going to be able to build anything close to a complex, multi-platform game straightaway. You need to get a hang of how you put together games. It doesn’t matter what programming language you use at this point, and as you know JS, it makes sense to learn to make games using JS. The principles do not change based on language

EDIT:

Google allows publishing PWAs in the app store. Apple does not, and PWAs have to be installed using the side menu in Safari. But if the browser app is wrapped as an app using [for example] Cordova, then it’s just an app, so same as any other app.

No, you can, just not the high performance games that you seem to describe. There are things like React Native that allow you to write mobile apps in JS. But JS is not native to iOS or Android so they will be working through an interpreter. Imagine trying to have a quick conversation with someone through and interpreter.

i need to learn a different language after i learnt all this? that’s sad when i learnt javascript, i was told you can build games

You can. That is not to say that you can build all games on all platforms.

and even i made the browser games, what would i do with it? Where can i publish it? nowhere.

You would publish it the same way you publish every web page.

But yeah, Dan knows more about this than I do, but if I wanted to become a game developer, I’d probably be learning C#/Unity or something like that. If I wanted to build high-performance mobile games, I’d be learning Java and Swift. That’s not to say that you can’t learn a lot from JS, but it’s not the same thing.

I would also offer a little bit of advice. I remember and interview with a famous director (I think it was Spielberg) and they asked for advice for young people that wanted to become directors. His advice was to just grab a video camera, no matter how low the quality, get some friends together, and just start making movies. You will make a lot of mistakes, but you will also learn a lot.

1 Like

sorry i don’t know any of these. can you suggest me some? i can’t literally think of anything. whatever i google i can’t find. sir, can you tell me some of that?

Can you guide me in that, i just wanna create android games with javascript with any game engine. but whatever game engine i look upon, there aren’t any tutorials or anything to say that you can create apk with that game engine. this thought is bothering me since morning. how can i create apk files with javascript or any game engine of javascript? And can you suggest me a game engine?

There are React Native game engines.

But again, games developed like that are going to be a little slower. For some games that won’t matter. I think you can also use Unity on mobile, according to this.

There is no perfect solution. Just pick a path and start learning. The odds are that you will change paths a few times so don’t worry about finding the perfect path. Just start learning.

How hard have you looked? No, no JS engines export APKs (edit what @kevinSmith says, cross-platform frameworks like React Native already export to Android/iOS). But there are pages and pages and pages of Google results explaining how to package JS-based games as APKs. Look, here is a framework to package HTML apps as mobile applications:

https://cordova.apache.org/

I think you are hung up on this. Unless you aren’t a beginner, and you already have a game, what I’m advising holds. You’re stuck on the extremely minor issue of being unable to find a game engine that builds APKs here (which seems to be entirely due to Googling the wrong thing). But going off your first post, you’re indicating you want to learn to make games. The platform is [almost always] an implentation detail here. I would have thought actually learning how to do the important bit, ie how to actually make games, might be a little bit more of a priority. And you can do that using JS just fine (and you can package the result as an app, there is nothing stopping you doing that).

If you want to program cross-platform games, and you want something where you just press a button and out pops your native code for {given platform} without you having to do much, you probably want a game engine that isn’t written in JS. And because it takes quite a lot of development effort to provide that functionality, you probably want one of the more established game engines, again, of which none use JS. So Unity, for example, will do everything you want to do. You will need to learn it (it is a complex program in of itself). And it uses C# as the scripting language, so you’ll need to use that. But, again, you don’t need to do that, you can just make games in JS for now

Just quoting this. I think you are focussing on highly specific technical things that are just not an actual issue in any way at this stage. If you want to learn to make games, you need to make some games. JS-based, browser-based games allow you to do that immediately. If your aim is to actually make games, it is vanishingly unlikely that you are going to want to have those first games you create deployed to the Play Store or whatever. If you do start making games, then what you produce will be mainly garbage for quite a while. That’s fine, you don’t know what you’re doing at this point.

Like in the quote. You can just make a film with your mates using the camera on your phone: you don’t need to carefully assess what’s the best camera available and how to market the film you haven’t made. Or if you want to play guitar, you don’t research the greatest amp setup you can get & look at the best places to play live, you just buy a crappy guitar off marketplace and start practising.

sorry, i was worried for the future probably stupid. and for react, i think that yeah i will find about 3d games later on, i will just build 2d games with react native game engine, and yeah of course i can build android package file with react native. thank you sirs, thank you a trillion to you both. i need to learn react and react native first.

It’ll work for simple games so go for it if you want, but as a word of warning:

React itself is a UI library: it’s not designed at all, in any way, for making games: it has a completely different usecase. The React Native game engine library will work, and it’s clever the way it works, and there are a few small released games which seem to work fine. But importantly, there’s not going to be any support for you at all if you get stuck. If you build a game in JS, and you get stuck, you can easily find help. If you build a game using a widely-used non-JS engine, you can easily find help. If you use React Native + the game engine library, you’re basically on your own, using a framework that people generally do not use to make games with. It sits in a weird middle ground where it doesn’t quite work like most other React libraries and doesn’t quite work like most other game engines. It has few of the features provided by other game engines (it’s almost a toy proof of concept) and requires you to write code [basically in XML] using something designed specifically for rendering UI.

then what do people mainly use? please tell me what do developers mainly use?

can i go with phaser?

If you’re still learning, I think that you don’t need to worry so much about the specifics of where you will end up. If you go to medical school, it doesn’t matter if you want to be a GP, a cardio thoracic surgeon, psychatrist, or dermatologist - most of the classes in the first year or so are going to be the same.

I would just start learning and start building games on the side, even simple and silly ones. If you really, really want to do higher performance games (intense graphics and ballistics) then you’re going to want something lower level for web (C#, C++) that uses some game engine. If you’re learning web dev then you can write some games in JS using various libraries. You won’t get some graphics intense FPS, but you can build games.

So, I say, just learn. If you are 100% sure you don’t want to do web dev and want to do games on the PC/Mac, then you may want to skip FCC and focus on C# or C++. If you want specifically to do mobile games, and you want a lot of graphics, etc., then probably want to learn Java/Kotlin and/or Objective-C/Swift. I guess you can run game engines on mobile so working on C#/C++ might work for that too.

I’m no expert on game dev, but that’s how I see it.

look, i have a lot of options here, i just wanna do game and a little app development too, options here for me

  • go for phaser.js (you can create complexed games too)
    -go for learning java (you know right? app game more stuff)
  • go for learning babylon.js (3d games, but probably later not now)

i think phaser is the best option here. but is it proffesional and used by developers? i mean not like that little language that are taught to littl 7 year old kiddos for learning

which do you think is the most preffered one? for app development i already know to go for react native

sorry to bother you since you aren’t a game dev

As said, I’m not a game developer. I’m not familiar with phaser or babylon so I can’t help you.

If I were you, I would seek out game developer forum for better and more specific advice. You could also seek out game developers (like on linkedin) and ask them what they recommend.

I’m not familiar

no problem’s sir you helped me and gave me confidence a trillion. thank you. @DanCouper you too sir!

2 Likes

Hi there @vishwajeetgautam999 , game dev here and I’ve been using phaser since 2015. I say phaser is the most thorough game framework to go for. I’ve even built really complex games such as point and click games like this one = https://www.andy-howard.com/halloween-game/index.html

If you have any questions I’d be glad to help out :slight_smile:

Thank you. But i left it all and started on c#, for which the way is very clear and very great. Unity. Xamarin. Asp.Net.

That’s probably a good idea if you’re starting out: there are a vast amount of resources available for learning Unity, and that should let you do what you were asking about pretty easily.