Posts: 442
Threads: 107
Joined: Feb 2005
i was messing around..and i came up w/ this little example
Code: 'center is 160 x 100 in scr 13
screen 13
'set up corners
type c1
x as integer
y as integer
end type
type c2
x as integer
y as integer
end type
type c3
x as integer
y as integer
end type
type c4
x as integer
y as integer
end type
'start main loop
do
cls
'mouse controll
getmouse (x,y)
c1.x = x - 50
c1.y = y - 50
c3.x = x - 50
c3.y = y + 50
c2.x = x + 50
c2.y = y + 50
c4.x = x + 50
c4.y = y - 50
'lines used to draw box
line (c1.x,c1.y)-(c3.x,c3.y),4
line (c2.x,c2.y)-(c4.x,c4.y),4
line (c1.x,c1.y)-(c4.x, c4.y),4
line (c3.x,c3.y)-(c2.x, c2.y),4
'if sleep is not used, cls makes screen really flashy
sleep 1
loop
well there it is, not much really, but its fun to see it work
url=http://www.random-seed.net] [/url]
Posts: 242
Threads: 29
Joined: Dec 2004
Try these little tweaks to make things smoother:
Code: 'center is 160 x 100 in scr 13
' make a double buffer (2 graphics pages)
screen 13, , 2
'set up corners
type c1
x as integer
y as integer
end type
type c2
x as integer
y as integer
end type
type c3
x as integer
y as integer
end type
type c4
x as integer
y as integer
end type
' set workpage and viewpage
' this way all drawing is done "offscreen"
screenset 0, 1
'start main loop
do
'mouse controll
getmouse (x,y)
c1.x = x - 50
c1.y = y - 50
c3.x = x - 50
c3.y = y + 50
c2.x = x + 50
c2.y = y + 50
c4.x = x + 50
c4.y = y - 50
' clear the screen
' this way you can use any BG color 15=white
line (0,0)-(319,199),15,BF
'lines used to draw box
line (c1.x,c1.y)-(c3.x,c3.y),4
line (c2.x,c2.y)-(c4.x,c4.y),4
line (c1.x,c1.y)-(c4.x, c4.y),4
line (c3.x,c3.y)-(c2.x, c2.y),4
' copy the work area to the view area
' no "flicker"
screencopy
' allow user a graceful way to leave the program
loop until inkey$ = chr$(255)+"X"
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Posts: 442
Threads: 107
Joined: Feb 2005
nice, really nice.. in the buffer part tho, what is the blank space for.. screen 13,(blank space) ,2
url=http://www.random-seed.net] [/url]
Posts: 242
Threads: 29
Joined: Dec 2004
[syntax="gfxlib docs"]+--------+---------------------
| SCREEN |
+--------+
Statement to set current gfx mode.
Syntax:
SCREEN mode[,[depth][,[num_pages][,flags]]]
Argument: Description:
mode Gfx mode number, see below.
depth Color depth in bits per pixel.
If you omit this argument, the
default depth for given mode is set.
num_pages Number of pages, see below.
Default if omitted is 1.
flags Mode options, see below.
Default if omitted is 0.
[/syntax]
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Posts: 442
Threads: 107
Joined: Feb 2005
ah i see.. heh, so i could use 4 bit color.. yay! j/k
url=http://www.random-seed.net] [/url]
Posts: 122
Threads: 6
Joined: Feb 2002
Heh, there are a couble of mistakes in that program, here's the fixed version (with what I changed in capitals):
[syntax="freebasic"]
OPTION EXPLICIT
'center is 160 x 100 in scr 13
screen 13
'set up corners
TYPE Cc
x as integer
y as integer
END TYPE
DIM c1 AS Cc, c2 AS Cc, c3 AS Cc, c4 AS Cc ' four variables of the same type
DIM x AS INTEGER, y AS INTEGER ' not related to Cc, but you use these with GetMouse
'start main loop
do
cls
'mouse controll
getmouse (x,y)
c1.x = x - 50
c1.y = y - 50
c3.x = x - 50
c3.y = y + 50
c2.x = x + 50
c2.y = y + 50
c4.x = x + 50
c4.y = y - 50
'lines used to draw box
line (c1.x,c1.y)-(c3.x,c3.y),4
line (c2.x,c2.y)-(c4.x,c4.y),4
line (c1.x,c1.y)-(c4.x, c4.y),4
line (c3.x,c3.y)-(c2.x, c2.y),4
'if sleep is not used, cls makes screen really flashy
sleep 1
loop
[/syntax]
Posts: 1,439
Threads: 15
Joined: Apr 2003
Quote:ah i see.. heh, so i could use 4 bit color.. yay! j/k
No; if you ask for 4-bit color, you'll get 8-bit color.
Posts: 442
Threads: 107
Joined: Feb 2005
oh
url=http://www.random-seed.net] [/url]
|