Forums > MaxMSP

if with multiple or's

November 5, 2008 | 4:01 pm

i am trying to stop my sprite from crossing the regions of an octagon on lcd

if i want to do it manually I am wanting to create the following:

if $i1 == 256 && $i2 > 185 then 185
or
if $i1 == 255 && $i2 > 186 then 186
or
if $i1 == 254 && $i2 > 187 then 187

…and so forth until

if $i1 == 185 && $i2 > 256 then 256

but i also need it with other numbers as well

if $i1 == 15 && $i2 > 185 then 185

…to

if $i1 == 86 && $i2 > 256 then 256

how do i go about this? is there an easier way?



f
November 6, 2008 | 2:02 am

6 nov 2008 kl. 01.01 skrev Paul de Casaparis:

>
> i am trying to stop my sprite from crossing the regions of an
> octagon on lcd
>
> if i want to do it manually I am wanting to create the following:
>
> if $i1 == 256 && $i2 > 185 then 185
> or
> if $i1 == 255 && $i2 > 186 then 186
> or
> if $i1 == 254 && $i2 > 187 then 187
>
> …and so forth until

you can chain if statements using the out2 as a dedicated ‘else’
outlet. [if ($i1==256)&&($i2>186) then 185 else out2 $i1 $i2]

but what you really want (i think) is a way of detecting the bounds
of any shape. here’s an example using my f0.bounds…

#P button 28 296 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 44 265 54 196617 change -1;
#P window linecount 2;
#P message 224 98 222 196617 clear , paintpoly 75 100 125 100 150
125 150 175 125 200 75 200 50 175 50 125 75 100;
#P user lcd 224 192 300 300 1 1 1 0 0;
#P window linecount 1;
#P comment 80 297 73 196617 1= yes , 0= no;
#P number 44 296 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 44 242 53 196617 f0.bounds;
#P newex 87 159 78 196617 route paintpoly;
#P newex 224 71 48 196617 loadbang;
#P comment 46 34 236 196617 track mouse position and see if inside
shape or not;
#P connect 7 0 2 0;
#P connect 7 0 6 0;
#P connect 1 0 7 0;
#P connect 2 0 3 1;
#P connect 8 0 9 0;
#P connect 8 0 4 0;
#P connect 3 0 8 0;
#P fasten 6 1 3 0 325 503 19 503 19 229 49 229;
#P window clipboard copycount 10;

#|
fredrikolofsson.com klippav.org musicalfieldsforever.com
|#


Viewing 2 posts - 1 through 2 (of 2 total)