• Create Account

# P0jahn

Member Since 21 Nov 2012
Offline Last Active May 24 2016 04:50 AM

### In Topic: Find tile coordinates within a given radius

01 September 2015 - 08:17 AM

Added the optimisations suggested here and got it down to 1 ms(radius 20). As samoth mentioned, this is going to be calculated when ever a major bomb explodes, so it is far from every frame. I can live with it.

### In Topic: Find tile coordinates within a given radius

01 September 2015 - 04:33 AM

Yeah, this wasn't so hard as I expected.

samoth: I found something very similar. The performance is ok I guess. Took 1.768828 milliseconds when the radius was 20, in Java. Complete code for future reference:

```	public Set<Vector2> searchTiles(int x, int y, int r) {
Set<Vector2> points = new HashSet<>();
for (int j=x-r; j<=x+r; j++)
for (int k=y-r; k<=y+r; k++)
if (distance(new Vector2(j,k), new Vector2(x,y)) <= r)

return points;
}
```

### In Topic: Find tile coordinates within a given radius

01 September 2015 - 03:51 AM

Thanks for the help. Tried some of the suggestions noted here, such as the link to Midpoint Circle Algorithm. While they work, they dont find the coordinates inside the circle. Ie they dont fill search.

### In Topic: Best way to store a stage for a platformer?

10 July 2015 - 09:08 AM

Background is the sky, clouds etc. Static images. Serve no purpose other than decoration. Foreground is the ground, walls etc. Affects where you can walk etc.

So say I store the stage data as tile, like Krypt0n suggested, should I have a bunch of small images that maps to the tile pieces? And render them each frame etc.

It's kinda hard to explain because I am not sure what I want to do haha =)

### In Topic: Best way to store a stage for a platformer?

10 July 2015 - 07:52 AM

I am not storing every pixel. That would take ages for the sprite batch to render and the game would lag to hell. Currently, I am using one large image for the background(which is ok), and one of the foreground(bad). The problem with that is that I can not transform the tiles at playtime, because manipulating an managed image is a big no. So would be a good idea to split the image to a few tiles, and render them every frames? Or would that affect performance badly?

PARTNERS