Hai,
As I'm sure you can tell I'm a newcomer to this site, to the language lua, and to this tremendous game engine LÖVE2D.
I had the idea to make a top down 2d fighting game using traditional M.O.B.A controls ("q" "w" "e" "r" for each individual ability/attack and mouse clicks to control where the player moves) Now, unfortunately due to my lack of lua knowledge and general idiocy I couldn't figure out how to change my currently
"w" "a" "s" "d" controlled character to mouse click control. I am aware this has been answered to before but after reading through the answer many times yet still failing to fully understand it I decided to ask the forums again despite it voiding the forum rules.
thank you very much for your time!
you are all awesome!
~Weeguy
Mouse controlled player movement; help please
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- xXweeguyXx
- Prole
- Posts: 5
- Joined: Fri Aug 16, 2013 9:57 pm
Mouse controlled player movement; help please
- Attachments
-
- Game_Test.love
- Here's the .love!
- (2.78 KiB) Downloaded 195 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Mouse controlled player movement; help please
Welcome! What exactly is your question?
Help us help you: attach a .love.
- Rhinoceros
- Prole
- Posts: 35
- Joined: Mon Jun 11, 2012 2:59 am
- Location: Under the Floorboards
Re: Mouse controlled player movement; help please
I'm pretty sure that they want the character to move to where the mouse was clicked, as per standard RTS style.
- xXweeguyXx
- Prole
- Posts: 5
- Joined: Fri Aug 16, 2013 9:57 pm
Re: Mouse controlled player movement; help please
Thankyou kind sir!Robin wrote:Welcome! What exactly is your question?
I'm sorry for not making clear, my question was how would I go about making mouse controlled player, as Rhinoceros said "as per standard RTS style"
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Mouse controlled player movement; help please
You'll need to get a pathfinding library first, preferably one with coroutines. (So the game doesn't halt when each character is checking for a path) If your game is standard tile based it'll be easy-ish. You'll need to make sure the pathfinding algorithm is aware of your map format. i.e. how each grid space is marked as solid or not.
Then when you click, you figure out which tile was clicked, tell the currently commanding characters to calculate a path to that tile. Then follow that path block by block one step at a time.
Complicated? Eh, maybe. I dunno.
Then when you click, you figure out which tile was clicked, tell the currently commanding characters to calculate a path to that tile. Then follow that path block by block one step at a time.
Complicated? Eh, maybe. I dunno.
Re: Mouse controlled player movement; help please
I'm not exactly sure how to do it, but in theroy:
You'd have a player's destinationX and destinationY value. Where ever the mouse clicks, make that the destinationX and destinationY value. If the player is not at that position yet, make the player move towards that position. I have tried to do this with your code, but for some reason it isn't working. There's the logic behind it: Make a desX and desY variable. Make it where ever the user clicks. Check if the player's X and Y position are not there yet and move them. Example:
Welcome to the LÖVEly world of LÖVE. We hope you enjoy your stay I see we have another sockmunkeedev tutorial video watcher... yeah, I can tell by your code. He does awesome tutorials.
EDIT: Guess VeeThree beat me to it! It's basically just pathfinding though. Check out Jumper if you want to use a library. If not, figure things out and learn.
You'd have a player's destinationX and destinationY value. Where ever the mouse clicks, make that the destinationX and destinationY value. If the player is not at that position yet, make the player move towards that position. I have tried to do this with your code, but for some reason it isn't working. There's the logic behind it: Make a desX and desY variable. Make it where ever the user clicks. Check if the player's X and Y position are not there yet and move them. Example:
Code: Select all
if player.x < desX then
player.x = player.x - player.speed * dt
end
if player.x > desX then
player.x = player.x + player.speed * dt
end
if player.y < desY then
player.y = player.y - player.speed * dt
end
if player.y > desY then
player.y = player.y + player.speed * dt
end
EDIT: Guess VeeThree beat me to it! It's basically just pathfinding though. Check out Jumper if you want to use a library. If not, figure things out and learn.
"In those quiet moments, you come into my mind" - Liam Reilly
- xXweeguyXx
- Prole
- Posts: 5
- Joined: Fri Aug 16, 2013 9:57 pm
Re: Mouse controlled player movement; help please
Thankyou very much It seems a little complex but i'll tryJasoco wrote:You'll need to get a pathfinding library first, preferably one with coroutines. (So the game doesn't halt when each character is checking for a path) If your game is standard tile based it'll be easy-ish. You'll need to make sure the pathfinding algorithm is aware of your map format. i.e. how each grid space is marked as solid or not.
Then when you click, you figure out which tile was clicked, tell the currently commanding characters to calculate a path to that tile. Then follow that path block by block one step at a time.
Complicated? Eh, maybe. I dunno.
- xXweeguyXx
- Prole
- Posts: 5
- Joined: Fri Aug 16, 2013 9:57 pm
Re: Mouse controlled player movement; help please
Again many thanks!Eamonn wrote:I'm not exactly sure how to do it, but in theroy:
You'd have a player's destinationX and destinationY value. Where ever the mouse clicks, make that the destinationX and destinationY value. If the player is not at that position yet, make the player move towards that position. I have tried to do this with your code, but for some reason it isn't working. There's the logic behind it: Make a desX and desY variable. Make it where ever the user clicks. Check if the player's X and Y position are not there yet and move them. Example:
Welcome to the LÖVEly world of LÖVE. We hope you enjoy your stay I see we have another sockmunkeedev tutorial video watcher... yeah, I can tell by your code. He does awesome tutorials.Code: Select all
if player.x < desX then player.x = player.x - player.speed * dt end if player.x > desX then player.x = player.x + player.speed * dt end if player.y < desY then player.y = player.y - player.speed * dt end if player.y > desY then player.y = player.y + player.speed * dt end
EDIT: Guess VeeThree beat me to it! It's basically just pathfinding though. Check out Jumper if you want to use a library. If not, figure things out and learn.
Yeah sorry about that... "see we have another sockmunkeedev tutorial video watcher" but hey you've got to start some where!
Re: Mouse controlled player movement; help please
No, I meant it was good that you started with him. He has awesome tutorials. What I meant was: Don't copy his tutorials almost line for line. It's almost exactly like copy and pasting. Maybe try changing a few things up e.g. adding another menu or something? Just avoid copy and paste where possible. I'm sure a lot of people can agree. Sorry if I came across a bit bossy or mean or anything I just like to see who people start LÖVE with. I started with Sock, but I know some people started with NeoSilky by their code and I also know some people that started with Goature because of their code. I've watched all the tutorials listed on the wiki and read through the wiki tutorials many times. I started with Sock, but I did change a lot of things from his tutorials.xXweeguyXx wrote:Again many thanks!Eamonn wrote:I'm not exactly sure how to do it, but in theroy:
You'd have a player's destinationX and destinationY value. Where ever the mouse clicks, make that the destinationX and destinationY value. If the player is not at that position yet, make the player move towards that position. I have tried to do this with your code, but for some reason it isn't working. There's the logic behind it: Make a desX and desY variable. Make it where ever the user clicks. Check if the player's X and Y position are not there yet and move them. Example:
Welcome to the LÖVEly world of LÖVE. We hope you enjoy your stay I see we have another sockmunkeedev tutorial video watcher... yeah, I can tell by your code. He does awesome tutorials.Code: Select all
if player.x < desX then player.x = player.x - player.speed * dt end if player.x > desX then player.x = player.x + player.speed * dt end if player.y < desY then player.y = player.y - player.speed * dt end if player.y > desY then player.y = player.y + player.speed * dt end
EDIT: Guess VeeThree beat me to it! It's basically just pathfinding though. Check out Jumper if you want to use a library. If not, figure things out and learn.
Yeah sorry about that... "see we have another sockmunkeedev tutorial video watcher" but hey you've got to start some where!
Also, you might want to not double post. If you were like me and haven't been on many forums, you may not know what double posting is. Basically, it's when you post 2 threads in a row without letting another person post inbetween. Maybe merged your 2 posts together? You won't get banned for doing it, but you might just get told off or something.
As for the games idea, it sounds fun, but I don't know if it will be purely because we only know that the ball can move from where the mouse is clicked. That sounds very VERY awesome(I tried doing that, didn't work, and just didn't do it).
"In those quiet moments, you come into my mind" - Liam Reilly
- xXweeguyXx
- Prole
- Posts: 5
- Joined: Fri Aug 16, 2013 9:57 pm
Re: Mouse controlled player movement; help please
I didn't take it as you being bossy I just thought seeing people requesting for help that have basically the exact same lines of code might get a bit monotonous... any who I've decided to stick to making a simpler game Using only trial and error and the wiki! I'll keep the idea for this fighting game just in case i ever get good at lua and think i can do it.Eamonn wrote:No, I meant it was good that you started with him. He has awesome tutorials. What I meant was: Don't copy his tutorials almost line for line. It's almost exactly like copy and pasting. Maybe try changing a few things up e.g. adding another menu or something? Just avoid copy and paste where possible. I'm sure a lot of people can agree. Sorry if I came across a bit bossy or mean or anything I just like to see who people start LÖVE with. I started with Sock, but I know some people started with NeoSilky by their code and I also know some people that started with Goature because of their code. I've watched all the tutorials listed on the wiki and read through the wiki tutorials many times. I started with Sock, but I did change a lot of things from his tutorials.xXweeguyXx wrote:Again many thanks!Eamonn wrote:I'm not exactly sure how to do it, but in theroy:
You'd have a player's destinationX and destinationY value. Where ever the mouse clicks, make that the destinationX and destinationY value. If the player is not at that position yet, make the player move towards that position. I have tried to do this with your code, but for some reason it isn't working. There's the logic behind it: Make a desX and desY variable. Make it where ever the user clicks. Check if the player's X and Y position are not there yet and move them. Example:
Welcome to the LÖVEly world of LÖVE. We hope you enjoy your stay I see we have another sockmunkeedev tutorial video watcher... yeah, I can tell by your code. He does awesome tutorials.Code: Select all
if player.x < desX then player.x = player.x - player.speed * dt end if player.x > desX then player.x = player.x + player.speed * dt end if player.y < desY then player.y = player.y - player.speed * dt end if player.y > desY then player.y = player.y + player.speed * dt end
EDIT: Guess VeeThree beat me to it! It's basically just pathfinding though. Check out Jumper if you want to use a library. If not, figure things out and learn.
Yeah sorry about that... "see we have another sockmunkeedev tutorial video watcher" but hey you've got to start some where!
Also, you might want to not double post. If you were like me and haven't been on many forums, you may not know what double posting is. Basically, it's when you post 2 threads in a row without letting another person post inbetween. Maybe merged your 2 posts together? You won't get banned for doing it, but you might just get told off or something.
As for the games idea, it sounds fun, but I don't know if it will be purely because we only know that the ball can move from where the mouse is clicked. That sounds very VERY awesome(I tried doing that, didn't work, and just didn't do it).
Thankyou again for all your advice, you're a great guy maybe i'll see you again on the forums but maybe next time not because i'm requesting help
Who is online
Users browsing this forum: No registered users and 6 guests