Author |
Message |
basketball4ever
|
Posted: Sun Jan 16, 2005 12:27 am Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TheZsterBunny
![](http://www.members.shaw.ca/rfolz/zstervava2.jpg)
|
Posted: Sun Jan 16, 2005 12:40 am Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
basketball4ever
|
Posted: Sun Jan 16, 2005 12:43 am Post subject: (No subject) |
|
|
o crap... would this work
var position1:int:=1
loop
x = (random roll thing)
delay(1000)
position1:=position1 + x
end loop |
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: Sun Jan 16, 2005 12:51 am Post subject: (No subject) |
|
|
Yes it would. |
|
|
|
|
![](images/spacer.gif) |
basketball4ever
|
Posted: Sun Jan 16, 2005 12:56 am Post subject: (No subject) |
|
|
Now NEXT and FAR MORE IMPORTANT problem... how can i set "1" as a variable for square #1... |
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: Sun Jan 16, 2005 12:58 am Post subject: (No subject) |
|
|
basketball4ever wrote: Now NEXT and FAR MORE IMPORTANT problem... how can i set "1" as a variable for square #1...
What do you mean? |
|
|
|
|
![](images/spacer.gif) |
basketball4ever
|
Posted: Sun Jan 16, 2005 1:07 am Post subject: (No subject) |
|
|
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... |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun Jan 16, 2005 7:20 pm Post subject: (No subject) |
|
|
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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|