Profile cover photo
Profile photo
Raining Chain
12 followers
12 followers
About
Raining's posts

Post has attachment
Modularity
Modularity is a very important concept when creating a large-scale project. It is the main reason why so many projects fail as they reach a considerable size. Modularity means to minimize the relations between modules (aka files) and to make sure modules pe...

Post has attachment
Static Class vs Prototype
There are many ways to create object constructors in a project. The most conventional way is to use prototypes. Even though they are the most performant, they also have disadvantages and restrictions. For example, the use of "this" keyword in prototypes pre...

Post has attachment
Preventing Socket.io DDOS
Raining Chain HTML5 MMORPG uses Socket io library for websockets. Even though it is a great library to handle websockets, it is very vulnerable to DDOS. A player could open the console with F12, type while(true) socket.emit('eventName',bigObject); and crash...

Post has attachment
Getting Rid of Global Variables
When I started this project about 2 years, I had little programming knowledge. Every function I coded was in the global scope and it didn't really cause problems. Eventually, the project became bigger and it started to be hard to remember the function names...

Post has attachment
Drawing Map Efficiently
There are many ways to draw the map where the player is. This is a quite big client side operation and map images take a lot of bandwidth so optimizing it is important. The most intuitive way is to generate a giant image representing the map and simply draw...

Post has attachment
Compressing Creation Data
Data transmission is a big part of the CPU usage for the server (and bandwidth obviously). The goal here is to minimize the size of the data we send. In this post, I will only focus on data that always follow the same pattern. A good example is the Creation...

Post has attachment
Drawing Map Efficiently
There are many ways to draw the map where the player is. This is a quite big client side operation and map images take a lot of bandwidth so optimizing it is important. The most intuitive way is to generate a giant image representing the map and simply draw...

Post has attachment
Try and Catch Performance Trap
I've recently started to optimize the code of the game. After using a profiler with Google Chrome, I realized that some functions had a triangle indicating that the Javascript V8 engine couldn't optimize them. Puzzled, I checked online and learned a bit mor...

Post has attachment
Optimizing Entity Collisions
Testing the collision between an actor and an attack is a very CPU intensive problem. Effectively, it's a n^2 problem: for every actor (n), you need to test if it collides with every attack (n). Note: Even if actor count is not the same than attack count, i...
Wait while more posts are being loaded