complicated math problem

Game Editor comments and discussion.

complicated math problem

Postby GuitarManGuitar » Sat Feb 02, 2008 12:48 am

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;}
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score

Re: complicated math problem

Postby DilloDude » Sat Feb 02, 2008 1:00 am

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).
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: complicated math problem

Postby GuitarManGuitar » Sat Feb 02, 2008 2:07 am

duuuuuude!!! your a genius!!!!!! 20000 points for you!
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron