Results 1 to 6 of 6

Thread: Help with animating PNG files

                  
   
  1. #1
    DCEmu Coder MasterChafed's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Age
    34
    Posts
    832
    Rep Power
    94

    Default Help with animating PNG files

    I am haivng trouble incorporating png files into my lua script. I currently can load them into a table, like so.

    player = {}
    player[1] = Image.load("1.png")
    player[2] = Image.load("2.png")
    player[3] = Image.load("3.png")
    player[4] = Image.load("4.png")
    player[5] = Image.load("5.png")

    but how do I go about printing them to the screen? Blitting them doesn't work because it is for single images and when i try it it tells me that it cannot blit "player" because it is a table. thx for any input.
    http://one.revver.com/watch/170516
    http://one.revver.com/watch/167200

    Please click the links above to watch my stick figure animations,
    and please, if you have the time, click the ads at the end to earn me some money.

  2. #2
    DCEmu Coder MasterChafed's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Age
    34
    Posts
    832
    Rep Power
    94

    Default

    p.s. this is very urgent as I was wanting to push out a concept release of my game by tommorrow. Also, if you can give me some pointers of how to make gravity so i can jump, that would be great.
    http://one.revver.com/watch/170516
    http://one.revver.com/watch/167200

    Please click the links above to watch my stick figure animations,
    and please, if you have the time, click the ads at the end to earn me some money.

  3. #3
    DCEmu Newbie
    Join Date
    Feb 2006
    Posts
    92
    Rep Power
    0

    Default

    I can't help you with the animations, as I'm not that far yet in my learning.

    However, I suggest you use PSP Millionaire's Lua tutorials, as they're simply awesome, for the gravity issue.

    You can find his tutorials at evilmana.com

    The site was hacked not too long ago, and most of the tutorials are up now. But the one for jumping (which includes gravity) is not yet. Thanks to Google cache, we still have access to it.

    http://66.102.7.104/search?q=cache:v...s&ct=clnk&cd=1

    That will display the tutorial for you. He said that by tomorrow, all the tutorials should be back up on his site, so just go to evilmana.com starting sometime tomorrow or the day after.

    Good luck! Hopefully somebody else can help you with the animations.

    EDIT: I suggest you do the tutorial first, and see the final result before putting into your game. You may want to play with the gravity to your liking, and it's far easier to do it when you know the code is correct.

  4. #4
    DCEmu Coder MasterChafed's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Age
    34
    Posts
    832
    Rep Power
    94

    Default

    Thx a lot. I have been waiting for evilmana to come back up for a few days now, it really sucked finding a site with all the tuts i need and it being down. lol. thx man.
    http://one.revver.com/watch/170516
    http://one.revver.com/watch/167200

    Please click the links above to watch my stick figure animations,
    and please, if you have the time, click the ads at the end to earn me some money.

  5. #5

    Default

    Here is a function I put together to display an sequence of .png files.


    function ShowAnimation (FileName,px,py,Frames,Time)

    local WaitTime = Time / Frames
    local AnimationTimer = Timer.new()
    local img

    img = Image.load(FileName .. "1.png")

    for i = 2, Frames + 1 do

    -- clear the screen and display the current imag
    screen:clear(Color.new(255,255,255))
    screen:blit(px,py ,img, 0, 0, img:width(), img:height(), true)
    screen.waitVblankStart()
    screen:flip()
    AnimationTimer:reset()
    AnimationTimer:start()

    -- Load the next image and the wait until it's time to display it
    if i <= Frames then
    img = Image.load(FileName .. i .. ".png")
    end -- if i <= Frames then
    while AnimationTimer:time() < WaitTime do

    end --

    AnimationTimer:stop()
    end -- for i = 2, Frames do

    -- not 100% sure if this is needed as img is 'local' but
    -- better safe then sorry
    img = nil
    end -- function ShowAnimation (FileName,px,py,Frames,Time)


    Use it as follows:

    Code:
    ShowAnimation("ts",30,30,10,1500)
    This will display a sequence of 10 .png files called
    ts1.png
    ts2.png etc..

    at position 30, 30 on screen

    over a period of 1.5 seconds

    I don't think it's exactly what you want but it might give you a start....
    Remember - Don't sweat the petty things and
    Don't pet the sweaty things......

  6. #6
    DCEmu Coder MasterChafed's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Age
    34
    Posts
    832
    Rep Power
    94

    Default

    thanx anyway man, I now have a method of animating png images. Hey you should check out the game I am developing, its called Halo 2d. Check it out.
    http://one.revver.com/watch/170516
    http://one.revver.com/watch/167200

    Please click the links above to watch my stick figure animations,
    and please, if you have the time, click the ads at the end to earn me some money.

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
  •