Forum rules: Forum rule Nº 15 is strictly enforced in this subforum.
#216426 by dragonxtamer596
Wed Dec 26, 2012 4:18 am
qwikrazor87 wrote:Hmm... I don't see what's wrong. :?

Well, happy x-mas, and since I actually got the writing to show up in this code I need help finalizing it.

In this part the player will cross the other one and a split second later the writing will disappear, so what I ask is how do you keep the text of whose it on screen but print only who is it on screen because when the players cross it prints "player2 is it" and "player1 is it" on the screen at the same time.

Code: Select allif player1x == player2x and player1y == player2y then
screen:print(20, 20, "player2 is it",white)
end
if player2x == player1x and player2y == player1y then
screen:print(20, 20, "player1 is it",white)
end


The whole code\/

Code: Select all--Created by dragonxtamer596
black = Color.new(0,0,0)
white = Color.new(255,255,255)

Room_width = 480
Room_height = 272
player1x =240
player1y =136
player2x =120
player2y =80

background=Image.load("images/Background.PNG")
player1=Image.load("images/Player1.PNG")
player2=Image.load("images/Player2.PNG")

function checkcontrols()
pad = Controls.read()
if pad:start() then
screen:fillRect(0, 0, 480, 272, black)
dofile("index.lua")
end

if pad:right() then
player1x = player1x +2
end

if pad:left() then
player1x = player1x -2
end

if pad:up() then
player1y = player1y -2
end

if pad:down() then
player1y = player1y +2
end

if pad:circle() then
player2x = player2x +2
end

if pad:square() then
player2x = player2x -2
end

if pad:triangle() then
player2y = player2y -2
end

if pad:cross() then
player2y = player2y +2
end
end

function drawall()
screen:blit(0,0,background)
screen:blit(player1x,player1y,player1)
screen:blit(player2x,player2y,player2)
if player1x == player2x and player1y == player2y then
screen:print(20, 20, "player2 is it",white)
end
if player2x == player1x and player2y == player1y then
screen:print(20, 20, "player1 is it",white)
end
screen.waitVblankStart()
screen.flip()
end

while true do
checkcontrols()
drawall()
end
Advertising
#216437 by qwikrazor87
Wed Dec 26, 2012 5:09 am
Merry christmas. :D
You need a value to determine who is it or not.
Maybe do something like,
Code: Select allwhoisit = math.floor(math.random(1, 3))
istag = "no"

while true do
screen:clear()
screen:print(20, 20, "player"..whoisit.." is it",white)
  if player1x == player2x and player1y == player2y then
    if istag == "no" then
    istag = "yes"
    whoisit = whoisit + 1
      if whoisit > 2 then
      whoisit = 1
      end
    end
  else
    if istag == "yes" then
    is tag = "no"
    end
  end
screen.waitVblankStart()
screen.flip()
end

I haven't tested it out, but it should work.
Advertising
#216728 by dragonxtamer596
Wed Dec 26, 2012 6:45 pm
qwikrazor87 wrote:Merry christmas. :D
You need a value to determine who is it or not.
Maybe do something like,
Code: Select allwhoisit = math.floor(math.random(1, 3))
istag = "no"

while true do
screen:clear()
screen:print(20, 20, "player"..whoisit.." is it",white)
  if player1x == player2x and player1y == player2y then
    if istag == "no" then
    istag = "yes"
    whoisit = whoisit + 1
      if whoisit > 2 then
      whoisit = 1
      end
    end
  else
    if istag == "yes" then
   [u] is tag = "no"[/u]
    end
  end
screen.waitVblankStart()
screen.flip()
end

I haven't tested it out, but it should work.

It works....IT WORKS tears of joy. :cry: The only issue with it was the is wasn't next to the tag now I just need to add collision, smaller characters, and a bigger room. :D
#216757 by qwikrazor87
Wed Dec 26, 2012 8:08 pm
:D
Well if you want to add the detection of collision for their edges just change the parameters to this.
Code: Select allwhoisit = math.floor(math.random(1, 3))
istag = "no"

while true do
screen:clear()
screen:print(20, 20, "player"..whoisit.." is it",white)
  if player1x <= player2x + player2:width() and player1y <= player2y + player2:height() and player1x >= player2x and player1y >= player2y then
    if istag == "no" then
    istag = "yes"
    whoisit = whoisit + 1
      if whoisit > 2 then
      whoisit = 1
      end
    end
  else
    if istag == "yes" then
   [u] is tag = "no"[/u]
    end
  end
screen.waitVblankStart()
screen.flip()
end

If there is something wrong with it let me know, but I'm sure it'll work.
#216891 by dragonxtamer596
Thu Dec 27, 2012 3:19 am
I have questions about the lua players you suggested to me earlier.
PGE and LuaDevR0 >\/
For LuaDevR0 does your lua code have to be in Spanish?
And a question for both do I have to change my code to make them work on either?
#216902 by qwikrazor87
Thu Dec 27, 2012 3:35 am
For LuaDevR0 does your lua code have to be in Spanish?
No, you can code in whatever language you want.

