There's a lot of code in the overall program. Here's just the relevant stuff (this won't run if you try to run it). And yes, I know it's probably very inefficient, but I figured it out, so I'm proud of it. Note, most of these subs are in different files. The following makes the textbox disappear all at once instead of "roll" open as it does when it opens. And note that I reveal the letters by shrinking a black box over them.
Code: (Select All)
Dim henryB2 As Integer ' Determines if Henry text box 2 is triggered
Dim henryDone As Integer ' Makes it so Henry won't start over when trying to close text box
Dim henryWait As Integer ' A timer for talking to Henry again
Dim boxDone As Integer ' Determines when it's time to roll-up the box
Dim Shared textbox1 As Integer: textbox1 = _LoadImage("images/text_box1.png") ' top third of the box
Dim Shared textbox2 As Integer: textbox2 = _LoadImage("images/text_box2.png")
Dim Shared textbox3 As Integer: textbox3 = _LoadImage("images/text_box3.png")
Do
' Henry Interaction
' All if this code needs to be present for a text box to appear; just modify variables for different sources
If _KeyDown(32) And Not keyPressed And cPlayX = 19 And cPlayY = 3 And henryDone = 0 And henryB2 = 0 Then henryT = 1 ' These are all tiles where Henry can be triggered with spacebar
If _KeyDown(32) And Not keyPressed And cPlayX = 19 And cPlayY = 5 And henryDone = 0 And henryB2 = 0 Then henryT = 1 ' keyPressed tests for a tap; if not keyPressed, then not held down
If _KeyDown(32) And Not keyPressed And cPlayX = 18 And cPlayY = 4 And henryDone = 0 And henryB2 = 0 Then henryT = 1
If _KeyDown(32) And Not keyPressed And cPlayX = 20 And cPlayY = 4 And henryDone = 0 And henryB2 = 0 Then henryT = 1
' henryB2 needs to be tested here because doing so is one part of getting rid of a certain bug, see below
If henryT = 1 Then
interact = 1 ' Player reads as interacting so they won't move
boxOpen ' Box unfolding animation
If boxdraw >= 3 Then ' The box needs to be unfolded before any text appears
drawText "ABCDEFGHIJKLMNOPQRSTUVWXYZ", textDnX, textDnY ' Activate the function that draws the text with the custom font; text is drawn at screen x, y
drawText "abcdefghijklmnopqrstuvwxyz", textDnX, textDnY + lineSpaceB
drawText "0123456789", textDnX, textDnY + lineSpaceC
drawText "!?,:;/%'&.-~()[]@#*^}", textDnX, textDnY + lineSpaceD
lineReveal4 ' Four lines need to be revealed, so this sub is used
End If
End If
If _KeyDown(32) And Not keyPressed And revealD >= blackBox Then ' revealD refers to the final line of the last text box, in this case the 4th, or D
revealReset
henryT = 0 ' Keeps the text box from being opened away from Henry; needs to be here and not below, because a strange bug makes it so the second text box can be repeated after waiting a bit
henryB2 = 1 ' makes possible to trigger Henry's second text box
End If
If henryB2 = 1 Then
boxAppear ' Box appearing to remain in place, unchanged, for the next text
DrawText "Second box!", textDnX, textDnY
Line (textDnX + revealA, textDnY)-(textDnX + blackBox + 1, textDnY + letterHeight), _RGB(0, 0, 0), BF
lineReveal1
End If
If _KeyDown(32) And Not keyPressed And henryB2 = 1 And revealA >= blackBox Then
revealReset ' Resets the letters being revealed
revealResetB ' Allows the player to move again, and resets the box roll-down
henryB2 = 0 ' Resets B2 and causes the second text box to disappear
henryDone = 1 ' As long as this is 1, Henry can't be talked to
henryWait = 1 ' Resets the waiting period
boxDone = 1 ' Trigger the box to unroll upwards
End If
If henryDone = 1 Then henryWait = henryWait + 1 ' The player must wait before being able to trigger Henry again
If henryWait = 40 Then henryDone = 0 ' The waiting period
Loop
' ==============================================================================================
' ==============================================================================================
$If lineReveal1_bi = UNDEFINED Then
$Let lineReveal1_bi = 1
Sub lineReveal1
Line (textDnX + revealA, textDnY)-(textDnX + blackBox + 1, textDnY + letterHeight), _RGB(0, 0, 0), BF ' These are black boxes that cover the text
textRevealDnA ' These subs reveal the text of each line from left to right
End Sub
$End If
' ==============================================================================================
' ==============================================================================================
$If lineReveal2_bi = UNDEFINED Then
$Let lineReveal2_bi = 1
Sub lineReveal2
Line (textDnX + revealA, textDnY)-(textDnX + blackBox + 1, textDnY + letterHeight), _RGB(0, 0, 0), BF ' These are black boxes that cover the text
Line (textDnX + revealB, textDnY + lineSpaceB)-(textDnX + blackBox + 1, textDnY + letterHeight + lineSpaceB), _RGB(0, 0, 0), BF
textRevealDnA
textRevealDnB
End Sub
$End If
' ===========================================================================
' ===========================================================================
$If revealReset_bi = UNDEFINED Then
$Let revealReset_bi = 1
Sub revealReset
revealA = 0 ' reset these variables as if the box was never displayed
revealB = 0
revealC = 0
revealD = 0
End Sub
$End If
' ===========================================================================
' ===========================================================================
$If revealResetB_bi = UNDEFINED Then
$Let revealResetB_bi = 1
Sub revealResetB
interact = 0 ' no longer interacting
boxDraw = 0 ' Resets the box unfolding open
End Sub
$End If
' ===========================================================================
' ===========================================================================
$If loadFont_bi = UNDEFINED Then
$Let loadFont_bi = 1
Sub loadFont
lowerA = _LoadImage("font/lower_a.png"): _ClearColor _RGB(255, 0, 255), lowerA
lowerB = _LoadImage("font/lower_b.png"): _ClearColor _RGB(255, 0, 255), lowerB
lowerC = _LoadImage("font/lower_c.png"): _ClearColor _RGB(255, 0, 255), lowerC
lowerD = _LoadImage("font/lower_d.png"): _ClearColor _RGB(255, 0, 255), lowerD
lowerE = _LoadImage("font/lower_e.png"): _ClearColor _RGB(255, 0, 255), lowerE
lowerF = _LoadImage("font/lower_f.png"): _ClearColor _RGB(255, 0, 255), lowerF
lowerG = _LoadImage("font/lower_g.png"): _ClearColor _RGB(255, 0, 255), lowerG
lowerH = _LoadImage("font/lower_h.png"): _ClearColor _RGB(255, 0, 255), lowerH
lowerI = _LoadImage("font/lower_i.png"): _ClearColor _RGB(255, 0, 255), lowerI
lowerJ = _LoadImage("font/lower_j.png"): _ClearColor _RGB(255, 0, 255), lowerJ
lowerK = _LoadImage("font/lower_k.png"): _ClearColor _RGB(255, 0, 255), lowerK
lowerL = _LoadImage("font/lower_l.png"): _ClearColor _RGB(255, 0, 255), lowerL
lowerM = _LoadImage("font/lower_m.png"): _ClearColor _RGB(255, 0, 255), lowerM
lowerN = _LoadImage("font/lower_n.png"): _ClearColor _RGB(255, 0, 255), lowerN
lowerO = _LoadImage("font/lower_o.png"): _ClearColor _RGB(255, 0, 255), lowerO
lowerP = _LoadImage("font/lower_p.png"): _ClearColor _RGB(255, 0, 255), lowerP
lowerQ = _LoadImage("font/lower_q.png"): _ClearColor _RGB(255, 0, 255), lowerQ
lowerR = _LoadImage("font/lower_r.png"): _ClearColor _RGB(255, 0, 255), lowerR
lowerS = _LoadImage("font/lower_s.png"): _ClearColor _RGB(255, 0, 255), lowerS
lowerT = _LoadImage("font/lower_t.png"): _ClearColor _RGB(255, 0, 255), lowerT
lowerU = _LoadImage("font/lower_u.png"): _ClearColor _RGB(255, 0, 255), lowerU
lowerV = _LoadImage("font/lower_v.png"): _ClearColor _RGB(255, 0, 255), lowerV
lowerW = _LoadImage("font/lower_w.png"): _ClearColor _RGB(255, 0, 255), lowerW
lowerX = _LoadImage("font/lower_x.png"): _ClearColor _RGB(255, 0, 255), lowerX
lowerY = _LoadImage("font/lower_y.png"): _ClearColor _RGB(255, 0, 255), lowerY
lowerZ = _LoadImage("font/lower_z.png"): _ClearColor _RGB(255, 0, 255), lowerZ
upperA = _LoadImage("font/upper_a.png"): _ClearColor _RGB(255, 0, 255), upperA
upperB = _LoadImage("font/upper_b.png"): _ClearColor _RGB(255, 0, 255), upperB
upperC = _LoadImage("font/upper_c.png"): _ClearColor _RGB(255, 0, 255), upperC
upperD = _LoadImage("font/upper_d.png"): _ClearColor _RGB(255, 0, 255), upperD
upperE = _LoadImage("font/upper_e.png"): _ClearColor _RGB(255, 0, 255), upperE
upperF = _LoadImage("font/upper_f.png"): _ClearColor _RGB(255, 0, 255), upperF
upperG = _LoadImage("font/upper_g.png"): _ClearColor _RGB(255, 0, 255), upperG
upperH = _LoadImage("font/upper_h.png"): _ClearColor _RGB(255, 0, 255), upperH
upperI = _LoadImage("font/upper_i.png"): _ClearColor _RGB(255, 0, 255), upperI
upperJ = _LoadImage("font/upper_j.png"): _ClearColor _RGB(255, 0, 255), upperJ
upperK = _LoadImage("font/upper_k.png"): _ClearColor _RGB(255, 0, 255), upperK
upperL = _LoadImage("font/upper_l.png"): _ClearColor _RGB(255, 0, 255), upperL
upperM = _LoadImage("font/upper_m.png"): _ClearColor _RGB(255, 0, 255), upperM
upperN = _LoadImage("font/upper_n.png"): _ClearColor _RGB(255, 0, 255), upperN
upperO = _LoadImage("font/upper_o.png"): _ClearColor _RGB(255, 0, 255), upperO
upperP = _LoadImage("font/upper_p.png"): _ClearColor _RGB(255, 0, 255), upperP
upperQ = _LoadImage("font/upper_q.png"): _ClearColor _RGB(255, 0, 255), upperQ
upperR = _LoadImage("font/upper_r.png"): _ClearColor _RGB(255, 0, 255), upperR
upperS = _LoadImage("font/upper_s.png"): _ClearColor _RGB(255, 0, 255), upperS
upperT = _LoadImage("font/upper_t.png"): _ClearColor _RGB(255, 0, 255), upperT
upperU = _LoadImage("font/upper_u.png"): _ClearColor _RGB(255, 0, 255), upperU
upperV = _LoadImage("font/upper_v.png"): _ClearColor _RGB(255, 0, 255), upperV
upperW = _LoadImage("font/upper_w.png"): _ClearColor _RGB(255, 0, 255), upperW
upperX = _LoadImage("font/upper_x.png"): _ClearColor _RGB(255, 0, 255), upperX
upperY = _LoadImage("font/upper_y.png"): _ClearColor _RGB(255, 0, 255), upperY
upperZ = _LoadImage("font/upper_z.png"): _ClearColor _RGB(255, 0, 255), upperZ
nZero = _LoadImage("font/number_0.png"): _ClearColor _RGB(255, 0, 255), nZero
nOne = _LoadImage("font/number_1.png"): _ClearColor _RGB(255, 0, 255), nOne
nTwo = _LoadImage("font/number_2.png"): _ClearColor _RGB(255, 0, 255), nTwo
nThree = _LoadImage("font/number_3.png"): _ClearColor _RGB(255, 0, 255), nThree
nFour = _LoadImage("font/number_4.png"): _ClearColor _RGB(255, 0, 255), nFour
nFive = _LoadImage("font/number_5.png"): _ClearColor _RGB(255, 0, 255), nFive
nSix = _LoadImage("font/number_6.png"): _ClearColor _RGB(255, 0, 255), nSix
nSeven = _LoadImage("font/number_7.png"): _ClearColor _RGB(255, 0, 255), nSeven
nEight = _LoadImage("font/number_8.png"): _ClearColor _RGB(255, 0, 255), nEight
nNine = _LoadImage("font/number_9.png"): _ClearColor _RGB(255, 0, 255), nNine
period = _LoadImage("font/period.png"): _ClearColor _RGB(255, 0, 255), period
dash = _LoadImage("font/dash.png"): _ClearColor _RGB(255, 0, 255), dash
exclamation = _LoadImage("font/exclamation.png"): _ClearColor _RGB(255, 0, 255), exclamation
question = _LoadImage("font/question.png"): _ClearColor _RGB(255, 0, 255), question
sQuote = _LoadImage("font/s_quote.png"): _ClearColor _RGB(255, 0, 255), sQuote
lParanthesis = _LoadImage("font/l_parathesis.png"): _ClearColor _RGB(255, 0, 255), lParanthesis
rParanthesis = _LoadImage("font/r_parathesis.png"): _ClearColor _RGB(255, 0, 255), rParanthesis
lBracket = _LoadImage("font/l_bracket.png"): _ClearColor _RGB(255, 0, 255), lBracket
rBracket = _LoadImage("font/r_bracket.png"): _ClearColor _RGB(255, 0, 255), rBracket
tilda = _LoadImage("font/tilda.png"): _ClearColor _RGB(255, 0, 255), tilda
colon = _LoadImage("font/colon.png"): _ClearColor _RGB(255, 0, 255), colon
semicolon = _LoadImage("font/semicolon.png"): _ClearColor _RGB(255, 0, 255), semicolon
slash = _LoadImage("font/slash.png"): _ClearColor _RGB(255, 0, 255), slash
comma = _LoadImage("font/comma.png"): _ClearColor _RGB(255, 0, 255), comma
percent = _LoadImage("font/percent.png"): _ClearColor _RGB(255, 0, 255), percent
atSign = _LoadImage("font/at.png"): _ClearColor _RGB(255, 0, 255), atSign
hash = _LoadImage("font/hash.png"): _ClearColor _RGB(255, 0, 255), hash
dQuote = _LoadImage("font/d_quote.png"): _ClearColor _RGB(255, 0, 255), dQuote ' type &
heart = _LoadImage("font/heart.png"): _ClearColor _RGB(255, 0, 255), heart ' type ^
star = _LoadImage("font/star.png"): _ClearColor _RGB(255, 0, 255), star ' type *
note = _LoadImage("font/note.png"): _ClearColor _RGB(255, 0, 255), note ' type }
End Sub
$End If
' ==================================================================================
' ==================================================================================
$If drawText_bi = UNDEFINED Then
$Let drawText_bi = 1
Sub drawText (text As String, x As Integer, y As Integer)
Dim i As Integer
Dim positionX As Integer
Dim letter As String
positionX = x
For i = 1 To Len(text)
letter = Mid$(text, i, 1) ' Get each letter, convert to uppercase
Select Case letter
Case "a"
_PutImage (positionX, y), lowerA
Case "b"
_PutImage (positionX, y), lowerB
Case "c"
_PutImage (positionX, y), lowerC
Case "d"
_PutImage (positionX, y), lowerD
Case "e"
_PutImage (positionX, y), lowerE
Case "f"
_PutImage (positionX, y), lowerF
Case "g"
_PutImage (positionX, y), lowerG
Case "h"
_PutImage (positionX, y), lowerH
Case "i"
_PutImage (positionX, y), lowerI
Case "j"
_PutImage (positionX, y), lowerJ
Case "k"
_PutImage (positionX, y), lowerK
Case "l"
_PutImage (positionX, y), lowerL
Case "m"
_PutImage (positionX, y), lowerM
Case "n"
_PutImage (positionX, y), lowerN
Case "o"
_PutImage (positionX, y), lowerO
Case "p"
_PutImage (positionX, y), lowerP
Case "q"
_PutImage (positionX, y), lowerQ
Case "r"
_PutImage (positionX, y), lowerR
Case "s"
_PutImage (positionX, y), lowerS
Case "t"
_PutImage (positionX, y), lowerT
Case "u"
_PutImage (positionX, y), lowerU
Case "v"
_PutImage (positionX, y), lowerV
Case "w"
_PutImage (positionX, y), lowerW
Case "x"
_PutImage (positionX, y), lowerX
Case "y"
_PutImage (positionX, y), lowerY
Case "z"
_PutImage (positionX, y), lowerZ
Case "A"
_PutImage (positionX, y), upperA
Case "B"
_PutImage (positionX, y), upperB
Case "C"
_PutImage (positionX, y), upperC
Case "D"
_PutImage (positionX, y), upperD
Case "E"
_PutImage (positionX, y), upperE
Case "F"
_PutImage (positionX, y), upperF
Case "G"
_PutImage (positionX, y), upperG
Case "H"
_PutImage (positionX, y), upperH
Case "I"
_PutImage (positionX, y), upperI
Case "J"
_PutImage (positionX, y), upperJ
Case "K"
_PutImage (positionX, y), upperK
Case "L"
_PutImage (positionX, y), upperL
Case "M"
_PutImage (positionX, y), upperM
Case "N"
_PutImage (positionX, y), upperN
Case "O"
_PutImage (positionX, y), upperO
Case "P"
_PutImage (positionX, y), upperP
Case "Q"
_PutImage (positionX, y), upperQ
Case "R"
_PutImage (positionX, y), upperR
Case "S"
_PutImage (positionX, y), upperS
Case "T"
_PutImage (positionX, y), upperT
Case "U"
_PutImage (positionX, y), upperU
Case "V"
_PutImage (positionX, y), upperV
Case "W"
_PutImage (positionX, y), upperW
Case "X"
_PutImage (positionX, y), upperX
Case "Y"
_PutImage (positionX, y), upperY
Case "Z"
_PutImage (positionX, y), upperZ
Case "0"
_PutImage (positionX, y), nZero
Case "1"
_PutImage (positionX, y), nOne
Case "2"
_PutImage (positionX, y), nTwo
Case "3"
_PutImage (positionX, y), nThree
Case "4"
_PutImage (positionX, y), nFour
Case "5"
_PutImage (positionX, y), nFive
Case "6"
_PutImage (positionX, y), nSix
Case "7"
_PutImage (positionX, y), nSeven
Case "8"
_PutImage (positionX, y), nEight
Case "9"
_PutImage (positionX, y), nNine
Case "!"
_PutImage (positionX, y), exclamation
Case "?"
_PutImage (positionX, y), question
Case "."
_PutImage (positionX, y), period
Case "'"
_PutImage (positionX, y), sQuote
Case "-"
_PutImage (positionX, y), dash
Case "("
_PutImage (positionX, y), lParanthesis
Case ")"
_PutImage (positionX, y), rParanthesis
Case "["
_PutImage (positionX, y), lBracket
Case "]"
_PutImage (positionX, y), rBracket
Case "~"
_PutImage (positionX, y), tilda
Case ":"
_PutImage (positionX, y), colon
Case ";"
_PutImage (positionX, y), semicolon
Case ","
_PutImage (positionX, y), comma
Case "/"
_PutImage (positionX, y), slash
Case "%"
_PutImage (positionX, y), percent
Case "@"
_PutImage (positionX, y), atSign
Case "#"
_PutImage (positionX, y), hash
Case "&"
_PutImage (positionX, y), dQuote
Case "*"
_PutImage (positionX, y), star
Case "^"
_PutImage (positionX, y), heart
Case "}"
_PutImage (positionX, y), note
Case " "
End Select
positionX = positionX + letterWidth + letterSpace
Next i
End Sub
$End If
' =====================================================================
' =====================================================================
$If textRevealUpA_bi = UNDEFINED Then
$Let textRevealUpA_bi = 1
Sub textRevealUpA
If revealA < blackBox And boxDraw >= 5 Then
revealA = revealA + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealUpB_bi = UNDEFINED Then
$Let textRevealUpB_bi = 1
Sub textRevealUpB
If revealB < blackBox And revealA >= blackBox Then
revealB = revealB + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealUpC_bi = UNDEFINED Then
$Let textRevealUpC_bi = 1
Sub textRevealUpC
If revealC < blackBox And revealB >= blackBox Then
revealC = revealC + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealUpD_bi = UNDEFINED Then
$Let textRevealUpD_bi = 1
Sub textRevealUpD
If revealD < blackBox And revealC >= blackBox Then
revealD = revealD + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
' =====================================================================
' =====================================================================
$If textRevealDnA_bi = UNDEFINED Then
$Let textRevealDnA_bi = 1
Sub textRevealDnA
If revealA < blackBox And boxDraw >= 5 Then
revealA = revealA + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealDnB_bi = UNDEFINED Then
$Let textRevealDnB_bi = 1
Sub textRevealDnB
If revealB < blackBox And revealA >= blackBox Then
revealB = revealB + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealDnC_bi = UNDEFINED Then
$Let textRevealDnC_bi = 1
Sub textRevealDnC
If revealC < blackBox And revealB >= blackBox Then
revealC = revealC + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If
$If textRevealDnD_bi = UNDEFINED Then
$Let textRevealDnD_bi = 1
Sub textRevealDnD
If revealD < blackBox And revealC >= blackBox Then
revealD = revealD + letterwidth + 1
Else
Exit Sub
End If
End Sub
$End If