Detecting images on contact
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Detecting images on contact
Is there a way to check if an image touches other image and if possiple make it a function?
- barsunduk
- Newbie
- Posts: 18
- Joined: Fri Jul 18, 2014 1:06 pm
- Completed: «Crystal City», «Mega City», «Kilmonger», «Neuronaut», «Love, Death & Veggies», «Arrow Tourney», «Big Red Hood: Halloween», «Succubus Throne»
- Projects: «Swordsman Tourney», «This Tiny Galaxy»
- Organization: 7DOTS
- itch: 7dots
- Contact:
Re: Detecting images on contact
As far as I know, Renpy doesn't support collision. But for simple skeet shooting, I use the code for one point.
Code: Select all
init python:
def get_opaque(img, x=None, y=None):
rv = renpy.render(renpy.displayable(img), config.screen_width, config.screen_height, 0, 0)
w, h = rv.get_size()
w, h = int(w), int(h)
if x is None:
x = w - 1
if y is None:
y = h - 1
return rv.is_pixel_opaque(x, y)
def is_opaque(img, x=None, y=None, min_a=0):
a = is_opaque(img, x, y)
return a > min_a
Who is online
Users browsing this forum: Bing [Bot]