DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Grids and Arrays

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
delphiman
Member


Joined: 30 May 2004
Posts: 2

PostPosted: 30/05/04 12:36    Post subject: Grids and Arrays Reply with quote

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
View user's profile
Johnny_Bit
Moderator


Joined: 15 Jun 2003
Posts: 154

PostPosted: 31/05/04 09:36    Post subject: Reply with quote

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
View user's profile
delphiman
Member


Joined: 30 May 2004
Posts: 2

PostPosted: 31/05/04 09:49    Post subject: Thanks Johnny_Bit Reply with quote

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
View user's profile
Johnny_Bit
Moderator


Joined: 15 Jun 2003
Posts: 154

PostPosted: 02/06/04 09:16    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group