Computer Science Canada Help with my monopoly game

 Author: poomanchunk [ Wed May 19, 2004 5:32 pm ] Post subject: Help with my monopoly game I've decided to do a monopoly game. I don't really know too much of all the advanced stuff, so this will be hard for me. I got a couple of questions for now. 1. I got 2 dices and that all works perfect (cept a few bugs that I can fix out) but when I get to the 7th square, which is the top of the screen, how do I get it so it will turn right and continue along with game. Is there a way I could make it stop at the top, then go right, with the amount the dice rolled. It sounds complicated, but maybe its not. If anyone understands and knows anything, please tell me. 2. Is there a way so I could click on an button so I could buy the place. Like I know how to do that, but what I don't understand is how can I get it so it buys the place I'm actually on (get it?). I could just make it so you could click on all the places, but just only click on the right one (and since I'll, or my family will play, this wont matter) but then if I wanna post it on here, ppl could cheat by buying other places they aren't on. Get any of that? If so please help me, thanks

 Author: Paul [ Wed May 19, 2004 5:53 pm ] Post subject: Monopoly is basically a linear path, so u just use a loop to input the coordinates of where your pieces would go on all your squares into an array, then say ur piece is on space 12, then it would look inside NameofArray (12) for where to put the piece. And when it reaches the end, it goes to the beginning again. You just add the dice roll value to another variable that keeps track of where ur piece is.

Author:  Cervantes [ Wed May 19, 2004 6:30 pm ]
Post subject:

I wouldn't use an array with preset values of where to draw the pieces, it makes it very difficult to change anything. instead, I prefer to use a generic bit of code that works for everything.
 code: setscreen ("graphics:400;400,offscreenonly") var keys : array char of boolean const gridnumber := 7 const gridwidth := maxx div gridnumber const gridheight := maxy div gridnumber type player :     record         spot, side, gridx, gridy : int     end record var player_1 : player player_1.side := 1 player_1.spot := 0 loop     Input.KeyDown (keys)     if keys (KEY_UP_ARROW) then         if player_1.spot = gridnumber * 4 - 1 then             player_1.spot := 0         else             player_1.spot += 1         end if         delay (100)     end if     player_1.side := player_1.spot div gridnumber     if player_1.side = 0 then         player_1.gridx := 0         player_1.gridy := player_1.spot     elsif player_1.side = 1 then         player_1.gridx := player_1.spot - gridnumber         player_1.gridy := gridnumber     elsif player_1.side = 2 then         player_1.gridx := gridnumber         player_1.gridy := gridnumber - player_1.spot mod gridnumber     elsif player_1.side = 3 then         player_1.gridx := gridnumber - player_1.spot mod gridnumber         player_1.gridy := 0     end if     cls     drawfilloval (player_1.gridx * (maxx div gridnumber), player_1.gridy * (maxy div gridnumber), 10, 10, green)     View.Update end loop

for Q#2, here is where you'd have to have an array that stores the information about the place you're on, like draw a card or it costs \$200 to buy or you are now in jail, etc. then you just compare, in the case of my code, player_#.spot to the value for that array.

i hope you know how to use arrays
oh and if you don't know about types and records, then you can still use them, but just understand that, in my code there, the line, "var player_1 : player" is just declaring the variable player_1. instead of delcaring it as an intiger or string or whatever im delcaring it as player. when declared as player, it inherits all the parts of player, as defind inside the record, end record part.

 Author: poomanchunk [ Wed May 19, 2004 8:40 pm ] Post subject: no actually I never learned arrays yet I'll look into them though, maybe figure out what they all mean.

 Author: Paul [ Wed May 19, 2004 9:21 pm ] Post subject: arrays are just a bunch of variables, so instead of var variable1, variable2, .... variable 100 :int u go var variable: array 1..100 of int and 100 variables are created variable(1), variable(2) etc

 Author: SuperGenius [ Thu May 20, 2004 3:03 pm ] Post subject: im sure there is a tutorial in the turorials section about arrays that would be helpfull.

 Author: poomanchunk [ Thu May 20, 2004 9:01 pm ] Post subject: Oh ok, I'll go check that out thx. Hmmm, seems really confusing, it will take me a long time before I will actually understand. Hey Cervantes, thx for the code, but I still don't really get it. Could you somehow show me how that type of thing would work with a dice, instead of pressing the up key. If not, doesn't matter, just wondering, cause it might be easy to do, or not

 :