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.

DarkBASIC Professional Discussion / [SOLVED] Sprite collision just flat-out not functioning at all?

Author
Message
Omega gamer 89
16
Years of Service
User Offline
Joined: 10th Sep 2007
Location: Pittsburgh, PA
Posted: 29th Aug 2020 08:21 Edited at: 13th Sep 2020 06:53
Manually move a sprite to the EXACT same X/Y coords as another sprite, and it somehow doesnt think thats a collision or hit?

Im not sure if my install of DB is bugged or if Im missing something obvious or what, but it appears that both the SPRITE HIT and SPRITE COLLISION commands just do not work, at all.

In the game Im making right now I was setting up some pretty simple platformer controls. Player presses "A," character moves left. Player presses "D," character moves right. Player presses up arrow, character jumps up, decelerates, then falls down. I had all of that working, right up until the part where I tried to have the character stop falling when they hit the floor. I tried to do something along the lines of "IF SPRITE HIT(PlayerObject,0) then JumpSpeed = 0" which would have effectively made the player character stop moving on the Y axis when it collided with another sprite, such as the ones that make up the floor.

Problem was, that didnt work. I tried using "SPRITE COLLISION" instead of sprite hit. Same issue. Ive been messing around with it for several hours and it just seems like these two commands just DONT detect sprite collisions at all. Am I going crazy here or are these commands actually just not doing the ONE thing theyre designed to do?

I wrote some very basic test code to make sure it wasnt something else in my game, and remove variables from the equation, and the same problem persists. Moving an existing sprite onto the x/y coords as another existing sprite somehow doesnt get recognized as a collision or a hit, regardless of how that sprite is moved to that position. The ONLY thing that seems to actually trigger it to recognize a colission, is creating a NEW sprite at the same x/y coords as an existing one, but what use is that if I want to check whether my EXISTING character sprite has collided with the floor?

Below is the code I wrote to test it. The image "blank.png" was just a 100x100 pixel blank white image I made to test this.



So yeah, I really dont know what I could possibly be missing. Those sprites are DEFINITELY colliding, and yet the SPRITE HIT and SPRITE COLLISION commands dont detect it when you move an existing sprite; only when you create a new one. Any ideas?

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

Go to answer

WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Aug 2020 15:46
This post has been marked by the post author as the answer.
If you will notice paste sprite creates a duplicate of the sprite that is not part of the sprite collision system. Use the same function to move the sprite used to create it. Sprite collision are not pixel perfect and will return a collision of the sprite bounding box.

Omega gamer 89
16
Years of Service
User Offline
Joined: 10th Sep 2007
Location: Pittsburgh, PA
Posted: 29th Aug 2020 17:57
Huh. Ok, first off, thank you, that works.

But second of all... I couldve SWORN I tried exactly that last night, but using "SPRITE" instead of "PASTE SPRITE" just... didnt work. Like, using "SPRITE" only worked once per sprite when I tried it; you could use it to create sprites initially, but not to move them around or reposition them after that. I coulda sworn thats what had happened.

Well, either way, its working now. thank you.

Login to post a reply

Server time is: 2024-03-28 11:24:56
Your offset time is: 2024-03-28 11:24:56