Page 1 of 1

complicated math problem

PostPosted: Sat Feb 02, 2008 12:48 am
by GuitarManGuitar
I need a math formula. There is a variable that that adds 1 per item you put in a menu. The menu has 4 spaces horizontally and 10 spaces vertically. You have to add 20 to x to move to the next box, and 20 to the y as well. When you pick up an item it goes into the first available space. The problem is that if you have four items and you pick up a fifth, it goes next to the fourth, not where i want it which is under the first. I need a formula that will put an item in the right space. Here is where it would go.

{///WIZARD HAT PICK UP
{collide.itemtype = strcmp(collide.name, wizhat.name);
if(collide.itemtype==0)
if(collide.itemown==0)
if(collide.hatequip==0)
ChangeParent("Collide Actor", "menu"),
collide.x=_________,
collide.y=_________,
menuquan=menuquan+1, collide.itemown=1;}

Re: complicated math problem

PostPosted: Sat Feb 02, 2008 1:00 am
by DilloDude
Code: Select all
collide.x = menu.x + ((position % 4) * 20);
collide.y = menu.y + ((int)(position / 4) * 20);

Replace menu.x and menu.y with the coordinates of the first box.
Replace position with the number of the box to place it in (the first box number is 0, the last 39).

Re: complicated math problem

PostPosted: Sat Feb 02, 2008 2:07 am
by GuitarManGuitar
duuuuuude!!! your a genius!!!!!! 20000 points for you!