Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hey, I started creating a outrun style game. I wanted to use your ray casting and floor casting code as base for the game. 

I ran into an issue... I cant seem to figure out how to move left and right. I tried to simply modify the x position of the player, but this does not take effect. 

Looking at your sample code and running it led to the player "rising up in the sky" and crashing the game. Is there any solution for this?

Thanks allot for your example code it did help allot!! 

I really hope you might be able to help me with this issue.

(2 edits)

yes, of course there is a solution. to move the car left and right, first you have to create a variable called: player_car_pos=[240,320], then change the line that is responsible of blitting the car that is: 

screen.blit(player_car,(240,320))

to this:

screen.blit(player_car,player_car_pos)


second, comment out the or delete the code under the if statements (conditions):

if keys[K_LEFT]:

and

elif keys[K_RIGHT]:

and replace it with:

if keys[K_LEFT]:

   player_car_pos[0]-=10

elif keys[K_RIGHT]:

   player_car_pos[0]+=10

then the car should move left and right, thank you for enjoying my work!.