Multiplayer..

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

Moderators: Shine, Insert_witty_name

Post Reply
ThE eNeTin
Posts: 4
Joined: Tue May 30, 2006 4:50 am

Multiplayer..

Post by ThE eNeTin »

How can i implement the multiplayer in my game through the irda?

I've written this code, but i haven't tried it.
it's only a test for see if i succeed to establish a logon between two psp, even if i don't know well like realizing it.
System.irdaInit()

ownCrossPressed = "false"
otherCrossPressed = "false"
sprite = Image.createEmpty(64, 64)


while true do
screen:clear()
screen:print(0, 0, otherCrossPressed, white)
screen:print(0, 10, ownCrossPressed, white)

pad = Controls.read()
if pad:cross() then
ownCrossPressed = "cros"
System.irdaWrite("X")
else
System.irdaWrite("false")
end

if pad:start() then break
end

opad = System.irdaRead()
if opad:cross() then
otherCrossPressed = "X"
else
otherCrossPressed = "false"
end

screen.waitVblankStart()
screen.flip()
end
There would be pleasing if you helped me.

excuse me for my bad english.

Thanks.
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

Code: Select all

System.irdaInit() 

black = Color.new(0,0,0)
white = Color.new(255,255,255)

ownCrossPressed = "false" 
otherCrossPressed = "false" 
sprite = Image.createEmpty(64, 64) -- You didn't even use this in your code

while not Controls.read():start() do

pad = Controls.read() 
if pad:cross() then 
ownCrossPressed = "cross" 
System.irdaWrite("X") 
else 
System.irdaWrite("false") 
end

opad = System.irdaRead() 
if string.len(opad) > 0 then 
otherCrossPressed = opad 
else 
otherCrossPressed = "false" 
end

screen:clear(black) 
screen:print(0, 0, otherCrossPressed, white) 
screen:print(0, 10, ownCrossPressed, white) 
screen.waitVblankStart() 
screen.flip() 
end
- be2003
blog
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Re: Multiplayer..

Post by daurnimator »

ThE eNeTin wrote:How can i implement the multiplayer in my game through the irda?

I've written this code, but i haven't tried it.
it's only a test for see if i succeed to establish a logon between two psp, even if i don't know well like realizing it.
System.irdaInit()

ownCrossPressed = "false"
otherCrossPressed = "false"
sprite = Image.createEmpty(64, 64)


while true do
screen:clear()
screen:print(0, 0, otherCrossPressed, white)
screen:print(0, 10, ownCrossPressed, white)

pad = Controls.read()
if pad:cross() then
ownCrossPressed = "cros"
System.irdaWrite("X")
else
System.irdaWrite("false")
end

if pad:start() then break
end

opad = System.irdaRead()
if opad:cross() then
otherCrossPressed = "X"
else
otherCrossPressed = "false"
end

screen.waitVblankStart()
screen.flip()
end
There would be pleasing if you helped me.

excuse me for my bad english.

Thanks.
problem is that you're trying to read a ctrl set from the opponent - when they're only sending X or false..

try something like:
System.irdaInit()

ownCrossPressed = "false"
otherCrossPressed = "false"

while true do
screen:clear()
screen:print(0, 0, "Other Cross Pressed: "..otherCrossPressed, white)
screen:print(0, 10, "Own Cross Pressed: "..ownCrossPressed, white)

pad = Controls.read()
if pad:cross() then
ownCrossPressed = "X"
System.irdaWrite("X")
else
ownCrossPressed = "false"
System.irdaWrite("false")
end

if pad:start() then break end

otherCrossPressed = System.irdaRead()

screen.waitVblankStart()
screen.flip()
end
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

and dont forget to define all of your colors. white = Color.new(255,255,255)
- be2003
blog
ThE eNeTin
Posts: 4
Joined: Tue May 30, 2006 4:50 am

Post by ThE eNeTin »

thank to all!! :D
Post Reply