Posts

Showing posts from December, 2023

platformer game - tips

Image
So you wanna make 2D platformer game? Here are tips for you: 1. You need to check collisions between objects. Treat each object as a rectangle and check coordinates to examine if there is overlap. If there is, perform pixel based detection (there can be transparent pixels). 2. You can use tile map for making game levels 3. Objects can have "platform" property. If platform == null, they are falling because of gravity. But if objects is falling you still need to examine if there's collision with a platform. 4. To make various bonuses/collectable items that player can collect - make inventory object where each property is value of some bonus or feature: {energy: 100, gold: 10, spells: 20} // player properties and make bonus object look like this: {energy: 10, gold: 2} // bonus that adds 10 energy and 2 gold. you can also make some negative bonuses (e.g. poisons, thorns) {energy: -10, xp: 2} // it takes 10 points of energy, though it gives you 2 xp. Read also about multisets

10 gamedev techniques you need to know

Image
tile map it allows for dividing big world into small pieces (e.g. into squares or hexagons). It makes programming games a lot easier. You could easily detect if something is standing or neighboring something else (e.g. if unit is standing on a road) links: https://www.redblobgames.com/grids/hexagons/ path finding it allows units for finding path from A to B, even when path is not obvious (e.g. if you need to go around obstacles, move across corridors etc.) Redblobgames has articles about it: https://www.redblobgames.com/pathfinding/a-star/introduction.html events/commands/messages Instead of directly calling method of given object, put data of "what you would like to happen" in special command object. This allows for better decoupling and for easier managing side-effects. https://gameprogrammingpatterns.com/command.html state machines and other asynchronous patterns - it's often needed for making AI for NPCs, having som

JavaScript gamedev

Image
JavaScript is a universal language, so it can be used for making games. This way you could create game which can run in browser (though it's not only way - you could use WebAsssembly and you won't be limited to JavaScript) But how to enter JS gamedev space? Try first to make simple games, then more complex. Complexity can have few aspects: graphics - GUI/button based games --> 2D graphics --> 3D graphics logic - very few rules (e.g. snake) --> games with more rules (e.g. platform game) --> whole simulation of the virtual world (strategy games, FPS games etc.) how to learn make graphics: Well, assuming you already know how to make websites in JavaScript I recommend that you first learn making very simple games with simple GUI based graphics - e.g. memory game, jigsaw puzzle, word guessing etc. This kind of games can be done in way you would usually make websites (e.g. using React or even with vanilla DOM) Then you could learn