Page 1 of 1

How do I make entities move?

Posted: Tue Jan 21, 2014 3:34 pm
by 23456bn
Hi,
Noob in programming here(:3), also first post, so bare with. I've attached my .love file (that's what I'm supposed to do right?) because I'm having problems with moving a player entity. I think I've managed to create an entity (with the help of a friend) in the form of a turtle (sorry, my graphics skills are rather bad) that I would like to be able to make move around the screen, and stop at the edges of my arena. Also, I've also attempted to update to love 0.9.0, and it says in the compiled file that the game was made for another version. How can I fix this?
Thanks for putting up will my noobiness and for all replies :D.

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 5:30 pm
by Roland_Yonaba
23456bn wrote: Also, I've also attempted to update to love 0.9.0, and it says in the compiled file that the game was made for another version. How can I fix this?
It just works fine here.
23456bn wrote:...I would like to be able to make move around the screen, and stop at the edges of my arena. Also, I've also attempted to update to love 0.9.0, and it says in the compiled file that the game was made for another version. How can I fix this?
Thanks for putting up will my noobiness and for all replies :D.
How exactly do you want it to move ? Randomly ?
Or does it supposed to follow a specific path ? Actually, when I say "path", I mean you have an ordered set of locations the entity should visit one after another.

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 5:47 pm
by 23456bn
I was hoping to be able to control my turtle by pressing the "WASD" keys to make it move left, right, front and back, rather than in a set path or randomly.
Thanks.

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 5:57 pm
by Roland_Yonaba
23456bn wrote:I was hoping to be able to control my turtle by pressing the "WASD" keys to make it move left, right, front and back, rather than in a set path or randomly.
Thanks.
There are many ways to achieve that. A simple one is to use love.keyboard.isDown and increase/decrease the x/y pair coordinates controlling the entity position accordingly. See the hamster ball tutorial for reference. ;)

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 6:00 pm
by 23456bn
Thanks, I'll try it out! :D

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 6:34 pm
by 23456bn
I might be being an idiot here, if so sorry, but when I press the W,A,S,D keys it gives me an error...(and yes, I have replaced the "left", "right" etc. with WASD).
Am I not selecting the entity for adjusting its x and y? If so, how do I do this?
Thanks again.

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 6:37 pm
by Davidobot
Welcome to the forums, my dear William! :monocle:

For the solution to all your problems look in gamestate.lua under updateTurtles(dt)

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 6:48 pm
by 23456bn
Salutations to you too David!
Thanks mate. Also thanks Roland_Yonaba!
Works now.
:D

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 7:09 pm
by Roland_Yonaba
Side note, instead of posting the whole file for such problem, you could have posted the relevant code.
Glad it worked out, though.

Re: How do I make entities move?

Posted: Tue Jan 21, 2014 7:19 pm
by mickeyjm
Roland_Yonaba wrote:Side note, instead of posting the whole file for such problem, you could have posted the relevant code.
Glad it worked out, though.
That's a bit of a catch-22 isn't it? When someone post code snippets we request the whole thing, when they post the whole thing we request snippets. Maybe posting both would be more useful though.