I’m trying to make a game in which the character simply moves whenever you push the respective key, like a top-down game. It’s simple; there’s no gravity involved at all. Yet I can’t figure it out.
function on_input(self, action_id, action)
if action.id == hash(“up”) then
if action.pressed then
--insert code for moving up when we have it
end
end
elseif action.id == hash(“left”) then
if action.pressed then
--insert code for moving left when we have it
end
end
elseif action.id == hash(“down”) then
if action.pressed then
--insert code for moving down when we have it
end
end
elseif action.id == hash(“right”) then
if action.pressed then
--insert code for moving right when we have it
end
end
end
I have no clue how to approach the code that would normally go where the comments go. I know there’s a function called go.set_position() but I don’t know how to use it in this situation.
Please help me!
EDIT: Oh wow! This is the 1,000th question asked on the forums. Talk about milestones!