New answers tagged

0

When you do "ECS by the book", then all logic belongs into systems and all data belongs into components. That means a component should never have a function. What's a rather common architecture in ECS for collision handling is one system which detects collisions and other systems which then react on the collisions detected by the first system. This ...


0

A common pattern in ECS is to add a single-use, disposable tag component after a collision. So you have a collision detection system. If you detect a collision between say a spikes and a zombie, you add a WalkedOnSpikes component to your zombie, and a ZombieWalkedOnMe component to your spike. Then you have separate systems that query for any zombies with the ...


0

If you treat each move message as a move unit, you don't need delta in this message at all. Whenever server receives a move message, apply it with a hardcoded delta (say 15ms in your case). However this is still vulnerable to message "spam" hack. Such that a client can send double or triple the amount of move messages. If the server unconditionally ...


0

Given the x/y of the player and the width/height you can get the position of all four corners, and then to translate to a point on the array do Math.floor((x or y)/tileSize) then you can do for (let i = topCorner; i < bottomCorner; i++) { //topCorner is the array offset of the top edge, bottomCorner is the offset for the bottom edge. for (let j = ...


1

Did I implement the various formulas correctly? No. A normal should be a single direction vector with one x value and one y value, not a line segment joining two points. Point projection where you divide by slope will behave badly for horizontal lines where the slope goes to zero. Your overlap test checks only one side of one polygon. How should I "...


1

When I remove the Game.drawLines(), the circles don't have the border around them anymore. Well, let's do the obvious thing and look at that function then. static drawLines() { ctx.strokeStyle = "#000000"; for(let i = 0; i < 5; i++) { ctx.moveTo(0, i * (canvas.width / 50) + 50); ctx.lineTo(canvas.width, i * (canvas.width / ...


Top 50 recent answers are included