Qix tipe of game
-
hi, i can't quite understand how to create a game like qix , if anyone has any idea how to do it, can you explain it to me? the main problem is understanding how to close the conquered areas
M. -
As it happens, I'm actually working on a Qix game too. In the end I went for the following approach:
- Lower the resolution, since the algorithms required are quite resource intensive.
- Keep the play area as a one-dimensional array (which makes it easy to display on screen using the uploadImage() function.
- The various states a pixel can have (border, active line, empty space, etc.) are represented as different colours in the array, so you can always look at a specific coordinate in the array and see if it for instance is inside the empty playfield area or not by reading its colour.
- When the drawn line of the player comes back to a non-empty pixel, we should fill. What I do then is a Flood fill from the Qix enemy's position with a special colour, and then go through the whole play area and set all the pixels that still have the "empty space" colour as filled, and the "special colour" as non-filled.
It's hard to explain, but I basically used this article, and tried to do the same thing:
https://www.idogendel.com/en/archives/738For the Flood fill algorithm I used the Wikipedia page, the pseudo code in the "Span Filling" section was quite straightforward:
https://en.wikipedia.org/wiki/Flood_fillThis is of course just one way of doing it, there are many others. Feel free to ask if you have more questions.
-
@vinicity omg ty