Hot answers tagged

2

Expanding on Greffin28's Answer Tile Based Collision Detection in Games In tile based games it's really easy and fast to detect whether an object is colliding with a tile. Some psuedo- code to accomplish this: /** * Moves our entity along the x, then y. If we do both at the same time the entity * will not move if any of the collision detections fail ...


2

For accessing the array i suggest you make a function like the following: String getState(int x, int y) { if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT) return "g"; // Let's say all blocks outside the map is solid. return blocks[y][x].state; } This simple function can save you from array out of bounds error. Basically, the function ...


1

Solved After thinking this through almost a complete day (I encountered the problem yesterday), I realized I had the function to determine the height of any given point using the distance to the ocean. Why would I need to take averages and complicated calculations if I could just check the distance to the nearest coast, and then use the formula?


1

An Alternative Approach As very astutely stated by Dan in the comments to your question, trigonometric functions are very expensive to calculate and for something as simple as a bouncy ball you can keep to simple and fast vector math. It appears that you're only doing AABB collision so this method will work perfectly for you. What to change Your Ball ...



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