Tag Info

Hot answers tagged

2

I think the fastest method will be by not generating the numbers at board generation (I know it's almost cheating). It's most likely fastest to only generate the number when the player clicks on a square rather then during board generation. Secondly consider how you are going to generate mines, is each place on the board going to pass a check (loop over ...


1

Create two dimensional array Randomly place mines and place mine location to list Foreach mines and add +1 to adjacent cells Mine creation int x = random.next(min, max); int y = random.next(min, max); mineList.add(new XYClass(x,y)) Number calculation Foreach(XYClass xy : mineList) addPlusOneToAdjacentCells(xy); This way, you don't even have to ...


1

Here's something off the top of my head, trying to minimize expensive operations, without resorting to approximation hacks (ie. with infinite precision real numbers, the algorithm below is exactly correct, although in practice finite precision will introduce numerical errors). Recommendations/edits to improve performance are welcome. Let s be the start ...


1

Your pixelOffset calculations are inconsistent... int pixelOffset = y + normX * 51; is different than... int j = x + normX; int i = y + normY; int pixelOffset = j + i * 51; One uses x * 51 + y and the other uses y * 51 + x. EDIT You are also reusing variable i and y. I think you want your blast circle to be based on your outer y value in addition to ...


1

Looks to me that your intersection code is not returning the correct position of impact. This could due that that when the game checks whether the bullet collide with the object, the bullet is already inside the barrier. You need to modify the intersection code to return the exact moment when the bullet hits the barrier.


1

Draw a straight line from the point of interest to a point of known location (indoor or outdoor) - usually traversing one of the four axes is sufficient. Then simply count the number of wall traversals and modulo it by 2. If the number of wall traversals is even then the point of interest is in the same location; if odd it is in the opposite location. ...


1

Essentially you are looking for some sort of graph traversal. In your case, a flood fill may work. In choosing a starting point, you could either use a point you know is outdoors (if the entire outdoor section is connected, or keep track of all the walls and test their neighbors. If their neighbor is "not visited," do a flood fill on it and mark all the ...


1

Just write a wrapper that takes your input and subtracts it from 100 float GetDamageInverse(int percent) { return GetDamage(100-percent); } Or you can change your equation to replace the 100 - SOURCE_PERCENT with SOURCE_PERCENT.



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