OK guys, thanks for claifying things.
I was doing a little bit of experimentation earlier and the following would not compile until I declared my types as global, maybe I'm mistaken but it seems they don't have global scope unless declared explicitly as such. A type is basically a blueprint from which to construct your entities.
// Project: DrawBox Experiment
// Created: 2015-02-10
// set window properties
SetWindowTitle( "DrawBox Experiment" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
global ScreenSize as tScreenBounds
global Gradient as tGradient
StoreScreenSize()
SetColourGradient()
do
DrawBox(ScreenSize.X1,ScreenSize.Y1,ScreenSize.X2,ScreenSize.Y2,Gradient.Top,Gradient.Top,Gradient.Bottom,Gradient.Bottom,1)
//Display some useful info to the user.
Print("Gradient.Top = " + Str(Gradient.Top))
Print("Red = " + Str(GetColorRed(Gradient.Top)))
Print("Green = " + Str(GetColorGreen(Gradient.Top)))
Print("Blue = " + Str(GetColorBlue(Gradient.Top)))
Print("")
Print("Gradient.Bottom = " + Str(Gradient.Bottom))
Print("Red = " + Str(GetColorRed(Gradient.Bottom)))
Print("Green = " + Str(GetColorGreen(Gradient.Bottom)))
Print("Blue = " + Str(GetColorBlue(Gradient.Bottom)))
//Press the up arrow key to change the gradient.
if(GetRawKeyPressed(38)) = 1 then SetColourGradient()
Sync()
loop
type tScreenBounds
X1 as float
Y1 as float
X2 as float
Y2 as float
endtype
type tGradient
Top as integer
Bottom as integer
endtype
function StoreScreenSize()
ScreenSize.X1 = GetScreenBoundsTop()
ScreenSize.Y1 = GetScreenBoundsLeft()
ScreenSize.X2 = GetScreenBoundsRight()
ScreenSize.Y2 = GetScreenBoundsBottom()
endfunction
function SetColourGradient()
Gradient.Top = MakeColor(Random(0,255),Random(0,255),Random(0,255))
Gradient.Bottom = MakeColor(Random(0,255),Random(0,255),Random(0,255))
endfunction
What is the relationship, if any, of the string returned from
Str(Gradient.Top)) and
Str(GetColorRed(Gradient.Top)),etc...? It doesn't seem to reflect the values of the red, green, and blue components of the colour?
Thanks.
[ Coding In BASIC using AppGameKit V2 ]