
-----------------------------------
basketball4ever
Sun Jan 16, 2005 12:27 am

Help with variable setting ... can they do this?
-----------------------------------
K so basically i'm doing snakes & Ladders the game.  Pretty simple.... but i want to make it more simple... meaning... i want to set certain points of the squares as a variable.

K so u have no clue what i'm talking about... so i'll explain more in depth
Theres 50 squares.... divided on the screen... i want to label each one from numbers 1-50 in the code.  Thus square number 1 = 1 square number 2 =2.  Doing this, a player can roll a random integer... if they roll a 5, i can write the code that currentposition := currentposition +5 ... thus they're on square #6 if they started at 1.  

The problem i'm having... is  setting a variable for each square.  More in depthly.... i need a (x,y) for each square.  Since each player will have oval shaped pieces... i only need the center point.

So lets say i want square #1 at the point 50,50  and #2 be at 150,50... and so on.

-----------------------------------
TheZsterBunny
Sun Jan 16, 2005 12:40 am


-----------------------------------
hrm

you could use a 2D array and some formulas to calculate where they are on the board.

I believe there is a turing tut. on arrays. read up!

-Z

-----------------------------------
basketball4ever
Sun Jan 16, 2005 12:43 am


-----------------------------------
o crap... would this work

var position1:int:=1

loop
x = (random roll thing)
delay(1000)
position1:=position1 + x
end loop

-----------------------------------
Neo
Sun Jan 16, 2005 12:51 am


-----------------------------------
Yes it would.

-----------------------------------
basketball4ever
Sun Jan 16, 2005 12:56 am


-----------------------------------
Now NEXT and FAR MORE IMPORTANT problem... how can i set "1" as a variable for square #1...

-----------------------------------
Neo
Sun Jan 16, 2005 12:58 am


-----------------------------------
Now NEXT and FAR MORE IMPORTANT problem... how can i set "1" as a variable for square #1...

What do you mean?

-----------------------------------
basketball4ever
Sun Jan 16, 2005 1:07 am


-----------------------------------
ooo wait... would this work

if position1 := 1 then
place1x:=50
place1y:=50
elsif position1 :=2 then
place1x:=150
place1y:=50
and wen i set where the circle (the player) is... i'll subsitute the coordinates with place1y and place1x...

-----------------------------------
Cervantes
Sun Jan 16, 2005 7:20 pm


-----------------------------------
Sure, but that's going to be one needlessly big if statement.  Zster's method would be the most effective method.  Read up on those arrays!  I guarantee you, they are simple, though they may look daunting.
If you absolutely insist against using a 2D array, at least spare yourself the trouble and use a case structure.
