Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Help with lua code

                  
   
  1. #11
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    69

    Default

    man... that didnt work either
    i tried this

    --Kirby's Lua Adventure
    --By crait
    --Version 0.35
    white = Color.new(255,255,255)
    green = Color.new(0,255,0)
    red = Color.new(255,0,0)
    black = Color.new(0,0,0)
    healthbar = {}
    healthbar.y = 20
    Player1 = Image.load("kirby.png")
    Player2 = Image.load("kirby2.png")
    Playerc = Image.load("crouch.png")
    Playerp = Image.load("kirbyp.png")
    Player = {}
    Player.lives = 4
    Player.health = 200
    Player.image = Player1
    Player.gravity = 200
    Player.y = 200
    Player.x = 30
    Player.jumpspeed = 10
    Player.jumpstate = "ground"

    background=Image.load("bg.png")
    while true do
    screen:blit(0,0,background,false)
    screen:blit(Player.x,Player.y,Player.image,true)
    pad=Controls.read()


    if pad:cross() and Player.jumpstate == "ground" and Player.image ~= Playerc then
    Player.jumpstate = "jumping"
    end


    if pad:up()then
    Player.image = Player1
    end

    if pad:down() then
    if Player.jumpstate == "ground" then
    Player.image = Playerc
    end
    if Player.jumpstate == "falling" then
    Player.image = Playerp
    Player.jumpstate = "pound"
    end
    end

    if pad:right() then
    Player.image = Player1
    Player.x = Player.x+4
    end

    if pad:left()then
    Player.image = Player2
    Player.x=Player.x-4
    end

    if pad:r() and Player.health > 0 then
    Player.health = Player.health - 20
    end

    screen:fillRect(0,242,480,30,black)
    screen:fillRect(29,259,202,22,white)
    screen:fillRect(30,260,200,20,red)
    screen:fillRect(30,260,Player.health, healthbar.y, green)
    screen:print(30,250, "Health:",green)
    screen:print(85, 250,Player.health,green)
    screen:print(260,250,"Lives left:",green)
    screen:print(260,260,Player.lives,green)
    screen:print(430,252,"V 0.35",white)
    screen:print(415,262,"By crait",white)
    if Player.health <= -1 then
    Player.health = Player.health + 1
    end
    if Player.health <= 0 then
    Player.lives = Player.lives - 1
    end
    if Player.lives <= 0 then
    screen:fillRect(100,100,200,50,black)
    screen:print(110,110,"Game Over!",red)
    screen:print(110,120,"Press (O) to return",red)
    screen:print(110,130,"to the Main Menu",red)
    if pad:circle() then
    dofile("script.lua")
    end
    if pad:right()then
    Player.image = Player1
    Player.x=Player.x-4
    end
    if pad:left()then
    Player.image=Player2
    Player.x=Player.x+4
    end
    end
    if Player.lives < 0 then
    Player.lives = Player.lives + 1
    end

    if Player.jumpstate == "jumping" then
    Player.jumpspeed = Player.jumpspeed - 0.5
    Player.gravity = Player.gravity - Player.jumpspeed
    end

    if Player.gravity < 200 and Player.jumpstate == "falling" then
    Player.gravity = Player.gravity + (Player.jumpspeed + 3)
    end
    if Player.gravity < 200 and Player.jumpstate == "pound" then
    Player.gravity = Player.gravity + (Player.jumpspeed + 4)
    end

    if Player.gravity == 200 then
    Player.jumpspeed = 10
    Player.jumpstate = "ground"
    end

    if Player.gravity > 200 then Player.gravity = 200
    end

    Player.y = Player.gravity

    screen.flip()
    screen.waitVblankStart()
    end

    the game loads fine, its just doesnt want to work

  2. #12
    PSP User dtothabreezy's Avatar
    Join Date
    Apr 2006
    Location
    the netherer realm
    Posts
    308
    Rep Power
    71

    Default

    im absolutley positive that this will work
    if pad:down() and player.jumpstate=="jumping"
    then your sprite

    i tested it my self

  3. #13
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    It be nice to say WHAT didn't work in VERY detailed terms.

    Edit: Nevermind. The problem is that your Player is NEVER in the falling state.

    change
    if pad:down() then
    if Player.jumpstate == "ground" then
    Player.image = Playerc
    end
    if Player.jumpstate == "falling" then
    Player.image = Playerp
    Player.jumpstate = "pound"
    end
    end
    to
    if pad:down() then
    if Player.jumpstate == "ground" then
    Player.image = Playerc
    end
    if Player.jumpstate == "jumping" then
    Player.image = Playerp
    Player.jumpstate = "pound"
    end
    end

  4. #14
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    69

    Default

    your right
    ill try this one yaustar
    but make some more mods to itt
    man, your really good at this lua thing

  5. #15
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    69

    Default

    yep this one worked! thanks everyone!
    espescially you Yaustar

  6. #16
    DCEmu Legend acn010's Avatar
    Join Date
    Dec 2005
    Location
    Galaxy not far away?
    Age
    37
    Posts
    4,656
    Rep Power
    103

    Default

    im glad it worked

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •