Seite 108 von 342 ErsteErste ... 8 58 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 158 208 ... LetzteLetzte
Zeige Ergebnis 3.211 bis 3.240 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 JaSo PsP how do i make an image move using the arrow keys? my image is called "smiley" ...

  
  1. #3211
    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 JaSo PsP
    how do i make an image move using the arrow keys? my image is called "smiley" so some code would be nice :)
    Code:
    smiley = Image.load("smiley.png")
    
    x = 0
    y = 0
    
    while true do
    
    screen:clear()
    
    screen:blit(x, y, smiley)
    
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:right() then
    y = y - 1
    end 
    
    screen.waitVblankStart()
    screen:flip()
    end


    --------------------------------------------------------------------------------------

  2. #3212
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    Code:
    smiley = Image.load("smiley.png")
    
    x = 0
    y = 0
    
    while true do
    
    screen:clear()
    
    screen:blit(x, y, smiley)
    
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:right() then
    y = y - 1
    end 
    
    screen.waitVblankStart()
    screen:flip()
    end
    thanx

    ps: u forgot:

    Code:
     pad = Controls.read()
    plus u got the directions all wrong, up doesnt work and right make it go diagonally
    Geändert von JaSo PsP (08-16-2006 um 10:09 AM Uhr)
    ...Just Returned To The Scene...

  3. #3213
    Developer
    Points: 5.650, Level: 48
    Level completed: 50%, Points required for next Level: 100
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    USA, Virginia
    Beiträge
    580
    Points
    5.650
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    I'm still having trouble with those two problem.. can someone send me a PM and take a look at my full script please? I dont want to give out everything in this thread. These are the last two problems i need to fix before i release and id like to get it out soon.

  4. #3214
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    what am i doing wrong here?:

    Code:
    if x = 272 then
    x = x + 0
    end
    
    if y = 480 then
    y = y + 0
    end
    ...Just Returned To The Scene...

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

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

    Standard

    if x == 272 then
    x = x + 0
    end

    if y == 480 then
    y = y + 0
    end

    You forgot the second equals sign.

  6. #3216
    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 JaSo PsP
    what am i doing wrong here?:

    Code:
    if x = 272 then
    x = x + 0
    end
    
    if y = 480 then
    y = y + 0
    end
    do u want it so that if the x hits 480 that it wont go any further?? if so: do this:
    Code:
    if x > 480 then
    x = 480
    end
    
    if y > 272 then
    y = 242
    end
    
    
    if x < 0 then
    x = 0
    end
    
    if y < 0 then
    y = 0
    end
    --------------------------------------------------------------------------------------

  7. #3217
    QJ Gamer Bronze
    Points: 5.924, Level: 49
    Level completed: 87%, Points required for next Level: 26
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Earth, UK
    Beiträge
    457
    Points
    5.924
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    This is simpler then adding more if's

    Code:
    smiley = Image.load("smiley.png")
    
    x = 0
    y = 0
    
    while true do
    
    screen:clear()
    
    screen:blit(x, y, smiley)
    
    if pad:right() and x<272 then
    x = x + 1
    end 
    
    if pad:left()  and x>0then
    x = x - 1
    end 
    
    if pad:down() and x<272 then
    y = y + 1
    end 
    
    if pad:right() and x>0 then
    y = y - 1
    end 
    
    screen.waitVblankStart()
    screen:flip()
    end
    <<Put A message Here>>
    <<Just made another rubbish website visit it here.>>

  8. #3218
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    do u want it so that if the x hits 480 that it wont go any further?? if so: do this:
    Code:
    if x > 480 then
    x = 480
    end
    
    if y > 272 then
    y = 242
    end
    
    
    if x < 0 then
    x = 0
    end
    
    if y < 0 then
    y = 0
    end
    k thanx

    theres a problem, i go thru the wall on the right and at the bottom. i found out the answer, i gotta add the dimensions of the smiley face.
    -= Double Post =-
    Yes! i now have boundries in my first game, now how can i make it detect a collision?
    Geändert von JaSo PsP (08-16-2006 um 11:40 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

  9. #3219
    I think I ripped my pants
    Points: 33.140, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Toronto
    Beiträge
    6.484
    Points
    33.140
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von JaSo PsP
    k thanxYes! i now have boundries in my first game, now how can i make it detect a collision?
    http://evilmana.com/tutorials/lua_tutorial_12.php
    [CENTER][IMG]http://i33.tinypic.com/wmeb8x.jpg[/IMG][/CENTER]
    [FIELDSET="Useful Links"][CENTER][SIZE="1"][B][URL="http://forums.qj.net/showthread.php?p=13162#post13162"][COLOR="Red"][Posting Guidelines][/COLOR][/URL] - [URL="http://forums.qj.net/f-qjnet-news-and-help-25/t-qj-quick-justice-policy-must-read-69509.html"][COLOR="Red"][Quick Justice Policy][/COLOR][/URL] - [URL="http://forums.qj.net/showthread.php?t=9708"][COLOR="Red"][PSPositive Posting][/COLOR][/URL] - [URL="http://forums.qj.net/showthread.php?t=4394"][COLOR="Red"][Piracy Policy][/COLOR][/URL]
    [URL="http://forums.qj.net/showthread.php?t=65979"][COLOR="SeaGreen"][Ultimate QJ Guide][/COLOR][/URL] - [URL="http://forums.qj.net/f-qjnet-news-and-help-25/t-faq-useful-info-and-links-for-new-members-53693.html"][COLOR="SeaGreen"][Newbie FAQ/Guide][/COLOR][/URL] - [URL="http://forums.qj.net/showthread.php?t=19128"][COLOR="SeaGreen"][Become Premium][/COLOR][/URL] - [URL="http://forums.qj.net/f-wii-general-108/t-wii-faq-20295.html"][COLOR="SeaGreen"][Wii FAQ][/COLOR][/URL][/B][/SIZE][/CENTER][/FIELDSET]

  10. #3220
    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

    I also wrote a simple collision detection program, bounding boxes.

    Search QJ's dev forum for collision.

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


  11. #3221
    QJ Gamer Blue
    Points: 4.580, Level: 43
    Level completed: 15%, Points required for next Level: 170
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    145
    Points
    4.580
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    I dont understand, I want my jump sprites to show when I jump, but they wont show! There was no error, but my jump sprites dont show!
    Background = Image.load("sunshine_bg.p ng")
    green=Color.new(255,0,0)
    rgreen=Color.new(0,255,0)
    white = Color.new(255,255,255)
    MarioScore = 0
    LuigiScore = 0
    Music.playFile("mus1.it")
    player1 = Image.load("mario_left.pn g")
    player2 = Image.load("mario_right.p ng")
    playerjumpleft = Image.load("mario_jump_le ft.png")
    playerjumpright = Image.load("mario_jump_ri ght.png")
    luigijumpleft = Image.load("luigi_jump_le ft.png")
    luigijumpright = Image.load("luigi_jump_ri ght.png")
    luigi1 = Image.load("luigi_left.pn g")
    luigi2 = Image.load("luigi_right.p ng")
    playerimage = player2
    luigiimage = luigi1
    math.randomseed(os.time() )
    keyimage = Image.load("key.png")
    displayTime = math.random(20,500)
    counter = 0
    screen:blit(0,0,Backgroun d)
    screen:blit(0,0,playerima ge)
    screen:blit(0,0,luigiimag e)
    ground = Image.createEmpty(480,14)
    ground:clear(green)

    player = {}
    player.gravity = 230
    player.y = 230
    player.x = 50
    player.jumpspeed = 10
    player.jumpstate = "ground"

    luigi = {}
    luigi.gravity = 230
    luigi.y = 230
    luigi.x = 50
    luigi.jumpspeed = 10
    luigi.jumpstate = "ground"
    key = {}
    key.x = math.random(1,3)
    key.y = math.random (1,3)

    while true do
    pad = Controls.read()
    counter = counter + 1
    if counter >= displayTime then
    key.x = math.random(1,3)
    key.y = math.random (1,3)
    if key.x == 1 then
    key.x = 224
    end
    if key.x == 1 then
    key.y = 182
    end

    if key.x == 2 then
    key.x = 60
    end
    if key.x == 2 then
    key.y = 132
    end

    if key.x == 3 then
    key.x = 404
    end
    if key.y == 3 then
    key.y = 154
    end

    displayTime = math.random(500,2000)
    counter = 0
    end


    if player.x > 480 then
    Mario.x = 480
    end
    if player.x < 0 then
    Mario.x = 0
    end

    if luigi.x > 480 then
    luigi.x = 480
    end
    if luigi.x < 0 then
    luigi.x = 0
    end

    if pad:left() then
    playerimage = player1
    player.x = player.x - 2
    end
    if pad:right() then
    playerimage = player2
    player.x = player.x + 2
    end

    if pad:up() and player.jumpstate == "ground" then player.jumpstate = "jumping" end

    if player.jumpstate == "jumping" then
    player.jumpspeed = player.jumpspeed - 0.5
    player.gravity = player.gravity - player.jumpspeed
    end

    if player.gravity < 0 then
    player.jumpstate = "falling"
    end

    if player.gravity < 230 and player.jumpstate == "falling" then
    player.gravity = player.gravity + (player.jumpspeed + 3)
    end

    if player.gravity == 230 then
    player.jumpspeed = 10
    player.jumpstate = "ground"
    end

    if player.gravity > 230 then player.gravity = 230 end

    player.y = player.gravity

    if pad:square() then
    luigiimage = luigi1
    luigi.x = luigi.x - 2
    end
    if pad:circle() then
    luigiimage = luigi2
    luigi.x = luigi.x + 2
    end

    if pad:triangle() and luigi.jumpstate == "ground" then luigi.jumpstate = "jumping" end

    if luigi.jumpstate == "jumping" then
    luigi.jumpspeed = luigi.jumpspeed - 0.5
    luigi.gravity = luigi.gravity - luigi.jumpspeed
    end

    if luigi.gravity < 0 then
    luigi.jumpstate = "falling"
    end

    if luigi.gravity < 230 and luigi.jumpstate == "falling" then
    luigi.gravity = luigi.gravity + (luigi.jumpspeed + 3)
    end

    if luigi.gravity == 230 then
    luigi.jumpspeed = 10
    luigi.jumpstate = "ground"
    end

    if luigi.gravity > 230 then luigi.gravity = 230 end

    luigi.y = luigi.gravity

    if pad:up() and player.jumpstate == "ground" and playerimage == player1 then
    playerimage = playerjumpleft
    end
    if pad:up() and player.jumpstate == "ground" and playerimage == player2 then
    playerimage = playerjumpright
    end
    if playerimage == playerjumpleft and player.jumpstate == "jumping" then
    playerimage = player1
    end
    if playerimage == playerjumpright and player.jumpstate == "jumping" then
    playerimage = player2
    end

    if pad:triangle() and luigi.jumpstate == "ground" and luigiimage == luigi1 then
    luigiimage = luigijumpleft
    end
    if pad:triangle() and luigi.jumpstate == "ground" and luigiimage == luigi2 then
    luigiimage = luigijumpright
    end
    if luigiimage == luigijumpleft and luigi.jumpstate == "jumping" then
    luigiimage = luigi1
    end
    if luigiimage == luigijumpright and luigi.jumpstate == "jumping" then
    luigiimage = luigi2
    end
    screen:blit(0,0,Backgroun d)
    screen:blit(key.x, key.y, keyimage)
    screen:blit(player.x,play er.y,playerimage)
    screen:blit(luigi.x,luigi .y,luigiimage)
    screen:blit(0,262,ground)
    screenrint(30,20,"Mario's Score: "..MarioScore,green)
    screenrint(30,50,"Luigi's Score: "..LuigiScore,rgreen)
    screen.waitVblankStart()
    screen.flip()
    end

  12. #3222
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    if pad:triangle() and luigi.jumpstate == "ground" then luigi.jumpstate = "jumping" end
    Right, here you say if the pad has triangle pressed and the jumpstate is "ground" then change jumpstate to "jumping".
    At this point in code, triangle has been pressed and the jumpstate is "jumping". A couple of lines down...

    Code:
    if pad:triangle() and luigi.jumpstate == "ground" and luigiimage == luigi1 then
    luigiimage = luigijumpleft
    end
    The image will never change to "luigijumpleft" since the jumpstate is now "jumping" rather then "ground". But.....

    Code:
    if luigiimage == luigijumpleft and luigi.jumpstate == "jumping" then
    luigiimage = luigi1
    end
    Even then it still won't show since at this point of code in the loop, the luigiimage is now "luigijumpleft" and the jumpstate is still "jumping", the luigiimage is chnaged BACK to "luigi1" before it is blitted to the screen.

    I would get rid of the last 2 bits of code. I would also prefer to have a variable that holds the players current direction rather then check the current image but using your current system, change the first bit of code to:
    Code:
    if pad:triangle() and luigi.jumpstate == "ground" then 
    luigi.jumpstate = "jumping" 
    if lugiimage == luigi1 then
    luigiimage = luigijumpleft
    else
    luigiimage = luigijumpright
    end
    end
    I let you deal with changing the sprite when the player lands as an exercise to see if you understand the fixes that I have done.

  13. #3223
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    I need to make the object that i collided with dissappear, make the score go up by one and make the object reappear in a random position on the PSP screen. The variables for random x and random y are 'rx and 'ry'. The player is called 'smiley' the object is called 'sad' the dimensions for both of these are 38 x 38. so please can you help me! some code would be nice
    Geändert von JaSo PsP (08-17-2006 um 01:04 AM Uhr)
    ...Just Returned To The Scene...

  14. #3224
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Are you serious? Unless you have had a decent go at the code yourself, I don't think anyone is going to just give you the code like that. By doing so, you are not learning anything.

    These should help you:
    http://evilmana.com/tutorials/lua_tutorial_12.php - box collision detection
    http://lua-users.org/wiki/MathLibraryTutorial - random numbers

  15. #3225
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    i will learn, im am currently a learner, if someone writes i will look throught it and understand. I just dunno where to put it all. Is it gonna be something like "if smiley.x + smileyWidth > sad.x then' rite?? i could make it all a function, but i dunno where to put the function. I dunno how to make an object delete then reappear somewhere else with the random variables, it appears first in the game when you start it as:
    Code:
    screen:blit(rx,ry,sad)
    
    and the variables are:
    
    rx = math.random(0,442)
    ry = math.random(0,234)
    ...Just Returned To The Scene...

  16. #3226
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    I just posted two links in my previous post to help you with your problem. You are never going to learn unless you have a decent shot at it yorself. Learning how to program is about solving problems. I will not give any advice unless you have a decent shot at this yourself and post some code.

    Hint: You are not deleting the object and making it reappear, you are moving it (aka changing the X and Y variable positions)

  17. #3227
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    look at all the stuff ive done so far, btw, ive tried the collision thing, i still dont know how to make the object delete:

    Code:
    --Smiley
    --JaSo PsP
    
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    boost = 1000
    
    x = 0
    y = 5
    
    function booster()
    boost = boost - 1
    end
    
    while true do
    
    screen:clear()
    
    screen:blit(0,0,background)
    screen:print(0,263,"Press X for SPEED BOOST",red)
    screen:print(0,0,"Boost Left: "..boost ,red)
    screen:blit(x, y, smiley)
    screen:blit(rx, ry, sad)
    
    pad = Controls.read()
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:up() then
    y = y - 1
    end 
    
    if pad:right() and pad:cross() then
    x = x + 3
    booster()
    end 
    
    if pad:left() and pad:cross() then
    x = x - 3
    booster()
    end 
    
    if pad:down() and pad:cross() then
    y = y + 3
    booster()
    end 
    
    if pad:up() and pad:cross() then
    y = y - 3
    booster()
    end 
    
    if pad:start() then
    return
    end
    
    if x > 442 then
    x = 442
    end
    
    if y > 234 then
    y = 234
    end
    
    if x < -2 then
    x = -2
    end
    
    if y < -2 then
    y = -2
    end
    
    screen.waitVblankStart()
    screen:flip()
    end
    ...Just Returned To The Scene...

  18. #3228
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Sorry, but I don't see any where in that code where you have tried to do any collision. I would at least like to see your attempt at it.

  19. #3229
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    ill see what i can do..
    ...Just Returned To The Scene...

  20. #3230
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Spoiler for To save me posting it up later:
    Code:
    --Smiley
    --JaSo PsP
    
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    boost = 1000
    score = 0
    x = 0
    y = 5
    
    function booster()
    boost = boost - 1
    end
    
    function CheckBoxCollisionHack()
    	if ((x + 38) > rx) and (x < (rx + 38)) then 
    		if ((y + 38) > ry) and (y < (ry + 38)) then
    			return true
    		end
    	end
    	
    	return false
    end
    
    while true do
    
    screen:clear()
    
    screen:blit(0,0,background)
    screen:print(0,263,"Press X for SPEED BOOST",red)
    screen:print(0,0,"Boost Left: "..boost ,red)
    screen:blit(x, y, smiley)
    screen:blit(rx, ry, sad)
    
    pad = Controls.read()
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:up() then
    y = y - 1
    end 
    
    if pad:right() and pad:cross() then
    x = x + 3
    booster()
    end 
    
    if pad:left() and pad:cross() then
    x = x - 3
    booster()
    end 
    
    if pad:down() and pad:cross() then
    y = y + 3
    booster()
    end 
    
    if pad:up() and pad:cross() then
    y = y - 3
    booster()
    end 
    
    if pad:start() then
    return
    end
    
    if x > 442 then
    x = 442
    end
    
    if y > 234 then
    y = 234
    end
    
    if x < -2 then
    x = -2
    end
    
    if y < -2 then
    y = -2
    end
    
    if CheckBoxCollisionHack() then
    	rx = math.random(0,442)
    	ry = math.random(0,234)
    	score = score + 1
    end
    
    screen.waitVblankStart()
    screen:flip()
    end

  21. #3231
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Ive just been working alot on the boost and now i got it to stop the boost count at 0 when when you run out and stop moving fast when you run out:
    Code:
    if pad:right() and pad:cross() then
    if boost < 1 then
    x = x + 0
    else 
    x = x + 3
    booster()
    end 
    end
    
    if pad:left() and pad:cross() then
    if boost < 1 then
    x = x - 0
    else
    x = x - 3
    booster()
    end 
    end
    
    if pad:down() and pad:cross() then
    if boost < 1 then
    y = y + 0
    else
    y = y + 3
    booster()
    end 
    end
    
    if pad:up() and pad:cross() then
    if boost < 1 then
    y = y - 0
    else
    y = y - 3
    booster()
    end 
    end
    -= Double Post =-
    Zitat Zitat von head_54us
    Spoiler for To save me posting it up later:
    Code:
    --Smiley
    --JaSo PsP
    
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    boost = 1000
    score = 0
    x = 0
    y = 5
    
    function booster()
    boost = boost - 1
    end
    
    function CheckBoxCollisionHack()
    	if ((x + 38) > rx) and (x < (rx + 38)) then 
    		if ((y + 38) > ry) and (y < (ry + 38)) then
    			return true
    		end
    	end
    	
    	return false
    end
    
    while true do
    
    screen:clear()
    
    screen:blit(0,0,background)
    screen:print(0,263,"Press X for SPEED BOOST",red)
    screen:print(0,0,"Boost Left: "..boost ,red)
    screen:blit(x, y, smiley)
    screen:blit(rx, ry, sad)
    
    pad = Controls.read()
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:up() then
    y = y - 1
    end 
    
    if pad:right() and pad:cross() then
    x = x + 3
    booster()
    end 
    
    if pad:left() and pad:cross() then
    x = x - 3
    booster()
    end 
    
    if pad:down() and pad:cross() then
    y = y + 3
    booster()
    end 
    
    if pad:up() and pad:cross() then
    y = y - 3
    booster()
    end 
    
    if pad:start() then
    return
    end
    
    if x > 442 then
    x = 442
    end
    
    if y > 234 then
    y = 234
    end
    
    if x < -2 then
    x = -2
    end
    
    if y < -2 then
    y = -2
    end
    
    if CheckBoxCollisionHack() then
    	rx = math.random(0,442)
    	ry = math.random(0,234)
    	score = score + 1
    end
    
    screen.waitVblankStart()
    screen:flip()
    end
    thanx
    -= Double Post =-
    now i need to know where to find help to make a timer, then when the timer reaches 0 it saves the score as high score, then if the high score is bigger than the current one, it overwrites it. I sort of know how to do this but i just need some help on the time and will the hi score be saved in an external document?
    Geändert von JaSo PsP (08-17-2006 um 01:57 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

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

    Just search these forums for a thread called 'collision'.

    Itll come up with my tutorial on using collision testing via bounding boxes. All you do is copy and paste my function into your code, Then call it supplying the 8 parameters needed.

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


  23. #3233
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Timers for LuaPlayer: http://wiki.ps2dev.org/psp:lua_playe...lisecond_timer
    To write and read from an external file you have to use the Lua IO library.

    edit:
    Spoiler for Proper Box Collision function:
    Code:
    --Smiley
    --JaSo PsP
    
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    boost = 1000
    score = 0
    x = 0
    y = 5
    
    function booster()
    boost = boost - 1
    end
    
    function ProperBoxCollision(x1, y1, w1, h1, x2, y2, w2, h2)
    	if ((x1 + w1) > x2) and (x1 < (x2 + w2)) then 
    		if ((y1 + h2) > y2) and (y1 < (y2 + h2)) then
    			return true
    		end
    	end
    	
    	return false
    end
    
    while true do
    
    screen:clear()
    
    screen:blit(0,0,background)
    screen:print(0,263,"Press X for SPEED BOOST",red)
    screen:print(0,0,"Boost Left: "..boost ,red)
    screen:blit(x, y, smiley)
    screen:blit(rx, ry, sad)
    
    pad = Controls.read()
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:up() then
    y = y - 1
    end 
    
    if pad:right() and pad:cross() then
    x = x + 3
    booster()
    end 
    
    if pad:left() and pad:cross() then
    x = x - 3
    booster()
    end 
    
    if pad:down() and pad:cross() then
    y = y + 3
    booster()
    end 
    
    if pad:up() and pad:cross() then
    y = y - 3
    booster()
    end 
    
    if pad:start() then
    return
    end
    
    if x > 442 then
    x = 442
    end
    
    if y > 234 then
    y = 234
    end
    
    if x < -2 then
    x = -2
    end
    
    if y < -2 then
    y = -2
    end
    
    if ProperBoxCollision(x, y, 38, 38, rx, ry, 38, 38) then
    	rx = math.random(0,442)
    	ry = math.random(0,234)
    	score = score + 1
    end
    
    screen.waitVblankStart()
    screen:flip()
    end

  24. #3234
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Timers for LuaPlayer: http://wiki.ps2dev.org/psp:lua_playe...lisecond_timer
    To write and read from an external file you have to use the Lua IO library.
    i just made a timer out of my own head:
    Code:
    function timer()
    screen.waitVblankStart(60)
    displayTime = displayTime - 1
    end
    but this slows down everything so 1 thing happends every second.. how do i make the vblankStart only relevant to the timer?
    ...Just Returned To The Scene...

  25. #3235
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    screen.waitVblankStart(X) is an API call to say, wait for the screen to finish refreshing the screen X number of times before proceeding. To answer your question, you can't.

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

    You cant. The vblank basically delays the current thread until a vertical sync, AKA the screen refreshing 'line' his the same spot twice, puesdo code of course.

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


  27. #3237
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    You cant. The vblank basically delays the current thread until a vertical sync, AKA the screen refreshing 'line' his the same spot twice, puesdo code of course.
    so is there any way of just making the timer count down every second?
    ...Just Returned To The Scene...

  28. #3238
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    SG57, do you know if the string.gmatch function is implemented in the latest PSP version of Luaplyer. I currently only have access to the Windows version and it doesn't seem to have it.

    Zitat Zitat von JaSo PsP
    so is there any way of just making the timer count down every second?
    Use the millisecond timer and every time you get the number of ms from the timer, divide by 1000 to get the number of seconds.

  29. #3239
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    You cant. The vblank basically delays the current thread until a vertical sync, AKA the screen refreshing 'line' his the same spot twice, puesdo code of course.
    BTW, thats why the maximum fps you get see on a screen is 60 correct?
    What did we think the world would look like in 2015?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  30. #3240
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Timers for LuaPlayer: http://wiki.ps2dev.org/psp:lua_playe...lisecond_timer
    To write and read from an external file you have to use the Lua IO library.

    edit:
    Spoiler for Proper Box Collision function:
    Code:
    --Smiley
    --JaSo PsP
    
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    boost = 1000
    score = 0
    x = 0
    y = 5
    
    function booster()
    boost = boost - 1
    end
    
    function ProperBoxCollision(x1, y1, w1, h1, x2, y2, w2, h2)
    	if ((x1 + w1) > x2) and (x1 < (x2 + w2)) then 
    		if ((y1 + h2) > y2) and (y1 < (y2 + h2)) then
    			return true
    		end
    	end
    	
    	return false
    end
    
    while true do
    
    screen:clear()
    
    screen:blit(0,0,background)
    screen:print(0,263,"Press X for SPEED BOOST",red)
    screen:print(0,0,"Boost Left: "..boost ,red)
    screen:blit(x, y, smiley)
    screen:blit(rx, ry, sad)
    
    pad = Controls.read()
    if pad:right() then
    x = x + 1
    end 
    
    if pad:left() then
    x = x - 1
    end 
    
    if pad:down() then
    y = y + 1
    end 
    
    if pad:up() then
    y = y - 1
    end 
    
    if pad:right() and pad:cross() then
    x = x + 3
    booster()
    end 
    
    if pad:left() and pad:cross() then
    x = x - 3
    booster()
    end 
    
    if pad:down() and pad:cross() then
    y = y + 3
    booster()
    end 
    
    if pad:up() and pad:cross() then
    y = y - 3
    booster()
    end 
    
    if pad:start() then
    return
    end
    
    if x > 442 then
    x = 442
    end
    
    if y > 234 then
    y = 234
    end
    
    if x < -2 then
    x = -2
    end
    
    if y < -2 then
    y = -2
    end
    
    if ProperBoxCollision(x, y, 38, 38, rx, ry, 38, 38) then
    	rx = math.random(0,442)
    	ry = math.random(0,234)
    	score = score + 1
    end
    
    screen.waitVblankStart()
    screen:flip()
    end
    the other collision worked and that site doesn't help, i want a time to count down and i didnt know what the variable was called for the actual number.
    ...Just Returned To The Scene...


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 07:53 AM Uhr.

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