minimum TO maximum?

For questions about using Classic.

Post » Mon Sep 13, 2010 11:22 am

Hi all,
Is there a way to make a mathematical formula that checks for any value between a set minimum and maximum number?

Specifically what i want done is this:

+ Dude: overlaps Tile : offset [color=#BF0000:f56bwyks](100 TO 200, 40 TO 80)[/color:f56bwyks]
-> Dude: make stuff happen!


Thanks!
B
5
S
1
G
3
Posts: 24
Reputation: 1,123

Post » Mon Sep 13, 2010 1:45 pm

You could use subevents, although i don't know what you mean by offset.

Dude overlaps tile-
subevent { - Offset is greater than 100,
+ Offset is less than 200,
subevent - { Offset is greater than 40
+ offset is less than 80}}:
Stuff happens here.

Not entirely sure what you're doing but i think that would work?
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Mon Sep 13, 2010 2:12 pm

The offset was just an example (picked "Copy as text" on an event with the condition "Is overlapping at offset" and edited it to fit what i wanted).

I need this as an algorithm for one condition, not only for the offset condition. My understanding of math is very low, but an algorithm like this shouldn't be too complex for those who do, i hope.

I hope my request is making sense :?
B
5
S
1
G
3
Posts: 24
Reputation: 1,123

Post » Mon Sep 13, 2010 6:27 pm

You're probably better off using a detector sprite in this situation, otherwise you would have to have many overlapping at offset checks. Overlapping at offset can't really use a range of values for the x and y offsets, because it uses the sprite as the collision checker, as opposed to just checking if numbers are within a range. Sure, you could make a For loop to iterate through all the offsets, but that'll use a lot more collision checks, and be slower.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Sep 14, 2010 9:37 am

thanks, i guess that's what i'll do in this case. it would be nice if this feature was added, though; i've found myself wanting to do similar things before, not using the offset condition.
B
5
S
1
G
3
Posts: 24
Reputation: 1,123

Post » Wed Sep 15, 2010 12:11 am

[quote="gugugu":1nb03yxn]Is there a way to make a mathematical formula that checks for any value between a set minimum and maximum number?[/quote:1nb03yxn]

I'm responding to this question in general, since it seems that the overlapping condition is not the only case you are looking to use. That would be a bit complicated and inefficient, as mentioned.

In case you don't know of this, and you just want to check if a variable is within a certain range, there are two easy ways to do that. The System conditions Number is between... and Evaluate can be used to do so:

+ System: Sprite.Angle is between 5 and 10
-> Do stuff...

+ System: Sprite.Angle >= 5 and Sprite.Angle <= 10
-> Do stuff...

Of course, you can use any variable for any of the numbers there, as well.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Fri Sep 17, 2010 6:12 pm

thanks a lot, that's exactly what i wanted to know :)
B
5
S
1
G
3
Posts: 24
Reputation: 1,123

Post » Fri Sep 17, 2010 6:25 pm

Theres also...
[code:2q4kqde4]Clamp(Value, Lower bound, Upper bound)
Returns Value if it is between Lower bound and Upper bound. Returns Lower bound if Value is less than Lower bound. Returns Upper bound if Value is greater than Upper bound [/code:2q4kqde4]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Sep 21, 2010 12:02 am

thus:
if 'x' equals clamp('x',min,max)
-do stuff
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest