Relative Content

Tag Archive for javascriptcanvashtml5-canvas

Drawing Diagonal Stripes In JS Canvas

I’ve managed to sort of draw some diagonal stripes on a JS canvas, but the tiling isn’t great. Can anyone help out? I can’t seem to work out why it won’t tile properly:

How to spawn pac-man pellets randomly on map [JAVASCRIPT]

I’ve been trying to make a mini-game using Javascript canvas and HTML5 that is like Pac-Man, but instead of a map full of pellets I only want a singular pellet to spawn at random locations on the map while recognizing barriers– like in another classic game: Snake. I would also like for these pellets to spawn in random locations but in a set order; for example, if the order is red, blue, green, the player would need to eat the red pellet and the blue pellet would spawn next randomly. Eating the blue pellet would spawn the green pellet at a new random location, etc. I am new to Javascript, so I don’t have much of a clue on how to do any of this, though I do have some inkling that Math.random() should be included somewhere.