Seite 121 von 342 ErsteErste ... 21 71 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 171 221 ... LetzteLetzte
Zeige Ergebnis 3.601 bis 3.630 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; Code: screenwidth = 480 - player:width() screen height = 272 - player: width () im not a big pro but ...

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

    Code:
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    im not a big pro but is this OK?

    btw. i found what was the problem of this code...

    Code:
    Music.playFile("music.xm ", true)
    i just had to put it outside main loop :o



  2. #3602
    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

    Zitat Zitat von myschoo
    Code:
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    im not a big pro but is this OK?
    yeah thats ok but now i have a new error
    Code:
    System.usbDiskModeActivate()
    line = Image.load("line.png")
    player = Image.load("player.png")
    linee = Image.load("line1.png")
    
    
    Player = { }
    Player[1] = { x = 10, y = 75 }
    playerHeight = 60
    playerWidth = 66
    oldx = Player.x
    oldy = Player.y
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    
    --Colisions
    function collisionCheck(object)
    if (Player.x + playerWidth > linem.x) and (Player.x < linemx + linem.width) and (Player.y + playerHeight > linem.y) and (Playery < linem.y + linem.height) then
    Player.x = oldx
    Player.y = oldy
    end
    end
    
    
     
    linem = { }
    linem[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(linem[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
    error:attempt to perform arithmetic on global 'X' and sometimes it says 'player x' insted of 'x' i under stand what its telling me but i dont understand why its telling me :P
    [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

  3. #3603
    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 iamcanadian
    yeah thats ok but now i have a new error
    Code:
    System.usbDiskModeActivate()
    line = Image.load("line.png")
    player = Image.load("player.png")
    linee = Image.load("line1.png")
    
    
    Player = { }
    Player[1] = { x = 10, y = 75 }
    playerHeight = 60
    playerWidth = 66
    oldx = Player.x
    oldy = Player.y
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    
    --Colisions
    function collisionCheck(object)
    if (Player.x + playerWidth > linem.x) and (Player.x < linemx + linem.width) and (Player.y + playerHeight > linem.y) and (Playery < linem.y + linem.height) then
    Player.x = oldx
    Player.y = oldy
    end
    end
    
    
     
    linem = { }
    linem[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(linem[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
    error:attempt to perform arithmetic on global 'X' and sometimes it says 'player x' insted of 'x' i under stand what its telling me but i dont understand why its telling me :P
    You have this line:

    oldx = Player.x
    oldy = Player.y

    and this line

    Player.x = oldx
    Player.y = oldy

    But you use neither of these variables, and you didn't define any of them. You defined each one of them as being equal to an undefined variable. It's a giant loop. Just take them out, or do something like

    Player.x = 0
    Player.y = 0
    oldx = 0
    oldy = 0

    Just to define them in some way.

  4. #3604
    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

    You also changed the code inside the collisionCheck function. Change it back.

  5. #3605
    Points: 3.800, Level: 38
    Level completed: 50%, Points required for next Level: 150
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Beiträge
    18
    Points
    3.800
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    I have a game where I print a 'bottle' to the screen when x is pushed, and it moves across the screen. Now I am having an issue being able to stop printing it once its x cord hits 0, so you can send another bottle down. I have the code to print it in a function, so its not working out to well. Heres my code.

    Code:
     
    function bottleSpawn()
    randSpeed = math.random(2,6)
    
    if bottleCheckTop == true then
    bottle[1].x = bottle[1].x - randSpeed
    screen:blit(bottle[1].x, bottle[1].y, Bottle)
    end
    
    --and...
    
    if pad:cross() and player.y == -20 then
    bottleCheckTop = true
    Any ideas to make iit possible to send more then one 'bottle' at a time?

    (Seems like such a simple problem, but I just can't figure it out. :rtfm: (What does RTFM mean anyways?))

  6. #3606
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    try maybe
    Code:
    i = 1
    
    function bottleSpawn()
    randSpeed = math.random(2,6)
    
    if bottleCheckTop == true then
    bottle[i].x = bottle[i].x - randSpeed
    screen:blit(bottle[i].x, bottle[i].y, Bottle)
    
    if bottle[i].x == 0 then
    i = i+ 1
    end
    end
    BTW, you need and 'end' here:
    Code:
    if pad:cross() and player.y == -20 then
    bottleCheckTop = true

  7. #3607
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von rybarnes
    I have a game where I print a 'bottle' to the screen when x is pushed, and it moves across the screen. Now I am having an issue being able to stop printing it once its x cord hits 0, so you can send another bottle down. I have the code to print it in a function, so its not working out to well. Heres my code.

    Code:
     
    function bottleSpawn()
    randSpeed = math.random(2,6)
    
    if bottleCheckTop == true then
    bottle[1].x = bottle[1].x - randSpeed
    screen:blit(bottle[1].x, bottle[1].y, Bottle)
    end
    
    --and...
    
    if pad:cross() and player.y == -20 then
    bottleCheckTop = true
    Any ideas to make iit possible to send more then one 'bottle' at a time?

    (Seems like such a simple problem, but I just can't figure it out. :rtfm: (What does RTFM mean anyways?))
    read the f*ckin manual.

  8. #3608
    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

    help me im getting this error quite alot:

    Code:
    <eof> expected near "end"
    what does it mean ?

  9. #3609
    Points: 3.800, Level: 38
    Level completed: 50%, Points required for next Level: 150
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Beiträge
    18
    Points
    3.800
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von myschoo
    help me im getting this error quite alot:

    Code:
    <eof> expected near "end"
    what does it mean ?
    You have one to many ends in your code.

  10. #3610
    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 myschoo
    help me im getting this error quite alot:

    Code:
    <eof> expected near "end"
    what does it mean ?
    It means that somewhere you forgot to put an 'end'. Probably at the end of a function or if/then statement.

  11. #3611
    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 ARza
    It means that somewhere you forgot to put an 'end'. Probably at the end of a function or if/then statement.

    actually, it means the opposite. you have an extra end somewhere. if you needed an end, it would say:

    Code:
    error: line: 'end' expected to close whatever.. on line ..whatever.
    --------------------------------------------------------------------------------------

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

    thx guys...it was true i removed end and it worked

  13. #3613
    Look at my user title :p
    Points: 14.103, Level: 77
    Level completed: 14%, Points required for next Level: 347
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Texas
    Beiträge
    1.183
    Points
    14.103
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    ok so i starte to code my game from the ground up again and i am just trying a simple code i made heres the error i get:
    error: script.lua:6: function arguments wxpected near 'while'
    heres my code:
    Code:
    red = Color.new(0,0,255)
    main1 = Image.load("main1.png")
    screen:print(0,0,"injustice",red)
    screen.flip()
    screen:clear
    while true do
    screen:clear
    screen:blit(0,0,main1)
    screen:clear
    screen.waitVblankStart()
    end 
    end
    i dont know whats wrong again. please dont flame me i just cant get this programing thing down but im trying

  14. #3614
    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 %chrono trigger%
    ok so i starte to code my game from the ground up again and i am just trying a simple code i made heres the error i get:
    error: script.lua:6: function arguments wxpected near 'while'
    heres my code:
    Code:
    red = Color.new(0,0,255)
    main1 = Image.load("main1.png")
    screen:print(0,0,"injustice",red)
    screen.flip()
    screen:clear
    while true do
    screen:clear
    screen:blit(0,0,main1)
    screen:clear
    screen.waitVblankStart()
    end 
    end
    i dont know whats wrong again. please dont flame me i just cant get this programing thing down but im trying

    youre not putting () after screen:clear(). it should be:

    Code:
    red = Color.new(0,0,255)
    main1 = Image.load("main1.png")
    screen:print(0,0,"injustice",red)
    screen.flip()
    screen:clear()
    while true do
    screen:clear()
    screen:blit(0,0,main1)
    screen:clear()
    screen.waitVblankStart()
    end 
    end
    btw, when it says function arguments, its usually referring to the ().
    --------------------------------------------------------------------------------------

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

    And you have to many 'end's.

  16. #3616
    Look at my user title :p
    Points: 14.103, Level: 77
    Level completed: 14%, Points required for next Level: 347
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Texas
    Beiträge
    1.183
    Points
    14.103
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    yeah i know i have to many ends i just typed one more its not in my code and with the function arguments is it always parentheses or can it be something else? i read in a error index that thats all it is plus thank you all for being patient with me and my noob questions

  17. #3617
    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 %chrono trigger%
    yeah i know i have to many ends i just typed one more its not in my code and with the function arguments is it always parentheses or can it be something else? i read in a error index that thats all it is plus thank you all for being patient with me and my noob questions

    its the parenthesis most of the time. im not sure though.
    --------------------------------------------------------------------------------------

  18. #3618
    Look at my user title :p
    Points: 14.103, Level: 77
    Level completed: 14%, Points required for next Level: 347
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Texas
    Beiträge
    1.183
    Points
    14.103
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    are there multiple reasons for why after you load the script it just stays black? or is that becasue of one main thing (error; mistake in the code)

  19. #3619
    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 %chrono trigger%
    and is there something generic that you always do if the screen just stays black? or are there multiple reasons for that?
    say what? in laymans terms please. ;)
    --------------------------------------------------------------------------------------

  20. #3620
    Look at my user title :p
    Points: 14.103, Level: 77
    Level completed: 14%, Points required for next Level: 347
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Texas
    Beiträge
    1.183
    Points
    14.103
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    i update my last post
    -= Double Post =-
    i updated my last post
    Geändert von %chrono trigger% (10-08-2006 um 08:50 PM Uhr) Grund: Automerged Doublepost

  21. #3621
    QJ Gamer Green
    Points: 5.559, Level: 48
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    506
    Points
    5.559
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von %chrono trigger%
    are there multiple reasons for why after you load the script it just stays black? or is that becasue of one main thing (error; mistake in the code)
    Well ofcourse there is an error in the code if the screen stays black. Or your screen just broke...

    Also watch out that you don't devide something by zero. Then the screen will also stay black and the PSP will crash. This is sometimes harder to see, because there isn't an obvious mistake. You'll have to check if it's possible that the denominator (that's what its caled right?) becomes zero yourself.
    LUA manual:
    [url]http://www.lua.org/manual/5.0/manual.html[/url]

    LUA Wiki:
    [url]http://wiki.ps2dev.org/psp:lua_player[/url]

  22. #3622
    Points: 3.873, Level: 39
    Level completed: 49%, Points required for next Level: 77
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Beiträge
    47
    Points
    3.873
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    is there a file number limiter in lua?

    I know there is a file size limiter but what about file number? I tried to load 100 sequenced .png (all 480x272) files and it gave me an error saying load failed. I thought it exceeded the file size limit so i tried 100 sequenced .jpgs. It didn't gave me the error but it froze up and crash. Then i tried 20 but it still crash. The most i could get is like 10 or so. I have checked the total size of all my pngs and it's less than 2mb. I used some script to check my free memory and it said i had 8MB free without loading all the images. :Argh:

    I have an OGG on playback in my script by the way. It may affect it?

    Can someone tell me workaround for this? I've seen people adding a lot sprites into one png but can someone tell me an example on how to do this, for say 10 x 10 images? I am currently using a .pkg file and extracting sprites out to load it.

    Please help me. Thanks :)
    Geändert von Fuzzie360 (10-11-2006 um 04:59 AM Uhr)

  23. #3623
    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 collision

    pls help i cant figure out whats the problem with this code:

    Code:
    white = Color.new(255,255,255)
    
    blockA = Image.createEmpty(480,1)
    blockA:clear(white)
    
    blockB = Image.createEmpty(480,1)
    blockB:clear(white)
    
    blockC = Image.createEmpty(1,272) 
    blockC:clear(white)
    
    blockD = Image.createEmpty(1,272)
    blockD:clear(white)
    
    BlockA = { x = 0, y = 0, height = blockA:height(), width = blockA:width() }
    
    BlockB = { x = 0, y = 271, height = blockB:height(), width = blockB:width() }
    
    BlockC = { x = 0, y = 0, height = blockC:height(), width = blockC:width() }
    
    BlockD = { x = 479, y = 0, height = blockD:height(), width = blockD:width() }
    
    player = Image.createEmpty(32,32)
    player:clear(white)
    
    Player = { x = 30, y = 100 }
    
    playerHeight = 32
    playerWidth = 32
    
    
    function movePlayer()
    pad = Controls.read()
    if pad:right() then
    Player.y = Player.y + 5
    end
    if pad:left() then
    Player.y = Player.y - 5
    end
    if pad:down() then
    Player.x = Player.x + 5
    end
    if pad:up() then
    Player.x = Player.x - 5
    end
    end
    
    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
    
    while true do
    
    oldx = Player.x
    oldy = Player.y
    screen:clear()
    
    collisionCheck(BlockA)
    collisionCheck(BlockB)
    collisionCheck(BlockC)
    collisionCheck(BlockD)
    
    screen:clear()
    
    movePlayer()
    
    screen:blit(Player.y,Player.x,player)
    
    screen:blit(BlockA.x,BlockA.y,blockA)
    
    screen:blit(BlockB.x,BlockB.y,blockB)
    
    screen:blit(BlockC.x,BlockC.y,blockC)
    
    screen:blit(BlockD.x,BlockD.y,blockD)
    
    screen.waitVblankStart()
    screen.flip()
    end
    it ment to stop player to get out from the screen but it doesnt work... can figure out what the prob :Cry: HELP

  24. #3624
    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 don't see any problems, but i havn't slept in 27 hours, so obviously my judgement will be affected...

  25. #3625
    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

    me to! i cant see any problems but it still doesnt work!!

  26. #3626
    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

    Didn't I tell you to look at your code and think logically what it will do? ;)

    I was going to tell you exactly what's wrong, but I don't feel like explaining. So I'll give you a hint: the order that you do things in your loop is the problem.

  27. #3627
    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 myschoo
    pls help i cant figure out whats the problem with this code:

    Code:
    white = Color.new(255,255,255)
    
    blockA = Image.createEmpty(480,1)
    blockA:clear(white)
    
    blockB = Image.createEmpty(480,1)
    blockB:clear(white)
    
    blockC = Image.createEmpty(1,272) 
    blockC:clear(white)
    
    blockD = Image.createEmpty(1,272)
    blockD:clear(white)
    
    BlockA = { x = 0, y = 0, height = blockA:height(), width = blockA:width() }
    
    BlockB = { x = 0, y = 271, height = blockB:height(), width = blockB:width() }
    
    BlockC = { x = 0, y = 0, height = blockC:height(), width = blockC:width() }
    
    BlockD = { x = 479, y = 0, height = blockD:height(), width = blockD:width() }
    
    player = Image.createEmpty(32,32)
    player:clear(white)
    
    Player = { x = 30, y = 100 }
    
    playerHeight = 32
    playerWidth = 32
    
    
    function movePlayer()
    pad = Controls.read()
    if pad:right() then
    Player.y = Player.y + 5
    end
    if pad:left() then
    Player.y = Player.y - 5
    end
    if pad:down() then
    Player.x = Player.x + 5
    end
    if pad:up() then
    Player.x = Player.x - 5
    end
    end
    
    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
    
    while true do
    
    oldx = Player.x
    oldy = Player.y
    screen:clear()
    
    collisionCheck(BlockA)
    collisionCheck(BlockB)
    collisionCheck(BlockC)
    collisionCheck(BlockD)
    
    screen:clear()
    
    movePlayer()
    
    screen:blit(Player.y,Player.x,player)
    
    screen:blit(BlockA.x,BlockA.y,blockA)
    
    screen:blit(BlockB.x,BlockB.y,blockB)
    
    screen:blit(BlockC.x,BlockC.y,blockC)
    
    screen:blit(BlockD.x,BlockD.y,blockD)
    
    screen.waitVblankStart()
    screen.flip()
    end
    it ment to stop player to get out from the screen but it doesnt work... can figure out what the prob :Cry: HELP
    Why do all that collision checking, when you can just put:
    Code:
    if pad:left() and player.x > 0 then
    player.x = player.x - 2
    end
    Just do that for all the sides. It's much easier.

  28. #3628
    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

    Zitat Zitat von LMelior
    Didn't I tell you to look at your code and think logically what it will do? ;)

    I was going to tell you exactly what's wrong, but I don't feel like explaining. So I'll give you a hint: the order that you do things in your loop is the problem.
    wow ur my master i got it :)
    -= Double Post =-
    Zitat Zitat von ARza
    Why do all that collision checking, when you can just put:
    Code:
    if pad:left() and player.x > 0 then
    player.x = player.x - 2
    end
    Just do that for all the sides. It's much easier.
    im learning by evilmana tuts and thats how they explained it...:)
    Geändert von myschoo (10-12-2006 um 10:04 AM Uhr) Grund: Automerged Doublepost

  29. #3629
    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 myschoo
    wow ur my master i got it :)
    -= Double Post =-


    im learning by evilmana tuts and thats how they explained it...:)
    [rant]
    i HATE it when some people have to do EVERYTHING by the tutorials.. geez, use YOUR brain for once! ever heard of the saying "there is more than one way to do something" ? LISTEN to it... [/rant] (not talking about you myscoo, just using you as an example. )

    anyways, myscoo try different things. try all ideas you get, one might help your performance a lot.
    --------------------------------------------------------------------------------------

  30. #3630
    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

    Read tutorial 7 of ProgramLua. That'll help you so your player doesn't go off screen.


 

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

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