tililng single background image

Monkey Forums/Monkey Beginners/tililng single background image

dubbsta(Posted 2016) [#1]
hey guys cant figure out how to tile a 1 image background. should i draw 2 of the same and put after the other or is there a better way. im sure single image bg's are probably not the best but just for practice. thanks


Pakz(Posted 2016) [#2]
Below is some code that draws rectangles on the screen so it fits the screen.

Replace the drawrect with your drawimage and load an image.

the step is the width and height of the image. DeviceWidth is the width of the monkey screen. For is a loop.

Import mojo

Class MyGame Extends App

    Method OnCreate()
        SetUpdateRate(60)
    End Method
    Method OnUpdate()        
    End Method
    Method OnRender()
        Cls 0,0,0 
        SetColor 255,255,255
        For Local y:=0 to DeviceHeight Step 64
        For Local x:=0 to DeviceWidth Step 64
			DrawRect x,y,32,32
        Next
        Next
    End Method
End Class


Function Main()
    New MyGame()
End Function



dubbsta(Posted 2016) [#3]
thanks pakz but i have an image that is full screen already so wondering the best method to repeat one image over!


MikeHart(Posted 2016) [#4]
Draw it next to the other one again?


dubbsta(Posted 2016) [#5]
lol thats what i was thinking so just 2 drawimages.. ok wasnt sure what was the best method


MikeHart(Posted 2016) [#6]
Mojo has no tiling feature, at least I don't know of any. So the only solution imho is to draw it as many times you need to.