Seite 262 von 342 ErsteErste ... 162 212 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 312 ... LetzteLetzte
Zeige Ergebnis 7.831 bis 7.860 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; * continues to have example ignored *...

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

    * continues to have example ignored *



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


  2. #7832
    QJ Gamer Blue
    Points: 3.726, Level: 38
    Level completed: 51%, Points required for next Level: 74
    Overall activity: 27,0%

    Registriert seit
    Jun 2007
    Beiträge
    82
    Points
    3.726
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    This is my main question code so far.

    System.usbDiskModeActivat e()
    question1 = "What is the common name of the disease that plagued medieval Europe?"
    answer1a = "Black Death"
    answer1b = "Bubonic Death"
    answer1c = "White Death"
    answer1d = "Dark Plague"
    question2 = "How long did the Hundred Years' War last?"
    answer2a = "100 Years"
    answer2b = "116 Years"
    answer2c = "123 Years"
    answer2d = "98 Years"
    question3 = "How was the Bubonic Plague spread throughout medieval Europe?"
    answer3a = "Ticks"
    answer3b = "Fleas"
    answer3c = "Rats"
    answer3d = "Beavers"
    question4 = "what object were Vikings buried in?"
    answer4a = "Crypts"
    answer4b = "Graves"
    answer4c = "Coffins"
    answer4d = "Their Ships"
    question5 = "What was another name for Vikings?"
    answer5a = "Plunderers"
    answer5b = "Wolfmen"
    answer5c = "Norsemen"
    answer5d = "They didn't have another name"
    question6 = "What countries did Vikings originate from?"
    answer6a = "Denmark, Sweden and Norway"
    answer6b = "Greenland, Iceland and Switzeland"
    answer6c = "Icelad, Germany, Norway"
    answer6d = "Denmark, Switzeland and Norway"
    question7 = "Knights fought on what?"
    answer7a = "Horses"
    answer7b = "Cows"
    answer7c = "Slaves"
    answer7d = "They fought on their own feet"
    question8 = "What 4 empires existed before the dark ages?"
    answer8a = "Chinese, Persian, Roman and American"
    answer8b = "Chinese, Japanese, Roman and British"
    answer8c = "Japanese, Britsh, Roman and Guptan"
    answer8d = "Chinese, Persian, Guptan and Roman"
    question9 = "How did the Roman's use the term barbarian"
    answer9a = "To describe invaders"
    answer9b = "To describe the strongest of their warriors"
    answer9c = "To describe foreigners"
    answer9d = "To describe warriors who had killed more than 100 people"
    question10 = "Why did Vikings originally travel overseas?"
    answer10a = "To steal people for slavery"
    answer10b = "To trade and barter"
    answer10c = "To steal food and animals"
    answer10d = "To explore"
    question11 = "What of the following were weapons used by vikings?"
    answer11a = "Double-Axe, Spear and Sword"
    answer11b = "Bows, Guns and Swords"
    answer11c = "Cannons, Rifles and Daggers"
    answer11d = "Daggers, Swords and rifles"
    pink = Color.new(255, 0 , 153)
    blue = Color.new(0 , 0, 255)
    orange = Color.new(255, 102, 0)
    gray = Color.new(153, 153, 153)
    black = Color.new(0 , 0 , 0)
    red = Color.new(255,0,0)
    green = Color.new(0,255,0)
    white = Color.new(255,255,255)
    oldpad = Controls.read()
    function printCentred(y,text,color )
    local length = string.len(text)
    local x = 240 - ((length*8)/2)
    screenrint(x,y,text,color)
    end
    RanNumber = 0 -
    math.randomseed(os.time() )
    RanNumber = math.random(1,11)
    gametimer=Timer.new()
    time=120
    gametimer:start()
    while true do
    pad = Controls.read()
    gamestime=gametimer:time( )
    screen:clear()
    if time == 0 then
    dofile("./sets.lua")
    end
    if gamestime > 1000 then time = time - 1 gametimer:reset(0) gametimer:start()
    end
    --Question Statement Starts Here
    if RanNumber == 1 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 1,green)
    printCentred(166,answer1a ,green)
    printCentred(176,answer1b ,green)
    printCentred(186,answer1c ,green)
    printCentred(196,answer1d ,green)
    screen.flip()
    if pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 2 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 2,green)
    printCentred(166,answer2a ,green)
    printCentred(176,answer2b ,green)
    printCentred(186,answer2c ,green)
    printCentred(196,answer2d ,green)
    screen.flip()
    if pad:left() and oldpad:left() ~= pad:left() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(20 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:up() and oldpad:up() ~= pad:up() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 3 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 3,green)
    printCentred(166,answer3a ,green)
    printCentred(176,answer3b ,green)
    printCentred(186,answer3c ,green)
    printCentred(196,answer3d ,green)
    screen.flip()
    if pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 4 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 4,green)
    printCentred(166,answer4a ,green)
    printCentred(176,answer4b ,green)
    printCentred(186,answer4c ,green)
    printCentred(196,answer4d ,green)
    screen.flip()
    if pad:down() and oldpad:down() ~= pad:down() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:up() and oldpad:up() ~= pad:up() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 5 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 5,green)
    printCentred(166,answer5a ,green)
    printCentred(176,answer5b ,green)
    printCentred(186,answer5c ,green)
    printCentred(196,answer5d ,green)
    screen.flip()
    if pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 6 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 6,green)
    printCentred(166,answer6a ,green)
    printCentred(176,answer6b ,green)
    printCentred(186,answer6c ,green)
    printCentred(196,answer6d ,green)
    screen.flip()
    if pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 7 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 1,green)
    printCentred(166,answer7a ,green)
    printCentred(176,answer7b ,green)
    printCentred(186,answer7c ,green)
    printCentred(196,answer7d ,green)
    screen.flip()
    if pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 8 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 8,green)
    printCentred(166,answer8a ,green)
    printCentred(176,answer8b ,green)
    printCentred(186,answer8c ,green)
    printCentred(196,answer8d ,green)
    screen.flip()
    if pad:down() and oldpad:down() ~= pad:down() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:up() and oldpad:up() ~= pad:up() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 9 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 9,green)
    printCentred(166,answer9a ,green)
    printCentred(176,answer9b ,green)
    printCentred(186,answer9c ,green)
    printCentred(196,answer9d ,green)
    screen.flip()
    if pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 10 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 10,green)
    printCentred(166,answer10 a,green)
    printCentred(176,answer10 b,green)
    printCentred(186,answer10 c,green)
    printCentred(196,answer10 d,green)
    screen.flip()
    if pad:left() and oldpad:left() ~= pad:left() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:up() and oldpad:up() ~= pad:up() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    --Question Statement Starts Here
    if RanNumber == 11 then
    screen:blit(0,0,backgroun d,false)
    screenrint(0,0,time,white)
    printCentred(0,"Question Number Is: "..RanNumber,green)
    printCentred(156,question 11,green)
    printCentred(166,answer11 a,green)
    printCentred(176,answer11 b,green)
    printCentred(186,answer11 c,green)
    printCentred(196,answer11 d,green)
    screen.flip()
    if pad:up() and oldpad:up() ~= pad:up() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    end
    if pad:down() and oldpad:down() ~= pad:down() or pad:left() and oldpad:left() ~= pad:left() or pad:right() and oldpad:right() ~= pad:right() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Incorre ct",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    --Question Statement Ends Here
    screen.waitVblankStart()
    oldpad = pad
    end

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

    eww... God invented arrays and structures for a reason ;)

    Look at my version for what I mean.

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


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

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

    Standard

    don't forget about code tags...
    that much text in a wall like that is enough to scare little kids like me

  5. #7835
    QJ Gamer Silver
    Points: 12.453, Level: 73
    Level completed: 1%, Points required for next Level: 397
    Overall activity: 80,0%

    Registriert seit
    Mar 2007
    Beiträge
    1.129
    Points
    12.453
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    yeah that is very scary. arrays would make it dynamic as well as easy to change and fix.

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

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

    Standard

    Zitat Zitat von drag_93
    This is my main question code so far.

    ...uGLY aSS cODE...
    Dude, At least put it in code tags. Also, The code structure is horrible, Its hard to read it. >.<

  7. #7837
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    seriously learn how to use an array it well make life so much easier

    anyways heres your prob:

    it's not choosing a new number because:

    if pad:left() and oldpad:left() ~= pad:left() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    end
    when the answer is correct you don't call the RanNumber again so do:

    if pad:left() and oldpad:left() ~= pad:left() then
    screen:clear()
    screen:blit(0,0,backgroun d,false)
    printCentred(156,"Correct ",green)
    screen.flip()
    screen.waitVblankStart(60 )
    RanNumber = math.random(1,11)
    end

    that well fix it however highly surgest you re-write it and use an array instead well be so much better to A incorporate new questions and B make your code so much clearer
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  8. #7838
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    what guys? it doesnt look so ba-*scrolls post* AAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAA!!!!!!! *dies of heart stress*

    LOL
    i could finish a potter book before that! wow!

    funny thing is, i remember when i posted something like this up and had youresam losing his mind. :ROFL: i believe i made interchangeable menus with different colors for text.. the very long way like this guy did here, good news is (knowing that): there is hope for this fellow too. :)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    Thumbs up

    Thanks people, I got my diagonal rectangle working.

    If anyone cares:

    Code:
    function GuRectangle(x,y,width,height,angle,colour)
    	local halfWidth = width/2
    	local halfHeight = height/2
    
    	triangles = {
    		{colour,-1*halfWidth,-1*halfHeight,0},
    		{colour,-1*halfWidth,1*halfHeight,0},
    		{colour,1*halfWidth,-1*halfHeight,0},
    
    		{colour,-1*halfWidth,1*halfHeight,0},
    		{colour,1*halfWidth,1*halfHeight,0},
    		{colour,1*halfWidth,-1*halfHeight,0}
    	}
    
    	Gum.matrixMode(Gu.MODEL)
    	Gum.loadIdentity()
    	Gum.translate(x, y, -290);
    	Gu.disable(Gu.TEXTURE_2D)
    	Gum.rotateXYZ(0, 0, angle * (math.pi/180))
    	Gum.drawArray(Gu.TRIANGLES, Gu.COLOR_8888+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, triangles)
    end

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

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

    Standard

    Thanks for the snippet!

  11. #7841
    QJ Gamer Silver
    Points: 12.453, Level: 73
    Level completed: 1%, Points required for next Level: 397
    Overall activity: 80,0%

    Registriert seit
    Mar 2007
    Beiträge
    1.129
    Points
    12.453
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    does anyone know how the paint bucket tool works? i could easily create a tool that fills a pixel, then checks its neighbors, and for each neighbor, repeat. but that would be extremely slow and memory consuming. it was done in yPaint by yongobongo, but he locked the script.

  12. #7842
    QJ Gamer Blue
    Points: 4.021, Level: 40
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Bavaria!
    Beiträge
    162
    Points
    4.021
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Hi guys, there is something that i havent understood yet...

    what does that mean: analogX/Y -ranges from -127 to 128

    what does that mean? I dont understand it? Why does it actually range from -127 to 128? Whats that good for? I need to understand...

  13. #7843
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    Thats so simple and makes perfect sense. Thanks for that, I'm still trying to get a handle on 3d designs, My background is in VBA apps so all these coordinates give me a headache sometimes.
    Just to Translate and further explain my understanding of this, Luaplayer considers your center point (the point at which the object is rotated) to be 0,0,0 . So when you build your object, be sure that you are making 0,0,0 your pivot point. Then no matter where to translate your object to, it will rotate at the center of your object. I mistook the original suggestion as to meaning that I could create my object, translate it to 0,0,0 (after the fact) and then it would rotate correctly, but it didn't quite work like that as I found out. Thanks again for the help.
    -= Double Post =-
    Zitat Zitat von bumuckl
    Hi guys, there is something that i havent understood yet...

    what does that mean: analogX/Y -ranges from -127 to 128

    what does that mean? I dont understand it? Why does it actually range from -127 to 128? Whats that good for? I need to understand...
    Its to determine how far to the left, right, up, down the stick is moved. This gives you the freedom to program pressure sensitivity into whatever app you're developing.
    Geändert von KleptoOne (07-31-2007 um 10:37 AM Uhr) Grund: Automerged Doublepost

  14. #7844
    QJ Gamer Blue
    Points: 4.021, Level: 40
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Bavaria!
    Beiträge
    162
    Points
    4.021
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    ah ok thx a lot...another thing: I dont know to make that real: If u move the dpad left on the x-axis, a picture should move right. Moving the picture aint so hard xD...the problem is, how can i tell my PSP that this should happen when i move dpad left...my code looks like this:

    pad = Controls.read()
    dx = pad:analogX()
    if math.abs(dx) > 32 then
    x0 = x0 + dx / sens
    end
    dy = pad:analogY()
    if math.abs(dy) > 32 then
    y0 = y0 + dy / sens
    end

    sens is a variable...soo dont worry, thats not the problem.

    so here is the picuter that should be moved right:
    screen:blit(box, boy, bg, 0, 0, bg:width(), bg:height(), false)
    box and boy are both varibles, in this case, box should increase while holding dpad left...

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

    As the d-pad can't be pressure sensitive (not without a hardware manipulation) just have

    dpad left: x0 = x0 - sens
    dpad right: x0 = x0 + sens
    dpad up: y0 = y0 - sens
    dpad down: y0 = y0 + sens

    Change the value of sens should you not want it to move full speed as if the analog were all the way pushed one direction.

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


  16. #7846
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von bumuckl
    ah ok thx a lot...another thing: I dont know to make that real: If u move the dpad left on the x-axis, a picture should move right. Moving the picture aint so hard xD...the problem is, how can i tell my PSP that this should happen when i move dpad left...my code looks like this:

    pad = Controls.read()
    dx = pad:analogX()
    if math.abs(dx) > 32 then
    x0 = x0 + dx / sens
    end
    dy = pad:analogY()
    if math.abs(dy) > 32 then
    y0 = y0 + dy / sens
    end

    sens is a variable...soo dont worry, thats not the problem.

    so here is the picuter that should be moved right:
    screen:blit(box, boy, bg, 0, 0, bg:width(), bg:height(), false)
    box and boy are both varibles, in this case, box should increase while holding dpad left...
    You mean the stick and I can't beleive this code is popping up again, I've explained a million times why this code is flawed... and here it goes again... math.abs() returns the absolute value of a number, meaning if its supposed to be -5, it will return 5, which means it will never go the other way because the number can never be negative... If you want to move something in some direction...
    Code:
    pad = Controls.read()
    if pad:analogX() > 30 then
        {move a direction}
    end
    if pad:analogX() < -30 then
        {move the other direction}
    end
    
    ....same idea for analogY()...

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

    Klepto, you're missing something here:

    Code:
    if math.abs(dy) > 32 then
    y0 = y0 + dy / sens
    This code is using the converted analog position only to check if the analog stick has been moved oustide the dead zone, the player movement formula here is using the original signed value of the analog to calculate the new coordinates, which will provide the correct movement. This setup lets you use one value comparison to see if the analog stick has been moved, compared with the two that would be needed without using math.abs

  18. #7848
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    Just to Translate and further explain my understanding of this, Luaplayer considers your center point (the point at which the object is rotated) to be 0,0,0 . So when you build your object, be sure that you are making 0,0,0 your pivot point. Then no matter where to translate your object to, it will rotate at the center of your object. I mistook the original suggestion as to meaning that I could create my object, translate it to 0,0,0 (after the fact) and then it would rotate correctly, but it didn't quite work like that as I found out. Thanks again for the help.
    Just a small note that this is not just limited to Lua Player, it's a generic 3D thing.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  19. #7849
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Merick
    Klepto, you're missing something here:

    Code:
    if math.abs(dy) > 32 then
    y0 = y0 + dy / sens
    This code is using the converted analog position only to check if the analog stick has been moved oustide the dead zone, the player movement formula here is using the original signed value of the analog to calculate the new coordinates, which will provide the correct movement. This setup lets you use one value comparison to see if the analog stick has been moved, compared with the two that would be needed without using math.abs
    oh I see, using the real value of dy as your movement speed and sens to limit the amount. Thats actually clever... my sneakers taste like rubber if anyone is wondering;-)

  20. #7850
    QJ Gamer Blue
    Points: 4.021, Level: 40
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Bavaria!
    Beiträge
    162
    Points
    4.021
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Guys i still dont get it working...the code is :
    dx = pad:analogX()
    if math.abs(dx) > 32 then
    x0 = x0 + dx / sens
    box = box - 1
    end
    if math.abs(dx) < -32 then
    x0 = x0 - dx / sens
    box = box + 1
    end
    dy = pad:analogY()
    if math.abs(dy) > 32 then
    y0 = y0 + dy / sens
    end
    if math.abs(dy) < -32 then
    y0 = y0 - dy / sens
    end

    The Problem is, when i press Dpad right, the image goes left, thats ok. But when i press Dpad-left, nothing happens, no it continues turnign right while pressing Dpad left...what is worng with it?

  21. #7851
    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

    bumuckl:

    math.abs returns absolute value from number, means:

    math.abs(-32) = 32
    math.abs(32) = 32
    so therefore this part:

    if math.abs(dx) < -32 then
    will NEVER happen

    this works for me:

    Code:
    pad = Controls.read()
    
    anaX = pad:analogX()
    anaY = pad:analogY()
    
    if anaX > 30 then
    Player.x = Player.x + (math.abs(pad:analogX())/ana)
    end
    
    if anaX < -30 then
    Player.x = Player.x - (math.abs(pad:analogX())/ana)
    end
    
    if anaY > 30 then
    Player.y = Player.y + (math.abs(pad:analogY())/ana)
    end
    
    if anaY < -30 then
    Player.y = Player.y - (math.abs(pad:analogY())/ana)
    end

  22. #7852
    QJ Gamer Blue
    Points: 4.021, Level: 40
    Level completed: 36%, Points required for next Level: 129
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Bavaria!
    Beiträge
    162
    Points
    4.021
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Thy very nice now ive understood...thy very much...ur going to be in the Credits...

  23. #7853
    QJ Gamer Silver
    Points: 12.453, Level: 73
    Level completed: 1%, Points required for next Level: 397
    Overall activity: 80,0%

    Registriert seit
    Mar 2007
    Beiträge
    1.129
    Points
    12.453
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    if anyone missed me,
    Zitat Zitat von Da_MerV
    does anyone know how the paint bucket tool works? i could easily create a tool that fills a pixel, then checks its neighbors, and for each neighbor, repeat. but that would be extremely slow and memory consuming. it was done in yPaint by yongobongo, but he locked the script.
    im still here

  24. #7854
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von myschoo
    bumuckl:

    math.abs returns absolute value from number, means:



    so therefore this part:



    will NEVER happen

    this works for me:

    Code:
    pad = Controls.read()
    
    anaX = pad:analogX()
    anaY = pad:analogY()
    
    if anaX > 30 then
    Player.x = Player.x + (math.abs(pad:analogX())/ana)
    end
    
    if anaX < -30 then
    Player.x = Player.x - (math.abs(pad:analogX())/ana)
    end
    
    if anaY > 30 then
    Player.y = Player.y + (math.abs(pad:analogY())/ana)
    end
    
    if anaY < -30 then
    Player.y = Player.y - (math.abs(pad:analogY())/ana)
    end
    Zitat Zitat von bumuckl
    Thy very nice now ive understood...thy very much...ur going to be in the Credits...
    .....my head hurts. Jump back a page to see why the code does work, I made the same mistake at a quick glance, but the previous method is actually better because it doesn't negate the sensitivity of the stick AND it only makes one logic check.

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

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

    Standard

    what is this "paint bucket" tool you speak of da_merv?

  26. #7856
    QJ Gamer Silver
    Points: 12.453, Level: 73
    Level completed: 1%, Points required for next Level: 397
    Overall activity: 80,0%

    Registriert seit
    Mar 2007
    Beiträge
    1.129
    Points
    12.453
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    you know, click and it fills it with your color, its a basic tool of paint

  27. #7857
    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

    lua player doesn't have one, you'll have to write it yourself

  28. #7858
    QJ Gamer Silver
    Points: 12.453, Level: 73
    Level completed: 1%, Points required for next Level: 397
    Overall activity: 80,0%

    Registriert seit
    Mar 2007
    Beiträge
    1.129
    Points
    12.453
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    ya i know luaplayer doesnt have one. i didnt ask that. i asked how the fill bucket works, i mean, it was done in yPaint, which was written in lua, but yongobongo compiled the script, and i dont have a decompiler, so theres no way i can find out how he did it unless he wants to tell me.
    -= Double Post =-
    oh, and in the last couple days of research (aka google 24/7), i found the proper name. its called flood fill
    -= Double Post =-
    oh and even more information, after actually looking at yongobongo's program, i found out the flood fill was implemented horribly, crashes frequently, and doesnt even work all the time.
    Geändert von Da_MerV (08-01-2007 um 06:24 PM Uhr) Grund: Automerged Doublepost

  29. #7859
    .info
    Points: 15.395, Level: 80
    Level completed: 9%, Points required for next Level: 455
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    ACT, Australia
    Beiträge
    1.674
    Points
    15.395
    Level
    80
    Downloads
    0
    Uploads
    0

    Standard

    I am trying to handle an Image.load() error but it's not working
    Is there a different way i should do this?
    Code:
    if not Image.load("test.png") then 
    screen:print(0,0,"error loading image")
    else
    test = Image.load("test.png")
    screen:blit(0,0,test)
    end

    http://www.yongobongo.com
    PSN - yongobongo

  30. #7860
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Yongobongo
    I am trying to handle an Image.load() error but it's not working
    Is there a different way i should do this?
    Code:
    if not Image.load("test.png") then 
    screen:print(0,0,"error loading image")
    else
    test = Image.load("test.png")
    screen:blit(0,0,test)
    end
    shouldnt 'test = Image.load("test.png") come before luaplayer checks if its there?

    i dont know, maybe:

    Code:
    test = Image.load("test.png")
    if not Image.load("test.png") then 
    screen:print(0,0,"error loading image")
    else
    screen:blit(0, 0, test)
    end
    thats my guess.
    -= Double Post =-
    Zitat Zitat von Da_MerV
    ya i know luaplayer doesnt have one. i didnt ask that. i asked how the fill bucket works, i mean, it was done in yPaint, which was written in lua, but yongobongo compiled the script, and i dont have a decompiler, so theres no way i can find out how he did it unless he wants to tell me.
    -= Double Post =-
    oh, and in the last couple days of research (aka google 24/7), i found the proper name. its called flood fill
    -= Double Post =-
    oh and even more information, after actually looking at yongobongo's program, i found out the flood fill was implemented horribly, crashes frequently, and doesnt even work all the time.
    didnt you say you already know how to do it? just improve on it.
    -= Double Post =-
    yongobongo, tacticalpenguin says:

    Zitat Zitat von TacticalPenguin on msn
    Code:
    test = io.open("img.png","r")
    if test then
    	test:close()
    	img = Image.load("img.png")
    else
    	print("error")
    end
    and that testing if the image actually loads instead of just checking if its there can only be done with Image.loadFromMemory and making sure that the string you load it from is complete
    Geändert von EminentJonFrost (08-03-2007 um 11:18 AM Uhr) Grund: Automerged Doublepost


 

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

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