Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
What am I missing in this code? I've done this before using _CLEARCOLOR, but for some reason it's not working this time. I must have forgotten how to use it correctly....
I was going to make a scrolling credits over the screen, using a separate screen image of text to scroll over the main display. Setting the background color of the credits screen as transparent it should work, but I'm not getting there. Using _CLEARCOLOR.
- Dav
Code: (Select All)
Screen _NewImage(800, 800, 32)
credits& = _NewImage(800, 800, 32)
_Dest credits&
_ClearColor _RGB(0, 0, 0), credits&
'just some sample text for now
For t = 1 To 1000
Print Rnd;
Next
_Dest 0
For x = 1 To _Width
For y = 1 To _Height
PSet (x, y), _RGB(Rnd * 100, Rnd * 100, Rnd * 100)
Next
Next
back& = _CopyImage(_Display)
y = _Height
Do
_PutImage (0, 0), back&
_PutImage (0, y), credits&
y = y - 10
_Display
_Limit 30
Loop Until y < -_Height
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
Ah.. Just got it working. I needed to put _ClearColor AFTER printing the text. Now it's scrolling.
- Dav (still holding the idiot of the day award )
Code: (Select All)
Screen _NewImage(800, 800, 32)
credits& = _NewImage(800, 800, 32)
_Dest credits&
'just some sample text for now
For t = 1 To 1000
Print Rnd;
Next
_ClearColor _RGB(0, 0, 0), credits&
_Dest 0
For x = 1 To _Width
For y = 1 To _Height
PSet (x, y), _RGB(Rnd * 100, Rnd * 100, Rnd * 100)
Next
Next
back& = _CopyImage(_Display)
y = _Height
Do
_PutImage (0, 0), back&
_PutImage (0, y), credits&
y = y - 10
_Display
_Limit 30
Loop Until y < -_Height
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
11-09-2024, 06:15 PM
(This post was last modified: 11-09-2024, 06:18 PM by bplus.)
Basically I just moved the call to _ClearColor to after the image was made and back to _dest 0
Code: (Select All) Screen _NewImage(800, 600, 32)
credits& = _NewImage(800, 600, 32)
_Dest credits&
'just some sample text for now
For t = 1 To 1000
Print Rnd;
Next
_Dest 0
_ClearColor _RGB32(0, 0, 0), credits&
For x = 1 To _Width
For y = 1 To _Height
PSet (x, y), _RGB32(Rnd * 100, Rnd * 100, Rnd * 100)
Next
Next
back& = _CopyImage(_Display)
y = _Height
Do
_PutImage (0, 0), back&
_PutImage (0, y), credits&
y = y - 10
_Display
_Limit 30
Loop Until y < -_Height
a minute late I see also using _RGB32 for exact coloring. So back to _dest 0 didn't matter.
b = b + ...
Posts: 2,693
Threads: 326
Joined: Apr 2022
Reputation:
217
Try: _Printmode _KeepBackground
Or: Color ,0
May also want to add a _DontBlend if you're screen scrolling the background image.
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
"Try: _Printmode _KeepBackground"
Yeah I prefer print not looking like it came from Label Maker.
b = b + ...
Posts: 723
Threads: 118
Joined: Apr 2022
Reputation:
106
11-09-2024, 10:50 PM
(This post was last modified: 11-09-2024, 10:51 PM by Dav.)
Thanks, guys. I plan to use a better font. Maybe with rotozoom can make a skewed text scroll up image like a Star Wars look.
- Dav
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
11-10-2024, 12:23 AM
(This post was last modified: 11-10-2024, 12:28 AM by bplus.)
(11-09-2024, 10:50 PM)Dav Wrote: Thanks, guys. I plan to use a better font. Maybe with rotozoom can make a skewed text scroll up image like a Star Wars look.
- Dav
We had worked on Star Wars crawl at old forum this code works in versions 3.2 to 3.4 but starting 3.6 it dies!
Code: (Select All) ' Star Wars Episode V: The Empire Strikes Back opening crawl?
' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
Screen _NewImage(800, 700, 32)
_ScreenMove 300, 20
swt& = _NewImage(320, 512, 32)
_Dest swt&
Color _RGB32(0, 180, 0)
nl$ = Chr$(10)
sw$ = "It is a dark time for the Rebellion." + nl$
sw$ = sw$ + "Although the Death Star has been" + nl$
sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
sw$ = sw$ + "and pursued them across the galaxy." + nl$
sw$ = sw$ + nl$ + nl$
sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
sw$ = sw$ + "Skywalker has established a new secret" + nl$
sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
sw$ = sw$ + nl$ + nl$
sw$ = sw$ + "The evil lord Darth Vader, obsessed" + nl$
sw$ = sw$ + "with finding young Skywalker, has" + nl$
sw$ = sw$ + "dispatched thousands of remote probes" + nl$
sw$ = sw$ + "into the far reaches of space.... " + nl$
Locate 20, 1
Print sw$
_Dest 0
yy = _Height / 3
For i = 11 To 60 Step .5
Cls
yy = yy - 60 / i
cText _Width / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
cText _Width / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
_Display
_Limit 15
Next
cx = _Width / 2
power = 1024 'TO 1 STEP -1
x = (_Height - 20) ^ (1 / power)
dy = 1 '256 pixel height / 50 blocks across
For y = -840 To -270
Cls
For i = 0 To power - 1
'_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]]
_PutImage (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), swt&, 0, (0, y + dy * i)-(319, y + dy * (i + 1))
'LINE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), , B
Next
Print y
_Display
_Limit 15
Next
yy = 80
For i = 60 To 0 Step -.5
Cls
yy = yy + 60 / i
cText _Width / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
cText _Width / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
_Display
_Limit 75
Next
Sub cText (x, y, textHeight, K As _Unsigned Long, txt$)
fg = _DefaultColor
'screen snapshot
cur& = _Dest
I& = _NewImage(8 * Len(txt$), 16, 32)
_Dest I&
Color K, _RGB32(0, 0, 0, 0)
_PrintString (0, 0), txt$
mult = textHeight / 16
xlen = Len(txt$) * 8 * mult
_PutImage (x - .5 * xlen, y - .5 * textHeight)-Step(xlen, textHeight), I&, cur&
Color fg
_FreeImage I&
End Sub
Ashish had a nice one too (Star Wars crawl) and it does still works!
Code: (Select All) '###########################
'# StarWars Opening Crawl #
'# By Ashish #
'###########################
_Title "STARSWARS Opening crawl"
Screen _NewImage(800, 600, 32)
Dim Shared glAllow, text&, text2&, lines$(26)
Dim Shared starWars&
text& = _NewImage(280, (UBound(lines$) + 1) * _FontHeight, 32)
text2& = _CopyImage(text&)
starWars& = _NewImage(65, 17, 32)
_Dest starWars&
Color _RGB32(255, 255, 255)
_PrintString (0, 0), "STARWARS"
_Dest 0
For i = 0 To UBound(lines$)
Read a$
lines$(i) = a$
Next
Color _RGB(0, 0, 255)
centerPrint "A long time ago in galaxy far,", _Width, 280
centerPrint "far away...", _Width, 308
_Delay 2
For i = 0 To 255 Step 5
Line (0, 0)-(_Width, _Height), _RGB32(0, 0, 0, i), BF
_Display
_Delay 0.01
Next
_PutImage (_Width / 2 - _Width(starWars&) * 3, _Height / 2 - _Height(starWars&) * 3)-Step(_Width(starWars&) * 6, _Height(starWars&) * 6), starWars&
_Display
_Delay 2
For i = 0 To 255 Step 5
Line (0, 0)-(_Width, _Height), _RGB32(0, 0, 0, i), BF
_Display
_Delay 0.01
Next
_Dest text2&
Color _RGB(255, 220, 0), _RGB(0, 0, 0)
For i = 0 To UBound(lines$)
If i = UBound(lines$) Then Color _RGB(255, 0, 255)
centerPrint lines$(i), _Width, y + i * _FontHeight
Next
_Dest 0
glAllow = -1
Color _RGB(255, 220, 0), _RGBA(0, 0, 0, 0)
y = _Height(text&) + 10
Do
_Dest text&
_PutImage (0, y), text2&
y = y - 1
_Limit 30
Loop Until y < -_Height(text2&) - 10
_Dest 0
Data "It is a period of civil war"
Data "Rebel spaceships, striking"
Data "from a hidden base, have "
Data "won their first victory"
Data "against the evil Galactic"
Data "Empire."
Data ""
Data ""
Data "During the battle, rebel"
Data "spies managed to steel"
Data "secret plans to the Empire's"
Data "ultimate weapon, the DEATH"
Data "STAR, an armored space station"
Data "with enough to destroy an entire"
Data "planet."
Data ""
Data ""
Data "Pursued by the Empire's sinister"
Data "agents, Princess Leia races"
Data "home abroad her starship,"
Data "custodian of the stolen plans"
Data "that cansave her people and"
Data "restore the freedom to the galaxy"
Data ""
Data ""
Data ""
Data "QB64 Rocks!"
Sub centerPrint (t$, w, y)
_PrintString ((w / 2) - (Len(t$) * _FontWidth) / 2, y), t$
End Sub
Sub _GL ()
Static glInit, tex&, texMem As _MEM ', clock!
If Not glAllow Then Exit Sub
If glInit = 0 Then
glInit = -1
_glViewport 0, 0, _Width, _Height
texMem = _MemImage(text&)
_glGenTextures 1, _Offset(tex&)
End If
If glInit = -1 Then clock! = clock! + 0.01
_glEnable _GL_TEXTURE_2D
_glEnable _GL_DEPTH_TEST
_glMatrixMode _GL_PROJECTION
_glLoadIdentity
_gluPerspective 60.0, _Width / _Height, 0.01, 10
_glMatrixMode _GL_MODELVIEW
_glLoadIdentity
_glBindTexture _GL_TEXTURE_2D, tex&
_glTexImage2D _GL_TEXTURE_2D, 0, _GL_RGB, _Width(texMem.IMAGE), _Height(texMem.IMAGE), 0, _GL_BGRA_EXT, _GL_UNSIGNED_BYTE, texMem.OFFSET
_glTexParameteri _GL_TEXTURE_2D, _GL_TEXTURE_MAG_FILTER, _GL_LINEAR
_glTexParameteri _GL_TEXTURE_2D, _GL_TEXTURE_MIN_FILTER, _GL_LINEAR
_glBegin _GL_QUADS
_glTexCoord2f 0, 1: _glVertex3f -0.8, -1, -0.5 'bottom left #
_glTexCoord2f 1, 1: _glVertex3f 0.8, -1, -0.5 'bottom right # Coordinates sign are same as in Cartesian Plane (3D)
_glTexCoord2f 1, 0: _glVertex3f 0.8, 3, -7 'upper right #
_glTexCoord2f 0, 0: _glVertex3f -0.8, 3, -7 ' upper left #
_glEnd
_glFlush
End Sub
It's _gl stuff.
b = b + ...
Posts: 649
Threads: 95
Joined: Apr 2022
Reputation:
22
(11-09-2024, 06:11 PM)Dav Wrote: Ah.. Just got it working. I needed to put _ClearColor AFTER printing the text. Now it's scrolling.
- Dav (still holding the idiot of the day award )
Code: (Select All)
Screen _NewImage(800, 800, 32)
credits& = _NewImage(800, 800, 32)
_Dest credits&
'just some sample text for now
For t = 1 To 1000
Print Rnd;
Next
_ClearColor _RGB(0, 0, 0), credits&
_Dest 0
For x = 1 To _Width
For y = 1 To _Height
PSet (x, y), _RGB(Rnd * 100, Rnd * 100, Rnd * 100)
Next
Next
back& = _CopyImage(_Display)
y = _Height
Do
_PutImage (0, 0), back&
_PutImage (0, y), credits&
y = y - 10
_Display
_Limit 30
Loop Until y < -_Height
Hah! I challenge that award!
I can't even make sense out of a lot of that code, but it all works!
I wish I had half of your skills!
Posts: 2,693
Threads: 326
Joined: Apr 2022
Reputation:
217
@bplus The issue is trying to grab a line which is offscreen. Something must've changed with the error checking inside _PutImage starting around version 3.6. Try this and see if it works for you, with manual error checking involved:
Code: (Select All)
' Star Wars Episode V: The Empire Strikes Back opening crawl?
' http://www.galaxyfaraway.com/gfa/2006/02...ing-crawl/
Screen _NewImage(800, 700, 32)
_ScreenMove 300, 20
swt& = _NewImage(320, 512, 32)
_Dest swt&
Color _RGB32(0, 180, 0)
nl$ = Chr$(10)
sw$ = "It is a dark time for the Rebellion." + nl$
sw$ = sw$ + "Although the Death Star has been" + nl$
sw$ = sw$ + "destroyed, Imperial troops have driven" + nl$
sw$ = sw$ + "the Rebel forces from their hidden base" + nl$
sw$ = sw$ + "and pursued them across the galaxy." + nl$
sw$ = sw$ + nl$ + nl$
sw$ = sw$ + "Evading the dreaded Imperial Starfleet," + nl$
sw$ = sw$ + "a group of freedom fighters led by Luke" + nl$
sw$ = sw$ + "Skywalker has established a new secret" + nl$
sw$ = sw$ + "base on the remote ice world of Hoth." + nl$
sw$ = sw$ + nl$ + nl$
sw$ = sw$ + "The evil lord Darth Vader, obsessed" + nl$
sw$ = sw$ + "with finding young Skywalker, has" + nl$
sw$ = sw$ + "dispatched thousands of remote probes" + nl$
sw$ = sw$ + "into the far reaches of space.... " + nl$
Locate 20, 1
Print sw$
_Dest 0
yy = _Height / 3
For i = 11 To 60 Step .5
Cls
yy = yy - 60 / i
cText _Width / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
cText _Width / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
_Display
_Limit 15
Next
cx = _Width / 2
power = 1024 'TO 1 STEP -1
x = (_Height - 20) ^ (1 / power)
dy = 1 '256 pixel height / 50 blocks across
For y = -840 To -270
Cls
For i = 0 To power - 1
'_PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]]
If y + dy * (i + 1) >= 0 Then
_PutImage (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), swt&, 0, (0, y + dy * i)-(319, y + dy * (i + 1))
End If
'LINE (cx - .75 * x ^ i, 10 + x ^ i)-(cx + .75 * x ^ i, 10 + x ^ (i + 1)), , B
Next
' Print y
_Display
_Limit 15
Next
yy = 80
For i = 60 To 0 Step -.5
Cls
yy = yy + 60 / i
cText _Width / 2, yy + yy, yy, _RGB32(230, 220, 50), "Star Wars"
cText _Width / 2, yy + yy, yy * .96, _RGB32(0, 0, 0), "Star Wars"
_Display
_Limit 75
Next
Sub cText (x, y, textHeight, K As _Unsigned Long, txt$)
Dim fg As _Unsigned Long
fg = _DefaultColor
'screen snapshot
cur& = _Dest
I& = _NewImage(8 * Len(txt$), 16, 32)
_Dest I&
Color K, _RGB32(0, 0, 0, 0)
_PrintString (0, 0), txt$
mult = textHeight / 16
xlen = Len(txt$) * 8 * mult
_PutImage (x - .5 * xlen, y - .5 * textHeight)-Step(xlen, textHeight), I&, cur&
Color fg
_FreeImage I&
End Sub
Looks to me like this is something which _PutImage used to catch, that it isn't currently catching. I've brought it up on Discord with our devs. Hopefully we'll see this fixed in the next update.
Posts: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
11-10-2024, 04:11 AM
(This post was last modified: 11-10-2024, 04:13 AM by bplus.)
@SMcNeill nice fix, I hadn't a clue! Thanks!
Looks like this was an added check before main _putimage line:
If y + dy * (i + 1) >= 0 Then ' _putimage
Meanwhile I try something without _putimage:
Code: (Select All) ' Star Wars Episode V: The Empire Strikes Back opening crawl?
' http://www.galaxyfaraway.com/gfa/2006/02/what-is-the-text-of-the-star-wars-episode-v-the-empire-strikes-back-opening-crawl/
Screen _NewImage(1200, 600, 32)
_ScreenMove 0, 20
Color _RGB32(0, 180, 0)
Dim sw$(14)
sw$(0) = "It is a dark time for the Rebellion."
sw$(1) = "Although the Death Star has been"
sw$(2) = "destroyed, Imperial troops have driven"
sw$(3) = "the Rebel forces from their hidden base"
sw$(4) = "and pursued them across the galaxy."
sw$(5) = "***"
sw$(6) = "Evading the dreaded Imperial Starfleet,"
sw$(7) = "a group of freedom fighters led by Luke"
sw$(8) = "Skywalker has established a new secret"
sw$(9) = "base on the remote ice world of Hoth."
sw$(10) = "***"
sw$(11) = "The evil lord Darth Vader, obsessed"
sw$(12) = "with finding young Skywalker, has"
sw$(13) = "dispatched thousands of remote probes"
sw$(14) = "into the far reaches of space.... "
cx = _Width / 2
row = _Height - 64 - 8
size = 64
tstart = 0
Do
row = _Height - 64 - 8
size = 64
Cls
t = tstart
For i = 20 To 1 Step -1
t = t - 1
If t >= 0 And t <= 14 Then t$ = sw$(t) Else t$ = " "
Text cx - (Len(t$) * size / 2) / 2, row, size, &HFFAA8800, t$
size = 64 * .9 ^ (21 - i)
row = row - size - 1
Next
_Display
_Limit 2
tstart = tstart + 1
Loop
Sub Text (x, y, textHeight, K As _Unsigned Long, txt$)
Dim fg As _Unsigned Long, bg As _Unsigned Long, cur&, i&
fg = _DefaultColor: bg = _BackgroundColor: cur& = _Dest
i& = _NewImage(8 * Len(txt$), 16, 32)
_Dest i&: Color K, _RGBA32(0, 0, 0, 0): _PrintString (0, 0), txt$
_PutImage (x, y)-Step(Len(txt$) * textHeight / 2, textHeight), i&, cur&
Color fg, bg: _FreeImage i&: _Dest cur&
End Sub
Not quite as smoooth!
b = b + ...
|