The crashes are most likely from the map borders not working.
The lighting works like this:
The game area is 240x240 pixels (the rightmost panel is planned for gui stuff). For each border pixel (ie 240*4 pixels), I draw a line from the center of the view towards the target pixel. For each pixel on that line, I check if the map is of color 0x000000, and if it is, I reduce the power of the light by 50% (this provides somewhat soft shadows). Walls thicker than three pixels will remove all light.
I set the light of each pixel on the line to that in a look-up-table (for speed, not for space) multiplied by the current light level.
To get the flashlight effect, I have an exponential falloff in base light level based on the difference in light ray angle and player view angle.
There’s also a sphere of light directly around the player to help when backing into corners and so.
Then I render the area around the player, and multiply the colors by the light level.
When the player moves, I check that he isn’t moving into a map pixel with color 0x000000. Zombies will use the same check.
The game is just under 2kb so far, and I still need to add
- Rotating graphics for zombies, players and bullets
- Bullets
- Zombies that walk towards the player
- Zombie hoards that spawn a whole pile of zombies at random
- Health bar + game over
Maybe, in order of importance:
- Scoring?
- Some way of winning?
- Blood splatter that sticks to the map graphics when killing a zombie?
- Tanks? Witches? Boomers?
- Four survivors you can select between with the 1-4 keys? (Blue outlines in the dark?)
- Pipe bombs?
- Molotovs/fire?