Re: Pygame and graphics?

Blit is still the correct approach, just used in a different way. As CAE_Jones mentioned, you'd use a camera offset to position everything around the player, as opposed to the player itself to create the illusion that the player is moving around the map, whilst they stay fixed in a single position.

So, lets say your working with a window thats 640 by 480, you'd want to position the player in the center, so 320 by 240, minus the image size of the player divided by 2. Then you could position either a large background image as your environment, or a series of smaller tiles, and move them based on the camera offset. So something like:

window = pygame.display.set_mode([640,480])
offset = [0,0]

...

window.blit(background,(0-offset[1],0-offset[0]))
window.blit(player,(320-(player.width/2), 240-(player.height/2)))

Whenever you press a key to move around, you'd add or subtract the offset, not the players position, thus moving the environment around you. Some side scrollers have some give to this though, where the player character can move within a  certain range within the center of the screen before hitting a collision box, where it then starts moving the camera offset instead, thus keeping the player on the screen. If you like, I can provide an example of this.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector

Reply via email to