I'm making a mini game in a visual novel. I have an object moving on the screen. And there is a second object that the player controls. If the difference between the coordinates of the first and the second object is small, the player loses.
The difference between the objects can be either positive or negative. How can I make the negative value positive to compare with the critical value?
[Solved]How to make a number positive
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.
-
- Newbie
- Posts: 10
- Joined: Wed Feb 28, 2024 3:10 am
- Deviantart: virdate
- itch: virtual-passion
- Contact:
[Solved]How to make a number positive
Last edited by VirtualPassion on Fri May 03, 2024 6:22 am, edited 1 time in total.
- m_from_space
- Eileen-Class Veteran
- Posts: 1057
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: How to make a number positive
Don't know if that is what you want, but making a negative value positive is easy using the abs() function:VirtualPassion wrote: ↑Fri May 03, 2024 3:32 am I'm making a mini game in a visual novel. I have an object moving on the screen. And there is a second object that the player controls. If the difference between the coordinates of the first and the second object is small, the player loses.
The difference between the objects can be either positive or negative. How can I make the negative value positive to compare with the critical value?
Code: Select all
$ positive_number = abs(-100)
-
- Newbie
- Posts: 10
- Joined: Wed Feb 28, 2024 3:10 am
- Deviantart: virdate
- itch: virtual-passion
- Contact:
Re: How to make a number positive
Thank you. Turns out I was just confused about the brackets.
Code: Select all
If((((coocker_posy>0.41)or(coocker_posy<0.39))and(abs(food1_pos-coocker_posx)<0.10)),
- m_from_space
- Eileen-Class Veteran
- Posts: 1057
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: How to make a number positive
Not sure if you're a former LISP coder, but you don't need that many brackets. So you are not getting confused as easily. ^^VirtualPassion wrote: ↑Fri May 03, 2024 6:19 am Thank you. Turns out I was just confused about the brackets.Code: Select all
If((((coocker_posy>0.41)or(coocker_posy<0.39))and(abs(food1_pos-coocker_posx)<0.10)),
Code: Select all
if (coocker_posy > 0.41 or coocker_posy < 0.39) and abs(food1_pos - coocker_posx) < 0.1:
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]