2
\$\begingroup\$

I'm trying to plan how to implement non-fixed boundaries so the player can expand their controlled territory without using a tiled based system. Each pixel can be fought over for who controls it.

I will need to set the color for each pixel depending on who controls it so I'm thinking I'll have to check each pixel for who controls it every refresh?

I'm not sure what the best way to do this and I think performance would be an issue

Any suggestions?

\$\endgroup\$
2
  • \$\begingroup\$ You could provide some insights of your ways to do it. How are you thinking of doing it and why you think performance is issue? \$\endgroup\$
    – Katu
    Aug 27, 2013 at 16:21
  • \$\begingroup\$ I experimented with using an int[][] array matching the size of the game window and drawing a 1x1 texture to each pixel every frame. The performance was bad, giving under 10fps. Maybe it would be feasible if I were to only update 30 times per second or something. \$\endgroup\$
    – Gamedevq
    Aug 27, 2013 at 21:10

1 Answer 1

2
\$\begingroup\$

Sounds to me like it's still a tile-based system, but with each pixel being a tile...

Regardless, caching is your friend.

Personally, I would split the map into regions, then cache each as an individual image. In your code, whenever control in an area shifts at all, set a flag saying that area needs to be updated. You'll have to experiment with different region sizes to determine what provides the best performance based on your game mechanics - if you end up with a single battlefield in the middle where all the change is happening, that's going to require different regions than, say, isolated pockets of resistance.

On the other hand, if you have most of your pixels shifting every frame, you may be better off checking every pixel every frame, and possibly skipping some frames if the performance is too unwieldy.

\$\endgroup\$
1
  • \$\begingroup\$ Good idea with the regions, I'll give it a go and see how it performs. \$\endgroup\$
    – Gamedevq
    Aug 27, 2013 at 21:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .