Hey guys.
So I decided to make my RPG point and click, however I've already encountered a problem haha.
I got the basics down but for some reason I'm having truoble with the landing and it seems pretty glitchy on the ride.
Basically from point A (where my player image is residing) to point B (the point inwhich mouse is clicked) the first thing the image does it rotate. Perfect. Then it moves to the point clicked. At this point maybe it is just me but it seems buggy while moving. Then once it gets to the end it makes a double image. I'm assuming that's because the code is telling it if it's not at the correct point (Which i know it will never be) to keep trying to get there. How do i stop this? Also how can I get around having to not call MouseX, MouseY in love.load.
Love file below.
Thanks!
Trouble With Math.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Trouble With Math.
- Attachments
-
- test.love
- (3.44 KiB) Downloaded 117 times
Re: Trouble With Math.
I didn't check the code but I thin it is because the player don't stop moving. So to stop that you can do something like :
Code: Select all
if player.x == pointB.x and player.y == pointB.y then
-- create a function that stop the player, for the exemple I will use :
player.stopMoving()
end
function love.load() end
function love.update(dt) end
function love.draw() end
function love.update(dt) end
function love.draw() end
Re: Trouble With Math.
What I tend to do is track the distance to my destination. So when you click, calculate the distance and store it. With each update, calculate your current distance to the destination. If it's got bigger than it was on the last update then you've either reached or overshot your destination, so set your current position to your destination position and stop moving.
Don't forget that after you've checked the distance to the destination, you'll need to store that distance, so you know what to compare it to next time.
Don't forget that after you've checked the distance to the destination, you'll need to store that distance, so you know what to compare it to next time.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 8 guests