Re: Shooter with C#

To put it on an example, let's say we have a map like this:
00000
01110
01110
01110
00000

If you wanted to use a matrix approach, you'd need a matrix of size 5 x 5 to store each point's value. Assuming we've used int type, you'd need 5*5*4=25*4=100 bytes of memory to save this piece.
With a regions based approach, instead of storing each point of the map, you store just regions of points. For example, on the image above, you can see, that it's a zero based canvas, with a square of size 3 x 3 of value 1 in its center.
So all you need to do to save this is to get the lower left and upper right corner based on which you can reproduce the square easyly.
The notation would look like this for this certain image:
1;1;4;4;1
Because the thing starts on 1;1, ends on 4;4 and is filled by ones. Using this approach, you have just 5 numbers, multiplied by 4 bytes per int, that's 20bytes of memory required to store a thing like this.
That's only 20% of the matrix size, and the differences would dramatically increase if you make the map bigger or even 3d.
You can mark a rectangle of sizes 10000 x 10000 using just 20 bytes, whereas in the matrix solution, you'd need 10000*10000*4 = 4*10^8 bytes, t.m. 400mb.

I hope it's somewhat clearer now. By having a list of regions marked like this, if you want to find out, what is stored under certain point, you just go through the list and check, if the point is contained in one of its regions, if yes, that point will have the value of the region.

Best regards

Rastislav

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : vlad25 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : omer via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector

Reply via email to