def LaunchL(): global collide while collide == "False": PN.setheading(180) PN.forward(5) PN.speed(6) wn_canvas = wn.getcanvas() x,y = PN.position() margin = 10 items = wn_canvas.find_overlapping(x+margin, -y+margin, x-margin, -y-margin) if (len(items) > 0): # get a property of the lowest object (canvas) canvas_color = wn_canvas.itemcget(items[0], "fill") if (canvas_color == wall_color): collide = "True" while collide == "True": -placeholder- I'm making a game where you move until you hit a wall (think ice sliding puzzles)
The color collision detecting code is from a project sent by my Computer-Science and Programming teacher in which the wall collision works just fine. What's the problem here.
https://stackoverflow.com/questions/66003101/python-turtle-color-collision-visual-code-studio February 02, 2021 at 11:04AM
没有评论:
发表评论