Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / BUG(S): GetSpriteHit() and GetSpriteCollision()

Author
Message
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 19th Aug 2015 20:13


If you run the code above you will get a display telling which sprite has been hit at the position of the moving sprite. Which is great.

However, if you comment out this line:

Then the hit isn't registered at all.

Uncomment it again and the line below it registers a hit. However, if you change the line so that the moving sprite is checked for a collision with the static sprites then GetSpriteCollision() works as expected but GetSpriteHit() only registers the sprite in the GetSpriteCollision() code.

So, this:

Only registers a HIT with sprite[0]
... and this:

only registers a HIT with sprite[1]

AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 19th Aug 2015 23:47 Edited at: 19th Aug 2015 23:50
i think the the problem is that you test the collision extact at the edge so it think its outside.
floating value problem.
also its better to use 50.0 float and not 50 integer because the parameter is flost.
means adding for floats without decimal places the .0

maybe try the middle of the sprite as hitpoint.
GetSpriteXByOffset & GetSpriteYByOffset



AGK (Steam) V2 Beta .. : Windows 10 Pro, 8.1 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 20th Aug 2015 08:21
That may well work but I wasn't looking for a workaround to get the code to function correctly. The only purpose of the code is to point out an obvious bug. Which it does. Commenting out the GetSpriteCollision command should have no affect on the GetSpriteHit command.

AGK V2 user - Tier 1 (mostly)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Aug 2015 12:49
i think that is something belongs the cpu.
a float value is not accurate like a value without decimal places.
means 50.0 is in reality 49.999999999 or 50.0000000001
that is a problem for the = operator and in this case => <=
i agree if paul can fix this issue it make the world better

AGK (Steam) V2 Beta .. : Windows 10 Pro, 8.1 Pro 64 Bit : AMD (15.7.1) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 11th Oct 2015 23:50
Floating point numbers are always an issue for comparison. It has to do with the way computers store them and use them. It isn't something that can be programmed away.
Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-04-23 20:11:03
Your offset time is: 2024-04-23 20:11:03