Grids and Arrays

Please discuss general Delphi programming topics here.

Grids and Arrays

Postby delphiman » May 30th, 2004, 12:36 pm

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.............
delphiman
Member
Member
 
Posts: 2
Joined: May 30th, 2004, 12:34 pm

Postby Johnny_Bit » May 31st, 2004, 9:36 am

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
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Thanks Johnny_Bit

Postby delphiman » May 31st, 2004, 9:49 am

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
delphiman
Member
Member
 
Posts: 2
Joined: May 30th, 2004, 12:34 pm

Postby Johnny_Bit » June 2nd, 2004, 9:16 am

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...
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron