As I've mentioned earlier, the game is designed to be like a "Smash TV" top-down shooting game; a more modern example would be "Binding of Isaac". The latter being inspired by the Zelda series, where dungeons were a series of rooms. Each screen was a room, which expanded into a maze across multiple directions.
Based on this design, I've redesigned the layout of the background to contain multiple rooms. The game window will only display a single room at a time, so I've adjusted both dimensions to fit each other. When the player reaches a boundary, the background image will scroll to load the next screen.
Within the code, the function "screen_change" within the background object checks if the player object's coordinates are exceeding the window boundaries. This triggers the "scroll" condition, which causes all objects (player, enemies, background, etc.) to be moved until the 2nd screen is fully displayed. To determine how far to scroll the background image, I store the coordinates of each screen within the a dictionary. Each screen is a set 408 x 312 size, so the coordinates of Screen #1 is (0, 0), Screen #2 is (408, 0), etc.
With this pattern, there are multiple objects (enemies) that exist but are not displayed within the window. To minimize memory usage, these off-screen objects would have conditions to check if their coordinates are within the game window prior to running any draw or AI functions.
Pathfinding
I have the screen scrolling worked out, but there's still an issue with collision. The walls on the background are not functional yet, and the objects are still just limited to the window size. Additionally, there are some walls that have passages, while others are completely solid. The figure below shows (in green) where objects should only travel through:
The pathfinding will be the foundation for more complicated enemy AI, with added complexity of obstacles. There's a lot to cover, so I'll dedicate it's own post to it.
Comments
Post a Comment