I'm working on a minigame where you can move cars by clicking them. It all works pretty fine, but instead of moving around, the cars just change position.
I am basically done with this game, but I want to make it look better.
I defined the cars to move as imagebuttons facing the correct direction by a Transform with rotate
Here is the code I use:
Code: Select all
init python:
def move_testcar():
global testcar_x
global testcar_y
global path
for p in path:
obstacle = False #checking for obstacle is done in another function
if not obstacle:
testcar_x = p[0]
testcar_y = p[1]
else:
break
label testlane:
scene bg trafficgame
call screen testlane
screen testlane:
image "minigames/trafficgame/townmap.png"
imagebutton:
idle Transform("minigames/trafficgame/othercar.png", rotate = 90, rotate_pad = False)
xpos testcar_x
ypos testcar_y
action Function(move_testcar)
default testcar_x = 602
default testcar_y = 803
default path =[
[602,803],
[702,803],
[802,803],
[902,803],
[1002,803],
[1102,803],
[1202,803],
[1302,803],
[1402,803]
]
What I'd like to have is that the car moves from the first to the second coordinates in the path list. And from there on to the third and so on.
I am totally confused about how to make this happen.
I already read about Transformations and that I can use them to move displayables. But I cannot imagine where to call that transformation and how.
Help would be appreciated...
Thanks in advance!