Image Wrapping

BlitzMax Forums/BlitzMax Programming/Image Wrapping

RetroRusty(Posted 2005) [#1]
If I've got an image that I want to scroll constantly from left to right, how do I wrap it so it looks like, one long image?

Thanks


Scott Shaver(Posted 2005) [#2]
try this with an image that is wider than the screen
Strict 

Framework BRL.GlMax2D

Import BRL.System
Import BRL.Basic
Import BRL.pngloader
Import BRL.Retro

?Win32
SetGraphicsDriver(GLMax2DDriver())
?

Graphics 640,480

Global x:Int=0

Global image:TImage = LoadImage("test.png")


While KeyDown(KEY_ESCAPE)=False
        cls
	DrawImage image,x,0
	x:-3
	If x<0 Then DrawImage image,(x+ImageWidth(image)),0
	If x<=-ImageWidth(image) Then x=0
	DebugLog x
	Flip
	flushmem
Wend



JazzieB(Posted 2005) [#3]
TileImage with the x and y parameters would avoid having to do two DrawImage's.


RetroRusty(Posted 2005) [#4]
Thanks Scott :)


Scott Shaver(Posted 2005) [#5]
JazzieB - That is a good idea but TileImage fills the entire current viewport. So I guess you would need to set the viewport before each TileImage call.


JazzieB(Posted 2005) [#6]
Yes you would need to set a viewport if you don't want the entire screen drawn to, but wouldn't you be using one anyway if that were the case - in order to ensure that sprites and other graphics are clipped to the active game play area? Depends on the game though, I suppose.