Zeige Ergebnis 7.231 bis 7.260 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; The GU code must be wrong then....
-
05-05-2007, 09:12 AM #7231
The GU code must be wrong then.
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-05-2007, 11:55 AM #7232words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
yum - You could always make a loader that flips an image's pixels across either axis... This would only have to be done at loading time as it's a whole new image, without having to have a new external image.
Loop through each pixel in the image you want flipped, and write it's color data to it's flipped position in the new image. I might just try to write one up for the sake of seeing if it works...
...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
-
05-05-2007, 12:41 PM #7233
Which would be so slow for 32 images that it would take like a minute to "load"
Zitat von SG57
This has been done many times, and the only way of achieving a good result would be to flip it in C, as lua is too slow for pixel-by-pixel operations.
Epic phale.牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-05-2007, 07:21 PM #7234QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Cant remember what is the offset for the nickname besides the 0x2380 in know it was somthing like 0x9????
-
05-05-2007, 11:22 PM #7235QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
0x980
-
05-05-2007, 11:27 PM #7236
anyone know some code that can make a character animation to look as though hes sabbing then return to the position he was it right before he stabed after you let go the button???
i made it work but when i push the button he stabs and stays in the stabbed position ??
any help would be apprecated
-
05-06-2007, 07:51 AM #7237QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Check out this code i made in around 45 seconds.
it cycles through all the colors the psp is capable of displaying (which is 16,581,375 colors). It would take approximately between 3 and 3.7 days to see them all.
Code:background = Image.createEmpty(480,272) r = 0 g = 0 b = 0 while true do color = Color.new(r,g,b) background:clear(color) screen:blit(0,0,background) if r < 255 then r = r + 1 end if r == 255 then r = 0 g = g + 1 end if g == 255 then g = 0 b = b + 1 end screen.waitVblankStart() screen.flip() end
and here is a code which draws parabolas all over the screen. This is the result of combining random code together to made something completely unexpected. this code is really not clean. a lot of it is not necessary.
Code:math.randomseed( os.time() ) green = Color.new(0,255,0) white = Color.new(255,255,255) black = Color.new(0,0,0) bullet = Image.createEmpty(4,4) bullet:clear(green) player = {} player.gravity = 500 player.y = 230 player.x = 50 pdir = "left" player.jumpspeed = 10 player.jumpstate = "ground" oldpad = Controls.read() currentBullet = 0 BulletInfo = {} for a = 1,1000 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player.x + 32, y = player.y } end function bulletSetup() if currentBullet < 1000 then currentBullet = currentBullet + 1 else currentBullet = 1 end if dir == "left" then BulletInfo[currentBullet].direction = "left" BulletInfo[currentBullet].x = player.x BulletInfo[currentBullet].y = player.y end if dir == "right" then BulletInfo[currentBullet].direction = "right" BulletInfo[currentBullet].x = player.x BulletInfo[currentBullet].y = player.y end BulletInfo[currentBullet].direction = direction BulletInfo[currentBullet].firing = true end function bulletFire() for i = 1,1000 do if BulletInfo[i].firing == true then if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic) end if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end end end f1 = Image.load("f1.png") ground = Image.createEmpty(480,10) ground:clear(black) while true do r = math.random(225) g = math.random(225) b = math.random(225) color = Color.new(r,g,b) bullet:clear(color) pad = Controls.read() screen:clear() bulletSetup() bulletFire() if walk == 1 then walk = 2 else walk = 1 end if player.jumpstate == "ground" then player.jumpstate = "jumping" end if player.jumpstate == "jumping" then player.jumpspeed = player.jumpspeed - 0.5 player.gravity = player.gravity - player.jumpspeed end if player.gravity < 0 then player.jumpstate = "falling" end if player.gravity < 230 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3) end if player.gravity == 230 then player.jumpspeed = 10 player.jumpstate = "ground" end if player.gravity > 230 then player.gravity = 230 end player.y = player.gravity screen:blit(player.x,player.y,f1) if pdir == "left" then player.x = player.x - 2 end if pdir == "right" then player.x = player.x + 2 end if player.x == 480 then dir = "left" pdir = "left" end if player.x == 0 then dir = "right" pdir = "right" end screen.waitVblankStart() screen.flip() oldpad = pad end
heres another one which flashes random colors and says "w00t" in another random color and a random x and y.
Code:math.randomseed( os.time() ) background = Image.createEmpty(480,272) while true do screen:clear() x = math.random(480) y = math.random(272) r = math.random(255) g = math.random(255) b = math.random(255) fontcolor = Color.new(b,r,g) color = Color.new(r,g,b) background:clear(color) screen:blit(0,0,background) screen:print(x,y,"w00t",fontcolor) screen.waitVblankStart() screen.flip() end
Geändert von Nicko01 (05-06-2007 um 08:29 AM Uhr)
-
05-06-2007, 08:10 AM #7238QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
x = math.random(272) --- it should be 480
y = math.random(480) --- it should be 272
r = math.random(225) --- its should be 255
g = math.random(225) --- same
b = math.random(225) --- same
fontcolor = Color.new(b,r,g) --- it should be R G B[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
05-06-2007, 08:28 AM #7239QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
no, if it was r,b,g, it would be the same color as the background.
ill fix the other stuff, i told you i made it in less than a minute.
-
05-06-2007, 08:44 AM #7240QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
oh yeah... text...my bad
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
05-06-2007, 10:58 AM #7241Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Nicko01
thats not a good excuse. you might as well spend 2 days on something and make it good, rather than make sucky stuff in 45 seconds. and your first sentence makes no sense. just because you use it like its b, g, r, doesnt mean its supposed to be like that. ;)
also, another reminder to all coders out there (especially beginners), start indenting. i simple tab makes your code 50 times easier to read. for example:
ugly, non-indented code:
same code, with indentations:Code:if a == 1 then if b == 2 then if c == 3 then if d == 4 then d = 1 end end end end
Code:if a == 1 then if b == 2 then if c == 3 then if d == 4 then d = 1 end end end end--------------------------------------------------------------------------------------
-
05-06-2007, 11:30 AM #7242
just bumping this up so i can get help
Zitat von waywardson
-
05-06-2007, 11:47 AM #7243Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
object states. ie
Code:pad = Controls.read() if pad:cross() then obj.attacking = true else obj.attacking = false end if obj.attacking then screen:blit(x,y,stabbing) else screen:blit(x,y,notstabbing) end
-
05-06-2007, 12:08 PM #7244
thanks a bunch man!!!!!!
-
05-06-2007, 01:25 PM #7245
what was the point of that stuff you posted nicko01?
-
05-06-2007, 01:35 PM #7246QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Nicko- Displaying all the colors in 7 lines (way shorter):
Code:for i = 1, 255 do for j = 1, 255 do for k = 1, 255 do screen:clear(Color.new(i,j,k)) end end end
-
05-06-2007, 03:03 PM #7247words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
TP - Try all the colors minus 765 ( i think )
Does the alpha channel add as well? Also, in Lua, do the for loops have a < or a <= for the number of loops to do?Code:for r = 0, 255 do for g = 0, 255 do for b = 0, 255 do screen:clear(Color.new(r,g,b)) end end end
...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
-
05-06-2007, 03:07 PM #7248QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Oh yea lol I forgot 0. And transparency might make a difference but I don't think so. If so then that's like 4-5 billion different backgrounds.
edit: 4228250625
-
05-06-2007, 03:11 PM #7249words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Yeah, transparency doesn't count apparently, as 256 cubed = 16,777,216 where 256 ^ 4 (what's after cubed?) = 4,294,967,296. The reason I think they dont count alpha channel is because having any pixel have an alpha channel (any transparency at all) will just be black as what;s underneathe it is nothing (either that, or just wont do anything as there isnt anything underneathe it)

