Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Text Box Issues for a Beginner
#1
Hi all, new here, and relatively new to programming. I've been working for about a week on a 2D RPG engine, and even AI (of various sorts) can't see to help me on certain issues.

The first issue is that I can't figure out how to take a screenshot of one particular area of the screen. When I use _ScreenImage it just takes a shot of the last window that was open OTHER than the game I'm working on. GET seems useless for whatever reason, and _NewImage only starts from 0, 0, which is useless to me. And I don't even understand _CopyImage.

I'm working in a 32-bit window.

The purpose of this is for the second issue, and for all I know isn't needed at all. I made code to animate the opening of a text box by splitting it into thirds. It appears from top to bottom over a certain period of frames. But the problem is that the only way I've been able to make those images disappear is by making them all disappear at the same time. However I simply want the animation to reverse itself so the box appears to be closing.

I must've worked seven hours today to try and make this happen, to no avail. And Claude, ChatGPT, and Gemini were all of no help. I'm desperate here!

Thank you.

Vespin
Reply
#2
Since you've started a project, please post the code. It is much easier to get help on what your are working on than what you are talking about. Also, please don't try to learn programming from these stupid so called AI apps. They are being hyped up to insure a some sort of a future when they actually may be useful.  I was around to see search engines go from trash to treasure, but thankfully, back then, we didn't have to contend with all the bonehead hype we see today.

Now the project you are undertaking may be a bit too advanced for starters. Usually folks cut their teeth by building up their coding ability with easier concepts; however some folks catch on pretty fast, provided they can just get past some hurdles. That's what posting the code, even if it doesn't work, helps with, recognizing and getting past those hurdles.

Welcome to the biggest and bestest BASIC forum on the internet. That's right, channeling Trump again.

Pete
Reply
#3
Quote:The first issue is that I can't figure out how to take a screenshot of one particular area of the screen
This is combo of maybe _Newimage, for sure _Putimage and _SaveImage.

_putimage gets a section of screen and can put it into a _newimage work area and _saveimage can convert that image to file for storage and retrieval anytime anywhere.
You might just be needing to learn to use _PutImage: https://qb64phoenix.com/forum/showthread.php?tid=1119

"Text boxes"
I know "text boxes" as controls in GUI that users use to fill with strings for processing info in the app.

This is not describing them:
Quote:The purpose of this is for the second issue, and for all I know isn't needed at all. I made code to animate the opening of a text box by splitting it into thirds. It appears from top to bottom over a certain period of frames. But the problem is that the only way I've been able to make those images disappear is by making them all disappear at the same time. However I simply want the animation to reverse itself so the box appears to be closing.
Could you be talking about View Print or Window commands used for controling areas of screen usually for text?

Pete says post code and usually that is great advice for newbies but trying to describe things with right words won't be helped much by code.

It seems like you are going for some visual effect with text? You can use _NewImage and _PutImage to create all sorts of effects with text like swirl it around with RotoZoom! Smile
b = b + ...
Reply
#4
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
Reply
#5
The code above, when in place with the rest of the code, works perfectly... I just can't figure out how to modify it to "roll" the box up when the conversation is over. It rolls down fine when it starts.
Reply
#6
@vespin

Is this what you mean?

Code: (Select All)
_Title "Roll Open and Close an Image" ' b+ 2024-10-29


Const SW = 1200, SH = 700
Screen _NewImage(SW, SH, 32): _ScreenMove 0, 0
i = _LoadImage("vespin.PNG")
Do
    BoxRollDown 10, 10, _Width - 20, _Height - 20, i, 1
    _PrintString (500, _Height - 40), "Press any to roll up."
    Sleep
    Cls
    BoxRollDown 10, 10, _Width - 20, _Height - 20, i, 0
    _PrintString (500, _Height - 40), "Press any to roll down."
    Sleep
    Cls
Loop

