Hot answers tagged

3

Call AudioListener.pause = true in function pause and then AudioListener.pause = false in function Resume. While the audio listener is paused, the whole sound system will be essentially frozen. When you set the paused state to false again, the audio system will resume playing as if nothing had happened. If you have some sounds which you still want to play ...


2

You don't need matrices at all. Just take the rotation angle in radians, get its cosine and sine, multiply them by the distance you want between the two objects and add the x and y values of the fixed object: rotatingObject.x = Math.cos(rotationAngle) * distance + fixedObject.x rotatingObject.y = Math.sin(rotationAngle) * distance + fixedObject.y


2

Math.acos() solution I have something very close to what I am looking for but I beleive there is an even better way of doing this. I started by plotting a graph using Desmos. I was actually looking for a less steep curve at the beginning but I think this is close enough to what I'm looking for. In this representation the Y axis is the velocity and the X ...


1

I'm afraid this answer won't be satisfactory for you. You say you have obstacles, and if i understand right, these would be inside a surrounding, large polygon? The Hertel-Melhorn algorithm works on a single polygon only, not on a polygon holding polygons inside. Additionally, having multiple obstacles (polygons) for partitioning on the outside creates a ...


1

There are several ways to approach this problem. When it comes to WebGL performance the key is to: (a) reduce number of drawcalls, (b) reduce gpu overdraw (fill-rate) and vertices. (c) reduce buffer data transfers. Because you're filling the screen at most once and scene complexity is low, we can totally ignore (b). (c) is a bit more complex and I'll get ...


1

This is due to depth testing. You need to order your sprite rendering back to front and either disable depth test or set it to gl.LEQUAL. Sprites will not render if the pixel depth is equal to a previously drawn sprite when the depth function is set to gl.LESS.


1

You are using rect to draw the background of the bars, but you forgot the beginPath. So the rect calls pile up and make the drawings slower and slower each frame. To explain a bit further, each non-direct draw command (arc, rect, lineTo, XXXTo) is used to build the current path. If you never use beginPath to reset the current path, the next frame will ...


1

Since i can't comment to get more information i'll do my best here. Have you tried clearing the canvas before each draw ? You could also change your code to due batch drawing instead of consecutive drawing calls as you are currently making; Another thing that may degrade the performance the fill style changes in your loop. Try to make all drawing calls ...



Only top voted, non community-wiki answers of a minimum length are eligible