Jump to content

Recommended Posts

Posted

I am programming a school project in delphi 4. It is a game based on the popular game "peg solitaire". So far it has went quite well. I have completed the HCI, the board (a delphi draw grid) is in place. Now, i need to "draw images to it". As it stands, i have it loading with the numbers 1, 2 and 0. 0 is blank as in not part of the board, 1 is a peg and 2 is a "hole"... as shown below:

Click Here For Screenshot

my code for this section is:

mplementation

{$R *.DFM}

uses Unit2, Unit3, Unit4;

type boardarray= array[0..6,0..6] of byte; //activate board array

const

mainboard:boardarray=( (0,0,1,1,1,0,0),

(0,0,1,1,1,0,0),

(1,1,1,1,1,1,1),

(1,1,1,2,1,1,1),

(1,1,1,1,1,1,1),

(0,0,1,1,1,0,0),

(0,0,1,1,1,0,0)) ;

and

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;

Rect: TRect; State: TGridDrawState);

begin

DrawGrid1.Canvas.TextOut(Rect.Left, Rect.Top,inttostr(mainboard[ACol, ARow]));

end;

I would like to replace the 0 with an image (image0.bmp), the 1 with an image (image1.bmp) and the 2 with an image (image 2.bmp), but havent got a clue what to do.

Hope one of you guys knows delphi and can help.

Cheers as always!

-Graham


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...