Advertisement

What do you think about using TypeScript instead of JavaScript for writing code for browser games?

Started by April 26, 2018 07:03 PM
6 comments, last by DexterZ101 6 years, 7 months ago

Hi,

What do you think about using TypeScript instead of JavaScript for writing code for browser games? I think, it is very similar to C#. What is good about TypeScript for gamedev? What is your opinion?

Cheers,
Ivan

Typescript's main advantages are of course type safety and the ability to compile onto older versions of js. If you think that would help you with your goals then Godspeed!

You'd probably end up using something like Three.js, which you should be able to set up with webpack . I just found a post here of someone trying to do just that. You'd probably run into a few pitfalls getting it set up, but depending on the complexity of your game I think it could be well worth it. I made a game in Three.js without ts, and I know that having type safety and those nice IDE features that come with ts development would've helped somewhat. It can be pretty cumbersome to create objects and enforce type safety without it.

Advertisement
8 hours ago, samoan62 said:

which you should be able to set up with webpack

I tried to use it with Gulp and created theme here. I understand what you're talking about. About the complexity of the installation, which is not in JavaScript.

I wrote a simple example how to use OOP-style for drawing triangle in pure WebGL in Plunker: https://plnkr.co/edit/PkqSZGwhv9zKSnUNSiXo?p=preview

I use AMD compilation setting in tsconfig and require.js library. It is cool.

Wow really cool. It seems like you could use this for a lot of things and also extend it to include support for more shapes/shaders as well.

Keep up the good work!

Tutorial: 2D breakout game using pure JavaScript

I rewrite the code to TypeScript -> GitHub

Live demo

Advertisement

Aside from writing clean code using TypeScript, you'll also have Classes, Interface in a type safety manner, it's like developing apps for the the web using C# ,  I've been developing a simple 2D game engine using TS and I'm loving it ^ _ ^y

 

This topic is closed to new replies.

Advertisement