PDA

View Full Version : Need help with Lua Collision and high score



fatcat04912
August 17th, 2007, 19:13
Hello im Making a A simple game Were you bounce a ball .. i have the bounce part set i think. but i Want to Have stars randomly appear And you jump your ball to collect them, And when you Collect then the star dissapers and you you score increases. But i cant figure out how Note this is my first Coding ever....

Here is my Code.... Its basically the How to jump code From this site but with alterations :

-- Load colors

black = Color.new(0,0,0)
green=Color.new(0,255,0)
white = Color.new(255,255,255)
blue= Color.new(37,6,237)

-- load images

player1 =Image.load("Img/earth.png")
ground =Image.load("Img/background.png")
bg =Image.load("Img/bg.png")

-- load player

ground =Image.load("Img/base.png") player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 5
player.jumpstate = "ground"
while true do
pad = Controls.read()
screen:clear()
-- load background
screen:blit(0, 0, bg, false)

-- control speed

if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end

-- Gravity
if pad:cross() and player.jumpstate == "ground" then
player.jumpstate = "jumping"
end
if player.jumpstate == "jumping" then
player.jumpspeed = player.jumpspeed -0.0
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 + -0.3)
end
if player.gravity == 230 then
player.jumpspeed =3
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)
-- Upper text
screen:print(20,15, "Welcome to Moon Mode =)",white)
if pad:start() then
dofile("options.lua")
end
-- Screen Shot
if pad:select() then screen:save("screenshot.png")
end
screen.waitVblankStart()
screen.flip()
end


I Made this using LuaDevKit R2:D

YOU DON"T NEED LUA PLAYER

Here are some ScreenShots:
http://i11.tinypic.com/66owb3a.png
http://i16.tinypic.com/4r94o6h.png


Download--->Click Me (http://www.sendspace.com/file/a9k1lw)

dangee
August 19th, 2007, 18:49
strongly recommend some time spent over at evilmana (http://www.evilmana.com)