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 anthonyjee, our newest member.

Who's Online:

Total Members: 522
Total Posts: 13085
Total Topics: 1515
Total Categories: 7
Total Boards: 42

Recent Posts:

Re: Hello every body... by DeniseVera
Need help please by Robbynator
Re: Hello every body... by horvathann
Re: background criminal record check by backgroundchecker
background criminal record check by backgroundchecker
Intro to Perl Part 2: What are Scalars? & Examples by Chi Kitory
Intro to Perl Part 1 About Perl and Hello World by Chi Kitory
Re: Trying To Get Rid of the Spammers by Charlie


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