How do I make entities move?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
23456bn
Prole
Posts: 5
Joined: Tue Sep 24, 2013 11:10 am

How do I make entities move?

Post 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.
Attachments
TurtleWars.love
(3.55 MiB) Downloaded 150 times
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How do I make entities move?

Post 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.
23456bn
Prole
Posts: 5
Joined: Tue Sep 24, 2013 11:10 am

Re: How do I make entities move?

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How do I make entities move?

Post 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. ;)
23456bn
Prole
Posts: 5
Joined: Tue Sep 24, 2013 11:10 am

Re: How do I make entities move?

Post by 23456bn »

Thanks, I'll try it out! :D
23456bn
Prole
Posts: 5
Joined: Tue Sep 24, 2013 11:10 am

Re: How do I make entities move?

Post 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.
Attachments
TurtleWars.love
(1.94 MiB) Downloaded 339 times
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: How do I make entities move?

Post by Davidobot »

Welcome to the forums, my dear William! :monocle:

For the solution to all your problems look in gamestate.lua under updateTurtles(dt)
Attachments
TurtleWars.love
(18.32 KiB) Downloaded 145 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
23456bn
Prole
Posts: 5
Joined: Tue Sep 24, 2013 11:10 am

Re: How do I make entities move?

Post by 23456bn »

Salutations to you too David!
Thanks mate. Also thanks Roland_Yonaba!
Works now.
:D
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How do I make entities move?

Post 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.
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: How do I make entities move?

Post 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.
Your screen is very zoomed in...
Post Reply

Who is online

Users browsing this forum: pgimeno and 11 guests