#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    5
    Rep Power
    0

    Question 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.
    Bubblez
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    32
    Rep Power
    10
    Add your images to an object list and have an index that points to the current image. Something along the lines of.....

    var
    ImageList : TObjectList
    CurrentImage : TImage;

    begin
    ImageList := TObjectList.Create;
    ImageList.Add(Image1);
    ImageList.Add(Image2);
    ......

    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

    e.g. THangmanClass.Create(Canvas)

    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.
    Mox.

IMN logo majestic logo threadwatch logo seochat tools logo