Submit Your Own Code

PSP Lua CodeBase : Simple Tile Map

Description:
This code will draw a simple tile map to the screen. This map does not scroll.

 -- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Draw A Simple TileMap
-- BY: Charlie

red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)

-- Create 3 Images to use for tiles
playerImage = Image.createEmpty(32,32)
playerImage:clear(red)

groundImage = Image.createEmpty(32,32)
groundImage:clear(green)

blueImage = Image.createEmpty(32,32)
blueImage:clear(blue)

tileWidth = 32
tileHeight = 32

tileData = { groundImage, playerImage, blueImage } 

worldMap = { }
worldMap[1] = { 3,3,3,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[2] = { 1,1,3,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[3] = { 1,1,3,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[4] = { 1,1,3,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[5] = { 1,1,3,3,3,1,1,1,2,1,1,1,1,1,1 }
worldMap[6] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[7] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }
worldMap[8] = { 1,1,1,1,3,1,1,1,1,1,1,1,1,1,1 }
worldMap[9] = { 1,1,1,1,3,3,3,1,1,1,1,1,1,1,1 }


while true do 
screen:clear()

xPos = -32
yPos = -32

for x = 1,9 do
yPos = yPos + tileHeight
xPos = -32
for y = 1,15 do
xPos = xPos + tileWidth
screen:blit(xPos,yPos, tileData[worldMap[x][y]])
end
end

screen.flip()
screen.waitVblankStart()

end

Back to CodeBase
 

Please welcome daryy, our newest member.

Who's Online: 1 Guest, 0 Users

Total Members: 556
Total Posts: 13060
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua 5.1.4 help. by daryy
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by yaustar
Re: Lua Loader? by Buddy4point0
Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl


Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie