Calculation of HH position (question for devs)

3 replies [Last post]
archerkir
User offline. Last seen 11 years 25 weeks ago. Offline
Joined: 2010-12-25
Posts: 17

First, sorry for my English, cant speak fluent, so it can be a little bit difficult to understand each other...
I thought about problem of HH movement: when climbing down his sprite looks like flying in the air. Looking what i want to ask and offer in the source code will take too much time, so better i will just ask. How are you using HH image: like square (1 on the image) or circle (2)? HH body is a circle, so if you will use in calculation circle with radius of his body (3), it will give a better visual look (4). The only minus, is that his needles will overlap environment texture. Just and offer, hope it will help somehow. Atleast, its much more simplier solution than rotating HH.

Additional question for other players: where HH looks better (on 1-3 or 4 of image) and what do you think about this?

sheepluva
sheepluva's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2009-07-18
Posts: 563

Well, hedgehogs have a "radius" of 10 pixels.
Normally the check for collisions for anything in the game is done at the bottom (and/or movement directions) of the object as _straight line_ though, that's why the resulting collision detection is similar to picture #1 in most cases (e.g. hog movement).

The reason for that was probably to keep it simple, to avoid complicated side effects and to save some cpu cycles.

A circular collision detection would of course lead to better visual results.
I did write one (using Bresenham's circle algorithm) for my physics patch (which never got far enough to make it into the official repository), but even there I didn't dare to use that collision detection on hedgehogs. That would require many many changes in the hedgehog code and would spawn a plenty of new bugs (which I'm too lazy to deal with atm :P).

If you are interested in trying it yourself though, you can create a hg clone and play around with that.
I'd be looking forward to that Smile

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

archerkir
User offline. Last seen 11 years 25 weeks ago. Offline
Joined: 2010-12-25
Posts: 17

How about to fast visual "fix": make _______ shorter (diameter of HH body) and up it a little (as tangent of the body circle)?

sheepluva
sheepluva's picture
User offline. Last seen 1 day 6 hours ago. Offline
Joined: 2009-07-18
Posts: 563

archerkir allegedly wrote:

How about to fast visual "fix": make _______ shorter (diameter of HH body) and up it a little (as tangent of the body circle)?

Wouldn't that have the opposite effect?
The hedgehogs would look fine on slopes then but would visually sink into horizontal ground too much (not to mention the possible side-effects on the gameplay as a whole)

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

User login

Copyright © 2004-2024 Hedgewars Project. All rights reserved. [ contact ]