简体   繁体   中英

Tkinter Canvas Collision Detection?

I'm currently trying to make a self-scrolling adventure game, where you have to kill enemies. But for killing them, I need to know how to do collision detection. Most things I found online didn't work, my own attempts neither. (I'm not gonna use Pygame)

Thanks for you help in advance.

Thank you all for your help, but I've found an answer myself:

a = canvas.bbox(object)
b = canvas.bbox(object2)
if b[0] in range(a[0],a[2]) or b[2] in range(a[0],a[2]) and b[1] in range(a[1],a[3]) or b[3] in range(a[1],a[3]):
    pass #collision

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM