PDA

View Full Version : Help on new lua game



fatcat04912
August 16th, 2007, 19:35
Hello im in need of allot of help for my first lua game. Im trying to encode collision so a ball could jump into platforms . and i have tried about 30 different ways and i still cant figure it out :( What im trying to do is create blocks so the ball can jump on one to another to another,ect but everytime i try something goes wrong


Here is the code for the in gamegreen=Color.new(0,255,0)
white = Color.new(255,255,255) player1 =Image.load("smiley.png")

ground=Image.load("background.png")
ground:clear(black) player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "ground"while true do
pad = Controls.read()
screen:clear()


if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end
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 < 230 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "ground"
end

if player.gravity > 230 then
player.gravity = 230 end player.y = player.gravity
screen:blit(player.x,player.y,player1)
screen:blit(0,262,ground)
screen:print(20,15, "How did you get a beta!",color[1])
if pad:start() then break
end
if pad:select() then screen:save("screenshot.png")
end
screen.waitVblankStart()
screen.flip()
end




Here is the code for the menu
System.usbDiskModeActivate()
-- Start Screen
background=Image.load( "background.png" )
while true do
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
screen.waitVblankStart()
screen.flip()
pad = Controls.read()
if pad:start() then
break
end
end
-- menu
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
screen.waitVblankStart(4)
end
if pad:down() then
menustatus = menustatus + 1
screen.waitVblankStart(4)
end
color={white, white, white}
color[menustatus]=red
screen:print(50, 50, "Play", color[1])
screen:print(50,60, "Credits", color[2])
screen:print(50,70, "Option", color[3])
if menustatus == 1 then
if pad:cross() then
dofile("game.lua")
end
end
if menustatus == 2 then
if pad:cross() then
dofile("Credit.lua")
end
end
if menustatus == 3 then
if pad:cross() then
end
if menustatus <= 0 then
menustatus = 3
end
end
if menustatus >= 4 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
Controls.read()
end

and here is my code for my Creditsblack = Color.new(0,0,0)
background=Image.load( "credits.png" )

function delay(seconds)
time=seconds*60
for i=1, time do
screen.waitVblankStart()

end
end
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
screen.flip()
delay(5)

And here are the graphics you are going to need http://www.sendspace.com/file/15cvu3


Please help me if you do you will get allot of credit given to you :)

Nicko01
August 18th, 2007, 14:05
ehh... that code is not very clean... It isn't going to do anything with what you're doing.