Seite 148 von 342 ErsteErste ... 48 98 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 198 248 ... LetzteLetzte
Zeige Ergebnis 4.411 bis 4.440 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; Yea i took out a bunch of points and was gonna buy no pm flood limit then i remembered i ...

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

    Yea i took out a bunch of points and was gonna buy no pm flood limit then i remembered i get the discount for premium and 300k, so with the 26k i saved i stickied this and bumped the MDPR.



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

    Hello im making my game and im pretty much finished with area 1. I want my guy to be able to walk to the edge of the screen and then go to a new area but if i keep it in the same loop wouldnt it just load my area 1 background and stuff back onto the screen?? I heard people saying that break changes the control to a different loop so couldnt i do

    while true do
    -- bla bla this is area 1
    if player.x == screen.x then
    break
    end
    end

    while true do
    --now we are in area 2 ya ya bla bla



    would that work?? im confused on how to make it load a level 2 or something? And what about sidescrolling how do i do that are there anymore tutorials besides evilmana?
    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!

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

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

    Standard

    Im trying to complete a LUA script thats for the PSP thats able to remotely control foobar2000 though controlserver. Everything was going smoothly untill I started retreving tracklists.
    Information sent gets split upon finding a "\n" for splitting lines and then retreving the data on those lines is done by finding a "|".
    I just expect a number in the first field but sometimes the script jumps to a section in the line and adds that to the result...
    For example: 6016016016016016016016016 01esk_-_excuses601601601
    "601" is given to an inactive track on a playlist and "esk_-_excuses" happens to be the title of the track. But I specificly asked for the first field so I dont understand why the title is there. This tends to occur with large amount of data.

    The socket gets polled for data all the time and data begins to get sorted when theres information.

    Code:
    if socket then
       incoming = socket:recv()
          if incoming ~= "" then
             values = splitString(incoming,"\n")
    	 for key, value in values do
    	    temp = splitString(value,"|")[1]
    The function that stringsplits

    Code:
    function splitString(str, de)
    	first = true
    	parts = {}
    	if de == ";" then
    		str = string.gsub(str,";;","@£$&")
    	end
    	while true do
    		s, e = string.find(str,de)
    		if e then
    			if not (first and string.sub(str,1,s-1) == "") then
    				tmp = string.sub(str,1,s-1)
    				if de == ";" then
    					tmp = string.gsub(tmp,"@£$&",";;")
    				end
    				table.insert(parts,tmp)
    			end
    			str = string.sub(str,e+1)
    			s = 1
    			first = false
    		else
    			tmp = string.sub(str,1)
    			if de == ";" then
    				tmp = string.gsub(tmp,"@£$&",";;")
    			end
    			table.insert(parts,tmp)
    		break
    		end
    	end
    	return parts
    end

  4. #4414
    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 GuitarGod1134
    Hello im making my game and im pretty much finished with area 1. I want my guy to be able to walk to the edge of the screen and then go to a new area but if i keep it in the same loop wouldnt it just load my area 1 background and stuff back onto the screen?? I heard people saying that break changes the control to a different loop so couldnt i do

    while true do
    -- bla bla this is area 1
    if player.x == screen.x then
    break
    end
    end

    while true do
    --now we are in area 2 ya ya bla bla



    would that work?? im confused on how to make it load a level 2 or something? And what about sidescrolling how do i do that are there anymore tutorials besides evilmana?
    how about this:

    Code:
    blah = 1 -- this will be where the player currently is
    
    while true...
    
    ...
    if blah == 1 then
    make this area appear
    elseif blah == 2 then
    make this area appear
    end
    
    ...
    
    end
    try that. its pretty simple.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    ya i was thinking about throwing a variable in thanks ill try that out.
    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!

  6. #4416
    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 question

    ok, i would like to know if there is a function in lua that will get the integer part of an double (decimal). So if i had 48.65, I could convert this to just 48.
    Hmmm, maybe i could just use like a rounding function...
    is there any out there

    Code:
    ok, i found this
    function math.round(num, idp) 
    local mult = 10^(idp or 0) 
    return math.floor(num * mult + 0.5) / mult 
    end
    idp being the number of decimals you want.

    i guess, this works fine, for me so nvm, i was just wondering if there was any function already incorporated into lua

  7. #4417
    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 emericaska8r
    ok, i would like to know if there is a function in lua that will get the integer part of an double (decimal). So if i had 48.65, I could convert this to just 48.
    Hmmm, maybe i could just use like a rounding function...
    is there any out there

    Code:
    ok, i found this
    function math.round(num, idp) 
    local mult = 10^(idp or 0) 
    return math.floor(num * mult + 0.5) / mult 
    end
    idp being the number of decimals you want.

    i guess, this works fine, for me so nvm, i was just wondering if there was any function already incorporated into lua

    for your purpose, this should be fine:
    Code:
    math.floor(num)
    that will mtake the decimal away. so 50.2 becomes 50, and 3.99 becomes 3.
    --------------------------------------------------------------------------------------

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

    can i do if statements inside of if statments??? im trying to make it so that when my creature goes to the edge of the screen he enters a new area and not a new level. Im not sure how to add this without making it have to read a new lua file with a new loop. someone help!!1 my source is posted a couple pages back if anyone bothered to read it. im trying to do what eminent said.
    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!

  9. #4419
    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 GuitarGod1134
    can i do if statements inside of if statments??? im trying to make it so that when my creature goes to the edge of the screen he enters a new area and not a new level. Im not sure how to add this without making it have to read a new lua file with a new loop. someone help!!1 my source is posted a couple pages back if anyone bothered to read it. im trying to do what eminent said.
    yes, you can put if statements in others. however, i think it would be better if, instead of making millions of 'if's, do this:

    Code:
    if [whatever] and [whatever] then
    that'll test both conditions in one 'if' statement. and its not limited to testing just two conditions either. so it could even be:

    Code:
    if [whatever] and [whatever] and [whatever] and [whatever] then
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    Spoiler for My game:
    -- Im Changing up Maze of Doom and I've been coming up with more ideas weekly so Im starting on this

    -- time to declare some variables
    --colors
    green = Color.new(0, 255, 0)
    red = Color.new(255, 0, 0)
    black = Color.new(0, 0, 0)

    --sprites
    demon = Image.load("demon.png")
    creature = Image.load("creature.png" )

    --what area are u in???
    currentarea = 0

    --the width and height of screen
    screenwidth = 480
    screenheight = 272

    -- the player looks in different directions right?
    splayer = {}
    --now hes looking straight
    splayer[1] = Image.load("lL.png")
    --now hes looking left
    splayer[2] = Image.load("lR.png")
    --now hes looking right
    splayer[3] = Image.load("lU.png")
    --now hes looking back
    splayer[4] = Image.load("lD.png")

    --now for the variable that makes his head turn .. literally
    direction = 1

    --the creature's health
    chp = 500

    --more sprites
    bullet = Image.createEmpty(1,1)
    bullet:clear(black)

    --and the level we are on
    level1 = Image.load("level1.png")


    -- player's health and armor and the aliens'
    health = 100
    armor = 50
    demonhp = 10

    --how long it takes to reload
    reload = Timer.new()

    --the player's bullets
    ammo = 1

    -- some tables
    Player = {}
    Player[1] = {x=0, y=0}

    -- your ammo
    Bullet = {}
    Bullet[1] = { x = Player[1].x, y = Player[1].y}

    --the creatures table
    creature = {}
    creature[1] = { x = 10, y = 10 }

    --whether the demon is alive or not
    demonal = {}
    demonal[1] = "true"
    demonal[2] = "true"
    demonal[3] = "true"
    demonal[4] = "true"
    demonal[5] = "true"
    demonal[6] = "true"

    -- the demon tables
    demon = {}
    demon[1] = {x = 400, y = 110}
    demon[2] = {x = 390, y = 80}
    demon[3] = {x = 410, y = 30}
    demon[4] = {x = 420, y = 20}
    demon[5] = {x = 400, y = 200}
    demon[6] = {x = 270, y = 260}

    --this is for our creature movement
    --prevents the same random numbers on each program run
    math.randomseed(os.time() )

    --x=width y=height
    -- REMINDER ^^^^

    -- the main loop
    while true do
    pad = Controls.read()
    screen:blit (0, 0, level1)

    --lets print some things to the screen shall we
    screenrint(0, 0, "Alanan",red)
    screenrint(0, 5, health, red)
    screenrint(0, 10, armor, green)
    screenrint(0, 15, ammo, green)

    --lets make him move around
    screen:blit(Player[1].x,Player[1].y,splayer[direction])
    if pad:left() and Player[1].x > 0 then
    Player[1].x = Player[1].x - 3
    direction = 1
    end

    if pad:right() and Player[1].x < screenwidth then
    Player[1].x = Player[1].x + 3
    direction = 2
    end

    if pad:up() and Player[1].y > 0 then
    Player[1].y = Player[1].y - 3
    direction = 3
    end

    if pad:down() and Player[1].y < screenheight then
    Player[1].y = Player[1].y + 3
    direction = 4
    end

    --we need our creature to move too
    screen:blit(creature[1].x,creature[1].y,creature)
    creaturemove = math.random(0,50)

    --now we make him move side note// i set creature move to math.random because i dont want him
    -- moving all the time or else he would reach the end of the screen way to fast.
    if creaturemove == 5 then
    creature[1].x = creature[1].x + 1
    end

    -- we have to blit are demons to the screen also

    if demonal[1] == "true" then
    screen:blit(demon[1].x,demon[1].y,demon)
    end

    if demonal[1] == "true" then
    screen:blit(demon[2].x,demon[2].y,demon)
    end

    if demonal[1] == "true" then
    screen:blit(demon[3].x,demon[3].y,demon)
    end

    if demonal[1] == "true" then
    screen:blit(demon[4].x,demon[4].y,demon)
    end

    if demonal[1] == "true" then
    screen:blit(demon[5].x,demon[5].y,demon)
    end

    if demonal[1] == "true" then
    screen:blit(demon[6].x,demon[6].y,demon)
    end

    -- now we make them chase the creature
    --we are only gonna make two demons attack the creature
    -- the other four will guard the exit

    --heres demon 1
    if demon[1].x > creature[1].x then
    demon[1].x = demon[1].x - 1
    end

    if demon[1].x < creature[1].x then
    demon[1].x = demon[1].x + 1
    end

    if demon[1].y > creature[1].y then
    demon[1].y = demon[1].y - 1
    end

    if demon[1].y < creature[1].y then
    demon[1].y = demon[1].y + 1
    end

    --now demon 2
    if demon[2].x > creature[1].x then
    demon[2].x = demon[2].x - 1
    end

    if demon[2].x < creature[1].x then
    demon[2].x = demon[2].x + 1
    end

    if demon[2].y > creature[1].y then
    demon[2].y = demon[2].y - 1
    end

    if demon[2].y < creature[1].y then
    demon[2].y = demon[2].y + 1
    end


    --lets get his gun firing and ammo is there for reload
    if pad:r() and ammo == 1 then
    screen:blit(Bullet[1].x,Bullet[1].y,bullet)
    fire = "true"
    ammo = ammo - 1
    reload:start()
    --what if hes out of ammo?
    elseif ammo == 0 then
    fire = "false"
    end

    --this makes his bullet he shoots go different ways depending on which way he faces
    if fire = "true" and direction == 1 then
    Bullet[1].x = Bullet[1].x + 2
    end

    if fire = "true" and direction == 2 then
    Bullet[1].x = Bullet[1].x - 2
    end

    if fire = "true" and direction == 3 then
    Bullet[1].y = Bullet[1].y - 2
    end

    if fire = "true" and direction == 4 then
    Bullet[1].y = Bullet[1].y + 2
    end

    -- now hes gotta reload
    if ammo == 0 and reload:time() == 10 then
    ammo = ammo + 1
    end

    --now lets make our bullet touch the demons
    if Bullet[1].x == demon[1].x and Bullet[1].y == demon[1].y then
    demonal[1] = "false"
    end

    if Bullet[1].x == demon[2].x and Bullet[1].y == demon[2].y then
    demonal[2] = "false"
    end

    if Bullet[1].x == demon[3].x and Bullet[1].y == demon[3].y then
    demonal[3] = "false"
    end

    if Bullet[1].x == demon[4].x and Bullet[1].y == demon[4].y then
    demonal[4] = "false"
    end

    if Bullet[1].x == demon[5].x and Bullet[1].y == demon[5].y then
    demonal[5] = "false"
    end

    if Bullet[1].x == demon[6].x and Bullet[1].y == demon[6].y then
    demonal[6] = "false"
    end

    --what happens when the demons touch our creature???
    if demon[1].x == creature[1].x and demon[1].y == creature[1].y then
    chp = chp - 2
    end

    if demon[2].x == creature[1].x and demon[2].y == creature[1].y then
    chp = chp - 2
    end

    if demon[3].x == creature[1].x and demon[3].y == creature[1].y then
    chp = chp - 2
    end

    if demon[4].x == creature[1].x and demon[4].y == creature[1].y then
    chp = chp - 2
    end

    if demon[5].x == creature[1].x and demon[5].y == creature[1].y then
    chp = chp - 2
    end

    if demon[6].x == creature[1].x and demon[6].y == creature[1].y then
    chp = chp - 2
    end

    --now this is if our creature dies
    if chp == 0 then
    screenrint(200,100,"Your Guide is Dead and hope is lost!", red)
    end

    --what if u die?
    if health == 0 the
    screenrint(200,110,"You have fallen all hope of escape is lost and your creature has fled!",red)
    end

    --new area
    if creature[1].x == screenwidth then
    currentarea = currentarea + 1
    end

    if currentarea == 1 then

    How do I make it so that when he reaches the end othe screen he enters a new area but i dont want to exit my main loop??!?!?!?!?!?

    EDIT: used spoiler because code is very long.
    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!

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

    Code:
    --the creatures table
    creature = {}
    creature[1] = { x = 10, y = 10 }
    
    --what area are u in???
    currentarea = 0
    
    --the width and height of screen
    screenwidth = 480
    screenheight = 272
    
    --new area
    if creature[1].x >= screenwidth then
    currentarea = currentarea + 1
    creature[1].x = 10 -- sending this guy back to where he started off in the map, but it could be anywhere you want.
    elseif creature[1].x <= screenwidth - 479 then
    currentarea = currentarea - 1
    end
    
    -- if put "creature[1].x <= screenwidth - 479 " so it could change 
    -- even if the player went the other way. 
    
    if currentarea == 0 then
    screen:blit(0, 0, area here)
    elseif currentarea == -1 then
    screen:blit(0, 0, another area here)
    elseif currentarea == 1 then
    screen:blit(0, 0, other area here)
    also, you might want to put an if statement that'll prevent 'currentarea' from reaching values other than the ones you want.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    Code:
    --the creatures table
    creature = {}
    creature[1] = { x = 10, y = 10 }
     
    --what area are u in???
    currentarea = 0
     
    --the width and height of screen
    screenwidth = 480
    screenheight = 272
     
    --new area
    if creature[1].x >= screenwidth then
    currentarea = currentarea + 1
    creature[1].x = 10 -- sending this guy back to where he started off in the map, but it could be anywhere you want.
    elseif creature[1].x <= screenwidth - 479 then
    currentarea = currentarea - 1
    end
     
    -- if put "creature[1].x <= screenwidth - 479 " so it could change 
    -- even if the player went the other way. 
     
    if currentarea == 0 then
    screen:blit(0, 0, area here)
    elseif currentarea == -1 then
    screen:blit(0, 0, another area here)
    elseif currentarea == 1 then
    screen:blit(0, 0, other shiznit here)
    That should work ;)

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

    lol
    savagefreak solved the problem GG.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  14. #4424
    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

    Are yu trying to make an engine where when you hit the edge of the screen you go to a new "area"? I've made a system for doing that and if you'd like you can take a look at it.

  15. #4425
    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 some help with my PPP game. (Ping Pong Powerups. It's my first, so...)

    Controls for both players work, thanks to EminentJonFrost, and the loader have been fixed thanks to eldiablov.

    Now i need ball movement. I have the sprite of the ball, or rather, the image.
    So i need a little help on turning it into an object, and help how to make it move random, and collosion with the bat's.

    Here is the script:


    Code:
    white = Color.new(255, 255, 255)
    
    screen:print(136, 136, "Loading LUA Pong...", white)
    screen.flip()
    
    background = Image.load("Background.png")
    
    bat11 = Image.load("Bat1.png")
    
    bat21 = Image.load("Bat2.png")
    
    bat1 = { x = 20, y = 100 }
    bat2 = { x = 460, y = 100 }
    
    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 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
    
    screen:print(136, 136, "Welcome to the world of PPP.", white)
    screen.waitVblankStart()
    screen.flip()
    end
    Help will be greatly apprisiated. (<-- Wrong spelled?)
    My PSP Projects:
    ___________________
    None.

  16. #4426
    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 -TacticalPaper-
    Are yu trying to make an engine where when you hit the edge of the screen you go to a new "area"? I've made a system for doing that and if you'd like you can take a look at it.
    sure thanks.
    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!

  17. #4427
    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 gameo
    I need some help with my PPP game. (Ping Pong Powerups. It's my first, so...)

    Controls for both players work, thanks to EminentJonFrost, and the loader have been fixed thanks to eldiablov.

    Now i need ball movement. I have the sprite of the ball, or rather, the image.
    So i need a little help on turning it into an object, and help how to make it move random, and collosion with the bat's.

    Here is the script:


    Code:
    white = Color.new(255, 255, 255)
    
    screen:print(136, 136, "Loading LUA Pong...", white)
    screen.flip()
    
    background = Image.load("Background.png")
    
    bat11 = Image.load("Bat1.png")
    
    bat21 = Image.load("Bat2.png")
    
    bat1 = { x = 20, y = 100 }
    bat2 = { x = 460, y = 100 }
    
    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 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
    
    screen:print(136, 136, "Welcome to the world of PPP.", white)
    screen.waitVblankStart()
    screen.flip()
    end
    Help will be greatly apprisiated. (<-- Wrong spelled?)
    making the ball into an object is actually fairly easy, its same as making the bat into an object, which you have already done.

    since this is ping pong, we'll make the ball first appear in the middle of the screen.

    Code:
    ball = { x = 240, y = 146, image = Image.load("ball image") } -- this is the middle of the screen, but blitting an
    -- image here will make the ball seem a little lower and to the right.
    -- play with the numbers til you get what you want.
    what that has done is: give the ball coordinates and an image (basically).
    i cant really help you very much with random movement. i'm kinda working on that myself (i hope within a few weeks you'll all see why :) ). i could help with collision though.

    Code:
    if ball.x == bat.x and ball.y >= bat.y and ball.y < [bats image length] then
    bounce away
    end
    this'll make it so that when the ball is at the same vertical point as the bat AND within the image's length (so its touching, which makes sense), it'll do whatever you code in place of "bounce away". also, you might want to do to the 'x' what i did to the 'y'. so that the ball collides on more than just the one point, unless your bat is a single pixel wide.
    -= Double Post =-
    quick question: what was the command to draw a rectangle? the psdevwiki site is down...
    Geändert von EminentJonFrost (12-02-2006 um 08:14 AM Uhr) Grund: Automerged Doublepost
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  18. #4428
    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

    screen.fillRect(x,y,w,h)
    or
    screen.drawLine(sx,sy,ex, ey) four times

  19. #4429
    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 -TacticalPaper-
    screen.fillRect(x,y,w,h)
    or
    screen.drawLine(sx,sy,ex, ey) four times
    hmm...so there isnt an actual command for it..oh well. Thanks!:)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  20. #4430
    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

    Well screen.fillRect() is, but it fills in the rectangle/square as well.

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

    yea, i know, i just need to draw the border of a rectangle. kinda like a frame for a health bar. well, actually, it'll do. i'll just put another rectangle over it in the background's color. problem solved!
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    Error: index.lua 27: unexpected symbol near [

    Press start to restart.

    Hmm?

    Here is the modified script:

    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] 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
    My PSP Projects:
    ___________________
    None.

  23. #4433
    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

    Yea for the border you'll have to draw each line. Also since thatd make it draw 4 lines every loop, id put it on a buffer along with the rest of your non-changing objects.

  24. #4434
    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 -TacticalPaper-
    Yea for the border you'll have to draw each line. Also since thatd make it draw 4 lines every loop, id put it on a buffer along with the rest of your non-changing objects.
    wait, put it on a buffer? whats that?
    -= Double Post =-
    Zitat Zitat von gameo
    Error: index.lua 27: unexpected symbol near [

    Press start to restart.

    Hmm?

    Here is the modified script:
    remove the brackets. (i think thats what theyre called)
    Geändert von EminentJonFrost (12-02-2006 um 08:51 AM Uhr) Grund: Automerged Doublepost
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

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

    Ok do this:
    Code:
    buffer = Image.createEmpty(480,272)
    Then for ALL your images and text and stuff that is NEVER changed at all, always stays in the same place, always says the same thing, do this:
    Code:
    buffer:blit(x,y,img)
    buffer:print(x,y,text,color)
    etc until everything on the screen that never moves has been put onto the image "buffer"
    Just treat buffer like screen and put stuff on it until you've got everything put on it, then do this:
    Code:
    while true do
    blah
    blah
    blah
    screen:blit(0,0,buffer)
    That'll put EVERYTHING on the buffer onto the screen. That makes luaplayer blit 1 image rather than blit 5 images, print 4 bits of text, draw 3 lines, etc each loop. It'll make your code more efficient if used properly.

    But remember, you still have to use screen:blit(x,y,img) for stuff that moves, like the main player or somethin.

  26. #4436
    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-
    Ok do this:
    Code:
    buffer = Image.createEmpty(480,272)
    Then for ALL your images and text and stuff that is NEVER changed at all, always stays in the same place, always says the same thing, do this:
    Code:
    buffer:blit(x,y,img)
    buffer:print(x,y,text,color)
    etc until everything on the screen that never moves has been put onto the image "buffer"
    Just treat buffer like screen and put stuff on it until you've got everything put on it, then do this:
    Code:
    while true do
    blah
    blah
    blah
    screen:blit(0,0,buffer)
    That'll put EVERYTHING on the buffer onto the screen. That makes luaplayer blit 1 image rather than blit 5 images, print 4 bits of text, draw 3 lines, etc each loop. It'll make your code more efficient if used properly.

    But remember, you still have to use screen:blit(x,y,img) for stuff that moves, like the main player or somethin.

    thats uself for stuff like healthbar, ammo, and maybe levels. although, be careful not to put too much stuff on it, cause itll make it even slower. (cause it has to reference something from outside the loop.)
    --------------------------------------------------------------------------------------

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

    oh, ok. buffer is good for stills and leave the rest normal. all right. i'll be sure to use it when i can. my problem with that though is that anything thats not part of the background pic moves. and well, the background is just one pic, would it be faster to put it to the buffer even though i have alot of other stuff moving?
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  28. #4438
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    How do you compile lua into an EBOOT, ive been searching every were for that tut.....if somebody could point me to the right direction i would be very thankfull.

  29. #4439
    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

    ok wait, i will give it to you

    ok here it is:

    http://www.mediafire.com/?8mwzrgg0dvg

    it includes README.txt so u know what to do with it ;)

  30. #4440
    QJ Gamer Blue
    Points: 4.918, Level: 44
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    6ft. Down Underground........Oh and guess what my avatar is
    Beiträge
    387
    Points
    4.918
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von myschoo
    ok wait, i will give it to you

    ok here it is:

    http://www.mediafire.com/?8mwzrgg0dvg

    it includes README.txt so u know what to do with it ;)
    ok thanks.....my next game will be an eboot so people wont have to screw with that stupid luaplayer
    -= Double Post =-
    I downloaded it but.....how do you edit it?
    Geändert von the undead (12-02-2006 um 11:45 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 07:52 AM Uhr.

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