• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

explain hangman game lingo 2

This lingo is for a hangman game, there are 6 stages of hanging each has its own image. A text file holding the words and the letters a-z. Can anyone explain thanks. i'm goin to post this question twice as i feel its worth more than 500 points.

"lingo below added to the letters"


property myLetter, spriteNum, used

global gHangmanWord

on beginSprite me
  used = 0
  myLetter = sprite(spriteNum).member.name.char[1]
end

on mouseEnter me
  if used = 0 then
    sprite(spriteNum).member = member(myLetter & "-red")
  end if
end

on mouseLeave me
  if used = 0 then
    sprite(spriteNum).member = member(myLetter & "-nor")
  else
    sprite(spriteNum).member = member(myLetter & "-used")
  end if
end

on mouseUp me
  if used = 0 then
    used = true
    if gHangmanWord contains myLetter then      
      sendAllSprites(#showLetter, myLetter)
      returnList = []
      sendAllSprites(#checkWin, returnList)
      if returnList.getOne(0) = 0 then
        go "hangmanwin"
      end if
     
    else
      sendAllSprites(#hangMe)
      sendAllSprites(#checkLoss)
    end if
    sprite(spriteNum).member = member(myLetter & "-used")
  end if
end


"code added to the image of the hanging base"


property spriteNum, hangWrong

global gHangmanWord

on hangMe me
  hangWrong = hangWrong + 1
  sprite(spriteNum).member = "JAY" & hangWrong
end

on beginSprite me
  hangWrong = 0
  sprite(spriteNum).member = "JAY" & hangWrong
end

on checkLoss me
  if hangWrong >= 6 then
    sendAllSprites(#showLoss)
    go "hangmanLoss"
  end if  
end


"added to dots that represent the number of letters"

property spriteNum, myLetter, showing

on showLetter me, whatLetter
  if myLetter = whatLetter then
    showing = true
    sprite(spriteNum).member = member(myLetter)
  end if
end

on checkWin me, winList
  winList.add(showing)
end

on assignLetter me, letterList
  sprite(spriteNum).member = member("dash")
  if letterList.count > 0 then
    myLetter = letterList[1]
    deleteAt(letterList, 1)
    showing = 0
    sprite(spriteNum).blend = 100
  else
    showing = 1
    myLetter = "empty"
    sprite(spriteNum).member = member("empty")
  end if
end

on beginSprite me
  sprite(spriteNum).blend = 0
end

on showLoss me
  sprite(spriteNum).member = member(myLetter)
end



"added to lingo script channel"


global gHangmanWord

on exitFrame me
  gHangmanWord = getHangmanWord()
  letterList = []
  repeat with x = 1 to gHangmanWord.char.count
    letterList.add(gHangmanWord.char[x])
  end repeat
  sendAllSprites(#assignLetter, letterList)    
end

on getHangmanWord
  pickText = member("hangmanWords").text
  howManyLines = pickText.line.count
  repeat with x = howManyLines down to 1
    if pickText.line[x] = "" then delete pickText.line[x]
  end repeat
  thisOne = random(howManyLines)
  return pickText.line[thisOne]
end
0
lukegriffiths110
Asked:
lukegriffiths110
1 Solution
 
LingoMasterCommented:
There appearss to be no external word list file, rather, field or text member "hangmanWords" contains a lsit of words from which one is randomly selected each play. (in getHangmanWord handler) The name is deleted from the list so it won't be used again, take care when testing one could save a movie after words have been test removed from the list, rune from a projector the list of words is complete each time the projetor is first started.

The game uses a specific member naming convention ( a form I favor by the way) that allows for one thing members to be arranged in any order in cast window without breaking the code, and avoids having to select a pile of member states in a behavior property setup dialog.

Each letter (of a whole aphapbet?) needs 3 versions of the art to be prepared:


"L-nor" -- initial version of L
"L-red" -- rolled over hilited version of L
"L-used" -- selected and in place appearance
 
The sprite determines from the name of the member assigned to it that it's letter is L, using
myLetter = sprite(spriteNum).member.name.char[1]

You need 7 members showing the hanged guy being drawn in 6 steps
"JAY0" is the empty placeholder, mabe the empty noose.
"JAY6" is the picture of the totaly drawn guy, (maybe 1 part short? since the fully hanged guy may not need to be shown until marker "hangNManLose" is reached )

The one sprite representing JAY gets assigned the behavior labeled:
"code added to the image of the hanging base"

it't handlers are called by sendAllSprites to the other sprites in the game don't have to know what sprite channel JAY is on, this gives one the freedom to rearrange the sprite channels without 'breaking' the code.

I don't recall how the dashes and letters are used in hangman, the code labeled:
"added to dots that represent the number of letters"

is assigned to the row of sprites that go from dashes to letters?
the on beginSprite handler makes these sprites initialy invisible by setting the blend to 0, the assignLetter sets the blend to 100 making the dash visible.

The details of how this dash code is called is a bit tedious to dg through provide a member named "dash" and "empty" and that section of code should function.

0
 
lukegriffiths110Author Commented:
LingoMaster you have really saved my life I’m grateful for taking out ur time to answer my questions. thank U
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now