Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: bikerboy on December 09, 2008
-
thanx man ;D
the least i could do is thank the people who helped me :D
EDIT: i managed to set the motion i wanted and add color to the letters.
what i can't find how to do it is to show all the letters in the scroller (it only shows some letters), and to make it show from right to left.
the code i'm using.
'' To keep our letters in memory
Dim as string LettersToScroll(50) => {"H","o","!"," ","H","o","!"," ","H","o","!"," ","M","e","r","r","y"," ","C","h","r","i","s","t","m","a","s"}
'' To keep our letters position somewhere :
Dim as single LettersX(12), LettersY(12)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 10
LettersX(i) = i*15
LettersY(i) = 480 '' middle screen
next
Screenres 640,480,16,2
Do : screenlock : cls
For i as integer = 0 to 12
LettersX(i) += 0.4 ' scroll along X axis
LettersY(i) = 320+70*sin(LettersX(i)/70) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)>640 then LettersX(i) = 0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 1,1
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
[Edit - This topic was split from "Hello Everyone" by Shockwave. The original topic is locked, please stay on topic here, once the problem is solved and you want to make something else, please create a new topic.]
-
/--\
||
||
bump ::)
-
There are more letters in the array, so you must declare more space in the arrays containing position of these letters. Plus, you must handle more letters in your loops :)
replace :
'' To keep our letters position somewhere :
Dim as single LettersX(12), LettersY(12)with
Dim as single LettersX(50), LettersY(50)
replace :
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 10
LettersX(i) = i*15
LettersY(i) = 480 '' middle screen
nextwith
For i as integer = 0 to 50
LettersX(i) = i*15
LettersY(i) = 480 '' middle screen
next
finally, replace :
For i as integer = 0 to 12with
For i as integer = 0 to 50
Do you see why you need those changes ?
-
yeah i got it thanx man ;D , i changed all the others you said and only got it to show up to the letter "M" , and when i tried to change this -> "For i as integer = 0 to 12" , it froze the compiler when compiled but now it works :updance:
how about making it go the other way? i tried to add this code to make it go from right to left
LettersX=LettersX-1
if LettersX<(-len(a)*8) then xText=632
like it was in the other intro but all i got was errors
EDIT: how can i make the scroller read a font and display it? and what type of image must the font be? (.bmp , .png). thanx in advance guys :D
-
i now have another question ::)
i'm trying to put some color in this string ->
Draw String(43,0)," hello guys "
but when i make it -->
Draw String(43,0),rgb(50,50,50)" hello guys "
i get this error -->
Compiler output:
C:/Program Files/FreeBASIC/FBIDETEMP.bas(28) error 55: Type mismatch, at parameter 5
Draw String(43,0),rgb(50,50,50)" hello guys "
so my questions is this, can i color the text inside the "Draw String" command?
-
Something like this should work mate.
COLOR rgb(50,50,50), rgb(0,0,0)
Draw String(43,0)," hello guys "
the freebasic color command takes two arguments the first is the forground color and the second is the background color. you can also use this on circles rectangles etc.
hope this helps
-
Something like this should work mate.
COLOR rgb(50,50,50), rgb(0,0,0)
Draw String(43,0)," hello guys "
the freebasic color command takes two arguments the first is the forground color and the second is the background color. you can also use this on circles rectangles etc.
hope this helps
yes it does cheers man :cheers:
now my question is this, i have several draw strings in my screen and i tried this
COLOR rgb(50,50,50), rgb(0,0,0)
Draw String(43,0)," hello guys "
COLOR rgb(150,150,150), rgb(0,0,0)
Draw String(43,0)," hello guys2 "
but the hello guys2 line doesn't have the color it's supposed do, it has the same color from the first line.
and to be exact i have about 52 draw strings i want to color with different color for each one, is this possible?
-
right it should be possible,
the peice of code above draws the text in the same place though which would give ( hello guys )( hello guys2 ) color.
could you maybe post the code that isnt working for you?
-
right, this does work ok.
SCREEN 19, 32
CLS
COLOR rgb(150,0,0), rgb(0,0,0)
Draw String(43,0)," hello guys "
COLOR rgb(150,150,150), rgb(0,0,0)
Draw String(43,15)," hello guys2 "
Sleep
do you wish for a single line of text to change colors. because that can also be done very simply with variables as your rgb indexes. let me know what your after and ill help.
-
yes it works :D :D
thanx man :cheers:
i can't post the source, not untill 1/1/2009 :P
not b/c it's a super secret nuclear eyes only top national sequrity thingie lol :P
but b/c i'm making a "newyeartro" (within my coding limits ::)) for you guys and i don't want you to see it yet ::) :P
the reason i wanted to color every line is b/c it will look like copper (i hope) but it won't move.
and i'm doing it this way b/c i can't make coppers that move yet :stirrer:, and to be precise i can't make any coppers at all :P
the dreamy thing would be to make the strings color up like in the "oracle sinemania" example but without the wave effect, but i can't do that yet.
-
cool im glad you got it going mate!
i look forward to seeing it finished. Btw you dont have to do 50 lines of text you can do something like this.
SCREEN 19, 32
CLS
Dim As Double DeltaF
Dim As Double R = 0
Dim As Integer Y
DeltaF = 255/(39/2)
For Y = 0 to 39
COLOR rgb(R,0,0), rgb(0,0,0)
Draw String(43,Y*14)," hello guys "
R += DeltaF
If R > 255 Then
R = 255
DeltaF = -DeltaF
EndIf
If R < 0 Then
R = 0
DeltaF = -DeltaF
EndIf
Next
Sleep
Can you see how that might work mate? Cause if not ill explain
-
perfect :carrot: :carrot:
exactly was i wanted to do ;D ;D ;D ;D ;D
i allready colored every string lol :P but didn't have the effect i hoped.
how do i change it to this color? -> r125,g146,b242
EDIT: i just applied the code inside the one i have and i get 2 results, note i have a sinescroller there too
result 1, i put the color code before the scroller and i get a black screen with the scroller only
result 2, i put the code adter the scroller and i get all lines in red also flashing :P , and the scroller is just a blue blurry line.
the scroller i'm using.
Screenres 640,480,16,2
'' To keep our letters in memory
Dim as string LettersToScroll(12) => {"H","e","l","l","o"," ","W","o","r","l","d"," ","!"}
'' To keep our letters position somewhere :
Dim as single LettersX(12), LettersY(12)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 12
LettersX(i) = i*10
LettersY(i) = 320 '' middle screen
next
Do : screenlock : cls
For i as integer = 0 to 12
LettersX(i) += 0.5 ' scroll along X axis
LettersY(i) = 320+10*sin(LettersX(i)/10) ' Sine Scroll along Y axis
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i)
if LettersX(i)>640 then LettersX(i) = 0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 1,1
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
also how can i make the scroller go backwards? ::)
-
For the color do this.
' Good old 320x200x8
SCREEN 19, 32
CLS
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(39/2)
DeltaFG = 146/(39/2)
DeltaFB = 242/(39/2)
For Y = 0 to 39
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(43,Y*14)," hello guys "
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
Sleep
ill have a look at the rest for you later as im just going out.
-
okies man ;) have fun :D
EDIT: here is the complete code i'm using.
i left in the starting strings and removed the rest :D
Screenres 640,480,16,2
#Include Once "tinyptc.bi"
#include "windows.bi"
'#include "ufmod.bi"
'#include "tune.bas"
'Dim hWave As HWAVEOUT
'hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim as string LettersToScroll(50) => {"H","a","p","p","y"," ","N","e","w"," ","Y","e","a","r"," ","2","0","0","9","!","!"," "," "," "," "," "," "}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(50), LettersY(50)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 50
LettersX(i) = i*15
LettersY(i) = 480 '' middle screen
next
''''Screenres 640,480,16,2
'bikerboy
Do : screenlock : cls
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(39/2)
DeltaFG = 146/(39/2)
DeltaFB = 242/(39/2)
For Y = 0 to 39
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(43,0)," ... _ _ _ _ ... "
Draw String(43,10)," ( oo) | | (_) | | | (- o) "
Draw String(43,20),"ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ ooO--(_)--Ooo"
Draw String(43,30)," | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Draw String(43,40)," | |_) | | < __/ | | |_) | (_) | |_| | "
Draw String(43,50)," |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Draw String(43,60)," __/ | "
Draw String(43,70)," _________________________________ |___/ "
'
'DBF url
Draw String(58,65)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 50
LettersX(i) += 0.6 ' scroll along X axis
LettersY(i) = 330+10*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)>640 then LettersX(i) = -0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 1,1
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
now that i look the code again, i think it only supports a single line of text, i have many lines.
but the flash must have something to do with the scroller i think.
-
sorry for the wait Biker boy iv got some hang over from last night ;D
is it something like this you were after.
Screenres 640,480,16,2
#Include Once "tinyptc.bi"
#include "windows.bi"
'#include "ufmod.bi"
'#include "tune.bas"
'Dim hWave As HWAVEOUT
'hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim as string LettersToScroll(50) => {"H","a","p","p","y"," ","N","e","w"," ","Y","e","a","r"," ","2","0","0","9","!","!"," "," "," "," "," "," "}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(50), LettersY(50)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 50
LettersX(i) = i*15
LettersY(i) = 480 '' middle screen
next
''''Screenres 640,480,16,2
'bikerboy
Dim Shared As String Message(9)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = "ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = " _________________________________ |___/ "
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(8/2)
DeltaFG = 146/(8/2)
DeltaFB = 242/(8/2)
For Y = 0 to 8
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(43,Y*10),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(0,0,255),RGB(0,0,0)
Draw String(58,75)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 50
LettersX(i) += 0.6 ' scroll along X axis
LettersY(i) = 330+10*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)>640 then LettersX(i) = -0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 1,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
-
Nice one ninogenio! ;) especially with an hangover! lol!
Obviously like that the scroller runs very fast . . . but just by changing the line
LettersX(i) += 0.6
to something like
LettersX(i) += 0.025
it is readable . . .
I like this!
DrewPee
-
sorry for the wait Biker boy iv got some hang over from last night ;D
is it something like this you were after.
no worries mate i'm in no rush :D
it's exactly what i was looking for :goodpost: :goodpost:
a quick question, should i change this -> Dim Shared As String Message(9) , to the number of lines i have? i have about 52-53 text lines, should i make it for example ->Dim Shared As String Message(53) ?
@DrewPee
yup i'll slow it down ;)
EDIT: ok figured that out, changed For Y = 0 to 55 and now it displays all text lines, but now a few more questions has risen :P
Q1 : can i somehow center the text to the screen?
Q2 : what should i change to make it a bit brighter? some text lines are not visible at all ::) EDIT: discard that one i've found it ;D
it's all perfect except that some text is off screen from bottom and right side, can i somehow add something like "Message(1),(58,75), = "insert text here". ?
lol EDIT: again :P never mind the above i found it, changed Draw "String(3,Y*9),Message(Y)", and everything fits on screen ok now :clap: now i need to add some spaces to some lines to make it look better
-
right now we get on to the fun part, understanding what i have done so you can change it to suit yourself ;).
firstly lets break open the copper part to see how it works and how it can be changed to suit more lines of text.
lets look at the delta values to see what all the numbers mean.
DeltaFR = 125/(39/2)
right what essentially we want to do is at the centre of our text lines we want the r value to hit 125 so what we need is some small factor we can add on to R = 0 each frame so that when we render the centre line of text R will equal 125.
So we use fractions or a delta factor as us coders like to call it to come up with a delta factor for red i did this in my original example DeltaFR = R / ( NoTextLines / 2 ) Try that on a calculator and multiply the Delta Factor be half the number of text lines it should give you a value of R. The exact same principle applys to G and B
Can you see how these calculations should be changed to achive diffrent colors and for diffrent numbers of text lines?
Now For This part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
now what i do is add our color delta factors onto r = 0 g = 0 b = 0 inside the for loop so that half way through the for loop our colors will equal 125,146,242 now when this point is reached we dont want to keep adding the delta factor on as it wouldn't be very copper barish so what i do is reverse the delta sign like DeltaFR = -DeltaFR now when we add this onto R it will start to take away from it so that when the for loop is finished r will equal 0 again.
does that make sense ok?
now onto moving the text around.
Draw String(43,Y*10),Message(Y)
just add an offset to y like so 10+Y*10 you might need to play about with the offset to get it just right. i hope this helps.
-
yup it helps a lot ;D :cheers: :cheers:
i think you guys need to assemble and write the DBF tutorial :P :P
i attached an image of how it looks now :D
Ps. my biggest problem ever was maths ... ::)
Ps2. i've tried to reverse the scroller to run from right to left instead of left to right and my best effort was to pause it, disapear it, and it appear from the center of the screen.
any ideas of how i can make it go backwards?
-
i really think your doing excellently bikerboy keep pluging away and you will get there.
how about this for making it go backwords notice i have added an offset to the scroller here.
LettersX(i) = 640+i*15
and iv reversed the signs here
LettersX(i) -= 0.6 ' scroll along X axis
LettersY(i) = 330-10*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
and the if check
if LettersX(i)<0 then LettersX(i) = 640 '' if a letter is too far on the left, make it start again on the left
#include "windows.bi"
'#include "ufmod.bi"
'#include "tune.bas"
'Dim hWave As HWAVEOUT
'hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim as string LettersToScroll(50) => {"H","a","p","p","y"," ","N","e","w"," ","Y","e","a","r"," ","2","0","0","9","!","!"," "," "," "," "," "," "}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(50), LettersY(50)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 50
LettersX(i) = 640+i*15
LettersY(i) = 480 '' middle screen
next
''''Screenres 640,480,16,2
'bikerboy
Dim Shared As String Message(9)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = "ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = " _________________________________ |___/ "
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(8/2)
DeltaFG = 146/(8/2)
DeltaFB = 242/(8/2)
For Y = 0 to 8
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(43,Y*10),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(0,0,255),RGB(0,0,0)
Draw String(58,75)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 50
LettersX(i) -= 0.6 ' scroll along X axis
LettersY(i) = 330-10*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)<0 then LettersX(i) = 640 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 1,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
does that help?
-
i really think your doing excellently bikerboy keep pluging away and you will get there.
thanx man ;D
now that i see it working i can say i was so close too, i didn't change the LettersY(i) = 165-15*sin(LettersX(i)/10) part.
does that help?
not only it helps, it's perfect :clap: :clap: much appreciated man thanx again for all your help ;D :cheers:
now it looks so nice that i want to add more to it :P :P
ASCII textlines colored the way they're now with a simple starfield --> classic intro :carrot:
is it easy to create a simple starfield? , nothing fancy and complicated , just dots moving from one left to right ::)
EDIT: just noticed the scroller starts from the middle of the screen and it does not repeat :skint:
and the full code i'm using (replaced only the text lines)
Screenres 640,480,16,2
#Include Once "tinyptc_ext++.bi"
#include "windows.bi"
#include "tune.bas"
#include "crt.bi"
'Play our music
Dim hWave As HWAVEOUT
hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim buffer as integer
Dim as string LettersToScroll(60) => {" "," "," "," "," "," "," "," ","!","!","!"," "," ","9","0","0","2"," "," ","R","A","E","Y"," "," ","W","E","N"," "," ","Y","P","P","A","H"}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(60), LettersY(60)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 60
LettersX(i) = 640-i*15
LettersY(i) = 480 '' middle screen
next
'bikerboy
Dim Shared As String Message(55)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = " ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ -ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = " _________________________________ |___/ "
Message(9) = "-------------------------------text-------------------------------"
Message(10) = "-------------------------------text-------------------------------"
Message(11) = "-------------------------------text-------------------------------"
Message(12) = "-------------------------------text-------------------------------"
Message(13) = "-------------------------------text-------------------------------"
Message(14) = "-------------------------------text-------------------------------"
Message(15) = "-------------------------------text-------------------------------"
Message(16) = "-------------------------------text-------------------------------"
Message(17) = "-------------------------------text-------------------------------"
Message(19) = "-------------------------------text-------------------------------"
Message(20) = "-------------------------------text-------------------------------"
Message(21) = "-------------------------------text-------------------------------"
Message(22) = "-------------------------------text-------------------------------"
Message(23) = "-------------------------------text-------------------------------"
Message(24) = "-------------------------------text-------------------------------"
Message(25) = "-------------------------------text-------------------------------"
Message(26) = "-------------------------------text-------------------------------"
Message(27) = "-------------------------------text-------------------------------"
Message(28) = "-------------------------------text-------------------------------"
Message(29) = "-------------------------------text-------------------------------"
Message(30) = "-------------------------------text-------------------------------"
Message(31) = "-------------------------------text-------------------------------"
Message(32) = "-------------------------------text-------------------------------"
Message(33) = "-------------------------------text-------------------------------"
Message(34) = "-------------------------------text-------------------------------"
Message(35) = "-------------------------------text-------------------------------"
Message(36) = "-------------------------------text-------------------------------"
Message(37) = "-------------------------------text-------------------------------"
Message(38) = "-------------------------------text-------------------------------"
Message(39) = "-------------------------------text-------------------------------"
Message(40) = "-------------------------------text-------------------------------"
Message(41) = "-------------------------------text-------------------------------"
Message(42) = "-------------------------------text-------------------------------"
Message(43) = "-------------------------------text-------------------------------"
Message(44) = "-------------------------------text-------------------------------"
Message(45) = "-------------------------------text-------------------------------"
Message(46) = "-------------------------------text-------------------------------"
Message(47) = "-------------------------------text-------------------------------"
Message(48) = "-------------------------------text-------------------------------"
Message(49) = "-------------------------------text-------------------------------"
Message(50) = "-------------------------------text-------------------------------"
Message(51) = "-------------------------------text-------------------------------"
Message(52) = "-------------------------------text-------------------------------"
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(8/2)
DeltaFG = 146/(8/2)
DeltaFB = 242/(8/2)
For Y = 0 to 55
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(3,Y*9),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 254 Then
R = 254
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 250 Then
G = 250
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 251 Then
B = 251
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(42,240,222),RGB(0,0,0)
Draw String(68,68)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 60
LettersX(i) -= 0.075 ' scroll along X axis
LettersY(i) = 165-15*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)>640 then LettersX(i) = -0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 2,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
-
you missed a few other lines too.
Screenres 640,480,16,2
'#Include Once "tinyptc.bi"
Screenres 640,480,16,2
'#Include Once "tinyptc_ext++.bi"
#include "windows.bi"
'#include "tune.bas"
#include "crt.bi"
'Play our music
' Dim hWave As HWAVEOUT
' hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim buffer as integer
Dim as string LettersToScroll(60) => {" "," "," "," "," "," "," "," ","!","!","!"," "," ","9","0","0","2"," "," ","R","A","E","Y"," "," ","W","E","N"," "," ","Y","P","P","A","H"}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(60), LettersY(60)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 60
LettersX(i) = 640+i*15
LettersY(i) = 480 '' middle screen
next
'bikerboy
Dim Shared As String Message(52)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = " ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ -ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = " _________________________________ |___/ "
Message(9) = "-------------------------------text-------------------------------"
Message(10) = "-------------------------------text-------------------------------"
Message(11) = "-------------------------------text-------------------------------"
Message(12) = "-------------------------------text-------------------------------"
Message(13) = "-------------------------------text-------------------------------"
Message(14) = "-------------------------------text-------------------------------"
Message(15) = "-------------------------------text-------------------------------"
Message(16) = "-------------------------------text-------------------------------"
Message(17) = "-------------------------------text-------------------------------"
Message(19) = "-------------------------------text-------------------------------"
Message(20) = "-------------------------------text-------------------------------"
Message(21) = "-------------------------------text-------------------------------"
Message(22) = "-------------------------------text-------------------------------"
Message(23) = "-------------------------------text-------------------------------"
Message(24) = "-------------------------------text-------------------------------"
Message(25) = "-------------------------------text-------------------------------"
Message(26) = "-------------------------------text-------------------------------"
Message(27) = "-------------------------------text-------------------------------"
Message(28) = "-------------------------------text-------------------------------"
Message(29) = "-------------------------------text-------------------------------"
Message(30) = "-------------------------------text-------------------------------"
Message(31) = "-------------------------------text-------------------------------"
Message(32) = "-------------------------------text-------------------------------"
Message(33) = "-------------------------------text-------------------------------"
Message(34) = "-------------------------------text-------------------------------"
Message(35) = "-------------------------------text-------------------------------"
Message(36) = "-------------------------------text-------------------------------"
Message(37) = "-------------------------------text-------------------------------"
Message(38) = "-------------------------------text-------------------------------"
Message(39) = "-------------------------------text-------------------------------"
Message(40) = "-------------------------------text-------------------------------"
Message(41) = "-------------------------------text-------------------------------"
Message(42) = "-------------------------------text-------------------------------"
Message(43) = "-------------------------------text-------------------------------"
Message(44) = "-------------------------------text-------------------------------"
Message(45) = "-------------------------------text-------------------------------"
Message(46) = "-------------------------------text-------------------------------"
Message(47) = "-------------------------------text-------------------------------"
Message(48) = "-------------------------------text-------------------------------"
Message(49) = "-------------------------------text-------------------------------"
Message(50) = "-------------------------------text-------------------------------"
Message(51) = "-------------------------------text-------------------------------"
Message(52) = "-------------------------------text-------------------------------"
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(52/2)
DeltaFG = 146/(52/2)
DeltaFB = 242/(52/2)
For Y = 0 to 52
COLOR rgb(R+60,G+40,B+13), rgb(0,0,0)
Draw String(3,Y*9),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(42,240,222),RGB(0,0,0)
Draw String(68,68)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 60
LettersX(i) -= 0.075 ' scroll along X axis
LettersY(i) = 165-15*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)<0 then LettersX(i) = 640 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 2,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
for a starfeild if you have a look through this freebasic forum shockwave has done a starfeild challenge which can be thought of like a tutorial. i think you will find a few tutorials too though.
-
weird, i just compiled the code in your post and there's no scroller and the text lines have a single color :skint:
thanx man i'll go look for it :D
EDIT: found two nice starfields to play with ;D :stirrer:
the first one is here http://www.dbfinteractive.com/forum/index.php/topic,1758.0.html
and the other one here http://www.dbfinteractive.com/forum/index.php/topic,3140.0.html
cooked the code a bit and i have the same problem with both starfields, the problem is that i can hear the tune play, i can see the starfield but i can't see the scroller and the colored text.
it seems that the starfield and the scroller use the word "buffer" in order to play so there's a conflict there.
the starfield uses ->DIM SHARED AS INTEGER BUFFER ( XRES * YRES ):
and the scroller uses -> Dim buffer as integer
at first i commented Dim buffer as integer and get the result above (no scroller and color text).
then i renamed DIM SHARED AS INTEGER BUFFER ( XRES * YRES ): to DIM SHARED AS INTEGER BUFFER2 ( XRES * YRES ):
also renamed buffer2 wherever it was used by the starfield, but no luck same result.
i'll look into it again tomorrow, now the time here is 6:33 in the morning and my brain does not compile lol :P
the code
'Screenres 640,480,16,2
#Include Once "tinyptc_ext++.bi"
#include "windows.bi"
#include "tune.bas"
#include "crt.bi"
OPTION STATIC
OPTION EXPLICIT
CONST XRES AS INTEGER = 640:' Screen Width In Pixels.
CONST YRES AS INTEGER = 480:' Screen Height In Pixels.
'Play our music
Dim hWave As HWAVEOUT
hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
DIM SHARED AS INTEGER BUFFER ( XRES * YRES ):' The Screen Array.
' This is how we define a variable;
DIM SHARED AS INTEGER NUMBER_OF_STARS = 1000:' How many stars to have.
DIM SHARED AS INTEGER SX(NUMBER_OF_STARS):' WILL STORE X POS
DIM SHARED AS INTEGER SY(NUMBER_OF_STARS):' WILL STORE Y POS
DIM SHARED AS INTEGER SS(NUMBER_OF_STARS):' WILL STORE SPEED
'' To keep our letters in memory
'Dim buffer as integer
Dim as string LettersToScroll(60) => {" "," "," "," "," "," "," "," ","!","!","!"," "," ","9","0","0","2"," "," ","R","A","E","Y"," "," ","W","E","N"," "," ","Y","P","P","A","H"}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(60), LettersY(60)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 60
LettersX(i) = 640-i*15
LettersY(i) = 480 '' middle screen
next
DECLARE SUB SET_STARS():' SET UP STARFIELD
DECLARE SUB DO_STARS():' MOVE / DRAW STARS ETC.
' This is how we call a subroutine;
SET_STARS():' Set Star Positions and speed.
' Open The Screen;
IF (PTC_OPEN("STARFIELD",XRES,YRES)=0) THEN
END-1
END IF
'
' Main Loop;
'
WHILE (1)
DO_STARS():' Do the starfield
PTC_UPDATE@BUFFER(0):' Update Screen
ERASE BUFFER:' Clear Screen
WEND
END
'
' Do The Starfield;
'
SUB DO_STARS()
' PLEASE NOTE THE VARIABLE "SL"
' ALTHOUGH THIS VARIABLE NAME IS THE SAME AS IN THE OTHER SUB, IT IS
' A COMPLETELY SEPERATE VARIABLE, AS IT IS A LOCAL VARIABLE :-)
' GENERALLY IT IS BAD PROGRAMMING PRACTICE TO DO WHAT I HAVE DONE HERE
' YOU SHOULD GIVE THE LOOP A PREFIX LIKE DO_STARS_SL
'
DIM AS INTEGER SL :' Used as a pointer in loop.
FOR SL=1 TO NUMBER_OF_STARS
SX(SL)=SX(SL)+SS(SL) : ' Move Star
IF SX(SL) > XRES THEN SX(SL)=SX(SL)-XRES :' reset it if off screen
IF SX(SL)>0 AND SX(SL)<XRES THEN:' Check if onscreen before drawing
'Draw in the correct colour according to speed.
IF SS(SL) =1 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H444444
IF SS(SL) =2 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H777777
IF SS(SL) =3 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HAAAAAA
IF SS(SL) =4 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HCCCCCC
IF SS(SL) =5 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HFFFFFF
END IF
NEXT
END SUB
'-------------------------------------------------------------------------------
' THIS SIMPLY MAKES A RANDOM X AND Y LOCATION FOR EACH STAR
'-------------------------------------------------------------------------------
SUB SET_STARS()
' Because this is being dimensioned inside a sub, the variable SL
' is inaccessible by any other part of the program, it will only work in
' THIS sub.
DIM AS INTEGER SL:' Loop counter variable
for SL = 1 TO NUMBER_OF_STARS
SX(SL) = INT(RND(1) * XRES):' GENERATE AND STORE NUMBER BETWEEN 0 AND XRES
SY(SL) = INT(RND(1) * YRES):' GENERATE AND STORE NUMBER BETWEEN 0 AND YRES
SS(SL) = INT(RND(1) * 5) + 1:' RANDOM SPEED
NEXT
END SUB
'bikerboy
Dim Shared As String Message(55)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = " ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ -ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = "
Message(9) = "-----------------------------text line-----------------------------"
Message(10) = "-----------------------------text line-----------------------------"
Message(11) = "-----------------------------text line-----------------------------"
Message(12) = "-----------------------------text line-----------------------------"
Message(13) = "-----------------------------text line-----------------------------"
Message(14) = "-----------------------------text line-----------------------------"
Message(15) = "-----------------------------text line-----------------------------"
Message(16) = "-----------------------------text line-----------------------------"
Message(17) = "-----------------------------text line-----------------------------"
Message(19) = "-----------------------------text line-----------------------------"
Message(20) = "-----------------------------text line-----------------------------"
Message(21) = "-----------------------------text line-----------------------------"
Message(22) = "-----------------------------text line-----------------------------"
Message(23) = "-----------------------------text line-----------------------------"
Message(24) = "-----------------------------text line-----------------------------"
Message(25) = "-----------------------------text line-----------------------------"
Message(26) = "-----------------------------text line-----------------------------"
Message(27) = "-----------------------------text line-----------------------------"
Message(28) = "-----------------------------text line-----------------------------"
Message(29) = "-----------------------------text line-----------------------------"
Message(30) = "-----------------------------text line-----------------------------"
Message(31) = "-----------------------------text line-----------------------------"
Message(32) = "-----------------------------text line-----------------------------"
Message(33) = "-----------------------------text line-----------------------------"
Message(34) = "-----------------------------text line-----------------------------"
Message(35) = "-----------------------------text line-----------------------------"
Message(36) = "-----------------------------text line-----------------------------"
Message(37) = "-----------------------------text line-----------------------------"
Message(38) = "-----------------------------text line-----------------------------"
Message(39) = "-----------------------------text line-----------------------------"
Message(40) = "-----------------------------text line-----------------------------"
Message(41) = "-----------------------------text line-----------------------------"
Message(42) = "-----------------------------text line-----------------------------"
Message(43) = "-----------------------------text line-----------------------------"
Message(44) = "-----------------------------text line-----------------------------"
Message(45) = "-----------------------------text line-----------------------------"
Message(46) = "-----------------------------text line-----------------------------"
Message(47) = "-----------------------------text line-----------------------------"
Message(48) = "-----------------------------text line-----------------------------"
Message(49) = "-----------------------------text line-----------------------------"
Message(50) = "-----------------------------text line-----------------------------"
Message(51) = "-----------------------------text line-----------------------------"
Message(52) = "-----------------------------text line-----------------------------"
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(8/2)
DeltaFG = 146/(8/2)
DeltaFB = 242/(8/2)
For Y = 0 to 55
COLOR rgb(R,G,B), rgb(0,0,0)
Draw String(3,Y*9),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 254 Then
R = 254
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 250 Then
G = 250
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 251 Then
B = 251
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(42,240,222),RGB(0,0,0)
Draw String(68,68)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 60
LettersX(i) -= 0.075 ' scroll along X axis
LettersY(i) = 165-15*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)>640 then LettersX(i) = -0 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 2,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
-
right the main problem here is that the starfeild is done in tinyptc. and your code runs on freebasic graphics library.
you should not mix the two. thats what all the buffer stuff is about, what i suggest doing is ripping all the x and y's out of the buffer commands and use somethig like draw point from the freebasic lib. also get rid of all the tinyptc stuff for now. then carefully put the starfeild stuff in your code making sure not to disrupt too much other stuff.
if you look at your example you will see you have two main loops one for the stars and your original one. the star mainloop comes first thats why you never see your code running.
btw about the scoller here it is fixed and the colors changed just cause i was messing around with them Just put them to what ever you like :p .
Screenres 640,480,16,2
'#Include Once "tinyptc_ext++.bi"
#include "windows.bi"
'#include "tune.bas"
#include "crt.bi"
'Play our music
' Dim hWave As HWAVEOUT
' hWave = uFMOD_PlaySong(@Music(0),31009,XM_MEMORY)
'' To keep our letters in memory
Dim buffer as integer
Dim as string LettersToScroll(60) => {" "," "," "," "," "," "," "," ","!","!","!"," "," ","9","0","0","2"," "," ","R","A","E","Y"," "," ","W","E","N"," "," ","Y","P","P","A","H"}
dim a as string
'' To keep our letters position somewhere :
Dim as single LettersX(60), LettersY(60)
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 60
LettersX(i) = 350+i*15
LettersY(i) = 480 '' middle screen
next
'bikerboy
Dim Shared As String Message(52)
Message(1) = " ... _ _ _ _ ... "
Message(2) = " ( oo) | | (_) | | | (- o) "
Message(3) = " ooO--(_)--Ooo-| |__ _| | _____ _ __| |__ ___ _ _ -ooO--(_)--Ooo"
Message(4) = " | '_ \| | |/ / _ \ '__| '_ \ / _ \| | | | "
Message(5) = " | |_) | | < __/ | | |_) | (_) | |_| | "
Message(6) = " |_.__/|_|_|\_\___|_| |_.__/ \___/ \__, | "
Message(7) = " __/ | "
Message(8) = " _________________________________ |___/ "
Message(9) = "-------------------------------text-------------------------------"
Message(10) = "-------------------------------text-------------------------------"
Message(11) = "-------------------------------text-------------------------------"
Message(12) = "-------------------------------text-------------------------------"
Message(13) = "-------------------------------text-------------------------------"
Message(14) = "-------------------------------text-------------------------------"
Message(15) = "-------------------------------text-------------------------------"
Message(16) = "-------------------------------text-------------------------------"
Message(17) = "-------------------------------text-------------------------------"
Message(19) = "-------------------------------text-------------------------------"
Message(20) = "-------------------------------text-------------------------------"
Message(21) = "-------------------------------text-------------------------------"
Message(22) = "-------------------------------text-------------------------------"
Message(23) = "-------------------------------text-------------------------------"
Message(24) = "-------------------------------text-------------------------------"
Message(25) = "-------------------------------text-------------------------------"
Message(26) = "-------------------------------text-------------------------------"
Message(27) = "-------------------------------text-------------------------------"
Message(28) = "-------------------------------text-------------------------------"
Message(29) = "-------------------------------text-------------------------------"
Message(30) = "-------------------------------text-------------------------------"
Message(31) = "-------------------------------text-------------------------------"
Message(32) = "-------------------------------text-------------------------------"
Message(33) = "-------------------------------text-------------------------------"
Message(34) = "-------------------------------text-------------------------------"
Message(35) = "-------------------------------text-------------------------------"
Message(36) = "-------------------------------text-------------------------------"
Message(37) = "-------------------------------text-------------------------------"
Message(38) = "-------------------------------text-------------------------------"
Message(39) = "-------------------------------text-------------------------------"
Message(40) = "-------------------------------text-------------------------------"
Message(41) = "-------------------------------text-------------------------------"
Message(42) = "-------------------------------text-------------------------------"
Message(43) = "-------------------------------text-------------------------------"
Message(44) = "-------------------------------text-------------------------------"
Message(45) = "-------------------------------text-------------------------------"
Message(46) = "-------------------------------text-------------------------------"
Message(47) = "-------------------------------text-------------------------------"
Message(48) = "-------------------------------text-------------------------------"
Message(49) = "-------------------------------text-------------------------------"
Message(50) = "-------------------------------text-------------------------------"
Message(51) = "-------------------------------text-------------------------------"
Message(52) = "-------------------------------text-------------------------------"
Do : screenlock
Dim As Double DeltaFR , DeltaFG , DeltaFB
Dim As Double R = 0 , G = 0 , B = 0
Dim As Integer Y
DeltaFR = 125/(52/2)
DeltaFG = 146/(52/2)
DeltaFB = 242/(52/2)
For Y = 0 to 52
COLOR rgb(R+60,G+40,B+13), rgb(0,0,0)
Draw String(3,Y*9),Message(Y)
'color part
R += DeltaFR
G += DeltaFG
B += DeltaFB
If R > 125 Then
R = 125
DeltaFR = -DeltaFR
EndIf
If R < 0 Then
R = 0
DeltaFR = -DeltaFR
EndIf
If G > 146 Then
G = 146
DeltaFG = -DeltaFG
EndIf
If G < 0 Then
G = 0
DeltaFG = -DeltaFG
EndIf
If B > 242 Then
B = 242
DeltaFB = -DeltaFB
EndIf
If B < 0 Then
B = 0
DeltaFB = -DeltaFB
EndIf
Next
'DBF url
Color RGB(42,240,222),RGB(0,0,0)
Draw String(68,68)," @ http://www.dbfinteractive.com"
'the scroller part
For i as integer = 0 to 60
LettersX(i) -= 0.6 ' scroll along X axis
LettersY(i) = 165-15*sin(LettersX(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(LettersX(i), LettersY(i)),LettersToScroll(i),rgb(98,39,252)
if LettersX(i)<0 then LettersX(i) = 640 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 2,1
cls
Loop until multikey(&h01) '' Will quit loop if ESC is pressed
-
what i suggest doing is ripping all the x and y's out of the buffer commands and use somethig like draw point from the freebasic lib. also get rid of all the tinyptc stuff for now.
btw about the scoller here it is fixed and the colors changed just cause i was messing around with them Just put them to what ever you like :p .
i'm not sure how to do all that ::)
thanx for the scroller man :clap:
-
as long as you show you are willing to try and learn new things the best you can bikerboy, im here to answer any of your questions to the best of my abilitys all year long ;)
really dont be affraid of studying code hard and long to try and figuare out how it works even though it looks complex take it apart if you have too. i have seen me looking at code i never thought in a million years i would understand, but by breaking it all up into small chunks and really analising it eventually i got it, and thats the best feeling trust me. its the only way you will progress.
now for the starfeild to understand how we might be able to port it we need to look at what is going on here.
DIM SHARED AS INTEGER BUFFER ( XRES * YRES ):' The Screen Array.
IF SS(SL) =1 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H444444
IF SS(SL) =2 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H777777
IF SS(SL) =3 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HAAAAAA
IF SS(SL) =4 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HCCCCCC
now for you too learn this you need to know what an array is do you know this?
also the buffer() array is essentally tinyptc's backbuffer when you put a Color hex value in the array. be it &H444444 , &H777777 or what ever and push the buffer array through with this command ( PTC_UPDATE(@BUFFER(0) ):' Update Screen ) a pixel will be lit on screen.
are you with me so far, dont be affraid of asking any questions. once you understand what i have said above we will move onto what a 1d array looks like and how we can move about it. basicaly what all this ( BUFFER (SX(SL) + ( SY(SL) * XRES) ) ) is about.
Also when i said get rid of the tinyptc stuff for now it was this stuff here.
IF (PTC_OPEN("STARFIELD",XRES,YRES)=0) THEN
END-1
END IF
PTC_UPDATE@BUFFER(0):' Update Screen
ERASE BUFFER:' Clear Screen
-
no i don't know what an array is or what it does, basically i have no idea what most of those commands do.
i know Dim is used to declare things, X Y Z are the positions,the draw string that shows a text message on screen, the cls that clears the screen,the color you showed me the other day,and the Loop until multikey(&h01) that plays until the esc is pressed.
that's all i know so far , oh and how to put a song and a picture on the screen
-
right so we have a starting point then, i need to know what you so far understand so i can teach you from there.
an array is simply an area in memory you attach to a variable.try to think of it like your assigning lots of boxes to a variable. now what you put in each box and how many boxes you have is up too you.
say we want 10 boxes attached to a variable called box. we might do this.
Dim Shared as Integer Box(10)
now the () tells freebasic we want it to put some boxes onto the box variable and the number 10 is how many.
now we can put any number in box 1 like so.
Box(1) = 10
and also in box 2.
Box(2) = 40
etc.
the reason we like arrays is that they can save us a lot of trouble of trying to do something silly like.
Dim Shared As Integer Box1,Box2,Box3,Box4,Box5 etc
Box1 = 10
Box2 = 40
etc
and it also happens that arrays are really flexible when it comes to storing information and reading that info, like so
For X = 0 To 10
Box(x) = 10
Next
now with that simple for loop you have just filled all your boxes with the value of 10! much nicer than writing it all out long hand.
try it out in practise once you get the fundimentals of this we will move on.
-
oh i get it, it's like the text message ;D
Dim Shared As String Message(55)
Message(1) = "text"
Message(2) = "text"
and so on
-
exactly!
and this tells freebasic we want it to add 640*480 boxes onto a variable called buffer like so DIM SHARED AS INTEGER BUFFER ( XRES * YRES ):' The Screen Array. Xres = 640 , Yres = 480
So now we have a buffer the same size as the screen which we can use as a backbuffer for page flipping.
the only thing about using a 1d array for the screen is there is no definition between X and Y.because a 1d array is layed out in memory like so.
Y = 0 Y = 1 Y = 2
| first 640 Boxes | Second 640 Boxes | Third 640 boxes | etc
instead of
| first 640 Boxes | Y = 0
| Second 640 Boxes | Y = 1
| Third 640 boxes | Y = 2
So if you wanted to plot a pixel at X = 0 , Y=2
on a 1d array you would have to put your color here.
Col
| first 640 Boxes | Second 640 Boxes | Third 640 boxes | etc
which would be the 1280th box in buffer. so to put a box at y = 2 x = 0 in a 1d buffer you could do this.
Buffer(1280) = col
or here is a special formula to make life easyer knowing this will be great for reading other peoples ptc code as you will likely see it everywhere.
Y*ScreenWidth+X = 1d array position
meaning that if we want to find out which box to put color into on our buffer if y = 2 and X = 0 then we could simply plug our X ,Y , And screen width into that Formula, So lets try it.
2*640+0 = 1280
Can you see how this formula applies to this.
IF SS(SL) =1 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H444444
IF SS(SL) =2 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &H777777
IF SS(SL) =3 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HAAAAAA
IF SS(SL) =4 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HCCCCCC
can you see whats happening here.
-
i think IF SS(SL) =4 THEN BUFFER (SX(SL) + ( SY(SL) * XRES) ) = &HCCCCCC tells the buffer to put the hex color &HCCCCCC at array 4 and the (SX(SL) + ( SY(SL) * XRES) at what box to put it?
when you say box you mean pixel right?
and the S,SS,SL, what are those?
it's a bit confusing
EDIT: i kept thinking of your previous example and couldn't sleep so i stayed up all night thinking what could i do as an exersise (got me a headache too) lol :P
so i took this code from the "cardtro".
Screenres 640,480,32,2
dim buffer as integer
dim a as string
dim xText as double
xText=632:buffer=1
a="Hey what's up? :) !! this is bikerboy at the k/b what you see before you is my first attempt of a cardtro in freebasic, but i couldn't have done it without the help of some great guys :) first of all i'd like to thank Shockwave for creating and maintaining DBF , DBF is the place to be :) DrewPee - Benny! - hellfire - Hezad - rbz - , without your priceless help in coding this, i'd still be struggling Stormbringer and the rest of the guys at www.retro-remakes.net for all those great intros they're remaking ,keep it up guys ! greets also go to everyone at DBF + GVY i'd like to wish to all of you and your families the best for the holidays :) the song you are listening is called 'MOD/Sidewinder..Xmas Jingles' and the author is Eric Gieseke signing off bikerboy scroller now restarts ... "
a=a+" "
Do
ScreenSync
ScreenSet buffer, buffer xor 1
cls
Draw String(xText,470),a
xText=xText-1
buffer= buffer xor 1
if xText<(-len(a)*8) then xText=632
Loop until xText<((-len(a)*8)-16)
sleep
and made an ASCII scroller :D :D :carrot:
Screenres 640,480,32,2
dim buffer as integer
dim a as string
dim b as string
dim c as string
dim d as string
dim e as string
dim f as string
dim g as string
dim h as string
dim i as string
dim j as string
dim k as string
dim xText as double
xText=632:buffer=1
Color RGB(92,140,222),RGB(0,0,0)
a=" ___ ___ ___ ___ ___ ___ ___ ___ ___ "
b=" /\ \ /\__\ /\__\ /\__\ /\__\ /\ \ /\ \ /\__\ /\ \ "
c=" /::\ \ /:/ _/_ /:/ / ___ ___ /:/ _/_ /:/ / /::\ \ /::\ \ /:/ _/_ /::\ \ "
d=" /:/\:\ \ /:/ /\ \ /:/ / /\__\ /\__\ /:/ /\ \ /:/ / /:/\:\__\ /:/\:\ \ /:/ /\__\ /:/\:\__\ "
e=" /:/ /::\ \ /:/ /::\ \ /:/ / ___ /:/__/ /:/__/ /:/ /::\ \ /:/ / ___ /:/ /:/ / /:/ \:\ \ ___ ___ ___ ___ /:/ /:/ _/_ /:/ /:/ / "
f=" /:/_/:/\:\__\ /:/_/:/\:\__\ /:/__/ /\__\ /::\ \ /::\ \ /:/_/:/\:\__\ /:/__/ /\__\ /:/_/:/__/___ /:/__/ \:\__\ /\ \ /\__\ /\ \ /\__\ /:/_/:/ /\__\ /:/_/:/__/___"
g=" \:\/:/ \/__/ \:\/:/ /:/ / \:\ \ /:/ / \/\:\ \__ \/\:\ \__ \:\/:/ /:/ / \:\ \ /:/ / \:\/:::::/ / \:\ \ /:/ / \:\ \ /:/ / \:\ \ /:/ / \:\/:/ /:/ / \:\/:::::/ /"
h=" \::/__/ \::/ /:/ / \:\ /:/ / ~~\:\/\__\ ~~\:\/\__\ \::/ /:/ / \:\ /:/ / \::/~~/~~~~ \:\ /:/ / \:\ /:/ / \:\ /:/ / \::/_/:/ / \::/~~/~~~~ "
i=" \:\ \ \/_/:/ / \:\/:/ / \::/ / \::/ / \/_/:/ / \:\/:/ / \:\~~\ \:\/:/ / \:\/:/ / \:\/:/ / \:\/:/ / \:\~~\ "
j=" \:\__\ /:/ / \::/ / /:/ / /:/ / /:/ / \::/ / \:\__\ \::/ / \::/ / \::/ / \::/ / \:\__\ "
k=" \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
a=a+" "
b=b+" "
c=c+" "
d=d+" "
e=e+" "
f=f+" "
g=g+" "
h=h+" "
i=i+" "
j=j+" "
k=k+" "
Do
ScreenSync
ScreenSet buffer, buffer xor 1
cls
Draw String(xText,270),a
Draw String(xText,280),b
Draw String(xText,290),c
Draw String(xText,300),d
Draw String(xText,310),e
Draw String(xText,320),f
Draw String(xText,330),g
Draw String(xText,340),h
Draw String(xText,350),i
Draw String(xText,360),j
Draw String(xText,360),k
xText=xText-1
buffer= buffer xor 1
if xText<(-len(a)*8) then xText=632
Loop until xText<((-len(a)*8)-16)
sleep
executable attached :D
Ps. i've never seen an ASCII scroller before, did i just discover the ASCII scroller? lol
-
[This topic may now be posted in again in order to allow Bikerboy's demo to progress. Please keep it on topic! The subject matter appears to be ascii text scrolling.]
-
it's ok there is no demo in progress here, i just came up with the ASCII scroller idea and wanted to share it in case someone is interested :)
-
really nice ascii scroller :) I'm sure it would look awesome if the ASCII letters were sine-scrolling ;D
-
really nice ascii scroller :) I'm sure it would look awesome if the ASCII letters were sine-scrolling ;D
i'm not so sure b/c this particular scroller has 11 lines of text and since there is no font there but just plain text it might look distorted.
but then again it would look nice if it had a bit of a sine movement
-
i'm not so sure b/c this particular scroller has 11 lines of text and since there is no font there but just plain text it might look distorted.
Yeah, and that'd exactly be the awesome thing ^^ Something like that, but in movement :
| __
|_| __ |
| | __ | | __|
| |_ _ | | __ |__
|_ | |__
_ |___
It's totally, astoundingly ugly XD sorry for that, but you get the idea :) It'd look way better with your font :D
just an idea though
-
yeah i guess it will look nice depending on the movement
i tried to add more lines to the sin scroller you gave me but couldn't make it happen
EDIT: tried to do this
Screenres 640,480,32,2
dim buffer as integer
dim a as string
dim b as string
dim c as string
dim d as string
dim e as string
dim f as string
dim g as string
dim h as string
dim m as string
dim j as string
dim k as string
dim xText as double
'' init Letters position (I assume a letter width and Height is 10)
For i as integer = 0 to 60
Xtext(i) = 350+i*15
Xtext(i) = 480
xText=632:buffer=1
Color RGB(92,140,222),RGB(0,0,0)
a=" ___ ___ ___ ___ ___ ___ ___ ___ ___ "
b=" /\ \ /\__\ /\__\ /\__\ /\__\ /\ \ /\ \ /\__\ /\ \ "
c=" /::\ \ /:/ _/_ /:/ / ___ ___ /:/ _/_ /:/ / /::\ \ /::\ \ /:/ _/_ /::\ \ "
d=" /:/\:\ \ /:/ /\ \ /:/ / /\__\ /\__\ /:/ /\ \ /:/ / /:/\:\__\ /:/\:\ \ /:/ /\__\ /:/\:\__\ "
e=" /:/ /::\ \ /:/ /::\ \ /:/ / ___ /:/__/ /:/__/ /:/ /::\ \ /:/ / ___ /:/ /:/ / /:/ \:\ \ ___ ___ ___ ___ /:/ /:/ _/_ /:/ /:/ / "
f=" /:/_/:/\:\__\ /:/_/:/\:\__\ /:/__/ /\__\ /::\ \ /::\ \ /:/_/:/\:\__\ /:/__/ /\__\ /:/_/:/__/___ /:/__/ \:\__\ /\ \ /\__\ /\ \ /\__\ /:/_/:/ /\__\ /:/_/:/__/___"
g=" \:\/:/ \/__/ \:\/:/ /:/ / \:\ \ /:/ / \/\:\ \__ \/\:\ \__ \:\/:/ /:/ / \:\ \ /:/ / \:\/:::::/ / \:\ \ /:/ / \:\ \ /:/ / \:\ \ /:/ / \:\/:/ /:/ / \:\/:::::/ /"
h=" \::/__/ \::/ /:/ / \:\ /:/ / ~~\:\/\__\ ~~\:\/\__\ \::/ /:/ / \:\ /:/ / \::/~~/~~~~ \:\ /:/ / \:\ /:/ / \:\ /:/ / \::/_/:/ / \::/~~/~~~~ "
m=" \:\ \ \/_/:/ / \:\/:/ / \::/ / \::/ / \/_/:/ / \:\/:/ / \:\~~\ \:\/:/ / \:\/:/ / \:\/:/ / \:\/:/ / \:\~~\ "
j=" \:\__\ /:/ / \::/ / /:/ / /:/ / /:/ / \::/ / \:\__\ \::/ / \::/ / \::/ / \::/ / \:\__\ "
k=" \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
a=a+" "
b=b+" "
c=c+" "
d=d+" "
e=e+" "
f=f+" "
g=g+" "
h=h+" "
m=m+" "
j=j+" "
k=k+" "
Do
ScreenSync
ScreenSet buffer, buffer xor 1
cls
Draw String(xText,270),a
Draw String(xText,280),b
Draw String(xText,290),c
Draw String(xText,300),d
Draw String(xText,310),e
Draw String(xText,320),f
Draw String(xText,330),g
Draw String(xText,340),h
Draw String(xText,350),i
Draw String(xText,360),j
Draw String(xText,360),k
For m as integer = 0 to 60
Xtext(i) -= 0.4 ' scroll along X axis
Xtext(i) = 165-15*sin(Xtext(i)/10) ' Sine Scroll along Y axis (the distance of letters)
Draw String(Xtext(i), Xtext(i)),Xtext(i),rgb(98,39,252)
if Xtext(i)<0 then Xtext(i) = 640 '' if a letter is too far on the right, make it start again on the left
Next
Screenunlock : sleep 10
cls
Loop until multikey(&h01)
and got this errors
Compiler output:
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(25) error 67: Array not dimensioned, before '('
Xtext(i) = 350+i*15
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(26) error 67: Array not dimensioned, before '('
Xtext(i) = 480
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(67) error 55: Type mismatch, at parameter 5
Draw String(xText,350),i
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(73) error 67: Array not dimensioned, before '('
Xtext(i) -= 0.4 ' scroll along X axis
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(75) error 67: Array not dimensioned, before '('
Xtext(i) = 165-15*sin(Xtext(i)/10) ' Sine Scroll along Y axis (the distance of letters)
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(77) error 67: Array not dimensioned, before '('
Draw String(Xtext(i), Xtext(i)),Xtext(i),rgb(98,39,252)
^
C:/Program Files/FreeBASIC/FreeBasic/FBIDETEMP.bas(80) error 67: Array not dimensioned, before '('
if Xtext(i)<0 then Xtext(i) = 640 '' if a letter is too far on the right, make it start again on the left
-
First, never unlock the screen without having it locked !
You may have suppressed the -screenlock- I added and forgot to suppress ther screenunlock.
This said, Screenlock/screenunlock is, imho, way better (and user friendly) than screensetting.
e.g. :
replace
ScreenSet buffer, buffer xor 1with
Screenlock
Screenunlock is already here since I added it and you forgot to suppress it. So let it :)
Secondly, for the "array" errors, take a look at this :
dim xText as double
and then, this :
Xtext(i)
Don't you see something wrong ? xText is not declared as an array but it's used as an array !
Plus, you use a variable called "i" to loop through the array, but the variable is called "m" when you start the second for loop :
Plus, you didn't closed the first for-loop (for ... Next)
...
For [b]m[/b] as integer = 0 to 60
Xtext([b]i[/b]) -= 0.4 ' scroll along X axis
...
Plus ....
There are really a lot of errors here, and to be honest, making those errors shows that you have a lack of basis knowledge about variables (you declare some variables as string and use it as integers [eg : "i"]), Array handling (already mentioned) and some other things.
That's not bad, you should just try to follow some basic tutorials :)
First, I'd start again from the working code (the first version) and try to think about the way I could handle the Sine stuff. First impression : The way you coded the ASCII text in the a,b,c,d... variables is an idea, but it'll be difficult to handle the Sine (You'll have to do some strings operations plus finding some offsets to make it work. Nothing impossible, but far from the easier).
Sorry, i'm in a hurry, i'll finish to speak about it later :)
-
That's not bad, you should just try to follow some basic tutorials :)
that is my main problem
where are those tutorials?
i mean even in the help file of FBIde there are either incomplete answers or examples for advanced users.
there should be a manual or something covering the basics, what commands FB has and what do they do, and variables and such.
everytime i see a code or try like the ASCIIsinscroller i go in blindly or guessing and hope it will work.
-
that is my main problem
where are those tutorials?
....
You can start reading this tutorial by Richard D. Clark / rdc, it got everything you need:
http://virtualink.wikidot.com/fbtut:fbasic
-
thanx rbz :)
i allready know that site, also posted it here http://www.dbfinteractive.com/forum/index.php/topic,3783.0.html
also read it but didn't understand much things ...... i'll read it again
-
Heh. Thanks for the link. It might be a good idea to do a basic 1-2-3 tutorial series there to help beginners get up and running. I'll think about it and see what I can come up with.
-
http://www.freebasic.net/forum/viewtopic.php?t=10830 (http://www.freebasic.net/forum/viewtopic.php?t=10830)
there should be some starting points here :)
By rereading myself, I found I used a pretty hard language, sorry for that :) You got the point though, that's the main thing :)
look there too :
http://www.petesqbsite.com/sections/tutorials/tutorials.shtml (http://www.petesqbsite.com/sections/tutorials/tutorials.shtml)
a huuuuuge number of tutorials for QBasic (look at the beginner section, the examples are for QBasic but they should halp you to get some stuff :) )
-
By rereading myself, I found I used a pretty hard language, sorry for that :) You got the point though, that's the main thing :)
no worries ;)
thanx for the links man :)
oh and to stick to the topic, if anyone can manage to do an ASCII sine scroller it would be nice to see the result :D