Scrolling

I’d wanted the screen to scroll when the character moves to regions not defined on screen, as it’s much nicer to look at, and more natural, than printing a new map. After initially trying to do it in a really stupid way, I settled on using the rect class in Pygame. This contains the physical positions of the sprite in the screen’s co-ordinate system, so it’s then just a matter of adding to or subtracting from the MapObjects’ positions when the character’s rect gets close to the edge of the screen.

However, I’ve found that the MapObjects and the Events move at different rates, meaning they’re no longer in the same location. It just means I’ll have to do something I should’ve done from the start and make them one and the same.

Oh, I also put in a few lines to stop the character annoyingly moving off the edge of the screen. Looks like the movement based drawing is nearly there 🙂

Leave a comment