Results 1 to 10 of 10

Thread: Lua coding help....round 2

                  
   
  1. #1
    DCEmu Pro Man's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    929
    Rep Power
    73

    Default Lua coding help....round 2

    ok, so i have learned the basics, and im ready to start a game or somthing extremely simple, but i cant find a guide or tutorial to add moving images, like for walking, i downloaded the "sprite" pack from here:http://www.evilmana.com/graphics/ and it has all seperate images, and i can see how they are supposed to work, but i dont know how to make them work with my player commands and such, if some one can point me to a guide or somthing, you would be helping out a lot, im really interested in making games and stuff for the psp, but i cant find out how to make these work, again, im a total noob at coding, but i do know most things and the things i dont, i will soon hopefully.

  2. #2

  3. #3
    DCEmu Pro Man's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    929
    Rep Power
    73

    Default

    ahh $#@!, didnt see that, thanks, wow, that makes mee feel silly, but where do i put the images i want to load?
    do i load them inside of the table at the top? srry, its not really a guide, its just like a code snippet, it isnt really usefull without a description on how to use it, or why.

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

    Default

    First it load the 5 animation images
    animation1.png
    animation2.png
    animation3.png
    animtaion4.png
    animation5.png
    and puts them into a table.
    Refers to the code at the top:
    -- Load Images Into A Table
    animation = {}
    for a = 1, 5 do
    animation[a] = Image.load("animation" ..a..".png")
    end
    The animation code is just this which is pretty straightforward:
    if pad:cross() then
    if loopCount >= 0 and loopCount < 6 then anim = animation[1]
    elseif loopCount >= 6 and loopCount < 12 then anim = animation[2]
    elseif loopCount >= 12 and loopCount < 18 then anim = animation[3]
    elseif loopCount >= 18 and loopCount < 24 then anim = animation[4]
    elseif loopCount >= 24 and loopCount < 30 then anim = animation[5] end
    if loopCount + 1 >= 30 then loopCount = 0 else loopCount = loopCount + 1 end
    end
    I can't remember how many comments I wrote for this snippet but here is an alternate way to do animations.
    http://www.dcemu.co.uk/vbulletin/showthread.php?t=28021

  5. #5
    DCEmu Pro Man's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    929
    Rep Power
    73

    Default

    do the images have to be in PNG format ? or can they be in gif or anything else? and does it matter if i just want to load two images ? like these two (see attached files ) this is what i have so far :
    -- Load Images Into A Table
    animation = { Image.load("1.PNG") ,Image.load("2.PNG")}
    for a = 1, 2 do

    end

    -- Player Info
    player = {}
    player.x = 220
    player.y = 110
    player.pad = "none"


    -- Set Default Image
    animation1 = anim

    -- Set loop count
    loopCount = 500

    -- Read Controls
    while true do
    pad = Controls.read()
    screen:clear()

    -- Animation Loop
    if pad:cross() then
    if loopCount >= 0 and loopCount < 6 then anim = animation[1]
    elseif loopCount >= 6 and loopCount < 12 then anim = animation[2]
    elseif loopCount >= 12 and loopCount < 18 then anim = animation[3]
    elseif loopCount >= 18 and loopCount < 24 then anim = animation[4]
    elseif loopCount >= 24 and loopCount < 30 then anim = animation[5] end
    if loopCount + 1 >= 30 then loopCount = 0 else loopCount = loopCount + 1 end
    end

    -- Display Default Image
    screen:blit(player.x,player.y,anim)

    -- End Loop
    screen.waitVblankStart()
    screen.flip()
    end
    do i have the images in the right places ?

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

    Default

    That will crash since the animation code will try to load the 3rd - 5th entry in the table which doesn't exist. Since the for loop is empty, remove it. Images HAVE to be in PNG. LuaPlayer doesn't support any other format besides PNG or JPEG.

  7. #7
    DCEmu Pro Man's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    929
    Rep Power
    73

    Default

    im so frigging frustrated with this, i cant get it to work and it seems to be a simple prosses, but i cant get it to work i removed the loops that are not needed, but it says attempt to blit player, a nil value. If anyone who has a lot of patience, walk me through this, or make a small guide or somthing, you would be my hero.

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

    Default

    -- Set Default Image
    animation1 = anim
    anim at this point in code doesn't exist yet so it is deemed as nil. animation1 is not used at all in the code. Remove it. This the reason why it throws the error on this line:
    screen:blit(player.x,player.y,anim)
    anim is nil therefore the function does a wobbly since it expects an image.

    This line should be:
    -- Set Default Image
    anim = animation[1]
    This sets anim to 'point' at the image that is stored in the first entry of the table animation.

  9. #9
    DCEmu Pro Man's Avatar
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    929
    Rep Power
    73

    Default

    ok never mind, iv got it now. Thanks for all your help, your my hero.

  10. #10
    DCEmu Pro dangee's Avatar
    Join Date
    Feb 2007
    Posts
    531
    Rep Power
    66

    psp break it to fix it..

    if debugging and yourLuaplayerVersion>=2.0 then youMayFindThisUseful=true end

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
  •