Seite 314 von 342 ErsteErste ... 214 264 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 ... LetzteLetzte
Zeige Ergebnis 9.391 bis 9.420 von 10238

Lua Programming Help Thread

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von wicked_fable I don't think he wants to UN-compress he wants to compress the file. Yes I want to ...

  
  1. #9391
    QJ Gamer Green
    Points: 4.034, Level: 40
    Level completed: 43%, Points required for next Level: 116
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    467
    Points
    4.034
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von wicked_fable Beitrag anzeigen
    I don't think he wants to UN-compress he wants to compress the file.
    Yes I want to compress the files into either a zip or rar


    My Releases:
    ---------------------------------------------------
    [URL="http://forums.qj.net/showthread.php?t=145654"]ROFLFlasher[/URL]

    [URL="http://forums.qj.net/showthread.php?t=144892"]DTS MGS Edition[/URL]

    [URL="http://forums.qj.net/showthread.php?t=143735"]Arkanoid Deluxe Beta[/URL]

    [URL="http://forums.qj.net/showthread.php?p=2144700#post2144700"]SAVIOR![/URL]

  2. #9392
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    1. Read this and listen to it. It's called indentation and it makes your code much easier to read.

    2. Learn to use for loops, they'll cut lots of redundancy

    3. Work through the logic of your code in your head and ask yourself why you're doing each step. If you don't know, either figure it out, or get rid of it until you do. If it makes more sense to do it a different way at seems like it would be faster, make it do it the faster way. It's called optimization.

    4. Why do you need to run the CPU at 333mhz just for a SIMPLE mp3 player, especially when the ME is doing all the MP3 work?
    [size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]

  3. #9393
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von eldiablov Beitrag anzeigen
    God, that just screams inefficient.
    thanks...
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  4. #9394
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Digikid13 Beitrag anzeigen
    thanks...
    You should optimize that chunk.

  5. #9395
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    1. Read this and listen to it. It's called indentation and it makes your code much easier to read.

    2. Learn to use for loops, they'll cut lots of redundancy

    3. Work through the logic of your code in your head and ask yourself why you're doing each step. If you don't know, either figure it out, or get rid of it until you do. If it makes more sense to do it a different way at seems like it would be faster, make it do it the faster way. It's called optimization.

    4. Why do you need to run the CPU at 333mhz just for a SIMPLE mp3 player, especially when the ME is doing all the MP3 work?
    1. I really didn't need indentation. *sigh*

    2. I just thought of that:
    Code:
    for a = 1, 100 do
          Image:fillRect((200 + a), Mp3me.visL(a), 1, 300)
          Image:fillRect((300 + a), Mp3me.visR(a), 1, 300)
    end
    3. =.=

    4. Wouldn't be based of off you game CPU settings.
    Geändert von Digikid13 (09-05-2008 um 06:08 PM Uhr)
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  6. #9396
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    1. Yes, you do need indentation. You're being ignorant if you think otherwise.

    2. Close but that would make you draw 200 bars, i would do for a = 0, 100, 10 do or similar so it increments in 10 instead of 1

    3. Don't shake your head at it, listen to it. It's how you get better, it's how you learn, it's how you stop needing to ask for help on trivial things like this.

    4. What?
    [size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]

  7. #9397
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    1. Yes, you do need indentation. You're being ignorant if you think otherwise.

    2. Close but that would make you draw 200 bars, i would do for a = 0, 100, 10 do or similar so it increments in 10 instead of 1

    3. Don't shake your head at it, listen to it. It's how you get better, it's how you learn, it's how you stop needing to ask for help on trivial things like this.

    4. What?
    1. I use indentation in all of my work. I just didn't need it in the last one, because I used it.

    2. That is what I wanted. It makes it look more uniform.

    3. You sent me through a loop with all of that. I try to use some logic with what I do, but I can't if I don't know what I am doing.

    4. In the VSH menu, you know where you select the CPU speed for the game, would it not be based off of that.
    -=Double Post Merge =-
    How can I record my game and turn it into my eboot pic.
    Geändert von Digikid13 (09-05-2008 um 06:34 PM Uhr) Grund: Automerged Doublepost
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  8. #9398
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    I think that only works for the ISOs and XMB speeds.

  9. #9399
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Anti-QuickJay Beitrag anzeigen
    I think that only works for the ISOs and XMB speeds.
    Oh really I don't know why it is 333 mhz then.
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  10. #9400
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    200 calls to drawRect will make it look more uniform but it'll also make it slow as all hell. And I didn't see complete proper indentation in your code
    [size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]

  11. #9401
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Well i didn't do the entire code, so i don't know if there is any. 333mhz =.= and it is not slow to me.
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  12. #9402
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    hey turtles where is the code not indented properly, unless your going to moan about the code inside the while true do loop?

    As I said that code probably isn't any good, while I was coding it I came across problems (one being that mp3me.eos() returns a string not a boolean o_O), I was unsure if these were speed issues or with the code that is why there is lots more code than would be needed to accomplish this feature and the reason for the cpu being set to 333mhz.

    All in all the code i posted was just a way to do what he wanted that worked, I did not say it was any good, in fact I said the complete opposite.
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  13. #9403
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    3. Work through the logic of your code in your head and ask yourself why you're doing each step. If you don't know, either figure it out, or get rid of it until you do. If it makes more sense to do it a different way at seems like it would be faster, make it do it the faster way. It's called optimization.
    I disagree, what you have described is premature optimisation. You should get it working, then get it working faster (not rip it out because it is slow) but only if it is seen as a performance bottleneck else leave it.

    If you find that a chunk of code is getting unwieldy to work with to make constant changes or you are copying and pasting a similar line/block of code a couple of times, then consider refractoring the code to make it more maintainable and/or reusable.

  14. #9404
    Points: 5.711, Level: 48
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    39
    Points
    5.711
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Spoiler for code:
    red = Color.new(255,0,0)
    blue = Color.new(0,0,255)
    green = Color.new(0,255,0)

    playerImage = Image.createEmpty(16,16)
    ground = Image.createEmpty(16,16) -- ground tiles
    wall = Image.createEmpty(16,16) -- wall tiels
    playerImage:clear(red)
    ground:clear(green)
    wall:clear(blue)

    function CreateWorld() --Create a Table with Data on the world
    local buffer1 = {rows,cols,TopRow,TopCol, Action,Direc,PlayerY} -- {total rows,total columns, Top Row the is seen, Top Column that is seen,Check for actions in the loop,Chack for directions,Player's y(not necessary as of now}

    return buffer1
    end

    function MAP()
    local buffer1 = {tile}
    local buffer2 = {}
    setmetatable(buffer2,buff er1)
    return buffer2
    end
    North = 1
    South = 2 -- Direction constants
    East = 3
    West = 4
    WorldData = CreateWorld()
    Map = MAP()
    worldMap = {} -- THE MAP
    worldMap[1] = {2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2 ,2,2,2,2}
    worldMap[2] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[4] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[5] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[6] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[7] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[8] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[9] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,2,2,2,2,1,1,1,1 ,1,1,1,2}
    worldMap[10] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[11] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[12] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[13] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[14] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[15] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[16] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[17] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[18] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[19] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[20] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[21] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[22] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[23] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[24] = {2,1,1,1,1,1,2,2,2,2,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[25] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[26] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[27] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[29] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[30] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[31] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[32] = {2,1,1,1,2,2,2,2,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[33] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[34] = {2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2 ,2,2,2,2}

    function InitVars() -- Init of the variables on the first map blit
    WorldData.TopCol = 14
    WorldData.TopRow = 9
    end

    function MoveDown()
    WorldData.Direc = South
    WorldData.TopRow = WorldData.TopRow + 1
    end

    function MoveLeft()
    WorldData.Direc = West
    WorldData.TopCol = WorldData.TopCol - 1
    end

    function MoveRight()
    WorldData.Direc = East
    WorldData.TopRow = WorldData.TopRow + 1
    end

    function MoveUp()
    WorldData.Direc = West
    WorldData.TopRow = WorldData.TopRow - 1
    end

    function DrawTile(x,y,TileNumber) -- draw a specific tile
    if TileNumber == 1 then
    screen:blit(x,y,ground)
    end
    if TileNumber == 2 then
    screen:blit(x,y,wall)
    end
    end
    function ShowMap() --draw the entire map
    for i = 0,8 do
    for j = 0,5 do
    DrawTile(i*16,j*16,worldM ap[i+WorldData.TopCol][j+WorldData.TopRow])
    end
    end
    end
    InitVars()
    WorldData.Action = true
    while true do
    pad = Controls.read()
    if pad:down() and oldpad:down() ~= pad:down()then
    MoveDown()
    WorldData.Action = true
    end

    if pad:right() and oldpad:right() ~= pad:right() then
    MoveRight()
    WorldData.Action = true
    end

    if pad:left() and oldpad:left() ~= pad:left() then
    MoveLeft()
    WorldData.Action = true
    end

    if pad:up() and oldpad:up() ~= pad:up() then
    MoveUp()
    WorldData.Action = true
    end

    if WorldData.Action == true then
    ShowMap()
    WorldData.Action = false
    end
    screen:flip()
    screen.waitVblankStart()
    oldpad = pad
    end

    (The code's a bit big so I wrapped it in spoiler tags)
    So heres my code for tile engine I'm porting from QBASIC to Lua
    for some reason the map shows up ( the part I want) however it's very choppy and when I come up to a wall it blits all over the screen. Is there anything wrong in the code or is it just my computer?

  15. #9405
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    This isn't the Lua help thread, it's the C/C++ help thread. Post in the appropiate thread. :)
    And have you tested it on your PSP?
    Last thing, indent your code.

  16. #9406
    No longer a community member.
    Points: 25.679, Level: 96
    Level completed: 33%, Points required for next Level: 671
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    2
    Points
    25.679
    Level
    96
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von michaelp Beitrag anzeigen
    This isn't the Lua help thread, it's the C/C++ help thread. Post in the appropiate thread. :)
    And have you tested it on your PSP?
    Last thing, indent your code.
    I would think a thread titled "Lua Programming Help Thread" would be the Lua help thread.

  17. #9407
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Whoops.
    Maybe I'm going blind...

  18. #9408
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Talking

    Zitat Zitat von michaelp Beitrag anzeigen
    Whoops.
    Maybe I'm going blind...
    Yup you are..... ^^
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  19. #9409
    Points: 5.711, Level: 48
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    39
    Points
    5.711
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    lol THIS is the C/C++ help thread? Anyway no I havent tried it on my PSP and I did indent my code but the spoiler tags took it out I put them there so the post looked neat not this huge wall of code.
    EDIT:
    GOD I feel like an idiot I had to add the ShowMap function at the top of the loop now it works perfectly
    Spoiler for code:
    red = Color.new(255,0,0)
    blue = Color.new(0,0,255)
    green = Color.new(0,255,0)

    playerImage = Image.createEmpty(16,16)
    ground = Image.createEmpty(16,16) -- ground tiles
    wall = Image.createEmpty(16,16) -- wall tiels
    playerImage:clear(red)
    ground:clear(green)
    wall:clear(blue)

    function CreateWorld() --Create a Table with Data on the world
    local buffer1 = {rows,cols,TopRow,TopCol, Action,Direc,PlayerY} -- {total rows,total columns, Top Row the is seen, Top Column that is seen,Check for actions in the loop,Chack for directions,Player's y(not necessary as of now}

    return buffer1
    end

    function MAP()
    local buffer1 = {tile}
    local buffer2 = {}
    setmetatable(buffer2,buff er1)
    return buffer2
    end
    North = 1
    South = 2 -- Direction constants
    East = 3
    West = 4
    WorldData = CreateWorld()
    Map = MAP()
    worldMap = {} -- THE MAP
    worldMap[1] = {2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2 ,2,2,2,2}
    worldMap[2] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[4] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[5] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[6] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[7] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[8] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[9] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,2,2,2,2,2,1,1,1,1 ,1,1,1,2}
    worldMap[10] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[11] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[12] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[13] = {2,1,1,1,1,2,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[14] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[15] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[16] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[17] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[18] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[19] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[20] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[21] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[22] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[23] = {2,1,1,1,1,1,2,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[24] = {2,1,1,1,1,1,2,2,2,2,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[25] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[26] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[27] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[29] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[30] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[31] = {2,1,1,1,2,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[32] = {2,1,1,1,2,2,2,2,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[33] = {2,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,2}
    worldMap[34] = {2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2 ,2,2,2,2}

    function InitVars() -- Init of the variables on the first map blit
    WorldData.TopCol = 14
    WorldData.TopRow = 9
    end

    function MoveDown()
    WorldData.Direc = South
    WorldData.TopRow = WorldData.TopRow + 1
    end

    function MoveLeft()
    WorldData.Direc = West
    WorldData.TopCol = WorldData.TopCol - 1
    end

    function MoveRight()
    WorldData.Direc = East
    WorldData.TopCol = WorldData.TopCol + 1
    end

    function MoveUp()
    WorldData.Direc = West
    WorldData.TopRow = WorldData.TopRow - 1
    end

    function DrawTile(x,y,TileNumber) -- draw a specific tile
    if TileNumber == 1 then
    screen:blit(x,y,ground)
    end
    if TileNumber == 2 then
    screen:blit(x,y,wall)
    end
    end
    function ShowMap() --draw the entire map
    for i = 0,10 do
    for j = 0,10 do
    DrawTile(i*16,j*16,worldM ap[i+WorldData.TopCol][j+WorldData.TopRow])
    end
    end
    end
    InitVars()

    while true do
    screen:clear()
    pad = Controls.read()
    ShowMap()
    if pad:down() and oldpad:down() ~= pad:down()then
    MoveDown()
    WorldData.Action = true
    end

    if pad:right() and oldpad:right() ~= pad:right() then
    MoveRight()
    WorldData.Action = true
    end

    if pad:left() and oldpad:left() ~= pad:left() then
    MoveLeft()
    WorldData.Action = true
    end

    if pad:up() and oldpad:up() ~= pad:up() then
    MoveUp()
    WorldData.Action = true
    end


    screen:flip()
    screen.waitVblankStart()
    oldpad = pad
    end

    heres the working code if anyone watns it.
    Geändert von bnc9 (09-06-2008 um 07:46 PM Uhr)

  20. #9410
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0
    [size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]

  21. #9411
    Points: 5.711, Level: 48
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    39
    Points
    5.711
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    FINE if you don't mind seeing a wall of code here:
    Code:
    red = Color.new(255,0,0)
    blue = Color.new(0,0,255)
    green = Color.new(0,255,0)
    
    playerImage = Image.createEmpty(16,16) 
    ground = Image.createEmpty(16,16) -- ground tiles
    wall = Image.createEmpty(16,16) -- wall tiels
    playerImage:clear(red)
    ground:clear(green)
    wall:clear(blue)
    
    function CreateWorld() --Create a Table with Data on the world 
    	local buffer1 = {rows,cols,TopRow,TopCol,Action,Direc,PlayerY} -- {total rows,total columns, Top Row the is seen, Top Column that is seen,Check for actions in the loop,Chack for directions,Player's y(not necessary as of now}
    	
    	return buffer1
    end
    
    function MAP()
    	local buffer1 = {tile}
    	local buffer2 = {}
    	setmetatable(buffer2,buffer1)
    	return buffer2
    end
    North = 1
    South = 2 -- Direction constants 
    East = 3
    West = 4
    WorldData = CreateWorld()
    Map = MAP()
    worldMap = {} -- THE MAP
    worldMap[1] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1}
    worldMap[2] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[4] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[5] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[6] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[7] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[8] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1}
    worldMap[9] = {2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,2,1}
    worldMap[10] ={2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1}
    
    function InitVars() -- Init of the variables on the first map blit
    	WorldData.TopCol = 1
    	WorldData.TopRow = 5
    end
    
    function MoveDown()
    	WorldData.Direc = South 
    	WorldData.TopRow = WorldData.TopRow + 1
    end
    
    function MoveLeft()
    	WorldData.Direc = West 
    	WorldData.TopCol = WorldData.TopCol - 1
    end
    
    function MoveRight()
    	WorldData.Direc = East 
    	WorldData.TopCol = WorldData.TopCol + 1
    end
    
    function MoveUp()
    	WorldData.Direc = West 
    	WorldData.TopRow = WorldData.TopRow - 1
    end
    
    function DrawTile(x,y,TileNumber) -- draw a specific tile
    	if TileNumber == 1 then
    		screen:blit(x,y,ground)
    	end
    	if TileNumber == 2 then
    		screen:blit(x,y,wall)
    	end
    end
    function ShowMap() --draw the entire map
    for i = 0,1 do
    	for j = 0,4 do 
    		DrawTile(i*16,j*16,worldMap[i+WorldData.TopCol][j+WorldData.TopRow])
    	end
    end
    end
    InitVars()
    
    while true do
    	screen:clear()
    	pad = Controls.read()
    	ShowMap()
    	if pad:down() and oldpad:down() ~= pad:down()then
    		MoveDown()
    		WorldData.Action = true
    	end
    	
    	if pad:right() and oldpad:right() ~= pad:right() then
    		MoveRight()
    		WorldData.Action = true
    	end
    	
    	if pad:left() and oldpad:left() ~= pad:left() then
    		MoveLeft()
    		WorldData.Action = true
    	end
    	
    	if pad:up() and oldpad:up() ~= pad:up() then
    		MoveUp()
    		WorldData.Action = true
    	end
    	
    
    	screen:flip()
    	screen.waitVblankStart()
    	oldpad = pad
    end

  22. #9412
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    You might want to add spacing too, I can't tell what goes together. Also, what is it that you want.
    -=Double Post Merge =-
    it only draws a corrner....
    Geändert von Digikid13 (09-07-2008 um 05:06 PM Uhr) Grund: Automerged Doublepost
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  23. #9413
    Points: 5.711, Level: 48
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    39
    Points
    5.711
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    About the corner:Well yea that's the point, I wanted to only see part of the map because say I made the map bigger I could place myself on one point that could by my start point and move my way through the level this is how 2d scrollers like zelda made their maps (of course their scrolling was way more advanced and looked much better than mine).

  24. #9414
    Seven Year Vet. BOW DOWN.
    Points: 14.794, Level: 78
    Level completed: 86%, Points required for next Level: 56
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Manchester, UK
    Beiträge
    2.240
    Points
    14.794
    Level
    78
    My Mood
    Cheerful
    Downloads
    1
    Uploads
    0

    Standard

    This is beggining to annoy me now. I'm trying to get a sound to play properly in a game that I'm currently developing, but it just won't work and I can't figure out why. I'm trying to get a sound to play continously as a laser if firing, without having it playing like 5 times at once, if that makes sense. I want it to loop continuously up until the point the laser stops firing. I'm not good at explaining things, so maybe this will help:

    Code:
    abc = Sound.load("a.wav", false)
    
    while true do
    
    if abc:playing() == false then
    abc:play()
    end
    
    end
    That's something I wrote in another file, just to see if I could get it to work elsewhere first, but it still gives me the same error, just saying 'Loop ingettable'. I don't see what I'm doing wrong. Oh, and if it helps at all, I'm using Luaplayer v0.16.

    Thanks in advance.

  25. #9415
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    The wav file needs to be mono and at a specific bitrate IIRC.

  26. #9416
    Seven Year Vet. BOW DOWN.
    Points: 14.794, Level: 78
    Level completed: 86%, Points required for next Level: 56
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Manchester, UK
    Beiträge
    2.240
    Points
    14.794
    Level
    78
    My Mood
    Cheerful
    Downloads
    1
    Uploads
    0

    Standard

    I had the mono / stereo problem at first, because I created the wav file myself, but that was quickly resolved. Also, thanks for the advice, I hadn't thought of that; I do have other sound effects that have worked in other lua programs, so I'll go find out what bitrate they are. Thanks a lot.

    EDIT:

    It's still being weird. I've tried quite a lot of bitrates and none of them will work, it will load and play the sound but at the point where I check to see if the siound is already playing, I always get an error. Odd.
    Geändert von Freshmilk (09-12-2008 um 06:09 AM Uhr)

  27. #9417
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    use a PCM unsigned 8 bit, mono .wav file, you can change the format of your sound files with goldwave audio player, if that is a bit too much hastle for you then just send me a link to the sound file and ill convert it for you.
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  28. #9418
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    A sound object does not have the method "playing"

    sound: play() returns a voice object, which you can then manipulate (e.g. stop, playing, etc)

    so:
    Code:
    sound = Sound.load(file)
    soundVoice = sound:play()
    
    ...
    if not soundVoice:playing() then
    	soundVoice = sound:play()
    end
    Next time, read the function documentation
    http://wiki.ps2dev.org/psp:lua_playe...ound_and_music

  29. #9419
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    I had I sound problem too I tried to play a wav. file, for the sound of a ball bumping against the wall =, but the problem was that it played a sec. later.
    Also, I had it in front of the calculation, would that matter.
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  30. #9420
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Hi, haven't posted here in a while, i was wondering, how could someone code Layers in Lua? For images in Lua. E.g background layer, spirte layer etc.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 12:46 AM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .