Post by OddChild on May 9, 2006 18:42:10 GMT -5
I have been continuing work on a game... I have ran into a problem...
While the background scrolls (right to left), a small line 1 pixel in width appears between where it ends and begins.
I basicly just backword programed the example, and changed directions...
I cannot figure out why it has that 1 pixel of blue space...
Any ideas?
While the background scrolls (right to left), a small line 1 pixel in width appears between where it ends and begins.
I basicly just backword programed the example, and changed directions...
I cannot figure out why it has that 1 pixel of blue space...
option explicit
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Declare our variables
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dim bRunning, tcar, x, y
dim xtcar, ytcar
bRunning = True
dim background ' variable for our animated image
'dim x, y ' variable for our curent position
x = 0
Dim imagewidth, imageheight, speed
imagewidth = 800 ' this is the width of our background image
imageheight = 600 ' this is the height of our background image
speed = 0.25 ' this is the speed we tell the background to scroll
'tcar = graphics.loadimage ("car.bmp")
xtcar = 300
ytcar = 300
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Our main routine
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub main()
if (graphics.initialize <> True) then exit sub
graphics.setTitle "Demo - Scroll - press [ESC] to exit"
key.initialize ' initialze the keyboard routines so we can ESC the program
background = graphics.loadimage("bg2.bmp", &HFFFF0000)' load the image with red being transparent
imagewidth = graphics.getwidth(background)
tcar = graphics.loadimage ("car.bmp")
graphics.setscalex tcar, 2
graphics.setscaley tcar, 2
do while bRunning = True
graphics.setimage tcar
if key.pressed(1) or key.pressed(0) = True then bRunning = False
if key.pressed(200) = True then ytcar = ytcar - .25 : graphics.sety tcar, ytcar : if ytcar < 260 then ytcar = 260
' move Up
if key.pressed(208) = True then ytcar = ytcar + .25 : graphics.sety tcar, ytcar : if ytcar > 450 then ytcar = 450 ' Down
if key.pressed(203) = True then xtcar = xtcar - .25 : graphics.setx tcar, xtcar : if xtcar < 0 then xtcar = 0 ' Left
if key.pressed(205) = True then xtcar = xtcar + .25 : graphics.setx tcar, xtcar : if xtcar > 610 then xtcar = 610 ' Right
if key.pressed(1) or key.pressed(0) = True then bRunning = False
graphics.setxy tcar, xtcar, ytcar
graphics.clear 255 ' clear the screen
ScrollBackground ' call the scroll sub routine
graphics.setimage tcar
graphics.display ' display our image
loop
key.terminate
graphics.terminate
end sub
Call Main ' start the program
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This is our routine to scroll a background image
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub ScrollBackground()
x = x - speed '
if x < 1 then x = imagewidth - 10' if at the end start over
graphics.SetX background, x ' set the image position
graphics.setimage background ' set the image in thebuffer
graphics.SetX background, x - imagewidth ' set the image position
graphics.setimage background ' set the image in thebuffer
End sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Declare our variables
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dim bRunning, tcar, x, y
dim xtcar, ytcar
bRunning = True
dim background ' variable for our animated image
'dim x, y ' variable for our curent position
x = 0
Dim imagewidth, imageheight, speed
imagewidth = 800 ' this is the width of our background image
imageheight = 600 ' this is the height of our background image
speed = 0.25 ' this is the speed we tell the background to scroll
'tcar = graphics.loadimage ("car.bmp")
xtcar = 300
ytcar = 300
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Our main routine
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub main()
if (graphics.initialize <> True) then exit sub
graphics.setTitle "Demo - Scroll - press [ESC] to exit"
key.initialize ' initialze the keyboard routines so we can ESC the program
background = graphics.loadimage("bg2.bmp", &HFFFF0000)' load the image with red being transparent
imagewidth = graphics.getwidth(background)
tcar = graphics.loadimage ("car.bmp")
graphics.setscalex tcar, 2
graphics.setscaley tcar, 2
do while bRunning = True
graphics.setimage tcar
if key.pressed(1) or key.pressed(0) = True then bRunning = False
if key.pressed(200) = True then ytcar = ytcar - .25 : graphics.sety tcar, ytcar : if ytcar < 260 then ytcar = 260
' move Up
if key.pressed(208) = True then ytcar = ytcar + .25 : graphics.sety tcar, ytcar : if ytcar > 450 then ytcar = 450 ' Down
if key.pressed(203) = True then xtcar = xtcar - .25 : graphics.setx tcar, xtcar : if xtcar < 0 then xtcar = 0 ' Left
if key.pressed(205) = True then xtcar = xtcar + .25 : graphics.setx tcar, xtcar : if xtcar > 610 then xtcar = 610 ' Right
if key.pressed(1) or key.pressed(0) = True then bRunning = False
graphics.setxy tcar, xtcar, ytcar
graphics.clear 255 ' clear the screen
ScrollBackground ' call the scroll sub routine
graphics.setimage tcar
graphics.display ' display our image
loop
key.terminate
graphics.terminate
end sub
Call Main ' start the program
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This is our routine to scroll a background image
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub ScrollBackground()
x = x - speed '
if x < 1 then x = imagewidth - 10' if at the end start over
graphics.SetX background, x ' set the image position
graphics.setimage background ' set the image in thebuffer
graphics.SetX background, x - imagewidth ' set the image position
graphics.setimage background ' set the image in thebuffer
End sub
Any ideas?