| View previous topic :: View next topic |
| Author |
Message |
delphiman Member
Joined: 30 May 2004 Posts: 2
|
Posted: 30/05/04 12:36 Post subject: Grids and Arrays |
|
|
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............. |
|
| Back to top |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 154
|
Posted: 31/05/04 09:36 Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
delphiman Member
Joined: 30 May 2004 Posts: 2
|
Posted: 31/05/04 09:49 Post subject: Thanks Johnny_Bit |
|
|
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 |
|
| Back to top |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 154
|
Posted: 02/06/04 09:16 Post subject: |
|
|
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... |
|
| Back to top |
|
 |
|