Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import mojo ' Graphics etc
- Function Main()
- ' Create an instance of the Game class
- New Game
- End
- Class Game Extends App
- ' Globals
- Field tiles:Image[5]
- Field isomap:=[New Tile[5], New Tile[5], New Tile[5], New Tile[5], New Tile[5]]
- Global tilemap:Int[][] = [
- [1, 2, 1, 1, 1],
- [1, 2, 1, 1, 1],
- [1, 2, 1, 1, 1],
- [3, 4, 3, 3, 3],
- [1, 2, 1, 1, 1] ]
- Field playerX:Float = 1
- Field playerY:Float = 3
- Field zoom:Float = .5
- ' Called when an instance of the class is created
- Method OnCreate()
- SetUpdateRate 30
- tiles[1] = LoadImage("tile-grass.png")
- tiles[2] = LoadImage("tile-path-v.png")
- tiles[3] = LoadImage("tile-path-h.png")
- tiles[4] = LoadImage("tile-path-hv.png")
- tiles[1].SetHandle(64, 64)
- tiles[2].SetHandle(64, 64)
- tiles[3].SetHandle(64, 64)
- tiles[4].SetHandle(64, 64)
- End
- ' Called via an infinite loop behind the scenes
- Method OnUpdate()
- If KeyDown(KEY_UP) And zoom < 1 Then zoom += .025
- If KeyDown(KEY_DOWN) And zoom > .25 Then zoom -= .025
- For Local x = 0 To 4
- For Local y = 0 To 4
- isomap[x][y] = New Tile
- isomap[x][y].x = (x + playerX) * (128 * zoom) - (y + playerY) * (128 * zoom)
- isomap[x][y].y = ((x - playerX) * (128 * zoom) + (y - playerY) * (128 * zoom)) / 2
- Next
- Next
- End
- ' Called via an infinite loop behind the scenes after everything else
- Method OnRender()
- ' Clear the screen
- Cls 0, 0, 0
- ' Then redraw
- For Local x = 0 To 4
- For Local y = 0 To 4
- DrawImage tiles[tilemap[x][y]], isomap[x][y].x + DeviceWidth() / 2, isomap[x][y].y + DeviceHeight() / 2, 0, (2 * zoom), (1 * zoom)
- Next
- Next
- DrawPoint DeviceWidth() / 2, DeviceHeight() / 2
- End
- End
- Class Tile
- Field x:Float
- Field y:Float
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement