New answers tagged

0

All it does is make the 'breathAmt' variable travel go up and down between 1 and -1 over time. This gets combined with the next snippet of code, about a few paragraphs down on the page: function redraw() { canvas.width = canvas.width; // clears the canvas drawEllipse(x + 40, y + 29, 160 - breathAmt, 6); // Shadow context.drawImage(images["leftArm"...


1

/* Detect nearest enemy */ for (var i = 0; i < nears.length; i++) { /* self.void is an array containing the types of objects I want to avoid */ if (self.avoid.indexOf(nears[i].type) > -1 && nears[i] != self) { var dist = Math_distance(nears[i].x, nears[i].y, self.x, self.y); if (dist > self.avoidRadius) continue; ...


0

I'm guessing your using plain Javascript with no engine. You could just hold off drawing your objects to the screen. If you put all of your game objects in a function then you could hold of rendering them until someone click continue. After that condition is met then the render of all your object can happen. There you go. A nice simple start menu. Was this ...


0

Well, that's a tricky question but i'll start from the begining. Get/Put imageData is faster than you think, but if you want to do it in a efficient way i'd recomend you to build a double buffer and rasterize your shapes in it (here's a double buffer module i wrote, have a peek). Estrange shapes' shadowing is as hard to do as rectangles shadowing, you only ...


1

My answer contains the following assumptions: You want to get the the x,y-coordinates in order from the upper left to the bottom right, even if your viewport overlaps the map. If it overlaps, you want to look at the repeated map. Your viewport does not exceed the size of the map. var mapDimensions = {x: 20, y: 20}; // Width of the map var ...



Top 50 recent answers are included