Posts

Showing posts with the label xna

Movement based on mouse click XNA

Image
Clash Royale CLAN TAG #URR8PPP Movement based on mouse click XNA I'm making a server/client game with movement similar to strategy games like Warcraft 1/2/3 etc.. where the player moves by right clicking on somewhere on the area and the character tries to move there. I'm trying to make the character always go in a straight line towards the point until it gets there (or close enough). The code I'm using now gets the character there but in a weird way. When I click somewhere under the character (higher Y coordinate) it moves in a straight line, but when I click above it (lower Y coordinate), the character moves like it's making a circle while moving, but it still gets there, only not the way I want it to. Here's the code that runs every update to move it. if (this.order == "Move") { if (Math.Abs(this.orderPos.X - this.warlockPos.X) < this.moveSpeed && Math.Abs(this.orderPos.Y - this.warlockPos.Y) < this.moveSpeed) ...