PDA

View Full Version : Lua help



jason215
August 31st, 2006, 14:33
im verry sorry but i cant figuere out what i am doing wrong so if someone can look at my code and suggest what im doing wrong

i appriciate it :) :confused: :confused:

Error : index.lua :151: 'end' expected (to close 'function' at line 78) near '<eo (strange keys)


-- Load pictures

background = Image.load("back.jpg")
player1 = Image.load("Naruto.png")
shadow1 = Image.load("shadow.png")
ground = Image.load("ground.jpg")

bullet = Image.CreateEmpty(4,4)
bullet:clear(green)
---------------------------------------------------
-- colors

black = Color.new(0,0,0)
green = Color.new(0,255,0)
---------------------------------------------------
-- player array's

player = {}
player.gravity = 200
player.x = 50
player.y = 270
player.jumpspeed = 10
player.jumpstate = "ground"

shadow = {}
shadow.x = 30
shadow.y = 270

BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player.x + 32,
y = player.y + 16 }
end
---------------------------------------------------
-- functions

function bulletSetup()

--Increase the current bullet by one, or reset it to 1

if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end

if direction == "left" then
BulletInfo[currentBullet].x = player.x
BulletInfo[currentBullet].y = player.y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = player.x + 32
BulletInfo[currentBullet].y = player.y + 16
end

BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end

function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end
if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then
BulletInfo[i].firing = false
end
end
end
----------------------------------------------------

-- controls

function movePlayer()
pad = Controls.read()
if pad:left() then
Player[1].x = player.x - 4
direction = "right"
end
if pad:right() then
Player[1].x = player.x + 4
direction = "right"
end

----------------------------------------------------
-- shadow replication technique

if pad:circle() and pad:r() then
screen:blit(shadow.x,shadow.y,shadow1)
screen:print(25,15, "Shadow Replication")
end
----------------------------------------------------
--jumping script

if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"
end

if player.jumpstate == "jumping"
then player.jumpspeed = player.jumpspeed - 0,5
player.gravity = player.gravity - player.jumpspeed

end

if player.gravity < 0 then player.jumpstate = "falling"

end

if player.gravity < 200 and player.jumpstate == "falling"
then player.gravity = player.gravity + (player.jumpspeed + 3)

end

if player.gravity == 200 then
player.jumpspeed = 5
player.jumpstate = "ground"

end

if player.gravity > 200 then player.gravity = 200

end

player.y = player.gravity
shadow.y = player.gravity
-----------------------------------------------------
-- printing to screen

--Main Loop

while true do
pad = Controls.read()
screen:clear()

screen:blit(player.x, player.y, player1)

if pad:triangle() and oldpad:triangle() ~= pad:triangle() then
bulletSetup()
end

movePlayer()

bulletFire()

screen:blit(0,250,ground)
screen.waitVblankStart()
screen.flip()
oldpad = pad
end