Seite 151 von 342 ErsteErste ... 51 101 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 201 251 ... LetzteLetzte
Zeige Ergebnis 4.501 bis 4.530 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; nope..that didnt do anything...i changed every "save" to "profile". oh, if you were wondering, 'save.lua' file only has the word ...

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

    nope..that didnt do anything...i changed every "save" to "profile". oh, if you were wondering, 'save.lua' file only has the word 'true' in it. thats it.


    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

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

    Standard

    Maybe it should be:

    while first == "true" do

    Try adding the quotes.

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

    didnt work either...

    i even added these: "" to the save file text...still nothing.

    could it be luaplayer? i have cool's mod.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

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

    Standard

    I don't think so. Cools mod is the same thing, only with a few more functions. Could you post your whole code?

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

    this is all the code that has anything to do with the problem. without these codes, it runs fine, but not how i want it to.

    main script -

    Code:
    profile = io.open("save.lua", "r")
    first = profile:read()
    profile:close()
    
    -- skipping some code
    
    while first == "true" do
    -- skipping alot of code
    end
    Save File -

    Code:
    "true" -- player's first time playing
    Geändert von EminentJonFrost (12-03-2006 um 01:03 PM Uhr)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

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

    Standard

    Zitat Zitat von EminentJonFrost
    this is all the code that has anything to do with the problem. without these codes, it runs fine, but not how i want it to.

    main script -

    Code:
    profile = io.open("save.lua", "r")
    first = profile:read()
    profile:close()
    
    -- skipping some code
    
    while first == "true" do
    -- skipping alot of code
    end
    Save File -

    Code:
    "true" -- player's first time playing
    Maybe instead of writing true, write 0 for false and 1 for true. Numbers might be easier to work with.

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

    nope. ...
    i'm gonna have to find some way around this then...

    if anyone thinks they know whats wrong though, please tell me.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    did you try adding
    Code:
    first = "true"
    to the savefile?
    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

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

    this, translated, pretty much means that.

    Code:
    first = profile:read()
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    i know but you may have to define it in the savefile then just us do:file(filename)
    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

  11. #4511
    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

    hmm...i'll try that :)
    so simple, it just might work.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  12. #4512
    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 slicer4ever
    i know but you may have to define it in the savefile then just us do:file(filename)

    taht wont work.
    -= Double Post =-
    Zitat Zitat von EminentJonFrost
    this is all the code that has anything to do with the problem. without these codes, it runs fine, but not how i want it to.

    main script -

    Code:
    profile = io.open("save.lua", "r")
    first = profile:read()
    profile:close()
    
    -- skipping some code
    
    while first == "true" do
    -- skipping alot of code
    end
    Save File -

    Code:
    "true" -- player's first time playing

    try this:

    main script -

    Code:
    profile = io.open("save.lua", "r")
    first = profile:read()
    profile:close()
    
    -- skipping some code
    
    if first == "true" then
    -- skipping alot of code
    end
    Geändert von Grimfate126 (12-03-2006 um 02:12 PM Uhr) Grund: Automerged Doublepost
    --------------------------------------------------------------------------------------

  13. #4513
    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

    Grimfate - that didnt work...errors started coming up about how many 'ends' there were

    slicer4ever - i did that, sorta. and it worked!

    i did this:

    Code:
    dofile("./save file.lua")
    
    while first == true do
    
    ...
    if button pressed
    save = io.open("save file.lua", "w")
    save:write("first = false")
    save:close()
    end
    ...
    end
    worked like a charm! :)
    successful bypass gentlemen! lol
    thanks Access_Denied, Grimfate, and slicer4ever! :Punk:
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  14. #4514
    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 EminentJonFrost
    Grimfate - that didnt work...errors started coming up about how many 'ends' there were

    slicer4ever - i did that, sorta. and it worked!

    i did this:

    Code:
    dofile("./save file.lua")
    
    while first == true do
    
    ...
    if button pressed
    save = io.open("save file.lua", "w")
    save:write("first = false")
    save:close()
    end
    ...
    end
    worked like a charm! :)
    successful bypass gentlemen! lol
    thanks Access_Denied, Grimfate, and slicer4ever! :Punk:
    tight, i don't know why nobody could get it to work, but this is a great bypass! nice ideas!!!

  15. #4515
    QJ Gamer Bronze
    Points: 9.316, Level: 64
    Level completed: 89%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Denmark
    Beiträge
    664
    Points
    9.316
    Level
    64
    Downloads
    0
    Uploads
    0

    Standard

    I need help with my ping pong game, once more...

    white = Color.new(255, 255, 255)

    screenrint(136, 136, "Loading LUA Pong...", white)
    screen.flip()

    background = Image.load("Background.pn g")

    bat11 = Image.load("Bat1.png")

    bat21 = Image.load("Bat2.png")

    bat1 = { x = 20, y = 100 }
    bat2 = { x = 460, y = 100 }

    ball = { x = 240, y = 146, image = Image.load("Ball.png") }

    screen.waitVblankStart(60 )

    while true do

    screen:clear()
    screen:blit(bat1.x, bat1.y, bat11, true)
    screen:blit(bat2.x, bat2.y, bat21, true)

    pad = Controls.read()

    if ball.x == bat.x and ball.y >= bat.y and ball.x < (16*64) then
    bounce away
    end

    if pad:down() then
    bat1.y = bat1.y +2
    end

    if pad:up() then
    bat1.y = bat1.y -2
    end

    if pad:cross() then
    bat2.y = bat2.y +2
    end

    if pad:triangle() then
    bat2.y = bat2.y -2
    end

    if pad:start() then
    break
    end

    screenrint(136, 136, "Welcome to the world of PPP.", white)
    screen.waitVblankStart()
    screen.flip()
    end
    What i need is, the variable for "bounce away" because i dont know what to write there.
    My PSP Projects:
    ___________________
    None.

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

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

    Standard

    Setup a direction system for the ball and make collisions change its directio. then do if direction == blah then ballx = ballx-1 or whatever

  17. #4517
    QJ Gamer Bronze
    Points: 9.316, Level: 64
    Level completed: 89%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Denmark
    Beiträge
    664
    Points
    9.316
    Level
    64
    Downloads
    0
    Uploads
    0

    Standard

    Sry Tactical, to be honest, i didn't understand a (beep) of what you said.
    Im a total n00b to lua...
    My PSP Projects:
    ___________________
    None.

  18. #4518
    No longer a community member.
    Points: 17.748, Level: 84
    Level completed: 80%, Points required for next Level: 102
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Nederland
    Beiträge
    3
    Points
    17.748
    Level
    84
    Downloads
    0
    Uploads
    0

    Standard

    Allright I hava a problem,
    1st time in this thread so don't pLh4M3 me

    When I run this code:
    Spoiler for Code:
    Code:
    --Load's
    menu = Image.load("data/menu.png")
    credits = Image.load("data/credits.png")
    load = Image.load("data/loading_screen.png")
    
    --Colors
    purple = Color.new(255,255,255)
    red = Color.new(255,0,0)
    
    current = 1 --this is our current menu selection
    oldpad = Controls.read()
    while true do
    pad = Controls.read()
    screen:clear()
    -- Prints our 5 menu options
    screen:print(23,62,"Start Sword Fight",purple)
    screen:print(23,86,"Go to options",purple)
    screen:print(23,110,"High Scores",purple)
    screen:print(23,134,"Cheats (not implented)",purple)
    screen:print(23,156,"Exit to XMB",purple)
    -- These make it so when the variable "current" changes
    -- so does the current menu selection
    
    screen:blit(0,0,menu)
    
    if current == 1 then
    screen:print(28,67,"Start Sword Fight",red)
    end
    if current == 2 then
    screen:print(28,91,"Go to options",red)
    end
    if current == 3 then
    screen:print(28,116,"High Scores",red)
    end
    if current == 4 then
    screen:print(28,139,"Show credits screen",red)
    
    screen:blit(0,0,credits)
    screen.waitVblankStart()
    if pad:down() then
    dofile("./index.lua")
    end
    if current == 5 then
    screen:print(28,163,"Exit to XMB",red)
    end
    -- Makes it so when UP/DOWN is pressed, the variable
    -- "current" changes making the selection change
    if pad:up() and oldpad:up() ~= pad:up() then
    current = current - 1
    end
    if pad:down() and oldpad:down() ~= pad:down() then
    current = current + 1
    end
    --Makes it so the selection goes from the bottom to top
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end


    Lowser will just do nothing,
    It loads something for about 2 seconds,
    and then it doesn't do anything!
    I can still use home and such...

    Can someone help me?!?




    btw: does anyone know where to download that luaplayer for windows that displays the error code, instead of just shutting off?
    I know it exists......

  19. #4519
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von gameo
    I need help with my ping pong game, once more...



    What i need is, the variable for "bounce away" because i dont know what to write there.
    on bounce away this is what i would do. I would assign a variable at the beginning of ur code outside of the main loop.... u know what let me just rewrite your code
    Spoiler for Your code:
    white = Color.new(255, 255, 255)

    screenrint(136, 136, "Loading LUA Pong...", white)
    screen.flip()

    background = Image.load("Background.pn g")

    bat11 = Image.load("Bat1.png")

    bat21 = Image.load("Bat2.png")

    bat1 = { x = 20, y = 100 }
    bat2 = { x = 460, y = 100 }

    ball = { x = 240, y = 146, image = Image.load("Ball.png") }

    screen.waitVblankStart(60 )

    --assigning this to make ur ball move HAHAHAHA that was funny anyways
    ballmoving = nil

    while true do

    screen:clear()
    screen:blit(bat1.x, bat1.y, bat11, true)
    screen:blit(bat2.x, bat2.y, bat21, true)

    pad = Controls.read()

    --theres collision for bat1 now for bat 2
    if ball.x == bat1.x and ball.y >= bat1.y and ball.x < (16*64) then
    ballmoving = "true"
    end

    --theres paddle 2's collision
    if ball.x == bat2.x and ball.y >= bat2.y and ball.x < (16*64) then
    ballmoving = "false"
    end

    --now what happens if ballmoving = true????
    --what operater do i use??? = or ===?? o well ill use ==
    if ballmoving == "true" then
    ball.x = ball.x + 2
    end

    --now if its going the other way
    if ballmoving == "false" then
    ball.x = ball.x - 2
    end

    if pad:down() then
    bat1.y = bat1.y +2
    end

    if pad:up() then
    bat1.y = bat1.y -2
    end

    if pad:cross() then
    bat2.y = bat2.y +2
    end

    if pad:triangle() then
    bat2.y = bat2.y -2
    end

    if pad:start() then
    break
    end

    screenrint(136, 136, "Welcome to the world of PPP.", white)
    screen.waitVblankStart()
    screen.flip()
    end


    Right off the top if any other coders find problems tell me. or just fix it
    Geändert von GuitarGod1134 (12-04-2006 um 12:33 PM Uhr) Grund: Automerged Doublepost
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

  20. #4520
    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 gameo
    I need help with my ping pong game, once more...



    What i need is, the variable for "bounce away" because i dont know what to write there.

    well, you cant just magically call a function called "bounceBall". set-up a physics system. ill get you started:

    Code:
    ball = {x = 50, y = 50, img = Image.load("ball.png"), xMove = 3, yMove = 3 }
    then..
    Code:
    ball.x = ball.x + ball.xMove
    ball.y = ball.y + ball.yMove
    
    if (ball hits paddle) then
    ball.xMove = (something else)
    ball.yMove = (something else)
    end
    --------------------------------------------------------------------------------------

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

    @frost np anytime
    @game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
    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

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

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

    Standard

    "@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
    "

    Issn't that exactly what I said? Anyways, by direction system I mean this:

    Add a variable called "d"or "direction" to the table for the ball. However, since the ball will be moving diagonally, you need to use two variables. For this ill use d1 and d2. The number on the endof the direction indicates how fast the ball should go when it is going that direction.
    Then to make the ball move do something like:
    if ball.d == u1 and ball.y > 0 then
    ball.y = ball.y - 1
    elseif ball.d == u2 and ball.y > 0 then
    ball.y = ball.y - 2
    end

    And then do that for however many you want each direction. The ball will move differently depending on what and how high its two directions are. Then for changing the ball's directions, make some formulas and then do something like
    if collision then ball.d1 = something ball.d2 = something end

    The something in there can be determined by a ricochet formula which I'll leave youto figure out.

  23. #4523
    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 savagefreak
    Allright I hava a problem,
    1st time in this thread so don't pLh4M3 me

    When I run this code:
    Spoiler for Code:
    Code:
    --Load's
    menu = Image.load("data/menu.png")
    credits = Image.load("data/credits.png")
    load = Image.load("data/loading_screen.png")
    
    --Colors
    purple = Color.new(255,255,255)
    red = Color.new(255,0,0)
    
    current = 1 --this is our current menu selection
    oldpad = Controls.read()
    while true do
    pad = Controls.read()
    screen:clear()
    -- Prints our 5 menu options
    screen:print(23,62,"Start Sword Fight",purple)
    screen:print(23,86,"Go to options",purple)
    screen:print(23,110,"High Scores",purple)
    screen:print(23,134,"Cheats (not implented)",purple)
    screen:print(23,156,"Exit to XMB",purple)
    -- These make it so when the variable "current" changes
    -- so does the current menu selection
    
    screen:blit(0,0,menu)
    
    if current == 1 then
    screen:print(28,67,"Start Sword Fight",red)
    end
    if current == 2 then
    screen:print(28,91,"Go to options",red)
    end
    if current == 3 then
    screen:print(28,116,"High Scores",red)
    end
    if current == 4 then
    screen:print(28,139,"Show credits screen",red)
    
    screen:blit(0,0,credits)
    screen.waitVblankStart()
    if pad:down() then
    dofile("./index.lua")
    end
    if current == 5 then
    screen:print(28,163,"Exit to XMB",red)
    end
    -- Makes it so when UP/DOWN is pressed, the variable
    -- "current" changes making the selection change
    if pad:up() and oldpad:up() ~= pad:up() then
    current = current - 1
    end
    if pad:down() and oldpad:down() ~= pad:down() then
    current = current + 1
    end
    --Makes it so the selection goes from the bottom to top
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end


    Lowser will just do nothing,
    It loads something for about 2 seconds,
    and then it doesn't do anything!
    I can still use home and such...

    Can someone help me?!?




    btw: does anyone know where to download that luaplayer for windows that displays the error code, instead of just shutting off?
    I know it exists......
    whats the name of the file of that script. it should be "index.lua". if thats not the problem then come back.

    oh, to have luaplayer for windows display the error you have to do this:

    right-click the "test" file. its a "Windows NT Command Script". (hover the mouse over the file to see it)

    Edit it.

    it should open and say "luaplayer index.lua"

    just go down one line (hit enter) and type "pause". then save. done!
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  24. #4524
    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 -TacticalPaper-
    "@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
    "

    Issn't that exactly what I said? Anyways, by direction system I mean this:

    Add a variable called "d"or "direction" to the table for the ball. However, since the ball will be moving diagonally, you need to use two variables. For this ill use d1 and d2. The number on the endof the direction indicates how fast the ball should go when it is going that direction.
    Then to make the ball move do something like:
    if ball.d == u1 and ball.y > 0 then
    ball.y = ball.y - 1
    elseif ball.d == u2 and ball.y > 0 then
    ball.y = ball.y - 2
    end

    And then do that for however many you want each direction. The ball will move differently depending on what and how high its two directions are. Then for changing the ball's directions, make some formulas and then do something like
    if collision then ball.d1 = something ball.d2 = something end

    The something in there can be determined by a ricochet formula which I'll leave youto figure out.

    its not called that but here is the basic formula:

    when you have a rounded object, that hits against a flat surface, your incoming angle is that angle between an imaginary perpendicular (which is drawn straight up from the point of collision), and the path of the object. your path of "reflection" (im using wave terminology) is equal to the incoming angle. a picture to help:




    so basically, you will have to use trig (sin and cos) to have a perfectly simulated game. but, no one cares that much, thankfully.
    --------------------------------------------------------------------------------------

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

    i made my own simple pong game, and i just had two variables for the x and y values of the ball's slope, and another variable for the speed.

    when the ball collides, just think about where it is going next, and it is easy to figure out what the new slope must be

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

    Anyone know whats wrong with this?
    if (housex + house:width() > packx) and (housex < packx + pack:width()) and (housey + house:height() > packy) and (housey < packy + pack:width()) then
    score = score + 1
    end

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

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

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

    Standard

    Zitat Zitat von Yongobongo
    Anyone know whats wrong with this?
    I don't see anything wrong, but sometimes I miss things. If I were you, I would use the evilmana tutorilas. It teaches you how to make a function, so you don't need to write dozens of if statements.

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

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

    Standard

    Its probably because hes using housex when it should be house.x and house.img:width()

  29. #4529
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    how would u make a racing game in lua? im confused on how.... want to make one after playing some racing games i was inspired lol. you would need like speed variable and acceleration but im not quite sure how to make it can someone give a quick example.
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

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

    u mean 3d racing game like wedge racer??


 

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 .