Devlogs might be ragebait… Lines 1 to 217 are basically just setup, nothing’s actually running yet.
Top of the file is the instruction manual docstring, how to install and run it. Then imports, math for angles and distances, random for scattering stuff and giving the bot some unpredictability, pygame doing the actual window and drawing and input work. After that’s a big constants block, basically a settings panel. Window size, tank stats, bullet speed, all the colors. The two fun ones are POWER_TYPES, which holds each powerup’s color and name in one place, and DIFFICULTIES, which is basically the bot’s stat sheet for easy medium and hard. Then MAPS, the four arenas, built so they’re mirror symmetric so nobody spawns with worse cover. Three small helper functions come next. clamp keeps a number in range. ang_diff figures out the short way to turn instead of spinning the long way around. circle_rect_hit checks if a circle touches a rectangle, and honestly this one function quietly handles every collision in the whole game.
Then the entity classes, Obstacle, Powerup, Bullet, Tank. All pretty dumb on purpose, they just hold data like position and health, they don’t do anything themselves. Last bit is Game.init setting up empty lists and the score, and reset_tanks, which puts player one at the bottom facing up and player two or the bot at the top facing down. That’s it, that’s everything before the game logic actually kicks in.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.