0

Need help with pygame by img movement

I am creating a game with pygame and stumbled upon a problem. The task is that when the player reaches the middle of screen(while moving from start pos :left, towards centre) the screen should be static, which I have no problem with, and once it reach middle instead of the player the bg img will move in opposite direction to give the feeling of movement. The problem is when the bg img reaches the I'm not able to stop the movement. I want it so that once the end of img is reached the player will again start moving and the black is not seen. It would be easier to run the the program and see it. I've tried to find a solution for a week but couldn't get any progress. Any help would be appreciated. Here's the drive link: https://drive.google.com/folderview?id=13hn7COEMjRAo1U-4cvYHwen73HvzsM6g

12th Jun 2020, 1:55 PM
NightSkyLeaf
NightSkyLeaf - avatar
4 Réponses
+ 1
Maybe modulo will help. You could use modulo to make the grass path stay on the screen, but you would need to make the grasspath little larger.
12th Jun 2020, 9:22 PM
Seb TheS
Seb TheS - avatar
+ 1
I was planning to loop through both img in list to make it never ending and later make it so that it stops at a certain distance.
13th Jun 2020, 9:31 AM
NightSkyLeaf
NightSkyLeaf - avatar
+ 1
On lines 57 and 62 I would change these: dct[blitimg][0] -= player.speed dct[blitimg][0] += player.speed into these: dct[blitimg][0] = (dct[blitimg][0] - player.speed)%50 - 50 dct[blitimg][0] = (dct[blitimg][0] + player.speed)%50 - 50 Involving a side problem, which you might able to fix.
13th Jun 2020, 10:24 AM
Seb TheS
Seb TheS - avatar
0
So far I have 2 solutions. First is easy, requires use of modulo and the grass path image needs to be enlarged. Second is more advanced and harder, from me it would require some more researches on the surface objects.
12th Jun 2020, 9:52 PM
Seb TheS
Seb TheS - avatar