[Solved]Rotating and drawing object to target correctly
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Gunroar:Cannon()
- Party member
- Posts: 1085
- Joined: Thu Dec 10, 2020 1:57 am
[Solved]Rotating and drawing object to target correctly
Pls fix this.. Should point to target (touch) and draw accordingly pls
Last edited by Gunroar:Cannon() on Tue Jan 19, 2021 10:20 pm, edited 4 times in total.
Re: Rotating and drawing object to target correctly
The least you can do if you want some help it to explain what you want to do, your message is very disrespectful ...
- Gunroar:Cannon()
- Party member
- Posts: 1085
- Joined: Thu Dec 10, 2020 1:57 am
Re: Rotating and drawing object to target correctly
Disrespectful? I do not know what you are talking about?
also me: *changes message *
(sorry, I was in a rush as you could have seen from the the spelling mistake so I didn't have much time.)
also me: *changes message *
(sorry, I was in a rush as you could have seen from the the spelling mistake so I didn't have much time.)
Re: Rotating and drawing object to target correctly
The perception of disrepsect likely stems from "here's my whole project, someone fix it for me please".
To request for community assistance, you should provide minimal code that illustrates your problem, explain what it is you're trying to accomplish, and what your own best approach so far has been.
To request for community assistance, you should provide minimal code that illustrates your problem, explain what it is you're trying to accomplish, and what your own best approach so far has been.
Re: Rotating and drawing object to target correctly
It's a pretty minimal example, but yeah, the attitude...
Looking into the code, it looks to me that the main problem is the overcomplicating of formulas, resulting in incorrect output (like, pi squared??), and the improper use of origin x and y (confusion of variables, it uses the one for v instead of the one for m).
After removing the *-1 from the angle calculation, this works for me:
The screw eye is at the centre of the images, so that's where the coordinates should point.
Looking into the code, it looks to me that the main problem is the overcomplicating of formulas, resulting in incorrect output (like, pi squared??), and the improper use of origin x and y (confusion of variables, it uses the one for v instead of the one for m).
After removing the *-1 from the angle calculation, this works for me:
Code: Select all
love.graphics.draw(v, self.x, self.y, 0, vw, vh, xx, yy)
love.graphics.draw(m, self.x, self.y, self.angle, mw, mh, mx/2, my/2)
- Gunroar:Cannon()
- Party member
- Posts: 1085
- Joined: Thu Dec 10, 2020 1:57 am
Re: Rotating and drawing object to target correctly
I wasn't trying to be disrespectful ... I was just in a rush and thought it was pretty self-explainatory. Anyway that's like less than 10% of my main project . Plus you can see my tries( math.pi^2 ) and I kept reshuffling tries but couldn't get it. So I say thnx to you all for taking the time to look at my code and Thnx for the solution. I'll check it soon, thnx!
Edited: So I checked it and it worked , yay! I removed the negative sign from Turret:getAngle and since I wanted the muzzle(?) to rotate at the center of the box I made the x origin 0: or something like that
Edited: So I checked it and it worked , yay! I removed the negative sign from Turret:getAngle and since I wanted the muzzle(?) to rotate at the center of the box I made the x origin 0:
Code: Select all
love.graphics.draw(m, self.x, self.y, self.angle, mw, mh, 0, my/2)
Who is online
Users browsing this forum: No registered users and 44 guests