Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: DrewPee on September 16, 2006
-
Hello again guys.
Cos i understand how the tinyptc library works now ive just knocked this together . . .
Point me in the right direction please if im doing it wrong - Im very happy with it though!
See what you think?
DrewPee
-
Well cant fault that really. They are indeed coppers, or at least as close as you can get to them on the pc......
I've seen your last few posts on here and i'd like to say you seem to be coming on very well indeed, everything you have posted has been a progression from your last effort, keep going like that and you'll soon be on the way to a full blown demo.....
-
Keep it coming dude, they are indeed copper bar look alikes, add a few more in a sine pattern and a scroll and you have an intro :)
-
Heres something I wrote a bit back to generate colors for copper bars.....
change the copper_height variable to determine how wide your bars should be (dont go above 254)
change the r_end, g_end, b_end values to determine the overall copper color
Hope its of some use....
'copper color generator - MrP.........
screenres 640, 480, 32, 2, 1, 75
screenset 0, 1
setmouse 0, 0, 0
dim copper_height = 30
dim copper_array(copper_height, 3) as ubyte
r_start = 0 'start rgb values for copper (top and bottom color of bar)
g_start = 0
b_start = 0
r_end = 255 'highest rgb values for copper (middle of bar)
g_end = 0
b_end = 0
r_inc = (r_end - r_start) / (copper_height / 2) 'calculate how much we need to increment each color to get a smooth bar
g_inc = (g_end - g_start) / (copper_height / 2)
b_inc = (b_end - b_start) / (copper_height / 2)
r_value = r_start 'setup the rgb values for storing into array
g_value = g_start
b_value = b_start
copper_line = 0 'start line of copper in our array
while copper_line < copper_height - 1
copper_array(copper_line, 1) = r_value 'store red component in array
copper_array(copper_line, 2) = g_value 'store green component in array
copper_array(copper_line, 3) = b_value 'store blue compnent in array
if copper_line = (copper_height / 2) - 1 then 'check to see if were in the middle of the bar
r_inc = -r_inc 'if we are make the color increments negative so we fade back out
g_inc = -g_inc
b_inc = -b_inc
end if
r_value += r_inc 'add the color increment to rgb colors
g_value += g_inc
b_value += b_inc
if r_value > 255 then r_value = 255 'make sure none of them go above 255
if g_value > 255 then g_value = 255
if b_value > 255 then b_value = 255
copper_line += 1 'increment our line in the array
wend
while inkey$ = ""
for copper_y = 0 to copper_height - 1
for copper_x = 0 to 639
pset(copper_x, copper_y), rgb(copper_array(copper_y, 1), copper_array(copper_y, 2), copper_array(copper_y, 3))
next copper_x
next copper_y
screensync
flip
wend
end
-
Works fine as long as you don't use an odd number for the bar height :)
-
Here's a fix. Seems to work but I hope I didn't break anything when I was fixing it, I've had a few tonight!
'copper color generator - MrP.........
screenres 640, 480, 32, 2, 1, 75
screenset 0, 1
setmouse 0, 0, 0
dim copper_height = 53
'dim shared r_inc,g_inc,b_inc as double
dim copper_array(copper_height, 3) as ubyte
r_start = 0 'start rgb values for copper (top and bottom color of bar)
g_start = 0
b_start = 0
r_end = 255 'highest rgb values for copper (middle of bar)
g_end = 100
b_end = 50
r_inc = (r_end - r_start) / (copper_height / 2) 'calculate how much we need to increment each color to get a smooth bar
g_inc = (g_end - g_start) / (copper_height / 2)
b_inc = (b_end - b_start) / (copper_height / 2)
r_value = r_start 'setup the rgb values for storing into array
g_value = g_start
b_value = b_start
copper_line = 0 'start line of copper in our array
while copper_line < copper_height - 1
copper_array(copper_line, 1) = r_value 'store red component in array
copper_array(copper_line, 2) = g_value 'store green component in array
copper_array(copper_line, 3) = b_value 'store blue compnent in array
'if copper_line = (copper_height / 2) then 'check to see if were in the middle of the bar
'r_inc = -r_inc 'if we are make the color increments negative so we fade back out
'g_inc = -g_inc
'b_inc = -b_inc
'end if
if copper_line <= (copper_height / 2) then
r_value + = r_inc 'add the color increment to rgb colors
g_value + = g_inc
b_value + = b_inc
else
r_value - = r_inc 'dec the color increment to rgb colors
g_value - = g_inc
b_value - = b_inc
end if
if r_value > 255 then r_value = 255 'make sure none of them go above 255
if g_value > 255 then g_value = 255
if b_value > 255 then b_value = 255
copper_line += 1 'increment our line in the array
wend
while inkey$ = ""
for copper_y = 0 to copper_height - 1
for copper_x = 0 to 639
pset(copper_x, copper_y), rgb(copper_array(copper_y, 1), copper_array(copper_y, 2), copper_array(copper_y, 3))
next copper_x
next copper_y
screensync
flip
wend
end
-
Thanks for the encouragement guys! Means a lot to a newbie like me . . . and thanks for the code!
DrewPee