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 only thing I can think of is maybe you're loading too many images OR what I think the problem ...
-
06-15-2006, 07:07 AM #2641Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
The only thing I can think of is maybe you're loading too many images OR what I think the problem is, is "lv1.png" Is "lv1.png" a huge image? If it is it might be having problems blitting it or even loading it.
Zitat von Noriko
-
06-15-2006, 07:09 AM #2642Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Well the images are like 4kb apiece and the BG is a 480x272 image thats.... wtf... 90kb... maybe thats the problem
EDIT: And it is. Thank you! now I need a new BG
Geändert von Mast3r_Shak3 (06-15-2006 um 07:12 AM Uhr)

--XBL Gamertag: PhenoM904--
-
06-15-2006, 10:58 AM #2643Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
OKay... umm how do I have it so when I press left on the d-pad a left arrow will show. But when I press right a right arrow shows? (And the left arrow be gone so it doesnt look like <->)

--XBL Gamertag: PhenoM904--
-
06-15-2006, 11:03 AM #2644Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Like this:
That should work.Code:right = Image.load("rightarrow.png") left = Image.load("leftarrow.png") background = Image.load("background.png") while true do pad = Controls.read() if pad:right() then screen:blit(0, 0, background) screen:blit(10, 10, right) end if pad:left() then screen:blit(0, 0, background) screen:blit(10, 10, left) end end
-
06-15-2006, 11:13 AM #2645Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Doesnt really work... It makes it all slow and Im doing it for a sidescrolling engine with multiple images on the screen.

--XBL Gamertag: PhenoM904--
-
06-15-2006, 12:40 PM #2646Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
I know that this is a real noob like question but:
What does the alpha channel in LUA do and how do i use it?
--Vaza
-
06-15-2006, 01:04 PM #2647
Mirroring an Image
Something I've noticed when looking through a bunch of the lua homebrew. In platformers, specifically, I see folks making multiple copies of the same sprite so they have a left and right direction of each. I assume that it'd be more convenient to simply mirror the sprite horizontally when drawing, depending on the desired direction. I'd hoped to test it myself, but I've been hard pressed to find a bit of code lending this function. Looking into the lua snippets, I found something that I thought might lead me to an answer, but I've hit a bit of a road block.
The rotate by 90 degrees code,
with the included image, seems to show an image being simply rotated by 90 degrees. However, when you change the image, you see that it actually gets mirrored either horizontally or vertically while being rotated.Code:-- Variables smile = Image.load("smiley.png") function rotateImage(theImage) newImage = Image.createEmpty(theImage:height(), theImage:width()) for x = 1, theImage:width() do for y = 1, theImage:height() do newImage:blit(y, x, theImage, x, y, 1, 1) end end return newImage end -- rotateImage --main program screen:blit(0, 0, smile) screen:blit(100, 0, rotateImage(smile)) screen:flip() screen.waitVblankStart(600)