And a question for both do I have to change my code to make them work on either?
There are some function names you will have to change, for example,
Lua Player 0.20
Code: Select allpicture = Image.load(pathtoimage)

list = System.listDirectory(directory)

LuaDEV R0
Code: Select allpicture = image.load(pathtoimage)

list = files.list(directory)

pgelua
Code: Select allpicture = pge.texture.load(pathtoimage)

dir = pge.dir.open(directory)
list = dir:read()
dir:close()

Those are just a few of the differences, but as you can see with pgelua you have to work a little more to get things done, that is why I suggest LuaDEV over pgelua.
It may be a little confusing at first but it's worth it. LuaDEV and pgelua are much faster.
#216908 by dragonxtamer596
Thu Dec 27, 2012 3:55 am
What's the diffence between LME and ME cfw? viewtopic.php?f=17&t=7334
I read this...
-I want to try 6.60ME can i return back to other firmwares?
There is a downgrader, some1 released the 6.60 version

...and I'm wondering does that mean I can't or can go back to my Pro-B if I don't like it?
Also which ones more like pro cfw because Pro is super easy to navigate press cross to start cross again to launch/finalize?
#216912 by qwikrazor87
Thu Dec 27, 2012 4:05 am
They both install and launch the same way, and can both be uninstalled.
With ME/LME you can run 1.50 homebrew with the leda plugin.
With PRO you can play adhoc games online with the PRO online client.
They both have there pros and cons.
#227373 by dragonxtamer596
Sun Jan 13, 2013 9:21 pm
Can you help with changing my code to lua devR0?

Code: Select allblue = Color.new(0, 50, 175)
white = Color.new(255,255,255)
black = Color.new(0,0,0)

ms = 1
mms = 4

oldpad = Controls.read()

while true do
screen:clear()
pad = Controls.read()

if pad:up() and oldpad:up() ~= pad:up() then
ms = ms - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
ms = ms + 1
end
if ms > mms then
ms = 1
elseif ms <= 0 then
ms = mms
end

mc = { white,white,white,white }
mc[ms] = blue
screen:print(98,107,"Game",mc[1])
screen:print(98,117,"Option 2",mc[2])
screen:print(98,127,"Option 3",mc[3])
screen:print(98,137,"Option 4",mc[4])

if pad:cross() and not oldpad:cross() and ms == 1 then
screen:fillRect(0, 0, 480, 272, black)
dofile("Game.lua")
end

if pad:cross() and not oldpad:cross() and ms == 2 then
end

if pad:cross() and not oldpad:cross() and ms == 3 then
end

if pad:cross() and not oldpad:cross() and ms == 4 then
end

if ms <= 0 then
ms = 4
end

if ms >= 5 then
ms = 1
end

screen.waitVblankStart()
screen.flip()
oldpad = pad
end


Code: Select all--Created by dragonxtamer596
black = Color.new(0,0,0)
white = Color.new(255,255,255)

whoisit = math.floor(math.random(1, 3))
istag = "no"

Room_width = 480
Room_height = 272
player1x =240
player1y =136
player2x =120
player2y =80

background=Image.load("images/Background.PNG")
player1=Image.load("images/Player1.PNG")
player2=Image.load("images/Player2.PNG")

function checkcontrols()
pad = Controls.read()
if pad:start() then
screen:fillRect(0, 0, 480, 272, black)
dofile("script.lua")
end

if pad:right() then
player1x = player1x +2
end

if pad:left() then
player1x = player1x -2
end

if pad:up() then
player1y = player1y -2
end

if pad:down() then
player1y = player1y +2
end

if pad:circle() then
player2x = player2x +2
end

if pad:square() then
player2x = player2x -2
end

if pad:triangle() then
player2y = player2y -2
end

if pad:cross() then
player2y = player2y +2
end
end

function drawall()
screen:clear()
screen:blit(0,0,background)
screen:blit(player1x,player1y,player1)
screen:blit(player2x,player2y,player2)
screen:print(20, 20, "player"..whoisit.." is it",white)
  if player1x <= player2x + player2:width() and player1y <= player2y + player2:height() and player1x >= player2x and player1y >= player2y then
    if istag == "no" then
    istag = "yes"
    whoisit = whoisit + 1
      if whoisit > 2 then
      whoisit = 1
      end
    end
  else
    if istag == "yes" then
    istag = "no"
    end
  end
screen.waitVblankStart()
screen.flip()
end

while true do
checkcontrols()
drawall()
end


Does Lua dev play music?
what type if so?
What file is the file lua dev first reads? example Index.lua, Script.lua...
Also could this be pulled off....
Code: Select allblack = Color.new(0,0,0)

image1=Image.load("images/image1.PNG")
screen:blit(0,0,image1)

if image1=Image.load("images/image1.PNG") and not image1=Image.load("images/image1.PNG") then
screen:fillRect(0, 0, 480, 272, black)
screen:clear()
image2=Image.load("images/image2.PNG")
screen:blit(0,0,image2)
end

