Seite 120 von 342 ErsteErste ... 20 70 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 170 220 ... LetzteLetzte
Zeige Ergebnis 3.571 bis 3.600 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; I wonder if your image load portion needs fixed! Anyways, anyone ko whats wrong with my script?...

  
  1. #3571
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    I wonder if your image load portion needs fixed! Anyways, anyone ko whats wrong with my script?



  2. #3572
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TacticalPenguin
    Oh, ok. It says:

    Error: index.lua :6: function arguments expected near 'scree'

    Press start to restart

    you write screen clear like this:

    Code:
    screen:clear
    it SHOULD be:
    Code:
    screen:clear()
    --------------------------------------------------------------------------------------

  3. #3573
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    OH I FORGOT THE LITTLE PARENTHESES THINGIES!!!!!!!!!!!!!!!!! !!!!!!

    Do I also need to do that on screen.flip?

  4. #3574
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TacticalPenguin
    Do I also need to do that on screen.flip?
    Yep.

    It's nice that these problems are working themselves out. :) The error descriptions are quite good, aren't they?

  5. #3575
    NeilR is back
    Points: 4.503, Level: 42
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    canada.. duh
    Beiträge
    180
    Points
    4.503
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    lol now i feel more dumb i cant fix my image problem and it works fine on my computer so im confused
    -= Double Post =-
    never mind i figured it out
    Geändert von iamcanadian (10-01-2006 um 05:11 PM Uhr) Grund: Automerged Doublepost
    [SPOILER="Donations"]Donators: TMK 1Mill, cowsruledaworld 300k, Arsonist 75k and 10 k, and thx spiral for the
    prem....Thank you every one that has donated :D[/SPOILER]
    [SPOILER="funny comic of the day!!!"][IMG]http://www.explosm.net/db/files/Comics/Matt/self-diagnosis.png[/IMG][/SPOILER]
    Join #QJChat and #marshalls on IRC, at irc.toc2rta.com

  6. #3576
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Ok, it shows the text up to where it should display the background pic then it shows this:

    Error: index.lua:14: Image.load: Error loading image.

    Press start to restart

    My code now is:

    Code:
    blue = Color.new(0, 0, 255)
    screen:print(0, 0, "Loading: 30%", blue)
    screen.flip()
    screen.waitVblankStart(120)
    screen:clear()
    screen:print(0, 0, "Loading: 70%", blue)
    screen.flip()
    screen.waitVblankStart(120)
    screen:clear()
    screen:print(0,0, "Loading Complete", blue)
    screen.flip()
    screen.waitVblankStart(120)
    screen:clear()
    background = Image.load("background.jpg")
    screen:print(0, 0, "Tux says hello!", blue)
    screen.flip()
    screen.waitVblankStart(240)
    screen:clear()
    background = Image.load("background.jpg")
    screen:print(0, 0, "Tux says goodbye!", blue)
    screen.flip()
    screen.waitVblankStart(180)
    while true do
    screen.waitVblankStart()
    end
    The pic is named background.jpg and is in the same directory as index.lua

  7. #3577
    NeilR is back
    Points: 4.503, Level: 42
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    canada.. duh
    Beiträge
    180
    Points
    4.503
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    ok i have 2 new problems now
    1. how do i make the car move faster and smoother (if you need to look at my code its in the last page
    2.how do i make a button to return to the lua player
    [SPOILER="Donations"]Donators: TMK 1Mill, cowsruledaworld 300k, Arsonist 75k and 10 k, and thx spiral for the
    prem....Thank you every one that has donated :D[/SPOILER]
    [SPOILER="funny comic of the day!!!"][IMG]http://www.explosm.net/db/files/Comics/Matt/self-diagnosis.png[/IMG][/SPOILER]
    Join #QJChat and #marshalls on IRC, at irc.toc2rta.com

  8. #3578
    QJ Gamer Silver
    Points: 11.326, Level: 70
    Level completed: 19%, Points required for next Level: 324
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    871
    Points
    11.326
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    how can i do this:

    if timerD > 120 and < 140 then characterL = Run_L[7] end

    where "and" is writin i dont know what to put to do:

    if timer D is > then 120 but < then 140

    My part of code:

    Code:
    if timerL == 140 then timerL = 0 end
    if timerL >= 120 < 140 then characterL = Run_L[7] end
    if timerL >= 100 < 120 then characterL = Run_L[6] end
    if timerL >= 80  < 100 then characterL = Run_L[5] end
    if timerL >= 60  < 80 then characterL = Run_L[4] end
    if timerL >= 40  < 60 then characterL = Run_L[3] end
    if timerL >= 20  < 40 then characterL = Run_L[2] end
    if timerL >= 0   < 20 then characterL = Run_L[1] end
    Free Prizes at Prizerebel Join us!
    I already got 11 Gifts. Ask me for details or proof.

  9. #3579
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    ZeroX, you must do:
    Code:
    if timerL >= 0 and timerL < 20 then characterL = Run_L[1] end
    But for all of them...

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  10. #3580
    QJ Gamer Silver
    Points: 11.326, Level: 70
    Level completed: 19%, Points required for next Level: 324
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    871
    Points
    11.326
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Tkz SG57 tomorow when im done jumping and shooting and maybe a part of the level collision il send you a demo.TKZ i whas to tired to find it out TKZ
    Free Prizes at Prizerebel Join us!
    I already got 11 Gifts. Ask me for details or proof.

  11. #3581
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    @ Tactical Penguin

    I never use jpegs, always pngs, and I've never had a problem. How big in pixels is background.jpg? Make sure the capitalization and spelling is correct. Also, you load it twice, which you obviously don't need to do.


    @ iamcanadian

    1. These kinds of problems are ones where you have to do trial and error, because there's hardly ever just one way to do things. Faster is easy, just make it move more pixels per loop. However, it generally makes the movement seem less smooth when you make it faster.

    2. When the interpreter reaches the end of the code, it goes back to luaplayer. So all you have to do is "break" out of the main loop.


    @ ZereoX

    It is far more efficient to use elseif's when you are testing the same variable, because it only runs through the if statements until it finds a satisfied condition.

    SG57 posted the easiest way since I started, so I'll post another way, which is probably less efficient time-wise, but it does condense the two conditions into one (I suppose that makes it more efficient space-wise):

    Code:
    if math.abs(timerL-9.5) < 10 then characterL = Run_L[1] end
    and to use elseif's:

    Code:
    if math.abs(timerL-9.5) < 10 then 
       characterL = Run_L[1] 
    elseif math.abs(timerL-29.5) < 10 then 
       characterL = Run_L[2] 
    end

  12. #3582
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Ok guys, I got mine all fixed! Thanks for the help!

  13. #3583
    NeilR is back
    Points: 4.503, Level: 42
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    canada.. duh
    Beiträge
    180
    Points
    4.503
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    ok i got the break code to work but my whole script is slow for some reason
    [SPOILER="Donations"]Donators: TMK 1Mill, cowsruledaworld 300k, Arsonist 75k and 10 k, and thx spiral for the
    prem....Thank you every one that has donated :D[/SPOILER]
    [SPOILER="funny comic of the day!!!"][IMG]http://www.explosm.net/db/files/Comics/Matt/self-diagnosis.png[/IMG][/SPOILER]
    Join #QJChat and #marshalls on IRC, at irc.toc2rta.com

  14. #3584
    QJ Gamer Silver
    Points: 11.326, Level: 70
    Level completed: 19%, Points required for next Level: 324
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    871
    Points
    11.326
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    My works perfect thanks guys.


    PS.Im participating in the Dream coding compo sponsor by DCemu also Zion's compo sponsor by him hope you vote for me when im done.
    Cheers,ZereoX
    Free Prizes at Prizerebel Join us!
    I already got 11 Gifts. Ask me for details or proof.

  15. #3585
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von LMelior
    It's pretty nice because since it returns an integer, you don't have to do an if statement (in the simplest case, at least).

    Code:
    player.x=player.x+math.floor(pad:analogX()/32)
    player.y=player.y-math.floor(pad:analogY()/32)
    You'll have to mess with the signs a bit to get it right, but that takes care of movement in almost all directions.


    @ Tactical Penguin and iamcanadian:

    Post errors.
    I did try that, but I keep getting some error that has nothing to do with those two lines. I put this in:

    Code:
    mx=mx+math.floor(pad:analogX()/32)
    my=my+math.floor(pad:analogY()/32)
    But I get some stupid error. Could somone maybe post a working example?

  16. #3586
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von ARza
    I did try that, but I keep getting some error that has nothing to do with those two lines. I put this in:

    Code:
    mx=mx+math.floor(pad:analogX()/32)
    my=my+math.floor(pad:analogY()/32)
    But I get some stupid error. Could somone maybe post a working example?
    This is from one of my projects; you should be able to tell what it does and why I did it this way. It works for me and it's not that different from what you posted, so I don't know what's wrong with your code.
    Code:
    -- Allow player to change map offset with analog
    if pad:analogX()<0 then
    	mapoffset.x=mapoffset.x-math.floor(pad:analogX()^2/2500)
    elseif pad:analogX()>0 then
    	mapoffset.x=mapoffset.x+math.floor(pad:analogX()^2/2500)
    end
    if pad:analogY()<0 then
    	mapoffset.y=mapoffset.y-math.floor(pad:analogY()^2/2500)
    elseif pad:analogY()>0 then
    	mapoffset.y=mapoffset.y+math.floor(pad:analogY()^2/2500)
    end

  17. #3587
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von LMelior
    This is from one of my projects; you should be able to tell what it does and why I did it this way. It works for me and it's not that different from what you posted, so I don't know what's wrong with your code.
    Code:
    -- Allow player to change map offset with analog
    if pad:analogX()<0 then
    	mapoffset.x=mapoffset.x-math.floor(pad:analogX()^2/2500)
    elseif pad:analogX()>0 then
    	mapoffset.x=mapoffset.x+math.floor(pad:analogX()^2/2500)
    end
    if pad:analogY()<0 then
    	mapoffset.y=mapoffset.y-math.floor(pad:analogY()^2/2500)
    elseif pad:analogY()>0 then
    	mapoffset.y=mapoffset.y+math.floor(pad:analogY()^2/2500)
    end

    sry for the n00bish question, but what DOES math.floor do??
    --------------------------------------------------------------------------------------

  18. #3588
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Surely a pro in 2D Lua would know to check the Lua Reference Manual. ;) I'll give you a hint, you don't need a separate rounding function because math.floor(x + 0.5) does the exact same thing.

  19. #3589
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von LMelior
    Surely a pro in 2D Lua would know to check the Lua Reference Manual. ;) I'll give you a hint, you don't need a separate rounding function because math.floor(x + 0.5) does the exact same thing.

    i got burned... so let me guess, it removes the decimal off of any number?

    and the reference is just too boring for me. sad how i know metatables, but not this..:Cry:
    --------------------------------------------------------------------------------------

  20. #3590
    QJ Gamer Blue
    Points: 4.241, Level: 41
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Alabama
    Beiträge
    142
    Points
    4.241
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    it removes the decimal off of any number?
    Yeah. It rounds down (or, returns the largest integer <= a specific number), and is antonymous with math.ceiling.

    I usually don't check for things I don't know exist, either. It's just too bad you had to learn something so important on the streets.

  21. #3591
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Aphonia
    Yeah. It rounds down (or, returns the largest integer <= a specific number), and is antonymous with math.ceiling.

    I usually don't check for things I don't know exist, either. It's just too bad you had to learn something so important on the streets.
    i get it! floor - down, ceiling - up! corny, but it works!
    -= Double Post =-
    Zitat Zitat von ARza
    I did try that, but I keep getting some error that has nothing to do with those two lines. I put this in:

    Code:
    mx=mx+math.floor(pad:analogX()/32)
    my=my+math.floor(pad:analogY()/32)
    But I get some stupid error. Could somone maybe post a working example?

    here is some code that *should* work. havent tested it, but it should.

    Code:
    sentivity = 32 -- the higher you put this, the slower it will move--
    
    
    mx = mx + (pad:analogX()/sentivity)
    my = my + (pad:analogX()/sentivity)
    Geändert von Grimfate126 (10-02-2006 um 06:21 PM Uhr) Grund: Automerged Doublepost
    --------------------------------------------------------------------------------------

  22. #3592
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    hello i have 3 questions:

    1. i found this timer on evilmana.com site:

    Code:
    white = Color.new(255,255,255)
    
    counter = Timer.new()
    counter:start()
    while true do
    screen:clear()
    
    currentTime = counter:time()
    
    screen:print(10,10,"Counter Time: " .. currentTime,white)
    
    if currentTime < 1000 then
    screen:print(100,100,"Less than 1000",white)
    end
    
    if currentTime > 1000 and currentTime < 2000 then
    screen:print(100,100,"Greater than 1000",white)
    end
    
    if currentTime > 2000 then
    counter:reset(0)
    counter:start()
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    its really good BUT...its TOO FAST! ... its moving maybe 50-100 numbers/second...
    so HOW do i set it to 1 number in 1 sec???

    2. Question:

    Code:
    --biela
    white = Color.new(255,255,255)
    
    while true do
    screen:clear()
    pad = Controls.read()
    
    screen:print(190,100,"Autor: myschoo",white)
    screen:print(110,110,"Podakovanie: QJ forum a EvilMana.com",white)
    screen:print(140,120,"Stlac X pre navrat do menu",white)
    
    if pad:cross() then
    break
    end
    
    screen.waitVblankStart()
    screen.flip()
    end
    this is simple code for info...i want it so when i press X it throw me back in Main Menu...it works but only sometimes...normally a i have to tap the button and then it randomly close and im back in menu...sometimes i pres X once...sometimes 20 times... i dont know whats the problem :/

    3. question is similar to 1st question:

    Code:
    Music.playFile("music.xm", true)
    when i use this code i can hear only maybe 0.5 sec from music then it plays from start..again and again and again...how to STOP this???

    THX 4 answers!
    Geändert von myschoo (10-03-2006 um 10:14 AM Uhr)

  23. #3593
    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

    1. The timer is in milliseconds which is why it seems so fast. If you want seconds then simply divide it by 1000.
    Code:
    currentTimeInSecs = currentTime / 1000
    (You may want to floor it to get a whole number)

    2. You need to store the state of the button in the previous frame so you can tell the difference between a button press and a when you hold down the button.

  24. #3594
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    head_54us:

    thx mate 1st. thing sorted...i will try the second one

    edit. sorted :)

    so my last question again:

    "Music.playFile("music.xm ", true)"

    when i use this code, i dont know what to add so the music plays correctly...

  25. #3595
    i r leet lol
    Points: 17.776, Level: 84
    Level completed: 86%, Points required for next Level: 74
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    England
    Beiträge
    2.615
    Points
    17.776
    Level
    84
    Downloads
    0
    Uploads
    0

    Standard

    Well atleast someone sorted your problem out
    whyHELLOder.

  26. #3596
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    yeeh well good thread!!

  27. #3597
    NeilR is back
    Points: 4.503, Level: 42
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    canada.. duh
    Beiträge
    180
    Points
    4.503
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    System.usbDiskModeActivate()
    line = Image.load("line.png")
    player = Image.load("player.png")
    linee = Image.load("line1.png")
    
    --Colisions
    function collisionCheck(object)
    if (Player.x + playerWidth > object.x) and (Player.x < object.x + object.width) and (Player.y + playerHeight > object.y) and (Player.y < object.y + object.height) then
    Player.x = oldx
    Player.y = oldy
    end
    end
    
    
    
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    
    Player = { }
    Player[1] = { x = 10, y = 75 }
    playerHeight = 60
    playerWidth = 66
    oldx = Player.x
    oldy = Player.y
    
    
    
     
    line = { }
    line[1] = { x = 0, y = 150 }
    
    while true do
    
    pad = Controls.read()
    screen:clear()
    
    screen:blit(0,50,linee)
    
    screen:blit(0,150,line)
    
    
    --check collision for line
    collisionCheck(line[1])
    
    
    
    screen:blit(Player[1].x,Player[1].y,player)
    
    if pad:left() and Player[1].x > 0 then
    Player[1].x = Player[1].x - 4
    end
    
    if pad:right() and Player[1].x < screenwidth then
    Player[1].x = Player[1].x + 4
    end
    
    if pad:up() and Player[1].y > 0 then
    Player[1].y = Player[1].y - 4
    end
    
    if pad:down() and Player[1].y < screenheight then
    Player[1].y = Player[1].y + 4
    end
    
    if pad:start() then break end
    screen.waitVblankStart()
    screen.flip()
    end
    im just trying to ad collisions what am i doing wrong here?
    [SPOILER="Donations"]Donators: TMK 1Mill, cowsruledaworld 300k, Arsonist 75k and 10 k, and thx spiral for the
    prem....Thank you every one that has donated :D[/SPOILER]
    [SPOILER="funny comic of the day!!!"][IMG]http://www.explosm.net/db/files/Comics/Matt/self-diagnosis.png[/IMG][/SPOILER]
    Join #QJChat and #marshalls on IRC, at irc.toc2rta.com

  28. #3598
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von iamcanadian
    Code:
    System.usbDiskModeActivate()
    line = Image.load("line.png")
    player = Image.load("player.png")
    linee = Image.load("line1.png")
    
    --Colisions
    function collisionCheck(object)
    if (Player.x + playerWidth > object.x) and (Player.x < object.x + object.width) and (Player.y + playerHeight > object.y) and (Player.y < object.y + object.height) then
    Player.x = oldx
    Player.y = oldy
    end
    end
    
    
    
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    
    Player = { }
    Player[1] = { x = 10, y = 75 }
    playerHeight = 60
    playerWidth = 66
    oldx = Player.x
    oldy = Player.y
    
    
    
     
    line = { }
    line[1] = { x = 0, y = 150 }
    
    while true do
    
    pad = Controls.read()
    screen:clear()
    
    screen:blit(0,50,linee)
    
    screen:blit(0,150,line)
    
    
    --check collision for line
    collisionCheck(line[1])
    
    
    
    screen:blit(Player[1].x,Player[1].y,player)
    
    if pad:left() and Player[1].x > 0 then
    Player[1].x = Player[1].x - 4
    end
    
    if pad:right() and Player[1].x < screenwidth then
    Player[1].x = Player[1].x + 4
    end
    
    if pad:up() and Player[1].y > 0 then
    Player[1].y = Player[1].y - 4
    end
    
    if pad:down() and Player[1].y < screenheight then
    Player[1].y = Player[1].y + 4
    end
    
    if pad:start() then break end
    screen.waitVblankStart()
    screen.flip()
    end
    im just trying to ad collisions what am i doing wrong here?
    whats your error?
    --------------------------------------------------------------------------------------

  29. #3599
    NeilR is back
    Points: 4.503, Level: 42
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    canada.. duh
    Beiträge
    180
    Points
    4.503
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    bad argument #2 'blit' (image expected, got table) but that dosent make sence beacuse it never had problems eith any blit's intill i added the collision script???
    [SPOILER="Donations"]Donators: TMK 1Mill, cowsruledaworld 300k, Arsonist 75k and 10 k, and thx spiral for the
    prem....Thank you every one that has donated :D[/SPOILER]
    [SPOILER="funny comic of the day!!!"][IMG]http://www.explosm.net/db/files/Comics/Matt/self-diagnosis.png[/IMG][/SPOILER]
    Join #QJChat and #marshalls on IRC, at irc.toc2rta.com

  30. #3600
    QJ Gamer Bronze
    Points: 5.975, Level: 50
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Alabama
    Beiträge
    272
    Points
    5.975
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    its because you created a table named line after you had already created line for an image.
    Change the name of one of the two.
    My lua tutorials for PSP - www.evilmana.com/tutorials
    PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/


 

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 07:53 AM Uhr.

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