I've messed with bits of it, but I'm still new to these lua functions, and find that one often has to find a workaround for non-defaults. Some help with the matter would be much appreciated.
-
06-15-2006, 01:36 PM #2648
You could use this to mirror it (just made it, so I haven't tested it, but it should work):
Pretty easy actually (yes I used this code as a basis).Code:-- Variables smile = Image.load("smiley.png") function mirrorImage(theImage) newImage = Image.createEmpty(theImag e:height(), theImage:width()) for x = theImage:width(),1,-1 do for y = 1, theImage:height() do newImage:blit(x, y, theImage, x, y, 1, 1) end end return newImage end -- rotateImageLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
06-15-2006, 01:37 PM #2649
It sets the transparency. 0 is no transparency and 255 is full transparency.
Zitat von Vaza
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
06-15-2006, 02:12 PM #2650
Actually, it does the exact same thing as if you had only swapped the x and y in the blit function: copied the image exactly as it had been. Thanks for the attempt, though.
Zitat von Altair
-
06-15-2006, 03:42 PM #2651<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
i need help on doing that too,,
Zitat von Paburo
-
06-15-2006, 03:52 PM #2652QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Can any one help me I want my program to Save a irda signal to a variable on a botton press while selecting an object on a menu.
This is what I have so far:
Code:if pad:circle() and menustatus == -1 then irdasignal = System.irdaRead() end
-
06-15-2006, 04:43 PM #2653
Huh? It should work assuming that LUA starts at the last x and ends with the first one. I looked it up in the manual and LUA should be able to do that because I make it use steps of -1.
Zitat von Paburo
Did you try it with the yellow/purple smiley?LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
06-15-2006, 05:16 PM #2654
I wouldn't try it with any other. Implimenting the code you handed me, the image is just copied exactly.
Zitat von Altair
Code:-- Variables smile = Image.load("smiley.png") function mirrorImage(theImage) newImage = Image.createEmpty(theImage:height(), theImage:width()) for x = theImage:width(),1,-1 do for y = 1, theImage:height() do newImage:blit(x, y, theImage, x, y, 1, 1) end end return newImage end -- rotateImage screen:blit(0, 0, smile) screen:blit(100, 0, mirrorImage(smile)) screen:flip() screen.waitVblankStart(600)
-
06-16-2006, 02:45 AM #2655
Got it I forgot that it uses the same x:
Code:smile= Image.load("smiley.png") function mirrorImage(theImage) newImage = Image.createEmpty(theImage:width(),theImage:height()) x2=0 --second x needed otherwise it pastes the x at the same place for x = theImage:width(),0,-1 do for y = 0, theImage:height() do newImage:blit(x, y, theImage, x2, y, 1, 1) end x2=x2+1 end return newImage end screen:clear() screen:blit(0, 0, smile) screen:blit(100, 0, mirrorImage(smile)) screen.waitVblankStart() screen:flip() while true do -- this is just for testing purpose screen.waitVblankStart() pad = Controls.read() if pad:start() then break end endGeändert von Altair (06-16-2006 um 03:01 AM Uhr)
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
06-16-2006, 07:39 AM #2656Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Ok.. Im making a sidescroll engine and I need help with direction association with the sprites when i press left and right. Ive tested a few things but I get over lapping images... help?

--XBL Gamertag: PhenoM904--
-
06-16-2006, 07:41 AM #2657Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von MaSt3r_ShAk3
are you coding your own? or are u using my tut? OR are you using lumos code??--------------------------------------------------------------------------------------
-
06-16-2006, 07:42 AM #2658Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Which tuts are you reffering to?
Heres my codeCode:black = Color.new(0,0,0) --VARIABLES/ARRAYS-- player = {} player.x = 20 player.y = 200 enemy = {} enemy.x = 420 enemy.y = 200 poox = nil --poox, pooy = player poo-- pooy = nil poo2x = nil --poo2x, poo2y = AI poo-- poo2y = nil at=1 --Air Time-- aj=0 --Active Jump-- r=0 --Ready (To Jump)-- z = 0 --IMAGES-- browndashleft = Image.load("brown/monkey1dashl.png") browndashright = Image.load("brown/monkey1dashr.png") brownhitleft = Image.load("brown/monkey1hitl.png") brownhitright = Image.load("brown/monkey1hitr.png") brownjumpleft = Image.load("brown/monkey1jumpl.png") brownjumpright = Image.load("brown/monkey1jumpr.png") brownstandleft = Image.load("brown/monkey1standl.png") brownstandright = Image.load("brown/monkey1standr.png") bluedashleft = Image.load("blue/monkey2dashl.png") bluedashright = Image.load("blue/monkey2dashr.png") bluehitleft = Image.load("blue/monkey2hitl.png") bluejumpleft = Image.load("blue/monkey2jumpl.png") bluejumpright = Image.load("blue/monkey2jumpr.png") bluestandleft = Image.load("blue/monkey2standl.png") bluestandright = Image.load("blue/monkey2standr.png") bg = Image.load("background.png") --FUNCTIONS-- function moveleft() z = 1 if player.x > 0 then player.x = player.x - 5 end end function moveright() z = 2 if player.x < 456 then player.x = player.x + 5 end end function textbgstuff() screen:blit(0,0, bg, false) screen:print(2,2, "WiP Engine Test", black) screen:print(2,12, "DONE: Movement, Sprites, jumping", black) screen:print(2,22, "TODO: throwing, AI, collision, directional association", black) end function blitstuff() screen:blit(player.x, player.y, browndashright) screen:blit(enemy.x, enemy.y, bluestandleft) end function throw() --being worked on-- end function jump() --being worked on-- end function direction() if z == 1 then screen:blit(player.x, player.y, browndashleft) end if z == 2 then screen:blit(player.x, player.y, browndashright) end end function jump() if aj==0 and math.abs(player.y) > 199 then r=1 else r=0 end if pad:square() and r==1 then aj=1 end if aj==1 and math.abs(at) < 100 then player.y=player.y-5 at=at+1 end if at==20 then aj=0 at=1 end if aj==0 and math.abs(player.y) < 200 then player.y=player.y+6 end end while true do ----MAIN LOOP---- screen:clear() textbgstuff() pad = Controls.read() if pad:left() then moveleft() end if pad:right() then moveright() end direction() jump() if pad:start() then break end blitstuff() screen.flip() screen.waitVblankStart() end
--XBL Gamertag: PhenoM904--
-
06-16-2006, 07:48 AM #2659Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von MaSt3r_ShAk3
umm, how is that a sidescrolling engine??--------------------------------------------------------------------------------------
-
06-16-2006, 07:50 AM #2660Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Well its sidescrolling... maybe im not using the right terminology... but i still need help...

--XBL Gamertag: PhenoM904--
-
06-16-2006, 07:51 AM #2661Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
is our background moving to the left or right automatically??
Zitat von MaSt3r_ShAk3
--------------------------------------------------------------------------------------
-
06-16-2006, 07:54 AM #2662Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
No... okay i get it its not an engine but I still need help..........

--XBL Gamertag: PhenoM904--
-
06-16-2006, 07:55 AM #2663TheMarioKartersGuest
Master Shake, is that the Monkey Poo fight game you and bronx are doing?
-
06-16-2006, 07:56 AM #2664Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Yeah.

--XBL Gamertag: PhenoM904--
-
06-16-2006, 07:57 AM #2665QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Are you gonna finish flipbook?
-
06-16-2006, 08:00 AM #2666Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
At one point... butterballer on psp-programming said he wanted to work with me and i accepted and he said he rewrote flipbook completely... but Im gonna wait til I get back in florida to do any more work on that

--XBL Gamertag: PhenoM904--
-
06-16-2006, 08:23 AM #2667Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von MaSt3r_ShAk3
can u pm me the files wit the images?? i u want?? i can tyr to fix it. i cant see wha you mean by using words. i wont steal. i dont need to,--------------------------------------------------------------------------------------
-
06-16-2006, 08:24 AM #2668QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
I got two questons
1.
Can any one help me I want my program to Save a irda signal to a variable on a botton press while selecting an object on a menu.
This is what I have so far:
2.Code:if pad:circle() and menustatus == -1 then irdasignal = System.irdaRead() end
when I hit left or right my pic. doesnt move but when I hit up or down it moves .
Code:red = Color.new(255, 0, 0); white = Color.new(255, 255, 255); char = Image.load("char.png") y = 100 x = 100 while true do screen:clear() -- read current pad pad = Controls.read() if pad:up() then y = y - 1 elseif pad:down() then y = y + 1 elseif pad:left() then X = x - 1 elseif pad:right() then X = x + 1 end screen:blit(x, y, char, 0, 0, char:width(), char:height(), true) screen.flip() screen.waitVblankStart() if pad:start() then break end endGeändert von zmathue (06-16-2006 um 09:06 AM Uhr)
-
06-16-2006, 08:28 AM #2669Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von zmathue
i dont know aboyut the first question, but in the second one, have you defined cx?? or did you men to put just "x"?--------------------------------------------------------------------------------------
-
06-16-2006, 09:05 AM #2670QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
I changed them to that to see if it was my variable that was the problem I guess I forgot to change it back to x when I posted.
^^i fixed the thred now^^


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