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 / [SOLVED] Sprite Physics Anomalies - Physics Walls, Contacts, DeleteSprite

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 15th Sep 2019 22:33 Edited at: 15th Sep 2019 22:47
back to working on this breakout clone and experiencing some anomalies with 2d physics.

stripped-down code that:
> deactivates the 4 auto-generated walls and recreates them for better control (are the 4 automatic walls always the same sprite IDs so we can tweak properties like normal ones?).
> creates and sets 50 bricks.
> sets the "ball" in motion
> (attempts to) count hits vs bricks only and marks them with small red boxes (while DEC the total variable) & deletes the brick(s).



from this image:

1) not all contact with bricks are deleting the sprites (top-middle blue brick should have been deleted); red mark registered but brick is still there.
2) the hit that took out brick 8,0 bounced off the brick that is 1 down and 1 to the right but did not register a hit, there.
3) ball contact with other-than brick (non-walls) is registering (is it hitting the auto-generated wall that was de-activated?) - lower-right corner.
4) total bricks remaining doesn't add up. total = 7 but 9 sprites visible. i've counted the red boxes = 43; the original 50-43 does = 7

this pic shows the 0,3 brick being hit twice (i watched it):

5) i'm assuming DeleteSprite doesn't fully delete it until sync() ?

as i'm writing this, i thought to go in and turn physics off on the sprite that's hit before deleting it by adding SetSpritePhysicsOff(thishit) before DeleteSprite(thishit) which, now, produces:

6) i'm assuming sprite 1 is the (deactivated) right wall? why was contact registered?

7) could SetPhysicsScale( 0.01 ) be the culprit in any/all of this?

i can build arrays and handle this stuff manually but things are not going as they should.

any help/thoughts is appreciated.


add last night when i started looking at counting brick hits i used GetManagedSpriteCount() which seemed to always be accurate.
in my main version, there's a sound that plays on a brick hit. while i watched the ball, i would occasionally hear the sound when no brick was hit (i don't recall a physics reaction from it, tho).
i'd leave the room with the sound up and, again, occasional "hit" sound. upon return to the screen, my total (continues) into the negative...

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 15th Sep 2019 23:02
This post has been marked by the post author as the answer.
...and, i think it found it. i thought GetSpriteNextContact() returned the spriteID. changing to this:

seems to fix it.

i'll leave all of the above for my reminder to stay humble

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Sep 2019 00:49
There's some nice sprites in the MEGA MEDIA PACK under;
MEGA MEDIA PACK\Giant Asset Pack 1\Content\Bricks
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 16th Sep 2019 03:19
I was going to suggest simply making sure it exists before attempting to delete it...

if GetSpriteExists( thishit) <> 0

DeleteSprite(thishit)

...

endif

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 18th Sep 2019 22:44

Login to post a reply

Server time is: 2024-11-22 16:38:18
Your offset time is: 2024-11-22 16:38:18