Sub BoxRollDown (x, y, w, h, i, DownTF)
    ' not likely the box w, h is same scale as image w, h
    ' so what fits what?
    saveAD = _AutoDisplay
    iw = _Width(i)
    ih = _Height(i)
    wR = w / iw
    hR = h / ih
    If wR < hR Then ' use w scale to accommodate smallest change
        scale = w / iw
        xo = 0: yo = (h - ih * scale) / 2
    Else ' use h to accomadate smallest change
        scale = h / ih
        xo = (w - iw * scale) / 2: yo = 0
    End If
    ' mult scale to fit box
    Line (x, y)-Step(w, h), , B ' draw box
    Line (x + xo, y + yo)-Step(iw * scale, ih * scale), &HFFFFFF00, B ' fit image inside
    If DownTF Then
        For yy = 0 To ih
            _PutImage (x + xo, y + yo)-Step(iw * scale, yy * scale), i, 0, (0, 0)-(iw, yy)
            _Display
            _Limit 120
        Next
    Else
        For yy = ih To 0 Step -1
            Line (x + xo, y + yo)-Step(iw * scale, ih * scale), &HFF000000, BF
            Line (x + xo, y + yo)-Step(iw * scale, ih * scale), &HFFFFFF00, B ' fit image inside
            _PutImage (x + xo, y + yo)-Step(iw * scale, yy * scale), i, 0, (0, 0)-(iw, yy)
            _Display
            _Limit 120
        Next
    End If
    If saveAD Then _AutoDisplay
End Sub

   
Animation in zip is way better!

Should work for any image, here is New PieSlice screen shot rolling down. This image had less width than height for box it was to be fit into.
   


Attached Files
.zip   Roll Box open close.zip (Size: 935.94 KB / Downloads: 11)
b = b + ...
Reply
#7
the most simplistic thing to do would be to copy the section of screen that the text box will go over. this also assumes your text box is an image itself,

Code: (Select All)

tempimagelayer = _NEWIMAGE( textboxXsize , textboxYsize, 32) 'temp area to store screen hidden by text box

_PUTIMAGE (0,0), _DISPLAY ,tempimagelayer, (ScreenPosX ,ScreenPosY)-step(textboxXsize -1, textboxYsize -1) 'move the section of screen to back it up


FOR Y%=0 TO textboxYsize-1 'Scroll out text box (this is from top down, for bottom up use  "textboxYsize -1 TO 0 STEP -1"

_PUTIMAGE (ScreenPosX,ScreenPosY + Y%), TEXTBOXLayer, _DISPLAY, (0,y%)-STEP(TextboxXsize-1,0) 'place textbox line by line onto screen

_LIMIT 30 'change value to speed up or slow down how fast the textbox is shown

NEXT Y%


'do textbox stuff


FOR Y%=0 TO textboxYsize-1 'remove text box with scroll (this is from top down, for bottom up use  "textboxYsize -1 TO 0 STEP -1"

_PUTIMAGE (ScreenPosX,ScreenPosY + Y%), tempimagelayer, _DISPLAY, (0,y%)-STEP(TextboxXsize-1,0) 'remove textbox from screen line by line.

_LIMIT 30 'change value to speed up or slow down how fast the textbox is removed

NEXT Y%

This code makes a lot of assumptions of how you are storing and using your text box and how fast you want it to scroll in and out and makes no attempt in controlling screen flickering.
You could also us a DO:LOOP as well if you don't like FOR\NEXT.
You can change how much of the text box is shown\removed with STEP, and how fast\slow with _LIMIT or even _DELAY.

I see B+ just made you some code too. Beat me to it.
Reply
#8
BTW Oh I just remembered something. @vespin

When I was working on my version reversing the down effect, I too wondered, "Why isn't this working?"

Oh! because I had to blank out the image area! BEFORE each redraw of the shrinking image! Otherwise the image is redrawing over the full image, doesn't look like anything is happening! LOL
b = b + ...
Reply
#9
@bplus - is there an exe file in the zip file? I have never had any problems downloading zipped files with an exe file. 
That can only be due to the host server. Chrome is on the default security settings, third-party cookies are blocked... all completely normal settings that don't otherwise cause any problems. And the Windows-Defender also.

[Image: Roll-Box-Virenwarnung-2024-10-29-185851.jpg]

And of course nothing was found!

[Image: Roll-Box-Fehlalarm-2024-10-29-191439.jpg]
Reply
#10
Yes there was an exe, here it is without (and both demo.png files just switch names or use your own image).


Attached Files
.zip   Roll Box open close (2).zip (Size: 60.13 KB / Downloads: 11)
b = b + ...
Reply




Users browsing this thread: 2 Guest(s)