...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
-
05-06-2007, 03:44 PM #7250
I am using different collsion then before in my shell but i am having problems. I don't encounter an error but it doesn't work.
Here is my code:
I was trying not to post here for help and do it on my own but i can't figure it out.Code:background=Image.load("images/menu.png") fb=Image.load("images/fb.png") fbclicked=Image.load("images/fbclicked.png") apps=Image.load("images/apps.png") appsclicked=Image.load("images/appsclicked.png") wb=Image.load("images/wb.png") wbclicked=Image.load("images/wbclicked.png") games=Image.load("images/games.png") gamesclicked=Image.load("images/gamesclicked.png") mp=Image.load("images/mp.png") mpclicked=Image.load("images/mpclicked.png") white=Color.new(255,250,250) cursor = Image.load("images/cursor.png") sensitivity = 40 maxspeed = 3 cursor = {x = 30, y = 100, w = 32, h = 32, oldx = 200, oldy = 50, img = Image.load ("images/cursor.png"), s = 4} cursorHeight = 32 cursorWidth = 32 button={} button[1] = {x = 21, y = 234, height = fb:height(), width = fb:width()} button[2] = {x = 210, y = 234, height = apps:height(), width = apps:width()} function moveCursor() pad=Controls.read() if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then cursor.x = cursor.x + pad:analogX()/(128/maxspeed) end if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then cursor.y = cursor.y + pad:analogY()/(128/maxspeed) end end function clock() time = os.time() timestring = os.date("%c",time) timeinfo = os.date("*t", time) hour = timeinfo.hour if hour > 11 then ampm = "PM" elseif hour < 12 then ampm = "AM" end min = timeinfo.min if min < 10 then min = "0" .. min end hour = timeinfo.hour if hour > 12 then hour = hour - 12 end screen:print(325, 26,hour..":" ..min .. " "..ampm, white) end function collisionCheck(object) if (cursor.x + cursorWidth > object.x) and (cursor.x < object.x + object.width) and (cursor.y + cursorHeight > object.y) and (cursor.y < object.y + object.height) then end end function button3() if pad:cross() and collisionCheck(button[1]) then dofile("fb.lua") end end function button4() if pad:cross() and collisionCheck(button[2]) then dofile("apps.lua") end end function screenPrint() screen:blit(0,0,background) screen:blit(21,234,fb) screen:blit(113,234,mp) screen:blit(210,234,apps) screen:blit(305,234,games) screen:blit(399,234,wb) screen:blit(cursor.x,cursor.y,cursor.img) screen:print(424,26, System.powerGetBatteryLifePercent(),white) end while true do screen:clear() collisionCheck(button[1]) collisionCheck(button[2]) moveCursor() button3() button4() screenPrint() clock() screen.waitVblankStart() screen.flip() end
Thanks Bob Hoil
-
05-06-2007, 04:24 PM #7251Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
You're not returning true or false in your collision function.
-
05-06-2007, 04:27 PM #7252QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Hmm...I was thinking about making my game online. I was kinda curious but I'm not sure if I should do it or not. I know Youresam made netlib and that would probably be what I need, but I haven't the slightest idea of how to use it. I just wanna know basic things about it, like how I could make someones character appear on my PSP screen...
Help is cool.
-
05-06-2007, 04:33 PM #7253QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You display the variables yourself. The coordinates of the image are what you actually send.
-
05-06-2007, 04:54 PM #7254
Thanks I got it working. Can't believe i forgot that.:Argh:
-
05-06-2007, 05:05 PM #7255QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 81
- Points
- 3.525
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I'm guessing that was directed at me, and you completely lost me.
Zitat von PSPJunkie_
How would I even get things to send. I have no idea how to use it, and nothing on the internets explains it for complete noobs like me.
And I'm guessing if I wanted to go anywhere with the game I would need a dedicated server?
-
05-06-2007, 05:19 PM #7256QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Look at the source of online.lua from the online sonic game. Youresam actually wrote that so it should be all good.
-
05-06-2007, 05:23 PM #7257words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
yum - You need to understand how to design a networked game.
My idea on how to do it would be to have a huge list (table in lua i guess) and compare data recieved from the other player with it, and act accordingly:
I havent tested it, so I don't know if it's the most efficient method, however, it's the most logical method I could create (I thought of this method last summer and have stuck with it).Code:action = { "move left", "move right", "move up", "move down", "attack" } recieved_data = "" while true do recieved_data = getDataSentFromOtherPSP() if recieved_data == action.move_left then Opponent.moveLeft() elseif recieved_data == action.move_right then Opponent.moveRight() elseif recieved_data == action.move_up then Opponent.moveUp() elseif recieved_data == action.move_down then Opponent.moveDown() elseif received_data == action.attack then Opponent.attack() end end
I may just test it this summer sometime for the sake of knowing how to properly design a networked game.
...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
-
05-06-2007, 05:28 PM #7258
netlib isnt running right now though...want me to turn it on..?
And SG57- lua is different from C in that it doesnt support define's, so what is received will probably be best to just compare to a string.牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-06-2007, 05:31 PM #7259
Are there any tutorials on how to use fonts? I have never used them and i am going to use a new font instead of the default one in lua player. I know how to load them(very easy) i just don't know how to make my text use the font.
-
05-06-2007, 05:56 PM #7260
screen:frontPrint(font, x, y, text, color)


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum