Seite 311 von 342 ErsteErste ... 211 261 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 ... LetzteLetzte
Zeige Ergebnis 9.301 bis 9.330 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; But first you need to put something like this in your code: Code: System.playAllMp3sInASpecificDirectoryOneAfterTheOther = function(dir) local list = System.listDirectory(dir) ...

  
  1. #9301
    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

    But first you need to put something like this in your code:
    Code:
    System.playAllMp3sInASpecificDirectoryOneAfterTheOther = function(dir)
    	local list = System.listDirectory(dir)
    	local bgcolor = Color.new(255,255,255)
    	table.remove(list,1)
    	table.remove(list,1)
    	for i = 1, table.getn(list) do
    		if not list[i].directory and string.lower(string.sub(list[i].name,-4)) == ".mp3" then
    			local path = dir.."/"..list[i].name
    			Mp3.load(path)
    			Mp3.play()
    			screen:print(0,0,path.." is playing and has been for")
    			while Mp3.eos ~= "true" do --note its a string not a boolean because some people are idiots
    				screen:clear(bgcolor)
    				screen:print((string.len(path)*8)+232,0,Mp3.gettime())
    				screen.flip()
    				screen.waitVblankStart(30)
    			end
    			Mp3.stop()
    		end
    	end
    end
    Also, the first letter of a function name is not capitalized (play not Play)



  2. #9302
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Ruining the fun, as usual, TurtlesPwn, I see.

  3. #9303
    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

    Oh come on I hate handing them code as much as you do, but im a junkie for making them go away

  4. #9304
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Oh snap, inside jokes suck

  5. #9305
    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

    Yea I don't think anybody except me, you, and one other person has any idea what the hell we're talking about. Let's let the noobs take back this thread.

  6. #9306
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Deal.

    (You can't stop me)
    -=Double Post Merge =-
    Har har, turtle is a pretty funny guy
    Geändert von _dysfunctional (08-21-2008 um 06:45 PM Uhr) Grund: Automerged Doublepost

  7. #9307
    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

    Oh why thank you, I've always wanted to be a comedian, but whenever I do something truly epic and funny I get in trouble

  8. #9308
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    And I thought our relationship was far past this nonsense. I forgive you <3

  9. #9309
    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

    *is confused due to confusion and unsureness of sarcasm detector*

  10. #9310
    OMFG
    Points: 19.453, Level: 88
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Toronto
    Beiträge
    2.814
    Points
    19.453
    Level
    88
    Downloads
    0
    Uploads
    0

    Standard

    my gaydar is going craaaaazy






    jk

  11. #9311
    Points: 2.976, Level: 33
    Level completed: 51%, Points required for next Level: 74
    Overall activity: 27,0%

    Registriert seit
    Sep 2007
    Beiträge
    5
    Points
    2.976
    Level
    33
    Downloads
    0
    Uploads
    0

    Standard

    I need help..my problem is that when I have like a menu and a submenu like this
    Code:
    if state="mainmenu" then
    --draw code--
        if pad:cross() and oldpad ~= pad then
        state="submenu"
        end
    end
    
    if state="submenu" then
    --draw code--
       if pad:cross() and oldpad ~= pad then
       --start game, etc
       end
    end
    The problem with this is it all happens too fast...I think it does all the code when you hold down cross because you still didnt lift it up yet. It works if I change one of them to a different button...and I tried to use system.sleep but it didnt work does anybody know how to solve this?

  12. #9312
    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

    Code:
    while true do
    if state == "MainMenu" then
         if pad:cross() and oldpad:cross() ~= pad:cross() then
              state = "SubMenu"
         end
    end
    
    if state == "SubMenu" then
         if pad:cross() and oldpad:cross() ~= pad:cross() then
              --start Game
         end
    end
    end
    -=Double Post Merge =-
    Zitat Zitat von _dysfunctional Beitrag anzeigen
    On a serious note, I was looking through the docs, and found this function:
    Code:
    System.PlayAllMp3sInASpecificDirectoryOneAfterTheOther(dirname)
    You should try that.
    -.-
    -=Double Post Merge =-
    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    Oh come on I hate handing them code as much as you do, but im a junkie for making them go away
    oh thanks.....-.-'
    Geändert von Digikid13 (08-22-2008 um 10:16 AM Uhr) Grund: Automerged Doublepost
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  13. #9313
    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

    Do an else if:
    Code:
    if state=="mainmenu" then
    --draw code--
        if pad:cross() and oldpad ~= pad then
        state="submenu"
        end
    elseif state=="submenu" then
    --draw code--
       if pad:cross() and oldpad ~= pad then
       --start game, etc
       end
    end
    The reason why it wasn't working was because it could process the second if statement after the state has changed in the same frame. ie:

    Code:
    if state=="mainmenu" then
    --draw code--
        if pad:cross() and oldpad ~= pad then
        state="submenu"
        end
    end
    Players presses Cross, state is now "submenu". It then processes the second if statement in the same frame so pad:cross is still false and oldpad is different to pad.
    Geändert von yaustar (08-22-2008 um 03:20 PM Uhr)

  14. #9314
    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

    also make sure you are using the right check functions

    Code:
    if something == "this" then
    --aaaaa
    end
    not
    Code:
    if something = "this" then
    --aaaaa
    end
    ------ 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).

  15. #9315
    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

    Do'h, fixed.

  16. #9316
    Points: 2.976, Level: 33
    Level completed: 51%, Points required for next Level: 74
    Overall activity: 27,0%

    Registriert seit
    Sep 2007
    Beiträge
    5
    Points
    2.976
    Level
    33
    Downloads
    0
    Uploads
    0

    Standard

    I tried adding elseif and else if neither worked though...I get

    error: index.lua: 82: 'end' expected (to close ' function' at line 28) near 'else'
    Error: No script file found.

    It runs without the else though..I dont get why

  17. #9317
    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

    Zitat Zitat von kevkevg Beitrag anzeigen
    I tried adding elseif and else if neither worked though...I get

    error: index.lua: 82: 'end' expected (to close ' function' at line 28) near 'else'
    Error: No script file found.

    It runs without the else though..I dont get why
    post the code and i will fix it for you right now.

    EDIT:

    nvm i just looked up and found it this has been said before but if it doesnt work then try the code below that, if that doesnt work then post your whole script and ill fix it.

    Code:
    if state == "mainmenu" then
    --draw code--
        if pad:cross() and oldpad ~= pad then
            state = "submenu"
        end
    elseif state = "submenu" then
    --draw code--
       if pad:cross() and oldpad ~= pad then
           --start game, etc
       end
    end
    Code:
    if state == "mainmenu" then
    --draw code--
        if pad:cross() and oldpad ~= pad then
            state = "submenu"
            oldpad = Controls.read():cross()
        end
    elseif state = "submenu" then
    --draw code--
       if pad:cross() and oldpad ~= pad then
           --start game, etc
       end
    end
    EDIT 2:

    Damn I just wasted my 1337'est post on this!
    Geändert von FaT3oYCG (08-22-2008 um 07:51 PM Uhr)
    ------ 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).

  18. #9318
    Points: 2.976, Level: 33
    Level completed: 51%, Points required for next Level: 74
    Overall activity: 27,0%

    Registriert seit
    Sep 2007
    Beiträge
    5
    Points
    2.976
    Level
    33
    Downloads
    0
    Uploads
    0

    Standard

    It doesnt work..Ill post my code but its pretty long. Also keep in mind this doesnt really do anything yet..im just working on the menu. Its going to be a tycoon game and I will be fixing up the graphics. Also the else ifs are spread apart alot
    Code:
    math.randomseed(os.time())
    System.usbDiskModeActivate()
    --Colors
    white = Color.new(255, 255, 255)
    red = Color.new(255,0,0)
    green= Color.new(0,255,0)
    blue=Color.new(0,0,255)
    --Font
    font = Font.load("Comic.ttf")
    font:setPixelSizes(0,15)
    
    --Variables
    state="menu"
    select=0
    
    money=100
    fans=0
    skill=0
    
    moneyearned=0
    fansgained=0
    expenses=0
    totalearned=0
    
    
    --Functions
    
    function menu()
    if state=="menu" then
       if select==0 then
       screen:fontPrint(font,20,100,"Start Day",blue)
       screen:fontPrint(font,20,120,"Location",white)
       screen:fontPrint(font,20,140,"Lessons",white)
       screen:fontPrint(font,20,160,"Equipment",white)
       end
    
       if select==1 then
       screen:fontPrint(font,20,100,"Start Day",white)
       screen:fontPrint(font,20,120,"Location",blue)
       screen:fontPrint(font,20,140,"Lessons",white)
       screen:fontPrint(font,20,160,"Equipment",white)
       end
    
       if select==2 then
       screen:fontPrint(font,20,100,"Start Day",white)
       screen:fontPrint(font,20,120,"Location",white)
       screen:fontPrint(font,20,140,"Lessons",blue)
       screen:fontPrint(font,20,160,"Equipment",white)
       end
    
       if select==3 then
       screen:fontPrint(font,20,100,"Start Day",white)
       screen:fontPrint(font,20,120,"Location",white)
       screen:fontPrint(font,20,140,"Lessons",white)
       screen:fontPrint(font,20,160,"Equipment",blue)
       end
    
       if pad:cross() and oldpad ~= pad then
          if select==0 then 
          state="startday" 
          select=0
          end
    
          if select==1 then
          state="locations"
          select=0
          end
    
          if select==2 then
          state="lessons"
          select=0
          end
    
          if select==3 then
          state="equipment"
          select=0
          end
       end
    end
    
    --startday
    elseif state="startday" then
    moneyearned=(fans*math.random(5))+10
    fansgained=math.floor(moneyearned/2)
    expenses=0
    totalearned=moneyearned-expenses
    
    screen:fontPrint(font,20,100,"Money Earned: ",white)
    screen:fontPrint(font,140,100,moneyearned,white)
    
    screen:fontPrint(font,20,120,"Fans Gained: ",white)
    screen:fontPrint(font,140,120,fansgained,white)
    
    screen:fontPrint(font,20,140,"Expenses: ",red)
    screen:fontPrint(font,140,140,expenses,red)
    
    screen:fontPrint(font,20,160,"Total: ",white)
    screen:fontPrint(font,140,160,totalearned,white)
    end
    
    elseif state="locations" then
    screen:fontPrint(font,20,80,"Choose Location",white)
    
       if select==0 then
       screen:fontPrint(font,20,100,"The Bronx",blue)
       screen:fontPrint(font,20,120,"Manhatten",white)
       end
    
       if select==1 then
       screen:fontPrint(font,20,100,"The Bronx",white)
       screen:fontPrint(font,20,120,"Manhatten",blue)
       end
    
       if pad:circle() and oldpad~=pad then
       state="menu"
       end
    end
    
    elseif state="lessons" then
    
       if select==0 then
       screen:fontPrint(font,20,100,"Take Lessons",blue)
       screen:fontPrint(font,20,120,"Leave",white)
       end
    
       if select==1 then
       screen:fontPrint(font,20,100,"Take Lessons",white)
       screen:fontPrint(font,20,120,"Leave",blue)
       end
    
       if pad:circle() and oldpad ~= pad then
       state="menu"
       end
    
       if pad:cross() and oldpad ~= pad then
          if select==0 then
          skill=skill+1
          money=money-skill*100
          state="menu"
          select=2
          end
    
          if select==1 then
          state="menu"
          select=2 
          end
       end
    end
    
    
    --Update Select
    if pad:down() and oldpad ~= pad then
    select=select+1
    end
    if pad:up() and oldpad ~= pad then
    select=select-1
    end
    if select>3 then
    select=0
    end
    if select<0 then
    select=3
    end
    
    
    end
    
    
    --Main Loop
    while true do
    screen:clear()
    pad=Controls.read()
    
    screen:fontPrint(font,5,15,"Money:",white)
    screen:fontPrint(font,55,15,money,white)
    screen:fontPrint(font,100,15,"Fans:",white)
    screen:fontPrint(font,160,15,fans,white)
    
    menu()
    
       if pad:triangle() then
       break
       end
    
    oldpad=pad
    screen.waitVblankStart()
    screen.flip()
    end

  19. #9319
    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

    Aside from the fact that the menu code is horrible, and your indenting is ridiculous, elseifs work like this:

    Code:
    if exp then block elseif exp then block end
    ( http://www.lua.org/manual/5.1/manual.html#2.4.4 )

    As you can see, you multiple times have:
    Code:
    end
    
    elseif state=...

  20. #9320
    Points: 2.976, Level: 33
    Level completed: 51%, Points required for next Level: 74
    Overall activity: 27,0%

    Registriert seit
    Sep 2007
    Beiträge
    5
    Points
    2.976
    Level
    33
    Downloads
    0
    Uploads
    0

    Standard

    How can I make it easier..because it gets kind of complicated. Should I use switch statements(if lua even has them). Also are you saying I cant have multiple elses.

  21. #9321
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    What he means is, you are doing:
    Code:
    if blah then
        -- something
    end
    elseif blah then
        -- something else
    end
    when you should be doing:
    Code:
    if blah then
        -- something
    elseif blah then
        -- something else
    end

  22. #9322
    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

    To make it easier, use tables and loops.
    Code:
    colour1 = Color.new(128,128,128)
    colour2 = Color.new(255,255,255)
    
    options = {
    	"lol1",
    	"lol2",
    	"lol3"
    }
    
    selection = 1
    seperation = 50
    
    while true do
    	--normal int stuff
    	
    	if pad:up and not oldpad:up() then
    		selection = selection - 1
    	end
    	if pad:down and not oldpad:down() then
    		selection = selection + 1
    	end
    	
    	if selection > table.getn(options) then
    		selection = 1
    	elseif selection < 1 then
    		selection = table.getn(options)
    	end
    	
    	for i, text in ipairs(options) do
    		if selection == i then
    			screen:print(50, (i - 1) * seperation, text, colour1)
    		else
    			screen:print(50, (i - 1) * seperation, text, colour2)
    		end
    	end
    	
    	--normal end stuff
    end
    Oh, and you can do multiple elseif. (I suggest you look through the lua reference manual to avoid these problems in future).

    Code:
    if blah then
    	lolcat
    elseif blah2 then
    	loldog
    elseif blah3 then
    	lolbird
    end

  23. #9323
    QJ Gamer Blue
    Points: 3.563, Level: 37
    Level completed: 43%, Points required for next Level: 87
    Overall activity: 54,0%

    Registriert seit
    Sep 2007
    Beiträge
    149
    Points
    3.563
    Level
    37
    Downloads
    0
    Uploads
    0

    Standard

    Hi all.

    I'm using the HM function to save date with officiel Sony Data Manager but Lua Player HM is always putting on the save a ugly ICON0 and PIC1. Does someone knoe how to fix it ?

  24. #9324
    QJ Gamer Silver
    Points: 12.501, Level: 73
    Level completed: 13%, Points required for next Level: 349
    Overall activity: 62,0%

    Registriert seit
    Sep 2007
    Ort
    AUS
    Beiträge
    284
    Points
    12.501
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    I will fix it
    Wyvern. That is all

  25. #9325
    Raining
    Points: 7.355, Level: 57
    Level completed: 3%, Points required for next Level: 195
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    In The Fog...
    Beiträge
    545
    Points
    7.355
    Level
    57
    My Mood
    Relaxed
    Downloads
    0
    Uploads
    0

    Standard

    Agh, my brain isn't working. I have been figuring out a whole bunch of things on my own but right now I guess I am feeling too much pressure to figure this out. This might seem simple to you all but for some reason I just can't wrap my head around ti. I am sure if I just spend some time thinking about it I will eventually get it but I would appreciate it if anyone can give me a hint as to how I would solve the following problem:

    Okay, if I were making a dodging style game where the speed kept increasing after every 30 seconds how would I do that? I want all of the objects to advance in speed and make sure that the game could go on to infinity if someone were that good(or maybe if I set an AI to control the player and make it able to dodge all the objects). How would I do this? Just a rough explanation or a quick example would be nice. I do not need a full blown explanation.

    Thanks,
    -Daniel

  26. #9326
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    You would do something like...

    Code:
    local timer = Timer()
    timer:start()
     
    local last = 0
     
    while gameRunning do
        local delta = timer:delta()
        local diff = delta - last
        if diff > (30 seconds) then
            PlayerSpeed = PlayerSpeed + 1
        end
     
        last = delta
     
        -- Other stuff
     
    end

  27. #9327
    Raining
    Points: 7.355, Level: 57
    Level completed: 3%, Points required for next Level: 195
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    In The Fog...
    Beiträge
    545
    Points
    7.355
    Level
    57
    My Mood
    Relaxed
    Downloads
    0
    Uploads
    0

    Standard

    Thank you dysfunctional. What does "timer:delta()" get? I have not used that before.

  28. #9328
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Those aren't actual luaplayer functions, I just used the names of the classes I export to lua in my own 'luaplayer'. Timer:delta() is the amount of time that passed since the timer started. If you look up the documentation to whichever lib you use (I suggest PGELua), you will find the corresponding function name.

  29. #9329
    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

    In luaplayer:
    Code:
    timer = Timer.new()
    timer:start()
     
    while gameRunning do
        if timer:time() > 30000 then
            PlayerSpeed = PlayerSpeed + 1
            timer:reset()
        end
    
        -- Other stuff
     
    end
    In PGE Lua: (Is't the delta the time since the last timer update?)
    Code:
    timer = pge.timer.create()
    
    timerTime = 0
    
    while gameRunning do
        timerTime = timerTime + timer:getdelta()
        if timerTime > 30000 then
            PlayerSpeed = PlayerSpeed + 1
            timerTime = 0
        end
    
        -- Other stuff
     
    end
    or simpler (but possabily slower):
    Code:
    timer = pge.timer.create()
    
    while gameRunning do
        timer:update()
        if timer:totalTime > 30000 then
            PlayerSpeed = PlayerSpeed + 1
            timer = pge.timer.create()
        end
    
        -- Other stuff
     
    end
    Geändert von Nielkie (08-24-2008 um 07:25 PM Uhr)

  30. #9330
    Raining
    Points: 7.355, Level: 57
    Level completed: 3%, Points required for next Level: 195
    Overall activity: 0%

    Registriert seit
    Jun 2005
    Ort
    In The Fog...
    Beiträge
    545
    Points
    7.355
    Level
    57
    My Mood
    Relaxed
    Downloads
    0
    Uploads
    0

    Standard

    Okay, thanks Nielkie and dystfunctional. That just made me feel like an idiot. Now that I look at it it seems so obvious. Thanks guys.


 

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 09:01 PM Uhr.

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