Lua Player for PSP

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

working on new project called "NORT"

Post by dragula96 »

hey everyone just thught id let everyone know im working on a project i like to call "NORT"

by looking at this picture i think you guys can guess how its gonna play :P
enyway, the thing im stuck with is the colition detection, i cant get it to work or cant figure out how to do it, can anyone point me to the right direction.

thanx
dragula96

UPDATE: NORT 0.1 is done get it here
http://www.megaupload.com/?d=23BCYZMZ
Last edited by dragula96 on Tue Aug 23, 2005 9:57 am, edited 2 times in total.
Evil Inside
Posts: 17
Joined: Thu Jul 21, 2005 4:42 am

Post by Evil Inside »

Nice, looks like it will be fun.

Take a look at Shine's snake for Collision detection.

You could also look at the PSP Air Hockey for multiplayer on one PSP controls.
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

well this is embarresing :^(

Post by dragula96 »

i cant draw just a single pixle on the screen
i can draw a line but not a single pixle
please help this noob :^(

im trying this and it dont work:
blue = (0,0,255)

screen:drawpixel(x,y,blue)
screen.waitVblankStart()
screen.flip()

"attempt to call method 'drawpixel' ( a nil value)"
also tried

screen:pixel(x, y, blue)

and still get an error.
>:(
MSX
Posts: 12
Joined: Wed Jul 06, 2005 2:16 pm

Re: well this is embarresing :^(

Post by MSX »

dragula96 wrote:i cant draw just a single pixle on the screen
i can draw a line but not a single pixle
please help this noob :^(

im trying this and it dont work:
blue = (0,0,255)

screen:drawpixel(x,y,blue)
screen.waitVblankStart()
screen.flip()

"attempt to call method 'drawpixel' ( a nil value)"
also tried

screen:pixel(x, y, blue)

and still get an error.
>:(
Try image:drawpixel(x, y, blue)
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

Post by dragula96 »

Evil Inside wrote:Nice, looks like it will be fun.

Take a look at Shine's snake for Collision detection.

You could also look at the PSP Air Hockey for multiplayer on one PSP controls.
ok i got good news and bad news, the good news is that i got it to work...
... the bad news is that the graphics had to take a hit :*^(

ok now for some info... looks like if i work on it overnight after i get out of work, ill have a basic working 2 player version with player 1 controling the D pad and player 2 using the buttons.

then on future releases i will include better grafics and a single player mode with an AI controlled opponent.

just dont be expecting a speed demon like squarz... at least not on the first version.

P.S. if anyone knows of a way to blit on "layers" so that the bottom layer dont blit only the first one, please let me know because the only way i see this happenning with drawing a cycle on it is to:
draw the "lines" on the bottom layer and draw the cycle on the top one then only blitting the top layer and leaving the bottom one alone so the lines dont dissapear.

-dragula96
Last edited by dragula96 on Tue Aug 23, 2005 9:58 am, edited 1 time in total.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: well this is embarresing :^(

Post by Shine »

dragula96 wrote:i cant draw just a single pixle on the screen
i can draw a line but not a single pixle
A pixel is a line with x0=x1 and y0=y1 (at least for Lua Player, not mathematical), but see http://www.luaplayer.org/functions.txt for the pixel function:

nil image:pixel(x, y, Color) --set

You can see the third parameter is a color object:

Code: Select all

blue = Color.new(0, 0, 255)
screen:pixel(100, 100, blue)
dragula96 wrote:P.S. if anyone knows of a way to blit on "layers" so that the bottom layer dont blit only the first one, please let me know because the only way i see this happenning with drawing a cycle on it is to:
draw the "lines" on the bottom layer and draw the cycle on the top one then only blitting the top layer and leaving the bottom one alone so the lines dont dissapear.
I don't understand what you mean, but sounds like it doesn't work. See the Snake game for an example with multiple layers. You have to draw your pixels to an image (which is called "snake" in the Snake game), blit this image every VSync to screen and then blit your cycles on top to the screen.
alex_dsnews
Posts: 13
Joined: Wed Aug 03, 2005 9:48 pm

Post by alex_dsnews »

just dont be expecting a speed demon like squarz... at least not on the first version.
you're not drawing every pixel each refresh, are you?
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

Post by dragula96 »

alex_dsnews wrote:
just dont be expecting a speed demon like squarz... at least not on the first version.
you're not drawing every pixel each refresh, are you?
no im not, just the next one the old ones stay, but the problem is that everytime it moves, it checks to see if it is = to the past moves like this

for i = 1, CurrentNumberofMoves

if x = past_x and y = past_y then
crash()

end
CurrentNumberofMoves = CurrentNumberofMoves +1


so you can see that after about 50 moves this can get slow
Benihana
Posts: 12
Joined: Sun Jul 31, 2005 4:54 am

Post by Benihana »

Try making i a local array (outside your for loop so that Lua does not assign it every loop);
local iArray = i

You should also be able to compare both variables;
if {x,y} == {past_x[iArray],past_y[iArray]} then
...
end

And finally make sure you are running this comparison once per move cycle, not once per screen refresh. Should be able to handle it... I haven't seen the code, have you posted it yet and I just missed it?
dragula96
Posts: 21
Joined: Fri Jun 17, 2005 4:46 pm

NORT 0.1 ready for download

Post by dragula96 »

ok i mannaged to get the collition detection to compair line differences instead of pixle difference which means alot less comparisons, a variable is only added each time the cycles turn and not each time they move forward.. ok enyway here is the link
(V 0.2) is now available here
http://www.megaupload.com/?d=2519XVN9




if anyone wants to mirror it then by all means do so.

NORT 0.2 (2 player version only for right now)
by dragula96



version 0.2 changes/fixes
------------------------------------
-added cycles to playfield
-changed blue color line and cycle to yellow
-removed white line in the middle of cycle walls
-changed background to a nicer one
- fixed bug where some people were not able to run game(ihope)
-fixed bug that would let you go "out of bounds" at the top


known bugs in 0.2
-pressing diagnaly is NOT RECOMMENDED, and slows down the game indefinetly
-if game goes on to long then slow down will occur however i cant find anyone
to test this with so i dont know how much slowdown you will get


version 0.1 NOTES:
-----------------------------
0.1 very first release, with very basic graphics
will be updated very soon with better graphics
and eventualy computer AI

Select = screenshot so dont press it if you dont want to take a pretty picture of my awsome program
OBJECTIVE OF THE GAME
---------------------------
simple: just make the other player crash into your "wall of death" before he does it to you
watch out the side walls and you are not immune to your own walls either.

(note: the game still does not keep track of score , players will have to do this in their heads)

player 1 controls "blue racer" with D pad
player 2 controls "red racer" with buttons (triangle,square,circle,cross)

this is only a test build please let me know if any bugs are found.
davidmtz2000@yahoo.com
-dragula96
Last edited by dragula96 on Tue Aug 23, 2005 9:57 am, edited 1 time in total.
MikeHaggar
Posts: 116
Joined: Mon Jul 18, 2005 2:20 am

Post by MikeHaggar »

http://haggar.pocketheaven.com/LUAtris Beta.zip

Beta version of what I've been working on the last 2 days.

Do not post as news (if any news site ppl reads this).

If anybody finds any bugs/crashes, then tell me (and it would be nice if you also say what line of code it crashes on).
Sir Harvo
Posts: 1
Joined: Wed Aug 24, 2005 6:06 am

Lua Player

Post by Sir Harvo »

Is a version planned to be usable with the European models?
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Re: Lua Player

Post by nevyn »

Sir Harvo wrote:Is a version planned to be usable with the European models?
No. It's currently impossible to run homebrew apps on European PSPs (and all PSPs running the 2.0 firmware), and is likely to be so for a while...
F34R
Posts: 29
Joined: Thu Jul 28, 2005 1:11 pm

Dpad converted to analog control..

Post by F34R »

Ok,

I have this basic control coded. It just pushes the square in the direction you input according to the dpad. I've been trying to learn how to use the analog function instead. Can someone help me convert this to analog instead of the dpad. Any help is appreciated.

Here is the code:

Code: Select all

-- Activate USB Mode
System.usbDiskModeActivate()

-- Get colors for text
white = Color.new(255, 255, 255)
red = Color.new(255, 0, 0)

-- Load images
square = Image.load("square.png")


-- Set starting X/Y positions
x = 200
y = 100 


while true do
pad = Controls.read()



if pad:up() then
	screen:clear()
	screen:print(200,1, "You Pressed Up", white) 
	y = y - 5
	if y < -4 then
		y = -4
	end
end


if pad&#58;down&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed Down", white&#41;
	y = y + 5
	if y > 230 then
		y = 230
	end
end


if pad&#58;left&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed Left", white&#41;
	x = x - 5
	if x < -4 then
		x = -4
	end
	
end


if pad&#58;right&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed Right", white&#41;
	x = x + 5
	if x > 440 then
		x = 440
	end
	
end


if pad&#58;cross&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed &#91;CROSS&#93;", white&#41;
end


if pad&#58;triangle&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed &#91;TRIANGLE&#93;", white&#41;
end


if pad&#58;square&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed &#91;SQUARE&#93;", white&#41;
end


if pad&#58;circle&#40;&#41; then
	screen&#58;clear&#40;&#41;
	screen&#58;print&#40;200,1, "You Pressed &#91;CIRCLE&#93;", white&#41;
end

if pad&#58;start&#40;&#41; then
		break
	end

-- Draw my little square

screen&#58;blit&#40;x, y, square&#41;
screen.flip&#40;&#41;

end
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Take a look at the Tutorial.
F34R
Posts: 29
Joined: Thu Jul 28, 2005 1:11 pm

Post by F34R »

Shine wrote:Take a look at the Tutorial.
I did already. I was able to use the analog, but it wasnt correct. I wasnt sure what type of x/y stuff I'd need to use. I'll go back and try and figure it out, unless someone wants to put a little hint down for me hehe.
nevyn
Posts: 136
Joined: Sun Jul 31, 2005 5:05 pm
Location: Sweden
Contact:

Post by nevyn »

F34R wrote:
Shine wrote:Take a look at the Tutorial.
I did already. I was able to use the analog, but it wasnt correct. I wasnt sure what type of x/y stuff I'd need to use. I'll go back and try and figure it out, unless someone wants to put a little hint down for me hehe.
If you keep asking for help with everything, you'll never learn properly yourself. Writing an app to test the behavior of the analog stick isn't that hard, and you'll probably learn more than just the analog stick in the process.
F34R
Posts: 29
Joined: Thu Jul 28, 2005 1:11 pm

Post by F34R »

nevyn wrote:
F34R wrote:
Shine wrote:Take a look at the Tutorial.
I did already. I was able to use the analog, but it wasnt correct. I wasnt sure what type of x/y stuff I'd need to use. I'll go back and try and figure it out, unless someone wants to put a little hint down for me hehe.
If you keep asking for help with everything, you'll never learn properly yourself. Writing an app to test the behavior of the analog stick isn't that hard, and you'll probably learn more than just the analog stick in the process.
Well, I continued to think about it, and write different things down, test them, and do it over again lol. I got it all working properly.

Thanks for the encouragement. I only asked for help because I was becoming very frustrated with failure. Fatigue from other things wasnt helping me think about what I wanted to accomplish, and... well, I was just very tired. I wish someone would have posted something for me to look at, but I did figure it out w/o it. So I guess its possible lol.

You were right, I learned something more than just how to implement basic movemen with the A-nub... I was able to figure out how to control its speed as well. Thanks.
Slopey
Posts: 24
Joined: Sun Jul 31, 2005 8:13 pm

Luaplayer windows controls question

Post by Slopey »

Hi All,

I'm using the windows lua player to code up my app without having to copy over to the PSP all the time, but I can't get the controls to work correctly. My test program (included below) produces the following results for the following keys:

a, s, q & w all work as described ie sel, start and triggers.

But f, r, c and d don't produce the desired behaviour. Instead, e,g,d and f seem to be up, down, left and right respectively. The upshot of this is that with the exception of the triangle and cross keys (r, c), the square and circle keys (d, f) don't produce the desired results - they come out as Left and Right???

Am I missing something totally obvious here? I've been over it so many times Im worried Im missing something thats staring me in the face.

Here's an attached listing which should display some chars based on the button pressed:

Code: Select all

color = Color.new&#40;0,0,0&#41;
white = Color.new&#40;255,255,255&#41;
black = Color.new&#40;0,0,0&#41;

myctrl = ""

while 1  do


	while myctrl == "" do
		screen.waitVblankStart&#40;&#41;
		pad = Controls.read&#40;&#41;
		if pad&#58;up&#40;&#41; then
			myctrl = "UP"
		elseif pad&#58;down&#40;&#41; then
			myctrl = "DN"
		elseif pad&#58;left&#40;&#41; then
			myctrl = "LF"
		elseif pad&#58;right&#40;&#41; then
			myctrl = "RG"
		elseif pad&#58;l&#40;&#41; then
			myctrl = "LS"
		elseif pad&#58;r&#40;&#41; then
			myctrl = "RS"
		elseif pad&#58;circle&#40;&#41; then
			myctrl = "CIR"
		elseif pad&#58;triangle&#40;&#41; then
			myctrl = "TRI"
		elseif pad&#58;square&#40;&#41; then
			myctrl = "SQUARE"
		elseif pad&#58;select&#40;&#41; then
			myctrl = "SEL"
		elseif pad&#58;start&#40;&#41; then
			myctrl = "START"
		elseif pad&#58;cross&#40;&#41; then
			myctrl = "X"
		end
	end

	screen&#58;clear&#40;white&#41;
	screen&#58;print&#40;10,10,myctrl,black&#41;
	screen.waitVblankStart&#40;&#41;
	screen.flip&#40;&#41;
	screen.waitVblankStart&#40;30&#41;
	myctrl = ""
	screen&#58;clear&#40;white&#41;
	screen.waitVblankStart&#40;&#41;
	screen.flip&#40;&#41;

end
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: Luaplayer windows controls question

Post by Shine »

Slopey wrote: I'm using the windows lua player to code up my app without having to copy over to the PSP all the time, but I can't get the controls to work correctly.
There was a bug, will be fixed in the next release.
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

Post by JJPeerless »

when do you expect the update that includes different color modes for png's?
zhaD
Posts: 5
Joined: Wed Sep 07, 2005 5:28 am
Location: Québec/Canada

Post by zhaD »

do you have an idea of when you will release the new version of the lua player for windows ? or is it : when its done..
Post Reply