this is what i have
"2DU"
what i want to do is have it replace the 3rd charecter in it. but instead of supplying the text i want tell it to look at a certain part of the array
Printable View
this is what i have
"2DU"
what i want to do is have it replace the 3rd charecter in it. but instead of supplying the text i want tell it to look at a certain part of the array
I'm making my first game in Lua, a Tag clone called TagX, which is basicly two player tag (on one psp) with fun maps, powerups stuff like that. Trust me, its fun. But it won't be fun unless I complete it, so please help me!
I need to find out a way to get collision detection (tagging) working. There are 4 sprites for each player, one for each direction.
Eg.
Player1n
Player1e
Player1s
Player1w
Player2n
Player2e
Player2s
Player2w
What I want to do, is make it so that when a player goes over another player, they swap sprites so that the player1 is now player2 and the player2 is player1 for every angle. If I didnt make it so they change directions it would be easy, but it has to swap for EVERY sprite in every direction.
Can anyone help me? :mrgreen:
how about this:
Do you understand that?Code:Player = { Player1 = { n = Image.load("image"), e = Image.load("image"), s = Image.load("image"), w = Image.load("image") }, Player2 = { n2 = Image.load("image"), e2 = Image.load("image"), s2 = Image.load("image"), w2 = Image.load("image") } }
x = 1
if [player1 and 2 meet] then
if x == 1 then
x = 2
elseif x == 2 then
x = 1
end
end
screen:blit(player_x, player_y, Player[x].n) -- when the 'x' changes, the sprites used will change.
Sort of...
How would I do 'the IF Player1 and player2 meet' thing?
dont get it? you may need to learn a bit more then.Zitat:
Zitat von fraseyboy
as for the two players meeting:
in words, that 'if' statement is:Code:if player1_x == player2_x and player1_y == player2_y then
If player1 is on the same 'x' point and the same 'y' point as player2 then...
[the code i showed before]
Ohhh i think i get it now... I'll try it and see.Zitat:
Zitat von EminentJonFrost
Hmm. It says 'attempt to index global ?, a nil value'.
Its on line 157 and that appears to be the...
screen:blit(player_x, player_y, Player[x].n) bit....
Where does Player_x and Player_y come from?
Heres my code BTW: http://pastebin.com/754753
I found this in your code, looks to me like the co-ordinates for the player, and there not in use because?Code:
- <LI class=li2>-- Player Coordinates
<LI class=li1>x1 = 45
<LI class=li2>y1 = 34
<LI class=li1>x2 = 415
<LI class=li2>y2 = 240
where'd you get them from? I can't see them anywhere in my code...Zitat:
Zitat von SG57
Well i got it from that luabin crud, i coopied and pasted, but look past the HTML junk to see it, imtoo lazy to do it myself ;-)