Seite 261 von 342 ErsteErste ... 161 211 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 311 ... LetzteLetzte
Zeige Ergebnis 7.801 bis 7.830 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; Ok i was wondering if anyone could give me a link to a tut that shows me how to add ...

  
  1. #7801
    QJ Gamer Bronze
    Points: 5.934, Level: 49
    Level completed: 92%, Points required for next Level: 16
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    654
    Points
    5.934
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Ok i was wondering if anyone could give me a link to a tut that shows me how to add a menu for my game, like main menu, and animation... Thanks if you can.



  2. #7802
    QJ Gamer Gold
    Points: 12.189, Level: 72
    Level completed: 35%, Points required for next Level: 261
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Under Your Bed
    Beiträge
    3.083
    Points
    12.189
    Level
    72
    Downloads
    0
    Uploads
    0

  3. #7803
    QJ Gamer Bronze
    Points: 5.934, Level: 49
    Level completed: 92%, Points required for next Level: 16
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    654
    Points
    5.934
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Ok heres my code so far
    Code:
    --Colors
    white = 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()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    But when i press X in the menu, nothing happens, any help?
    Oh and is there any tutorials on like making the screen scroll to see the rest of a map (like in Halo Genocide, if u keep moving right the screen will start to scroll)?

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

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

    Standard

    anyone ever seen this error?
    Code:
    libpng error: Too many IDAT's found
    i have a feeling its from loading over 50 pngs but i thought i deleted them by setting them to nil. this does delete them correct?

  5. #7805
    QJ Gamer Bronze
    Points: 4.563, Level: 43
    Level completed: 7%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Louisiana
    Beiträge
    183
    Points
    4.563
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _-Tiger-_
    Ok heres my code so far
    Code:
    --Colors
    white = 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()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    But when i press X in the menu, nothing happens, any help?
    Oh and is there any tutorials on like making the screen scroll to see the rest of a map (like in Halo Genocide, if u keep moving right the screen will start to scroll)?
    1. clicking x on current 1 only set variables
    2. have you written the functions for Options() and Exit()
    Survived Hurricane Gustav!!!!!

  6. #7806
    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 _-Tiger-_
    Ok heres my code so far
    Code:
    --Colors
    white = 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()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    But when i press X in the menu, nothing happens, any help?
    Oh and is there any tutorials on like making the screen scroll to see the rest of a map (like in Halo Genocide, if u keep moving right the screen will start to scroll)?
    very easy, just put this:

    Code:
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    in the 'while' loop, you have it outside.

    Code:
    --Colors
    white = 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()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end

  7. #7807
    QJ Gamer Bronze
    Points: 4.563, Level: 43
    Level completed: 7%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Louisiana
    Beiträge
    183
    Points
    4.563
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _-Tiger-_
    Ok heres my code so far
    Code:
    --Colors
    white = 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()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear()
    )background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    But when i press X in the menu, nothing happens, any help?
    Oh and is there any tutorials on like making the screen scroll to see the rest of a map (like in Halo Genocide, if u keep moving right the screen will start to scroll)?
    change you code to this:

    Code:
    --Colors
    white = Color.new(255,255,255)
    red = Color.new(255,0,0)
    --Images
    background = Image.load("images/background.jpg")
    player2 = Image.load("images/player2.png")
    
    current = 1 --this is our current menu selection
    oldpad = Controls.read()
    while true do
    pad = Controls.read()
    screen:clear()
    screen:print(240,100,"Single Player",white)
    screen:print(240,110,"Options",white)
    screen:print(240,120,"Exit",white)
    if current == 1 then
    screen:print(240,100,"Single Player",red)
    end
    if current == 2 then
    screen:print(240,110,"Options",red)
    end
    if current ==3 then
    screen:print(240,120,"Exit",red)
    end
    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
    if current == 6 then
    current = 1
    end
    if current == 0 then
    current = 5
    end
    
    if pad:cross() and current == 1 then
    Single = Player(
    screen:clear())
    screen:blit(0,0,background)
    screen:blit(0,0,player2)
    end
    if pad:cross() and current == 2 then
    Options()
    end
    if pad:cross() and current == 3 then
    Exit()
    end
    
    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    Survived Hurricane Gustav!!!!!

  8. #7808
    QJ Gamer Bronze
    Points: 5.934, Level: 49
    Level completed: 92%, Points required for next Level: 16
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Beiträge
    654
    Points
    5.934
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Hey thanks all. So does anyone know where i can find a tutorial on how to make the screen slid so to speak? For like sidescrolling games?

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

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

    Standard

    TacticalPenguin's code

    Code:
    playerimg = Image.load("player.png")
    player = {x = 0, y = 272-playerimg:height()}
    bgp1 = {x = 0, img = Image.load("bgp1.png") }
    bgp2 = {x = 480, img = Image.load("bgp2.png") }
    bgp3 = { x = 960, img = Image.load("bgp3.png") }
    while true do
    if player.x < 120 and bgp1.x < 0 then
    bgp1.x = bgp1.x + 1
    bgp2.x = bgp2.x + 1
    bgp3.x = bgp3.x + 1
    end
    if player.x + playerimg:width() > 360 and bgp1.x > -960 then
    bgp1.x = bgp1.x - 1
    bgp2.x = bgp2.x - 1
    bgp3.x = bgp3.x - 1
    end
    if pad:left() and player.x > 0 then player.x = player.x - 1 end
    if pad:right() and player.x < 480-playerimg:width() then player.x = player.x + 1 end
    screen:blit(bgp1.x,0,bgp1 .img)
    screen:blit(bgp2.x,0,bgp2 .img)
    screen:blit(bgp3.x,0,bgp3 .img)
    screen:blit(player.x,play er.y,playerimg)
    screen.waitVblankStart()
    screen.flip()
    end

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

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

    Standard

    Zitat Zitat von Da_MerV
    anyone ever seen this error?
    Code:
    libpng error: Too many IDAT's found
    i have a feeling its from loading over 50 pngs but i thought i deleted them by setting them to nil. this does delete them correct?
    when you set them to nil, try putting in this function after:
    Code:
    collectgarbage()
    see here and here

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

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

    Standard

    function cleanUp()
    image1 = nil
    image2 = nil
    image3 = nil
    collectGarbage()
    end

    Then call the function when needed. It is slow though.

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

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

    Standard

    ah, thanks to the both of ya

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

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

    Standard

    Zitat Zitat von Merick
    Here's a function that uses the GU for a fast resizing/flipping of images:

    Code:
    function Gu.blit(x, y, image, scale, flip)
    	
    	if not scale or type(scale) == "string" then 
    		flip = scale
    		scale = 1
    	end
    	
    	if flip then
    		if flip == "H" then
    			x_start = image:width()
    			y_start = 0
    			x_end  = 0
    			y_end = image:height()
    		elseif  flip == "V" then
    			x_start = 0
    			y_start = image:height()
    			x_end  = image:width()
    			y_end = 0
    		elseif flip == "HV" then
    			x_start = image:width()
    			y_start = image:height()
    			x_end = 0
    			y_end = 0
    		end
    	else
    		x_start = 0
    		y_start = 0
    		x_end = image:width()
    		y_end = image:height()
    	end
    	
    	width = (image:width()*scale)+x
    	height = (image:height()*scale)+y
    	temp = {
    	{x_start, y_start, x, y, 0},
    	{x_end, y_end, width, height, 0}
    	}
    	Gu.enable(Gu.TEXTURE_2D)
    	Gu.texImage(image)
    	Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp)
    end
    the argument "scale" is a multiplier for the size of the image, I.E. 0.5 is half size, 2 is double size, etc... If you leave this out the scale will default to 1

    the argument "flip" is a string, "H" flips horizontally, "V" flips it vertically, "HV" will flip it both ways.

    Because this uses the GU, you need to use Gu.start3d() and Gu.end3d(), also remember that you can't use the regular screen:blit function while the GU is running or lua player will crash.

    and, here's an example script for how to use it:

    Code:
    img = Image.load("image.png")
    
    pad = Controls.read()
    screen:clear()
    Gu.start3d() 
    Gu.blit( 20,  20, img, 0.5, "H")
    Gu.blit(100,  10, img, 1.5, "HV")
    Gu.blit(300,  10, img, "V")
    Gu.end3d() 
    screen:flip()
    
    while not pad:start() do
    	pad = Controls.read()
    end
    To rotate an image to any angle, see this old post I made on Evilmana for an example:

    http://www.forums.evilmana.com/index.php?topic=676.0
    on the topic of image modification with the gu, would anyone know where to start in creating a gu model that could produce as effects as this:

    exact numbers can be tweaked, just a general form.

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

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

    Standard

    Check this one out:

    Code:
    function RotateBlit(bx, by, bz, img, xrot, yrot, zrot, size) -- special blit function using the GU
    --[[ 
    bx, by, bz = x, y, and z coordinates to draw the image at
    img = image to use
    xrot,  yrot, zrot = rotation in degrees for each axis
    size = size to display image in %, will default to 100% if left blank
    ]]
    local w = img:width()/2
    local h = img:height()/2
    
    xrot = xrot * (Gu.PI/180)
    yrot = yrot * (Gu.PI/180)
    zrot = zrot * (Gu.PI/180)
       
    
    if size == nil then size = 1
    	else size = size / 100
    end
    
    local imagetile = {
    	-- top section
    	{ .5,  .5,   0,   0,  0},
    	{  0,   0,  -w*size,   h*size,  0},
    	{  1,   0,   w*size,   h*size,  0},
    	-- right section
    	{0.5, 0.5,   0,   0,  0},
    	{  1,   0,   w*size,   h*size,  0},
    	{  1,   1,   w*size,  -h*size,  0},
    	-- bottom section
    	{0.5, 0.5,   0,   0,  0},
    	{  1,   1,   w*size,  -h*size,  0},
    	{  0,   1,  -w*size,  -h*size,  0},
    	-- left section
    	{0.5, 0.5,   0,   0,  0},
    	{  0,   1,  -w*size,  -h*size,  0},
    	{  0,   0,  -w*size,   h*size,  0},   
    	}
    
    
    	Gu.enable(Gu.TEXTURE_2D);
    	Gu.texImage(img)
    	Gu.texFunc(Gu.TFX_MODULATE, Gu.TCC_RGBA)
    	Gu.texFilter(Gu.NEAREST, Gu.NEAREST)
    	Gu.texScale(1, 1)
    	Gu.texOffset(0, 0)
    	Gum.matrixMode(Gu.MODEL)
    	Gum.loadIdentity()
    	Gum.translate(bx, by, bz);
    	Gum.rotateXYZ(xrot, yrot, zrot)
    	Gum.drawArray(Gu.TRIANGLES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_3D, imagetile)
    end
    
    function start_gu(fov) -- starts the gu for drawing with the GuBlit function, 
    --if you dont put anything in the () when calling this function the fov will default to 50
    
    	if fov == nil then fov = 50 end
    	Gu.start3d()
    	Gu.clearDepth(0);
    	Gu.clear(Gu.COLOR_BUFFER_BIT+Gu.DEPTH_BUFFER_BIT)
    	Gum.matrixMode(Gu.PROJECTION)
    	Gum.loadIdentity()
    	Gum.perspective(fov, 480/272, 0.5, 1000)
    	Gum.matrixMode(Gu.VIEW)
    	Gum.loadIdentity()
    	Gum.matrixMode(Gu.MODEL)
    	Gum.loadIdentity()
    	Gu.enable(Gu.BLEND)
    	Gu.blendFunc(Gu.ADD, Gu.SRC_ALPHA, Gu.ONE_MINUS_SRC_ALPHA, 0, 0)
    end
    When used as-is these functions will let you blit a rotated image, but you might be able to alter them to do the other image transforms you wanted

    example:

    startSP() -- sets up the Gu for 3d

    RotateBlit(0, 0, -290, image, 0,0,90, 150) -- blits an image rotated at 90 degrees in the center of the screen

    Gu.end3d() -- stops the Gu

    screen:flip()

    Because this one uses perspective mode, any images blitted normally will always be underneath the images drawn with this function, anything drawn with fillRect or screenrint will be on top

    Also, if used as-is this function will only work with images where the height and width are the same, and are multiples of 8

    One last note - this is an old function that I gave up on a while ago, before mod 4 came out. Since mod 4 is supposed to have ortho mode implemented, if you can figure out how to use it instead of perspective mode you could probably fix the problems.

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

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

    Standard

    how come the model is drawn with 4 triangles versus 2?

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

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

    Standard

    by drawing with 4 triangles, you can rotate it around the center of the image, if you were to draw it with 2 triangles the image would rotate around a corner, I've attached a crappy drawing to illustrate this
    Miniaturansicht angehängter Grafiken Miniaturansicht angehängter Grafiken Lua Programming Help Thread-rotate.jpg  

  17. #7817
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Does anyone know an easy way to draw a diagonal rectangle?

    I mashed up this...

    Code:
    function round(num, idp)
    	local mult = 10^(idp or 0)
    	return math.floor(num * mult + 0.5) / mult
    end
    
    function diagline(x,y,width,height,angle)
    	for i=0,height do
    		local x0 = round(x - (i * math.cos((angle + 90)*math.pi/180)),0)
    		local y0 = round(y - (i * math.sin((angle + 90)*math.pi/180)),0)
    
    		Image:drawLine(
    			x0,
    			y0,
    			round(x0 - (width * math.cos(angle*math.pi/180)),0),
    			round(y0 - (width * math.sin(angle*math.pi/180)),0),
    			grey
    		)
    	end
    end
    ... but obviously it fragments up at certain angles, most noticeably at 45.

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

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

    Standard

    You could try using the gu, seems its the hot topic of today.

    Speaking of which, can anyone explain the different texture filters that I found in pspgu.h?
    * - GU_NEAREST
    * - GU_LINEAR
    * - GU_NEAREST_MIPMAP_NEAREST
    * - GU_LINEAR_MIPMAP_NEAREST
    * - GU_NEAREST_MIPMAP_LINEAR
    * - GU_LINEAR_MIPMAP_LINEAR
    What are they, how do they work, what side effects do they have (ie. speed), and whats the result?

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

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

    Standard

    You shouldn't need to change them from what Lua Player inits them to.

    If you really must know, then Google for the OpenGL counterparts.

    Merick: You don't need four triangles, you could do the same with two.

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

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

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

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

    Standard

    How? the only way that I can think of for doing it with only two triangles would require using extra calculations to create coordinate offsets which would need to rotate around the center of the image in the opposite direction of the image rotation...

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

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

    Standard

    You just need to create the vertices for the outmost points, forget about the central point.
    Geändert von Insert_Witty_Name (07-29-2007 um 07:12 PM Uhr)

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

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

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

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

    Standard

    Zitat Zitat von Insert_Witty_Name
    You just need to create the vertices for the outmost points, forget about the central point.
    Whenever I use that method it rotates around the corner point instead of the center, which is usually what I want, am I doing something wrong?

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

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

    Standard

    i used triangle_strip and got it to run perfectly on 2 triangles. it also fixed the flicker problem.

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

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

    Standard

    See attached image.

    You need to translate to the centre point of where the image will be located, and plot your vertices around that central point.

    Pseudo code:

    Code:
    drawRotatedRect(x, y, width, height, angle)
    (
    	halfWidth = width/2
    	halfHeight = height/2
    
    	createVert(x = -realWidth, y = -realHeight, 0)
    	createVert(x = -realWidth, y = realHeight, 0)
    	createVert(x = realWidth, y = realHeight, 0)
    	createVert(x = realWidth, y = -realHeight, 0)
    	
    	loadIdentity()
    	translate(x + halfWidth, y + halfHeight, 0)
    	rotateZ(angle)
    	
    	draw(triangle_fan, verts)
    )
    I've used a triangle fan instead of two triangles, but you get the idea.
    Miniaturansicht angehängter Grafiken Miniaturansicht angehängter Grafiken Lua Programming Help Thread-quad.png  

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

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

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

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

    Standard

    I'm really stuck. I'm trying to create my own quiz game and everything works perfectly but I can't figure out a way to go the next question. The questions work on random numbers (as in a random number is made and the questions are shown accordingly to that random number e.g if random == 1 then) but after it says whether the answer is correct or not, it returns to the same question. Does anyone know how to fix this?

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

    Post your code. For a quiz game, the general design should be something similar to having an array of structures/classes (in Lua, an array of tables). Within each structure/class members generally should be: question string, an array of answer strings and a variable saying which element in the answer array is the correct answer. Other members could include colors for each question or answer, a timer for each question so on more difficult questions they are given more time, X and Y coordinates for the question and answers to display, number of answers, etc. Then you assign a variable a random value ranging between how many elements in your question array.

    Here's the general design of a quiz game I'd use. Implementing a time limit, different colors, etc. is made easy by this design. However, some designs may be made to run faster via sacrificing this ability Don't let this influence you to always use this sort of design, as there may be others out there that are better and the only way to find them is design your own.
    Code:
    math.randomseed(os.time());
    
    NUM_QUESTIONS = 4
    NUM_ANSWERS = 4
    
    question = {}
    
    question[1] = { name = "What is 2 + 2?", answer = {"X: 2","[]: 3","^: 4","O: 5"}, correctAnswer = 3 }
    question[2] = { name = "What is SG57's real name?", answer = {"X: Jordan","[]: John","^: George","O: Bob"}, correctAnswer = 1 }
    question[3] = { name = "How old is SG57?", answer = {"X: 12","[]: 13","^: 14","O: 15"}, correctAnswer = 4 }
    question[4] = { name = "How long has SG57 been programming?", answer = {"X: ~1 year","[]: ~2 years","^: ~3 years","O: ~4 years"}, correctAnswer = 2 }
    
    currentQuestion = math.random(1, NUM_QUESTIONS) -- does math.random generate a number including the smallest and biggest?  so 1 and 4 may be an output? if not, change thisto 0 and 5
    
    correct = 0
    incorrect = 0
    
    oldQuestion = 0
    oldpad = Controls.read()
    
    function printCentered(y, STRING, color)
        screen:print( 240-string.len(STRING)/2*8, y, STRING, color)
    end
    
    while true do
        pad = Controls.read()
    
        if oldpad ~= pad then
            if pad:cross() then
                if question[currentQuestion].correctAnswer == 1 then
                    correct = correct + 1
                else
                    incorrect = incorrect + 1
                end
                
                oldQuestion = currentQuestion
                while currentQuestion == oldQuestion do
                    currentQuestion = math.random(1,4)
                end
            elseif pad:square() then
                if question[currentQuestion].correctAnswer == 2 then
                    correct = correct + 1
                else
                    incorrect = incorrect + 1
                end
                
                oldQuestion = currentQuestion
                while currentQuestion == oldQuestion do
                    currentQuestion = math.random(1,4)
                end
            elseif pad:triangle() then
                if question[currentQuestion].correctAnswer == 3 then
                    correct = correct + 1
                else
                    incorrect = incorrect + 1
                end
                
                oldQuestion = currentQuestion
                while currentQuestion == oldQuestion do
                    currentQuestion = math.random(1,4)
                end
            elseif pad:circle() then
                if question[currentQuestion].correctAnswer == 4 then
                    correct = correct + 1
                else
                    incorrect = incorrect + 1
                end
                
                oldQuestion = currentQuestion
                while currentQuestion == oldQuestion do
                    currentQuestion = math.random(1,4)
                end
            end
        end
    
        oldpad = pad
    
        screen:clear()
    
        printCentered(140,question[currentQuestion].name, Color.new(255,255,255))
    
        for i=1,NUM_ANSWERS do
            printCentered(160 + i*15,question[currentQuestion].answer[i], Color.new(200,200,200))
        end
    
        printCentered(10,"Correct:  " .. correct .. "                                 Incorrect:  " .. incorrect, Color.new(255,255,255))
    
        screen.waitVblankStart()
        screen.flip()
    end
    Geändert von SG57 (07-30-2007 um 02:13 AM Uhr)

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

    make sure that ur calling recalling the random variable after the player has chosen the correct answer
    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

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

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

    Standard

    Zitat Zitat von Insert_Witty_Name
    See attached image.

    You need to translate to the centre point of where the image will be located, and plot your vertices around that central point.

    Pseudo code:

    Code:
    drawRotatedRect(x, y, width, height, angle)
    (
    	halfWidth = width/2
    	halfHeight = height/2
    
    	createVert(x = -realWidth, y = -realHeight, 0)
    	createVert(x = -realWidth, y = realHeight, 0)
    	createVert(x = realWidth, y = realHeight, 0)
    	createVert(x = realWidth, y = -realHeight, 0)
    	
    	loadIdentity()
    	translate(x + halfWidth, y + halfHeight, 0)
    	rotateZ(angle)
    	
    	draw(triangle_fan, verts)
    )
    I've used a triangle fan instead of two triangles, but you get the idea.
    Thats so simple and makes perfect sense. Thanks for that, I'm still trying to get a handle on 3d designs, My background is in VBA apps so all these coordinates give me a headache sometimes.

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

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

    Standard

    Zitat Zitat von slicer4ever
    make sure that ur calling recalling the random variable after the player has chosen the correct answer
    How do I do that?

  30. #7830
    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 drag_93
    I'm really stuck. I'm trying to create my own quiz game and everything works perfectly but I can't figure out a way to go the next question. The questions work on random numbers (as in a random number is made and the questions are shown accordingly to that random number e.g if random == 1 then) but after it says whether the answer is correct or not, it returns to the same question. Does anyone know how to fix this?
    you have to post some code up so someone can actually help you, or the most people can really do is throw examples at you like SG57 did.

    and what slicer4ever means (correct me if i'm wrong!) is for the variable 'random' to change its value after the player answers the question correctly so that a new one appears, but i'm assuming thats in the case that a different question appears depending on the value of 'random'.

    it would really help us help if you posted some code

    [edit]an example i guess would be:

    Code:
    random = 1
    
    if random == 1 then
    -[post question]
    --if question is answered then
    --random = some other number
    --end
    elseif random == some other number then
    -[post another question]
    end
    get it?
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]


 

Tags for this Thread

Forumregeln

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





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:00 PM Uhr.

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