I'm working on a simple 2d game in JS using canvs.
The game consists of a knight who runs around to kill goblins, the goblin once touched, resets to a rangom location. I want to leave bloodsplatters for every goblin killed.
Currently, before I redraw the canvas, I use the previous X and Y co-ordinates from where the goblin died to paint my blood splatter image.
I want to do it for all goblins though. In a traditional language like Java, I would define a type, for example "blood" with two properties, X and Y.
I'd then create a new instance of this type each round using the goblins current co-ords and then add this type to an array, I'd loop and print all the objects in this array then.
I'm quite new to JS and since it's a functional language, things are a bit different. How exactly would I define a type like this that I could "new" into an array every iteration of the game?
var blood = {
x: 0,
y: 0
};
Here's the current blood object I have