ivansla

Member

5

100 Neutral

• Rank
Newbie
1. Movement animation in hexagon map

Ok I found this article: [url="http://gdreflections.com/2011/02/hexagonal-grid-math.html"]http://gdreflections.com/2011/02/hexagonal-grid-math.html[/url]. So Tom, thanks for showing me my error. Since I have poor mathematical background no wonder. I will try to redraw the hexes.
2. Movement animation in hexagon map

Yes, Tom you are correct, I did it the way showed on the right side. When I was reading following articles: [url="http://www.gamedev.net/page/resources/_/technical/game-programming/isometric-n-hexagonal-maps-part-i-r747"]http://www.gamedev.n...aps-part-i-r747[/url] [url="http://www.gamedev.net/page/resources/_/technical/game-programming/coordinates-in-hexagon-based-tile-maps-r1800"]http://www.gamedev.n...tile-maps-r1800[/url] I got the impression that's how it's suppose to be. Especially the second one. So, in order to fix my problem, I need to draw smaller tank or draw different hexes? Because my hexes are 40x40 px. I thought that when I draw a hex into square, the hex will have all sides the same. In your case certain sides of the hex are bigger than others.
3. Movement animation in hexagon map

Ok, Tom, for better visualization, I decided to upload my project. it contains source as well it's in Java, if you just want to run it, you can do it by double clicking. [url="https://rapidshare.com/files/1778542098/hex-tutorial-src.jar"]http://rapidshare.com/files/1778542098/hex-tutorial-src.jar[/url]. As you can see, the tank is not inside in exact hex tile, but is out of bounds. and the lower it get the bigger error it has.
4. Movement animation in hexagon map

Hi Tom, thanks for the reply. Here's the picture you asked. [img]http://uploads.gamedev5.net/gallery/album_392/gallery_196065_392_2344.png[/img] I imagine there is a circle inside the hexagon. and since all the sides are the same I just divide 360 / 6. and I get 60 degrees for each direction.

6. Movement animation in hexagon map

Hi guys! I'm trying to create a hexmap based game, like Panzer General, well actually I'm trying to animate unit movement. And this is where I have problem. I am using A* algorithm to determine the path, so that is not problem. My problem is that image I'm animating is always a couple of pixels on X-axis late. This is how I calculate the movement: [code] int SPEED = 1; int SOUTH_EAST = 300; double newX = Math.cos(Math.toRadians(SOUTH_EAST)); double newY = Math.sin(Math.toRadians(SOUTH_EAST)); this.speedX = SPEED * newX; this.speedY = -SPEED * newY; .... // later in code inside each frame this.x += this.speedX; this.y += this.speedY // drawing of image inside each frame g.drawImage(this.tileImage, (int) this.x, (int) this.y, (int) this.x + TILE_SIZE, (int) this.y + TILE_SIZE, frameX, frameY, frameX + TILE_SIZE, frameY + TILE_SIZE, observer); [/code] The problem is that those 300 degrees is from 0,0 to 39,39 (My tile size is 40) which is diagonal of the square inside which the hexagon is, and I need a little sharper angle since I'm not working with squares but hexagons. Ok, I know I need to provide correction for x and y, but that is not the point, point is that my movement by X-axis is late and if I put the angle of 305 that is too much. Well my question is, how am I suppose to animate the unit movement from one hextile to another? Is my approach good and I just need to do a better math calculation (I'm terrible in math, BTW) or is there some other approach?