Page 1 of 13 1 2 3 11 ... LastLast
Results 1 to 10 of 122

Thread: Lua Help Thread

  
  1. #1
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    Need help with lua ask here (I will only reply to lua help under this thread)

    Rules:
    Be as specific as possible.
    Check if question has already been answered.

    dP :paranoid:

    july 19

  2. #2
    CT_Bolt's Avatar
    CT_Bolt is offline -Hacks Neophyte
    Join Date
    Jan 2006
    Location
    With the humans
    Posts
    54
    Rep Power
    14

    Default

    My Problem: Animation using sprite sheets. :posessed:

    My problem: Click Here

    I mean if i have this:
    0 1 2 | PerRow = 3
    3 4 5 | Count = 9
    6 7 8 | Current = 3 (this number changes)

    0 to 8 are images in a sprite sheet. :sigh: I want to get a current row & coloumn from the current frame. :/

    Any help would be awesome. ;)

  3. #3
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    Easy, a video game none the less >__> .

    This built in function will get your sprite and draw it based on the values of the variables.

    screen:blit(blitwhereonscreenxyouwanttodrawthesprite, blitwhereonscreenyyouwanttodrawthesprite, nameofspritesheet, locationofspritex, locationofspritey, sizeofspritex, sizeofspritey, alpha)

    like my var. names 8)

    It is now just a matter of making an animation function that selects the current image.

    sprite sheet looks like this:
    |_|_|_|
    |_|_|x| <-- that is the image you want to draw on point 0, 0 of the screen
    |_|_|_|

    so:

    blitwhereonscreenxyouwanttodrawthesprite = 0
    blitwhereonscreenyyouwanttodrawthesprite = 0
    nameofspritesheet = animationspritesheet
    locationofspritex = 3(because it is in column 3) *thewidthofonerowonspritesheet
    locationofspritey = 2(because it is in column 2) *thewidthofonerowonspritesheet
    sizeofspritex = 14 (becuase your sprite's are 14 pixels wide)
    sizeofspritey = 24 (becuase your sprite's are 24 pixels tall)
    alpha = false

    K?
    july 19

  4. #4
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    fast rotation of sprites and an example of a file browser :D
    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

  5. #5
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    "fast rotation of sprites" that could be a number of things -- please be VERY specific (I'll put up some rules).

    Lua Filebrowser Example:
    click to download

    (script is easy to follow)
    july 19

  6. #6
    cls
    cls is offline Senior Member -Hacks Guru
    Join Date
    Jun 2005
    Location
    the netherland Rank: Mod
    Posts
    1,782
    Rep Power
    16

    Default

    dude i need to learn how to program also......i dont get understand a shit about this.....illfoundedmind can you give me a link to a good tut?

  7. #7
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    Sure

    I'll keep them basic for now:

    Lua tuts:
    http://www.scriptscribbler.com/psp/ <-- start here
    http://wiki.ps2dev.org/psp:lua_player:tutorial

    Things to understand about programming. Programming is just putting basic logic into words

    example: if Jen says hello then you say goodbye (note this is just a basic programming idea it will not actually run)

    Jensmessage= "hello";

    if (jensmessage == 'hello'){
    yourmessage = "goodbye";
    } else {
    // nothing
    }
    july 19

  8. #8
    CT_Bolt's Avatar
    CT_Bolt is offline -Hacks Neophyte
    Join Date
    Jan 2006
    Location
    With the humans
    Posts
    54
    Rep Power
    14

    Default

    Well, thanks but I found my answer:
    Code:
    X = 0 ; Y = 0
    Img = Image.load(SpriteSheet.PNG)
    cRow = math.mod(Current,PerRow) ; cCol = math.floor(Current/PerRow)
    CellWidth = 15 ; CellHeight = 20
    screen:blit(X,Y, Img, cRow * CellWidth, cCol * CellHeight, CellWidth, CellHeight)
    That's the basics of it. :sigh:

    Thank you again though. :)

  9. #9
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    by rotation of sprites I mean rotate an image by 30 degrees and it won't make your app lag
    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

  10. #10
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    Quote Originally Posted by CT_Bolt
    Well, thanks but I found my answer:
    screen:blit(X,Y, Img, cRow * CellWidth, cCol * CellHeight, CellWidth, CellHeight)
    That's the basics of it. :sigh:

    Thank you again though. :)
    Quote Originally Posted by illfoundedmind
    screen:blit(blitwhereonscreenxyouwanttodrawthesprite, blitwhereonscreenyyouwanttodrawthesprite, nameofspritesheet, locationofspritex, locationofspritey, sizeofspritex, sizeofspritey, alpha)
    Umm same thing I had there :paranoid: just I explained it :sleep:

    Quote Originally Posted by soulkiller
    by rotation of sprites I mean rotate an image by 30 degrees and it won't make your app lag
    the code is in the cube demo downloaded with any lua player ;)
    july 19

Page 1 of 13 1 2 3 11 ... LastLast

Posting Permissions

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