The Player

Draw a sprite for the player.

Click on the + in the code editor to creat tab 2. This will be used for the code related to the player.

 
-- player code
function make_player()
p={}
p.x=3
p.y=2
p.sprite=1
p.keys=0
end
function draw_player()
spr(p.sprite,p.x*8,p.y*8)
end
 

Call these functions from the game loop tab (tab 0).

 
--game loop
function _init()
map_setup()
make_player()
end
function _update()
end
function _draw()
cls()
draw_map()
draw_player()
end
 

End Result

Save your changes with ctrl+s. Run them with ctrl+r. You should see your player displayed on the map. The player cannot move around yet. We'll add some movement to the player in the next section.

Download