How would I do player 2 controls?
would I end up copying the movement controls for player 1? Or is there an easier way?
would I end up copying the movement controls for player 1? Or is there an easier way?
If you wanted to do 2-player controls (WSAD/Arrows), for player 1, you would have do something like
update = function()
if keyboard.W == 1 then
player1Y += 1
end
if keyboard.S == 1 then
player1Y += 1
end
if keyboard.S == 1 then
player1X += 1
end
if keyboard.D == 1 then
player1X += 1
end
end
draw = function()
screen.drawSprite("player1",player1X,player1Y,32,32)
end
If you wanted to add a second player on the arrow keys, you can use
update = function()
if keyboard.ARROW_UP == 1 then
player2Y += 1
end
if keyboard.ARROW_DOWN == 1 then
player2Y += 1
end
if keyboard.ARROW_LEFT == 1 then
player2X += 1
end
if keyboard.ARROW_RIGHT == 1 then
player2X += 1
end
end
draw = function()
screen.drawSprite("player2",player2X,player2Y,32,32)
end
Theres no other way to do this without classes, objects, lists, and pointers, but its also not quite difficult to copy
thank you for clearing this up for me