Seite 238 von 342 ErsteErste ... 138 188 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 288 338 ... LetzteLetzte
Zeige Ergebnis 7.111 bis 7.140 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 SG57 TP - Have you considered using a OO approach to your programming? Nothing's wrong with what you ...

  
  1. #7111
    QJ Gamer Silver
    Points: 20.361, Level: 90
    Level completed: 3%, Points required for next Level: 489
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    ~* Confidential *~
    Beiträge
    839
    Points
    20.361
    Level
    90
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    TP - Have you considered using a OO approach to your programming? Nothing's wrong with what you currently do, but I highly recommend it (that doesnt mean much though, as ive yet to release anything decent using it (anything actually :P) but that will change soon)
    youresam: For something as simple as a filebrowser, implementing OOP would be both useless and a waste of time.

    Did this for youresam, for reasons that you have to ask him yourself.



    "Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder."-me
    Anime/Manga and Fanfiction is my inspiration!

    Creator of:
    - PSPSDK makefile creator - Lua Prompt - Animated Sprite Class\Library for Lua - Gmax2PSP -

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

    Well, relay this to youresam:

    When did i tell him to make a filebrowser OO? your implying just because the quetsion he answered, when really, it was an 'in-general' type of thing, as I believe OO programming is 'better' then any other type (given the project is suitable for it).

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


  3. #7113
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    he said:

    youresam: OOP is a better programming style, but only for certain things. Simple things dont need OOP, and it should be avoided, whereas most other things, OOP is a good thing. And learn the rule of the square bracket.

  4. #7114
    QJ Gamer Green
    Points: 40.380, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    Grand Line
    Beiträge
    5.996
    Points
    40.380
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Holy crap, I actually understand the code now that I'm almost done with Java class. I need to start developing again. Jeez.
    [CENTER][IMG]http://img130.imageshack.us/img130/1640/acefcbanner2wo9.gif[/IMG]
    [SIZE=1][B]I'm soo hot[/B][/SIZE]
    [/CENTER]
    [SIZE=2][CENTER][/SIZE][/CENTER]
    [center]Sorry. No Advertising[/center]

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

    Best of luck, however, i recommend using C as, from what i hear, Java has heavy (a lot of) syntax that must be followed, so it wouldnt be that difficult using C knowing you must follow some strict syntax (all from what i hear, is Java closer to Lua or C?)

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


  6. #7116
    QJ Gamer Blue
    Points: 5.303, Level: 46
    Level completed: 77%, Points required for next Level: 47
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    219
    Points
    5.303
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Java is closer to C,

    As the guys who created JAVA based JAVA's Syntax on C-ish style.

  7. #7117
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    OO is a great design flow to follow and it is good to get into it early. Whether or not it is a large project, it is always good to keep an OO approach to things.

    Before youresam gets another person to flame me, yes, this is opinon based.

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

    Either use OO programming all the time, or none of the time... You cant get experience and improve by object orienting only projects you feel are big enough for it.

    PSPJunkie - i think you mean 'bias'...

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


  9. #7119
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    To make it more portable, here's a function for what you want:
    Code:
    function randomFloatFromOrigin(center,range)
         return ( math.random( (center-range), (center+range) )+math.random() )
    end
    I believe that will work, however, i havent tested it.
    Zitat Zitat von LMelior
    Code:
    function math.randfloat(low, high)
       x=math.random()*(high-low)+low
       return x
    end
    That might work.
    Zitat Zitat von Merick
    well if you take my version and just use a range in the first section like this:

    var = math.random(-10, 10)+math.random()

    you will get a float between -10 and 10

    if you want to set the range based on your original value, then do it like this:

    var = math.random( (orig-10), (orig+10) )+math.random()
    goodd thaks you all guys, i will be testhig this stuff as sson as in have some more free time and a pc thks

  10. #7120
    QJ Gamer Blue
    Points: 4.812, Level: 44
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    London, United Kingdom
    Beiträge
    131
    Points
    4.812
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    By using gsub, how can I extract only the file name from the path?

    Example
    C:\somepath\somefile.tmp

    Results in "somefile"

    Cant get my head around the patterns.

  11. #7121
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    filepath = "C:\somepath\somefile.tmp";
    for loop = 0 , sizeof(filepath) do
          if(filepath[loop] == '\') then 
                    currentPosition = 0;
           end
          else if filepath[loop] == '.' then
                    currentPosition = -1;
           end
          else if currentPosition != -1 then
               filename[currentPosition] = filepath[loop];
               currentPosition++;
           end
    end
    k , this will be probebly horrible LUA

  12. #7122
    QJ Gamer Blue
    Points: 4.812, Level: 44
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    London, United Kingdom
    Beiträge
    131
    Points
    4.812
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    imageName = string.gsub(string.gsub(s tring.gsub(currentlyPlayi ng.values["Thumb"],"(.*\\)([^\\]+)$","%2"),";;",";"),".tb n","")

    Thats what I got now
    Except it relies on the file being a .tbn which is making things harder for me.
    Too many string.gsubs IMO.

    Thanks for the effort though...

  13. #7123
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I've got a partially working function for that using string.sub instead of gsub. It doesn't quite work though because I'm having trouble figuring out how to compare a character from the string to the \ . Anyway, what I have so far:

    Code:
    function find_name(text)
    
    for i = text:len(), 1, -1 do
    	if string.sub(text, i, i) == "." then
    		local name_end = i-1
    	end
    	if string.sub(text, i, i) == "\" then
    		local name_start = i+1
    	end
    end
    
    return string.sub(text, name_start, name_end)
    
    end
    if you could figure out how to get this line to work:

    if string.sub(text, i, i) == "\"

    then with this:

    filename = find_name(""C:\somepath\s omefile.tmp")

    filename would be "somefile"

  14. #7124
    QJ Gamer Blue
    Points: 4.812, Level: 44
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    London, United Kingdom
    Beiträge
    131
    Points
    4.812
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    In lua "\\" means "\"
    You cant use "\"

    Code:
    if string.sub(text, i, i) == "\\"
    That should work

    I'll give it a go...
    Thanks!

  15. #7125
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    well, I tried to use "\\" but that didn't work either. now that I think about it, it's probably because the text string with the file path only has single \'s in it, so lua probably skips over it. If you change all the \ over to / it will work, however I don't know how that will effect the rest of your program

    anyway, I looked at my code again and re-wrote it a little:

    Code:
    function find_name(text)
    	for i = 1, text:len() do
    		if string.sub(text, i, i) == "\\" then
    			name_start = i+1
    		elseif string.sub(text, i, i) == "." then
    			name_end = i-1
    		end
    	end
    	return string.sub(text, name_start, name_end)
    end

  16. #7126
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    Code:
    filepath = "C:\somepath\somefile.tmp";
    for loop = 0 , sizeof(filepath) do
          if(filepath[loop] == '\') then 
                    currentPosition = 0;
           end
          else if filepath[loop] == '.' then
                    currentPosition = -1;
           end
          else if currentPosition != -1 then
               filename[currentPosition] = filepath[loop];
               currentPosition++;
           end
    end
    k , this will be probebly horrible LUA
    What language is that?

  17. #7127
    QJ Gamer Blue
    Points: 4.812, Level: 44
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    London, United Kingdom
    Beiträge
    131
    Points
    4.812
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Certainly isn't lua
    -= Double Post =-
    Code:
    imageName = string.gsub(string.gsub(currentlyPlaying.values["Thumb"],"(.*\\)([^\\]+)$","%2"),"%.[^%.]*$","")
    Got it
    Geändert von trex6662k5 (04-27-2007 um 03:23 PM Uhr) Grund: Automerged Doublepost

  18. #7128
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    lol, and I just figured it out with my function too

    if you use double square brackets [[]] instead of "", then lua will not parse the escape sequences in the text:

    Code:
    filepath = [[C:\somepath\somefile.tmp]]
    white=Color.new(255,255,255)
    
    function find_name(text)
    	for i = 1, text:len() do
    		if string.sub(text, i, i) == [[\]] then
    			name_start = i+1
    		elseif string.sub(text, i, i) == "." then
    			name_end = i-1
    		end
    	end
    	return string.sub(text, name_start, name_end)
    end
     
    filename = find_name(filepath)
    screen:clear()
    screen:print(10,10, filename, white)
    screen:flip()
    
    pad = Controls.read()
    
    while not pad:cross() do
    	pad = Controls.read()
    end

  19. #7129
    QJ Gamer Blue
    Points: 4.812, Level: 44
    Level completed: 31%, Points required for next Level: 138
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    London, United Kingdom
    Beiträge
    131
    Points
    4.812
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    I'll keep that in mind

  20. #7130
    QJ Gamer Blue
    Points: 4.296, Level: 41
    Level completed: 73%, Points required for next Level: 54
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    132
    Points
    4.296
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    i kno i am doing something wrong, gives me an error ( i am a nooob at LUA)

    PHP-Code:
    --Load images into a table
    Images 
    = {
        
    Image.load("images/background.jpg"),
        
    Image.load("epic.png"),
        
    Image.load("img_3.png"),
        
    Image.load("img_4.png"),
        
    Image.load("img_5.png"),
        
    Image.load("img_6.png"),
        
    Image.load("img_7.png")
    }

    currentImageToDisplay 1;  

    while 
    true do
        
    screen:clear()
        
    pad Controls.read()
        
        if 
    pad:r() and currentImageToDisplay table.getn(Imagesthen
            currentImageToDisplay 
    currentImageToDisplay 1;
        
    end
        
        
    if pad:l() and currentImageToDisplay 0 then
            currentImageToDisplay 
    currentImageToDisplay 1;
        
    end

        screen
    :blit(00Images[background]);
        
        
    screen.waitVblankStart() 
        
    screen.flip()
    end 
    EDIT

    PHP-Code:
    --Load images into a table
    Images 
    = {
        
    Image.load("images/background.jpg"),
        
    Image.load("images/epic.png"),
        
    }

    currentImageToDisplay 1;  

    while 
    true do
        
    screen:clear()
        
    pad Controls.read()
        
        if 
    pad:r() and currentImageToDisplay table.getn(Imagesthen
            currentImageToDisplay 
    currentImageToDisplay 1;
        
    end
        
        
    if pad:l() and currentImageToDisplay 0 then
            currentImageToDisplay 
    currentImageToDisplay 1;
        
    end

        screen
    :blit(00Images[currentImageToDisplay]);
        
        
    screen.waitVblankStart() 
        
    screen.flip()
    end 
    ok i can get the images to load but when i try to go back to an image it says

    index.lua :22: bad argument #2 to /blit/ (image expected, got nil)
    Error: no script file found
    Geändert von cruisx (04-28-2007 um 05:53 PM Uhr)

  21. #7131
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    in lua, tables start at 1, so here:

    if pad:l() and currentImageToDisplay > 0

    you need to change the 0 to a 1

  22. #7132
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    i have one question, when i try to redefine Player.x and Player.y, how come when i run the game Player's moves are limited but not only that but the Player moves in like a invisible box, and then it just resets back to the middle of the invisible box

  23. #7133
    QJ Gamer Blue
    Points: 4.296, Level: 41
    Level completed: 73%, Points required for next Level: 54
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    132
    Points
    4.296
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    really sorry for the doubble post but i have a prob

    Code:
    --Load images into a table
    Images = {
        Image.load("images/background.jpg"),
        Image.load("images/epic.png"),
        Image.load("images/test2.jpg"),
        Image.load("images/work2.jpg")
        
    }
    
    currentImageToDisplay = 1;  
    
    while true do
        screen:clear()
        pad = Controls.read()
        
        if pad:r() and currentImageToDisplay < table.getn(Images) then
            currentImageToDisplay = currentImageToDisplay + 1;
        end
        
        if pad:l() and currentImageToDisplay > 1 then
            currentImageToDisplay = currentImageToDisplay - 1;
        end
    
        screen:blit(0, 0, Images[currentImageToDisplay]);
        
        screen.waitVblankStart() 
        screen.flip()
    end
    when i try to run it, it skips rlly fast from pic 1 to pic 2. The pics in between load for like 0.1 secconds lol. can someone pls help =)

  24. #7134
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Urameshi: can't be sure without seeing the code, but to me it sounds like instead of adding the analog x,y to the screen position you are using the analog position as the actual screen position

    cruisx: right after you flip the screen, add this line: "oldpad = pad"
    then, add this to your if statments: "and pad ~= oldpad"

  25. #7135
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Merick
    can't be sure without seeing the code, but to me it sounds like instead of adding the analog x,y to the screen position you are using the analog position as the actual screen position
    there ya go

    Code:
    white=Color.new(255,255,255)
    
    ball=Image.load("./Images/ball.png")
    Sball=Image.load("./Images/Spike Ball.png")
    square=Image.load("./Images/10x10.jpg")
    bigSquare=Image.load("./Images/30x30.jpg")
    stick=Image.load("./Images/190x23.jpg")
    lvl=Image.load("./Images/backgrounds/silkwave black.png")
    menu=Image.load("./Images/menu.png")
    next=Image.load("./Images/next level.png")
    stick2=Image.load("./Images/23x190.png")
    
    ball:width()
    ball:height()
    
    screenwidth=480-ball:width()
    screenheight=272-ball:width()
    
    Player={x=40,y=25,w=40,h=40,img=ball,oldimg=Sball}
    
    Enemy={x=0,y=0,w=30,h=30,img=bigSquare,}
    Square={x=0,y=0,w=10,h=10,img=square}
    Stick={x=0,y=0,w=190,h=23,img=stick}
    Stick2={x=0,y=0,w=23,h=190,img=stick2}
    
    enemylist = {}
    enemylist[1] = Stick1
    enemylist[2] = Stick2
    --------------------------------------------------------------------------functions
    function menu1()
    pad=Controls.read()	
    screen:blit(0,0,menu)
    
    if pad:cross() then
    level1()
    end
    end
    ------------------------------------------------------lvl1
    function level1()
    	while true do
    	screen:clear()
    Enemy.x=100
    Enemy.y=100
    
    if collision(Player,Enemy) then
    screen:blit(0,0,next)
    screen.flip()
    screen.waitVblankStart(90)
    level2()
    end
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    
    screen.waitVblankStart()
    screen.flip()
    end
    end
    ---------------------------------------------------lvl2
    function level2()
    	while true do
    	screen:clear()
    Enemy.x=300
    Enemy.y=50
    
    if collision(Player,Enemy) then
    screen:blit(0,0,next)
    screen.flip()
    screen.waitVblankStart(90)
    level3()
    end
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    
    screen.waitVblankStart()
    screen.flip()
    end
    end
    ---------------------------------------------------lvl3
    function level3()
    nbc=0
    ncc=2
    	while true do
    	screen:clear()
    Enemy.x=400
    Enemy.y=50
    Stick.x=117
    Stick.y=234
    Stick2.x=230
    Stick2.y=0
    
    if collision(Player,Enemy) then
    screen:blit(0,0,next)
    screen.flip()
    screen.waitVblankStart(90)
    level4()
    end
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    screen:blit(Stick.x,Stick.y,Stick.img)
    screen:blit(Stick2.x,Stick2.y,Stick2.img)
    screen.waitVblankStart()
    screen.flip()
    end
    end
    -------------------------------------------------------------------------level4
    function level4()
    run=false
    nbc=0
    ncc=1
    	while true do
    	screen:clear()
    Enemy.x=40
    Enemy.y=50
    Stick.x=117
    Stick.y=234
    Stick2.x=230
    Stick2.y=0
    Square.x=470
    Square.y=45
    
    if collision(Player,Stick2) and Player.img==Player.oldimg then 
    nbc=nbc-1 
    else if collision(Player,Stick2) then
    nbc=nbc+1
    end
    end
    
    if nbc>ncc then
    dofile("br.lua")
    end
    
    if collision(Player,Square) then
    Player.img = Player.oldimg
    end
    
    if collision(Player,Enemy) then
    screen:blit(0,0,next)
    screen.flip()
    screen.waitVblankStart(90)
    level5()
    end
    
    screen:blit(Stick2.x,Stick2.y,Stick2.img)
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    screen:blit(Stick.x,Stick.y,Stick.img)
    screen:blit(Square.x,Square.y,Square.img)
    screen.waitVblankStart()
    screen.flip()
    end
    end
    
    ----------------------------------------------------------------------Level 5
    function level5()
    run=false
    nbc=0
    ncc=1
    	while true do
    	screen:clear()
    Enemy.x=378
    Enemy.y=49
    Stick.x=384
    Stick.y=79
    Stick2.x=280
    Stick2.y=90
    Square.x=22
    Square.y=236
    Player.x=14
    Player.y=17
    
    if collision(Player,Stick2) and Player.img==Player.oldimg then 
    nbc=nbc-1 
    else if collision(Player,Stick2) then
    nbc=nbc+1
    end
    end
    
    if nbc>ncc then
    dofile("br.lua")
    end
    
    if collision(Player,Square) then
    Player.img = Player.oldimg
    end
    
    screen:blit(Stick2.x,Stick2.y,Stick2.img)
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    screen:blit(Stick.x,Stick.y,Stick.img)
    screen:blit(Square.x,Square.y,Square.img)
    screen.waitVblankStart()
    screen.flip()
    end
    end
    
    --------------------------------------------------------------------------Other Function
    function collision(ob1_,ob2_) 
         if (ob1_.x + ob1_.w > ob2_.x) and (ob1_.x < ob2_.x + ob2_.w) and (ob1_.y + ob1_.h > 
    
    ob2_.y) and (ob1_.y < ob2_.y + ob2_.h) then 
              return true 
         else 
              return false 
         end 
    end
    
    function movePlayer()
    pad=Controls.read()
    
    if pad:right() and Player.x < screenwidth then
    Player.x=Player.x + 5
    end
    
    if pad:left() and Player.x>0 then
    Player.x=Player.x - 5
    end
    
    if pad:down() and Player.x < screenheight then
    Player.y=Player.y + 5
    end
    
    if pad:up() and Player.y>0 then
    Player.y=Player.y - 5 else if not pad:up() then
    Player.y=Player.y + 8
    end
    end
    end
    
    falling=false
    
    ------------------------------------------------------------------------Main loop
    while true do
    screen:clear()
    
    menu1()
    
    screen.waitVblankStart()
    screen.flip()
    end

  26. #7136
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    first, at the beginning of your script you've got this:

    ball:width()
    ball:height()

    there are no operations on these, so what are you trying to do there?

    as for the movement problem, I can't really see anything that would cause the behavior you described

  27. #7137
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    idk why those
    ball:width()
    ball:height()
    are there either i just have alot of useless stuff in there

  28. #7138
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von cruisx
    really sorry for the doubble post but i have a prob

    Code:
    --Load images into a table
    Images = {
        Image.load("images/background.jpg"),
        Image.load("images/epic.png"),
        Image.load("images/test2.jpg"),
        Image.load("images/work2.jpg")
        
    }
    
    currentImageToDisplay = 1;  
    
    while true do
        screen:clear()
        pad = Controls.read()
        
        if pad:r() and currentImageToDisplay < table.getn(Images) then
            currentImageToDisplay = currentImageToDisplay + 1;
        end
        
        if pad:l() and currentImageToDisplay > 1 then
            currentImageToDisplay = currentImageToDisplay - 1;
        end
    
        screen:blit(0, 0, Images[currentImageToDisplay]);
        
        screen.waitVblankStart() 
        screen.flip()
    end
    when i try to run it, it skips rlly fast from pic 1 to pic 2. The pics in between load for like 0.1 secconds lol. can someone pls help =)
    you can use an oldpad type thing:
    Code:
    oldpad = Controls.read()
    while true do
    pad = Controls.read()
    if pad:cross() and oldpad:cross() ~= pad:cross() then
         --do something
    end
    oldpad = pad
    end
    here, if you hold cross, it will only execute the "do something" once. It waits for you to lift off the button, and press it again before it re-executes.
    -= Double Post =-
    @ Urameshi:

    i think your problem is that you define your players x and y values in the main loop. Therefor once you move, you are just moved back once the loop restarts again.
    Geändert von emericaska8r (04-29-2007 um 05:38 AM Uhr) Grund: Automerged Doublepost

  29. #7139
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    thanks dude that worked

  30. #7140
    QJ Gamer Blue
    Points: 4.561, Level: 43
    Level completed: 6%, Points required for next Level: 189
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    224
    Points
    4.561
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    no problem


 

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

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