![simcity 5 kickass simcity 5 kickass](https://i.pinimg.com/originals/65/4a/fd/654afdba1cb6e51be14a80c751eddde8.png)
Each time we have drawn a building, we set all its tiles to true in the buffer, so we know not to read them again, and we draw accordingly.This means that we can technically have a HUGE city, with little RAM usage (100x100x4bits = 5k), we could go twice as big and still have RAM to spare even using a 160x128 display buffer at 4 bits / 16 colors. Now, when comes the time for rendering, we will need a bool buffer that is somewhat wider than the area on screen, and with the height of the maximum building size (here 5). We can, for example, store the position of the airplane(s) directly in the airport tile using a pointer. We can keep the state of every building in there with lots of room to spare (technically, a 5x5 building has 24x4=96 bits of info). Now, again, if its for example residential, we read the next tile:Ĩ super-high super-special building that merges with its neighborsĪlternatively, if we have houses, we read the next 8 bits and we get the position of the houses in a circle around the R in the center of the building (01101010). So, we can read the data of the next tile (or the next two tiles for a 8 bits index, whatever seems the best) in the 3x3 grid and get some more info on our building:
![simcity 5 kickass simcity 5 kickass](https://geekbeat.tv/wp-content/uploads/2013/03/Spark_2013-03-06_01-57-51.png)
It might be better to partition the data into several lookup tables (residential, commercial, etc.) or into a specialized binary tree.
![simcity 5 kickass simcity 5 kickass](https://i2.wp.com/pics.mobygames.com/images/covers/large/1297532667-00.jpg)
#Simcity 5 kickass code#
That would be fast, but it would also mean a lot of code to handle what does what. From there, there’s many ways to go, that number of bits is big enough that we could just have a BIG lookup table for the images and building info. We know that a building is at least 3x3 tiles in size, so when we encounter one, we read all the other tile values from that 3x3 square and we get 8x4=32 bits of information. It fits exactly for all the single tile things we need… I have a feeling the original Sim City might have been done that way.Īlright, so now, when we encounter the building id, something interesting happens. I had some time to think about this, and here's a quick draft of what I mean.