October 12th, 2004, 02:22 AM
Delphi Hangman game, need urgent help
Hello to whoever is veiwing this message,
I need help with my game that i need to make in Delphi 7.
I chose to make a Hangman game and have found some code to derive from. The only problem being that the code i found actually used delphi to draw the hangman pictures. What i would like to do is to make the pictures become visible when a letter is guessed wrong. There would be say Image1, Image2, Image3, etc. So therefore it would be along the lines of:
if Guess1 = wrong
then Image 1.visible:= true;
and so on in a kind of loop or something
But, I'm not sure how to go about it. I need urgent help. Any information would be great. Thanx in advance.
October 12th, 2004, 05:12 AM
Add your images to an object list and have an index that points to the current image. Something along the lines of.....
ImageList : TObjectList
CurrentImage : TImage;
ImageList := TObjectList.Create;
CurrentIndex := 0;
if guesswrong then Inc(CurrentIndex)
CurrentImage := TImage(ImageList[CurrentIndex]);
Display the image....
you could make this all very tidy by writing a new image class
so you pass it the canvas on creation
and it could keep the current index internal and all the images and then all you have to do is call the guess wrong method of the class and it could draw the correct image etc....
sorry I cant get down to the nitty gritty at work !!!!
hope that hleps a little.