Page 1 of 1

Grids and Arrays

PostPosted: May 30th, 2004, 12:36 pm
by delphiman
Hi

I wonder if someone can give me some advice
I am working through Delphi, and was wondering if anyone knew how to write the code for an array of 10 rows by 10 columns, of random numbers, whereby a user guesses which number a treasure is hidden in (a game), and this array must be displayed to the screen as a grid......???

Any help would be gladly appreciated.

Thanks in advance.............

PostPosted: May 31st, 2004, 9:36 am
by Johnny_Bit
Hmm.. I think it's kinda simple if there is only one treasure and rest of cells are empty. You have to get position of treasure cell by random(10) (cells are [0..9]) to display it you can use draw/string grid

Thanks Johnny_Bit

PostPosted: May 31st, 2004, 9:49 am
by delphiman
Thanks Johnny_Bit

But I have no idea how to write the source code.....

Would you be able to help me further ?? any help would be appreciated.

Thanks

PostPosted: June 2nd, 2004, 9:16 am
by Johnny_Bit
i see no problem here... for sample:

treasure:tpoint;
..
randomize;
...
treasure.x:=random(10);
treasure.y:=random(10);
...

grid.onclick:

if cell.x=treasure.x and cell.y=treasure.y then //here the sip

currently i have no delphi nearby to check code...