Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Help with lua code

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

    Question Help with lua code

    g'day chaps, and stuff
    anyways let me get to it
    i need help with lua codes
    i put something in that should work, but it wont!
    so um, get me on an IM

    thecrait (aim)
    the_crait (msn)
    crait.is (gmail/gtalk)

  2. #2
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    88

    Default

    Post the code up, you havea better chance of getting it answered. Also stick it in the developers forum.

  3. #3
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    70

    Default

    --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() and Player.jumpstate == "ground" then
    Player.image = Playerc
    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)
    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 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



    ok, thats the code, but for some reason kirby does not change into 'pound mode'

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

    Default

    what part of the code is wrong do u need something like
    if jumpstate==jumping and pad:cross then pound

    or something else

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

    Default

    it loads, just when you press down when your falling, nothing happens

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

    Default

    so u want it to load while your falling

  7. #7
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    70

    Default

    no, i want it to load the picture kirbyp if kirby is falling and you press down bottun

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

    Default

    if player.jumpstate=="falling" and pad:down then your image here

  9. #9
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    88

    Default

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

  10. #10
    PSP User crait's Avatar
    Join Date
    Jul 2006
    Posts
    212
    Rep Power
    70

    Default

    oh man, thanks yaustar, you are amazing!

Page 1 of 2 12 LastLast

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
  •