![]() |
Game Preview |
Pygame is look like a cartesius diagram that flipped vertically. Thats mean the Y-axis positive is on bottom and the negative Y-axis is on the top side. So the Pygame coordinate will look like this image.
Pygame Coordinate |
here is the syntax:
Now I will explain as many as i can.
- Basic syntax
- Movement
Ycoord = (playerCoord[A]['y']) #This to for shorter the player Y coordinate
if move == STOP:
newCoord = {'x':Xcoord, 'y':Ycoord} #Dont add a move while looping
elif move == UP and Ycoord>25:
newCoord = {'x':Xcoord, 'y':Ycoord-2} #For each looping the Y coordinate is reduction by 2 point so the object will move to up
elif move == DOWN and Ycoord<ywindow-25:
newCoord = {'x':Xcoord, 'y':Ycoord+2} #For each looping the Y coordinate is added by 2 point so the object will move to down
elif move == LEFT and Xcoord>25:
newCoord = {'x':Xcoord-2, 'y':Ycoord} #For each looping the X coordinate is reduction by 2 point so the object will move to left
elif move == RIGHT and Xcoord<xwindow-25:
newCoord = {'x':Xcoord+2, 'y':Ycoord} #For each looping the X coordinate is added by 2 point so the object will move to right
else:
newCoord = {'x':Xcoord, 'y':Ycoord} #Dont add a move while looping same as stop
I think that all a concept to create this basic movement. For more information you can ask me in comment. Thanks for visiting ^^
0 comments:
Post a Comment