if image1=Image.load("images/image2.PNG") and not image1=Image.load("images/image2.PNG") then
screen:fillRect(0, 0, 480, 272, black)
screen:clear()
image3=Image.load("images/image3.PNG")
screen:blit(0,0,image3)
end

while true do
screen.waitVblankStart()
screen.flip()
end
#227439 by qwikrazor87
Mon Jan 14, 2013 12:32 am
Code: Select allblue = color.new(0,0,255)
white = color.new(255,255,255)
black = color.new(0,0,0)

ms = 1
mms = 4

while true do
screen.clear()
controls.read()

  if controls.press("up") then
  ms = ms - 1
  end
  if controls.press("down") then
  ms = ms + 1
  end
  if ms > mms then
  ms = 1
  elseif ms <= 0 then
  ms = mms
  end

mc = {white, white, white, white}
mc[ms] = blue
screen.print(98, 107, "Game", mc[1])
screen.print(98, 117, "Option 2", mc[2])
screen.print(98, 127, "Option 3", mc[3])
screen.print(98, 137, "Option 4", mc[4])

  if controls.press("cross") and ms == 1 then
  draw.fillrect(0, 0, 480, 272, black)
  dofile("Game.lua")
  end
  if controls.press("cross") and ms == 2 then
  end
  if controls.press("cross") and ms == 3 then
  end
  if controls.press("cross") and ms == 4 then
  end
  if ms <= 0 then
  ms = 4
  end
  if ms >= 5 then
  ms = 1
  end
screen.waitvblankstart()
screen.flip()
end


Code: Select allblack = color.new(0, 0, 0)
white = color.new(255, 255, 255)

whoisit = math.floor(math.random(1, 3))
istag = "no"

Room_width = 480
Room_height = 272
player1x = 240
player1y = 136
player2x = 120
player2y = 80

background = image.load("images/Background.PNG")
player1 = image.load("images/Player1.PNG")
player2 = image.load("images/Player2.PNG")

function checkcontrols()
controls.read()
  if controls.press("start") then
  draw.fillrect(0, 0, 480, 272, black)
  dofile("script.lua")
  end

  if controls.right() then
  player1x = player1x + 2
  end

  if controls.left() then
  player1x = player1x - 2
  end

  if controls.up() then
  player1y = player1y - 2
  end

  if controls.down() then
  player1y = player1y + 2
  end

  if controls.circle() then
  player2x = player2x + 2
  end

  if controls.square() then
  player2x = player2x - 2
  end

  if controls.triangle() then
  player2y = player2y - 2
  end

  if controls.cross() then
  player2y = player2y + 2
  end
end

function drawall()
screen.clear()
background:blit(0,0)
player1:blit(player1x, player1y)
player2:blit(player2x, player2y)
screen.print(20, 20, "player"..whoisit.." is it", white)
  if player1x <= player2x + player2:width() and player1y <= player2y + player2:height() and player1x >= player2x and player1y >= player2y then
    if istag == "no" then
    istag = "yes"
    whoisit = whoisit + 1
      if whoisit > 2 then
      whoisit = 1
      end
    end
  else
    if istag == "yes" then
    istag = "no"
    end
  end
screen.waitvblankstart()
screen.flip()
end

while true do
checkcontrols()
drawall()
end


dragonxtamer596 wrote:Does Lua dev play music?
what type if so?
Yes, mp3, wav, at3 and bgm.

dragonxtamer596 wrote:What file is the file lua dev first reads? example Index.lua, Script.lua...
It looks for two files, script.lue if the file is encrypted, or script.lua if it's not encrypted.

dragonxtamer596 wrote:Also could this be pulled off....
Code: Select allblack = Color.new(0,0,0)

image1=Image.load("images/image1.PNG")
screen:blit(0,0,image1)

if image1=Image.load("images/image1.PNG") and not image1=Image.load("images/image1.PNG") then
screen:fillRect(0, 0, 480, 272, black)
screen:clear()
image2=Image.load("images/image2.PNG")
screen:blit(0,0,image2)
end

if image1=Image.load("images/image2.PNG") and not image1=Image.load("images/image2.PNG") then
screen:fillRect(0, 0, 480, 272, black)
screen:clear()
image3=Image.load("images/image3.PNG")
screen:blit(0,0,image3)
end

while true do
screen.waitVblankStart()
screen.flip()
end

The way you made the statements are wrong.
It should be like this when asking if an image is loaded.
Code: Select allimage1=image.load("images/image1.PNG")
  if image1 then
  --code here
  end

In your code you are asking if the image is loaded and if it's not loaded at the same time,
Code: Select allif image1 and not image1 then
--code here
end
That will not bring out the results you are expecting.

Who is online

Users browsing this forum: No registered users and 0 guests

On the blog

logo

Thursday January 01, 1970

logo

Thursday January 01, 1970

logo

Thursday January 01, 1970

logo

Thursday January 01, 1970

Twitter

About Us

Wololo.net is a community of gaming console fans, developers, and security enthusiasts.

We're the largest community of PS Vita, PS4, and PSP hackers on the intertubes. We also dive into the 3DS and PS3 when we feel like it.

Making S0ny Nervous since 2008