aphonia
March 13th, 2006, 22:06
I'm having a lot of trouble getting my game to save. I read a tutorial about it, but couldn't get any results.
Could anyone tell me what code to add to save my state to the file save.txt when I press pad:r()?
Here's a little sample code to work with:
--COLOR
white = Color.new(255,255,255)
--IMAGE
Player = Image.createEmpty(12,12)
Player:clear(white)
--PLAYER ARRAY
player = {}
player = {48,80,130}
player.x=player[1]
player.y=player[2]
--PAD
oldpad=Controls.read()
--MAIN LOOP
while true do
pad = Controls.read()
screen:clear()
screen:blit(player.x,player.y,Player)
--PLAYER MOVEMENT
if pad:left() then
player.x = player.x - 2
end
if pad:up() then
player.y = player.y - 2
end
if pad:right() then
player.x = player.x + 2
end
if pad:down() then
player.y = player.y + 2
end
screen.waitVblankStart()
screen.flip()
oldpad=pad
end
Could anyone tell me what code to add to save my state to the file save.txt when I press pad:r()?
Here's a little sample code to work with:
--COLOR
white = Color.new(255,255,255)
--IMAGE
Player = Image.createEmpty(12,12)
Player:clear(white)
--PLAYER ARRAY
player = {}
player = {48,80,130}
player.x=player[1]
player.y=player[2]
--PAD
oldpad=Controls.read()
--MAIN LOOP
while true do
pad = Controls.read()
screen:clear()
screen:blit(player.x,player.y,Player)
--PLAYER MOVEMENT
if pad:left() then
player.x = player.x - 2
end
if pad:up() then
player.y = player.y - 2
end
if pad:right() then
player.x = player.x + 2
end
if pad:down() then
player.y = player.y + 2
end
screen.waitVblankStart()
screen.flip()
oldpad=pad
end