PDA

View Full Version : Using for to check x and y seperate?



Nimono
11-28-2007, 01:15 PM
for (int cmbchk = 0; cmbchk < 176; cmbchk++)

....How would I go about changing that to where it's keeping the x and y positions seperate? My updated Cane of Somaria script is gonna need to keep the x and y seperate so I can modify them to check for combos above, below, to the left of, and to the right of the Somaria Block. But I have no idea how to do that when the X and Y positions are combined into one with that for loop. I also have no clue how I'd keep them seperate and still have them check everything right! Thanks in advance.... :(

C-Dawg
11-28-2007, 02:00 PM
for (int cmbchk = 0; cmbchk < 176; cmbchk++)

....How would I go about changing that to where it's keeping the x and y positions seperate? My updated Cane of Somaria script is gonna need to keep the x and y seperate so I can modify them to check for combos above, below, to the left of, and to the right of the Somaria Block. But I have no idea how to do that when the X and Y positions are combined into one with that for loop. I also have no clue how I'd keep them seperate and still have them check everything right! Thanks in advance.... :(

Your question is not clear. What are you trying to accomplish? Please post your code.

However, this tidbit might help. If you're using the combo numbers and not x,y coordinates:

the center combo = the combo number you're currently at.
the combo to the north of the center combo = current combo - 16
the combo to the south of the center combo = current combo + 16
the combo to the west of the center combo = current combo - 1
combo to the east of the center combo = current combo + 1

UNLESS of course, those checks take you out of range or you're at the edge of a screen. So, for example, you don't need to check the north combo if your current combo is on the top row.

Nimono
11-28-2007, 04:37 PM
I can't post the code, since it's not complete yet. Nor is it very much done. Here's what I'm trying to accomplish, as said in my Cane of Somaria release thread:

1: When the Somaria Block is made, the combo at its location is saved to variable "Reset", then the Block appears.
2: A new Global script then checks for if the Block is on-screen. If so, it uses new variables for each of the 4 cardinal directions, and sets the combos around it to those variables. It also then stores the Block's position to another variable.
3: Loop back to start, and a check happens for if the block is in the same position as was stored previously. If so, continue on. If not, it checks for if it's above, below, to the left of, or to the right of the old position. The combo stored in the variable Reset is placed at the old position, and the combo stored in the variable of the direction the Block was moved becomes the new Reset combo.
4: Repeat steps 2 and 3 forever. Or until the block is removed.

That's basically what I'm trying to accomplish. You see, I don't want to force the user to place all his/her ground/floor on Layer 1 just so they can have multiple tiles for the floor/ground. It may be more work this way for me, but it's worth it. I mean, why waste screens when the script can store the correct variables? And as for Combo number, I have no clue. As you can see in what I first put in the post, it's a single number. So I'd assume it's checking Combo numbers. But I don't know how that thing works, either...