Code: Select all
player = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -700,
speed = 450,
flySpeed = 700,
state = "",
h = 32,
w = 32,
standing = false,
}
Code: Select all
player = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -700,
speed = 450,
flySpeed = 700,
state = "",
h = 32,
w = 32,
standing = false,
}
Code: Select all
player = {
index = 1, -- index of currently selected player
x = 256, -- shared between chars
y = 127,
xvel=0,yvel=0,
jumpheight = {10, 64, -2, 19},
vel_multiplier= {1,1,1,4}
}
actually I did see that and I tried it in my game it didnt really workzorg wrote:Literally just missed it: viewtopic.php?f=4&t=2490
*unless you were asking about whether you really need to define each character's stats, which in my opinion would be a yes
Code: Select all
characters = {
player1
player2
player3
player4
}
player1 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player2 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player3 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player4 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
characters = Player
end
function love.keypressed(k)
if k == 1 then player = player1
elseif k == 2 then player = player2
elseif k == 3 then player = player3
elseif k == 4 then player = player4
end
end
That would almost work but doesnt make sense. You reassign The variable player and lose the list of players (that doesnt even work because they arent defined yet anyway)pactace wrote:Here a hypothisis but maybe this would workthats just my guessCode: Select all
characters = { player1 player2 player3 player4 } player1 = { x = 256, y = 256, x_vel = 0, y_vel = 0, jump_vel = -4000, speed = 400, flySpeed = 859, state = "", h = 55, w = 45, standing = false, } player2 = { x = 256, y = 256, x_vel = 0, y_vel = 0, jump_vel = -4000, speed = 400, flySpeed = 859, state = "", h = 55, w = 45, standing = false, } player3 = { x = 256, y = 256, x_vel = 0, y_vel = 0, jump_vel = -4000, speed = 400, flySpeed = 859, state = "", h = 55, w = 45, standing = false, } player4 = { x = 256, y = 256, x_vel = 0, y_vel = 0, jump_vel = -4000, speed = 400, flySpeed = 859, state = "", h = 55, w = 45, standing = false, } characters = Player end function love.keypressed(k) if k == 1 then player = player1 elseif k == 2 then player = player2 elseif k == 3 then player = player3 elseif k == 4 then player = player4 end end
I could but I won't. If I just give you working code you will never improve and come back with the next question in 5 minutes. You will need to learn and understand on your own, and it seems you have a lot of Lua and programming in general to learn.pactace wrote:Can you improve the code cause I have no Idea what you just said
Code: Select all
player1 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player2 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player3 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
player4 = {
x = 256,
y = 256,
x_vel = 0,
y_vel = 0,
jump_vel = -4000,
speed = 400,
flySpeed = 859,
state = "",
h = 55,
w = 45,
standing = false,
}
Player = player1
end
function love.keypressed(k)
if k == 1 then player = player1
elseif k == 2 then player = player2
elseif k == 3 then player = player3
elseif k == 4 then player = player4
end
end
Users browsing this forum: Bing [Bot], Semrush [Bot] and 8 guests