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

Thread: lua help

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

    Arrow lua help

    ok, im programming a kirby game, and i need some help :(

    whenever i jump in the air, and i press down while facing left, i do not go into "pount mode", but instead the picture changes to player2 and it moves about 1-2 pixels to the left
    another thing, is whenever i enter pound mode, while facing right, and jumpstate = ground, then you press right, it messes up, and displays an error
    heres the error
    ./game.lua:51: bad argument #2 to 'blit' (Image expected, got table)


    yet when you are on the ground in "pound mode" and press left, your image turns to player2

    this is my code....
    ---------------------------------------------------------------
    --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)
    Music.stop()
    healthbar = {}
    healthbar.y = 10
    Player1 = Image.load("kirby.png")
    Player2 = Image.load("kirby2.png")
    Playerc = Image.load("crouch.png")
    Playerc2 = Image.load("crouch2.png")
    Playerp = Image.load("kirbyp.png")
    Playerp2 = Image.load("kirbyp2.png")
    Punch = Image.load("punch.png")
    Punch2 = Image.load("punch2.png")
    Playerj = Image.load("kirbyj.png")
    Playerj2 = Image.load("kirbyj2.png")
    kirbyPoint = 0
    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"
    spawnpoint = {}
    spawnpoint.y = 300
    spawnpoint.x = 30
    playerHeight = 32
    playerWidth = 32


    function reSpawn()
    Player.image = Player1
    Player.x = spawnpoint.x
    Player.y = spawnpoint.y
    Player.health = 200
    Player.lives = Player.lives - 1
    end

    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 and Player.image ~= Playerp and Player.image ~= Playerc2 and Player.image ~= Playerp2 then
    Player.jumpstate = "jumping"
    end

    if pad:r()then
    if Player.image == Player1 or Player.image == Playerj then
    Player.image = Punch
    end
    if Player.image == Player2 or Player.image == Playerj2 then
    Player.image = Punch2
    end
    end

    if Player.image == Punch then
    kirbyPoint = kirbyPoint + 1
    end
    if Player.image == Punch2 then
    kirbyPoint = kirbyPoint + 1
    end

    if Player.image == Punch and kirbyPoint == 14 then
    Player.image = Player1
    kirbyPoint = 0
    end
    if Player.image == Punch2 and kirbyPoint == 14 then
    Player.image = Player2
    kirbyPoint = 0
    end

    if pad:up()then
    if Player.image == Playerc or Player.image == Playerp and Player.jumpstate == "ground" then
    Player.image = Player1
    end
    if Player.image == Playerc2 or Player.image == Playerp2 and Player.jumpstate == "ground" then
    Player.image = Player2
    end
    end

    if pad:down() and Player.image == Player1 and Player.jumpstate == "ground" then
    Player.image = Playerc
    end
    if pad:down() and Player.jumpstate == "jumping" and Player.image == Playerj then
    Player.image = Playerp
    Player.jumpstate = "pound"
    end
    if pad:down() and Player.image == Player2 and Player.jumpstate == "ground" then
    Player.image = Playerc2
    end
    if pad:down() and Player.jumpstate == "jumping" and Player.image == Playerj2 then
    Player.image = Playerp2
    Player.jumpstate = "pound"
    end


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

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

    if pad:left() and Player.jumpstate == "ground" and Player.image == Playerp or Player.image == Playerp2 then
    Player.image = Player2
    Player.x=Player.x-4
    end

    if pad:right() and Player.jumpstate == "ground" and Player.image == Playerp or Player.image == Playerp2 then
    Player.image = Player
    Player.x=Player.x+4
    end

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

    screen:fillRect(0,242,480,30,black)
    screen:fillRect(29,259,202,12,white)
    screen:fillRect(30,260,200,10,red)
    screen:fillRect(30,260,Player.health, healthbar.y, green)
    screen:print(30,250, "Health:" .. 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.lives <= 0 then
    dofile("./go.lua")
    end

    if Player.health <= 0 and Player.lives > 0 then
    reSpawn()
    end

    if Player.lives == -1 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.jumpstate == "pound" 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.jumpstate == "jumping" and Player.image == Player1 then
    Player.image = Playerj
    end
    if Player.jumpstate == "jumping" and Player.image == Player2 then
    Player.image = Playerj2
    end
    if Player.jumpstate == "ground" and Player.image == Playerj then
    Player.image = Player1
    end
    if Player.jumpstate == "ground" and Player.image == Playerj2 then
    Player.image = Player2
    end

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

    Player.y = Player.gravity

    screen.flip()
    screen.waitVblankStart()
    end

    ---------------------------------------------------------------

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

    Default

    Whats the error message that comes up?
    Can you also zip up everything including images to download?

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

    Default

    i updated my post
    lol, i cant believe i forgot to put error message up

    oh, also, i cannot upload the files... two reasons
    1 i dont want anyone to have the update before its released
    2 my 300 mhz compy takes about 5 hours to upload 1 meg

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

    Default

    Well, considering that you have just posted the entire code, we already have the update, just no images.

    The error is caused by:
    if pad:right() and Player.jumpstate == "ground" and Player.image == Playerp or Player.image == Playerp2 then
    Player.image = Player
    Player.x=Player.x+4
    end
    You are changing an image variable to a table

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

    Default

    LMFAO!
    I can't believe I did that!
    omg lol

    thanks soooo much yaustar
    your amazing!

    also, do you know whats up with the not being able to go into "pound mode" whilst in the air, facing left

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

    Default

    The logic looks fine. Check what kirbyp2.png actually looks like.

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

    Default

    it looks like its supposed to
    i also searched my code many times for where it makes the picture move a few pixels to the left, but i cant even find that!
    as soon as i fix this one error, ill release
    also, there are many new things that are not in the gameplay itself, like the game over screen

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

    Default

    I can't do anything here unless I have the whole code and iamges to play about with.

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

    Default

    get on msn, and ill send the files to you

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

    Default

    Can't uni firewall blocks all file transfers.

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
  •