And i use self.offset_x and self.offset_y with the area parameters of the blit function to blit my circuit :
However, i noticed than i should consider the fact than my car move 'speedx' and 'speedy' pixels each frames. So actually, when i reach the left side of the circuit (for example), the self.offset_x value is never 0 and always increase each time the scrolling stop. I think to that since hours and i still don't find solutions...
I thought to do something like :
#check if the car is not out of the scrolling space on X
if self.virtual_x < MAP_SIZE_X - SCREEN_SIZE_X/2 and self.virtual_x > SCREEN_SIZE_X/2:
self.offset_x += speedx #move the screen
else:
if self.virtual_x < SCREEN_SIZE_X/2:
self.offset_x = 0
if self.virtual_x > MAP_SIZE_X - SCREEN_SIZE_X/2:
self.offset_x = MAP_SIZE_X - SCREEN_SIZE_X
self.x += speedx #move the car
But i'm not sure i'm doing well since after playing sometimes i feel the car virtual position no more match with the screen position.
I'm a bit lost and if anyone know what i'm doing wrong or if someone know a better way to implement scrolling in car game, i would be happy to hear that :)
Thanks for reading me.
PS : here is a code of a little application i use for testing scrolling method :
http://pastebin.com/deMv0TpB