TileBackground?

Monkey Forums/Monkey Programming/TileBackground?

zoqfotpik(Posted 2012) [#1]
Does Monkey have a way to tile a background the way Blitzmax did, with smooth motion? Am I right in remembering that Blitzmax could rotate the background and have it tile?

Obviously we can do this ourselves. If functionality is not available perhaps we should write something.


AdamRedwoods(Posted 2012) [#2]
I think this may have been an opengl assisted trick, using the texture to repeat an image. very quick.

i don't know if this is possible on html5, and the way mojo currently works it's not rotating the texture but the quad. If you could get mojo to scale smaller than the quad and repeat, then it could work in opengl targets.

So in short, no, mojo can't be easily extended to incorporate this trick, you'd have to edit mojo directly to make this work.

EDIT: A DrawTexturedPoly() function would work, but don't think Mark has implemented it. Right now it's a hack.
http://www.monkeycoder.co.nz/Community/posts.php?topic=1742#16409


Jesse(Posted 2012) [#3]
the Blitzmax "TileImage" function is a simple routine that draws tiles to the screen. you can actually look at the source and see how it was done. nothing really special.


Neuro(Posted 2012) [#4]
Does Monkey have a way to tile a background the way Blitzmax did, with smooth motion?

There is a way to Tile an image, i believe in the /bananas/Richard Benson folder has an example of how to do it.


slenkar(Posted 2012) [#5]
if you want to rotate the background from the middle of the screen you draw the background like this:

Translate to middle of screen
rotate by the angle you want the background to be rotated by
translate to each tile position and draw them


zoqfotpik(Posted 2012) [#6]
Looks like I have fill rate to burn.

I can do without rotation. Since I'm going to be filling the screen with bitmaps, is there any way to speed this? Should I have the bitmaps be sized as a power of 2?


zoqfotpik(Posted 2012) [#7]
Here's a class for tiled, rotating backgrounds.

xoffset and yoffset will be used for panning across the background but this is not currently implemented. WIDTH and HEIGHT are the height and width of the device.

Maybe this will help someone.

Class Tbackground
	Field myimage:Image
	Field r:Int, g:Int, b:Int
	Field xoffset:Int,yoffset:Int
	Field mywidth:Int
	Field myheight:int
	
	Method load(imagename:String)
		myimage = LoadImage(imagename)
		mywidth=myimage.Width()
		myheight=myimage.Height()
		
	End Method
	
	Method draw()
		PushMatrix
		Translate WIDTH/2,HEIGHT/2
		Rotate ticks/10.0
		SetColor 128,128,128
		Local x:Int=0
		Local y:Int=0
		
		x = (WIDTH)*-1
		While x < WIDTH
			y = (HEIGHT)*-1
			While y < HEIGHT
				DrawImage myimage, x, y
				y = y + myheight
			Wend
			x = x + mywidth
		Wend
		PopMatrix

	End Method
End class