Having a hard time with collisions. Somehow over a few releases I have lost collision. what exactly do I need to code to have two sprites collide?
I have GameCollide(true); in my code, but the WM_COLLIDE is not firing
ps. ALSO. All my sprites are moving, but CO_COLLIDE doesn't work, and CO_CHECKSOLLIDE does. What's going on?
PPS. Also, I have set the id and collide list, but the WM_COLLIDE event is firing when anything touches. Very frustrating
You need to AddSpriteOption(sprite$, SO_CHECKCOLLIDE | SO_COLLIDE).
SO_CHECKCOLLIDE will make sure the collision detection is done.
SO_COLLIDE will call a WM_COLLIDE when collision occurs.
I do have both of those options added. The WM_COLLIDE is firing events even when it is not on the list.
Example:
Monster
Id = "MONSTER"
Collide: "HERO, HBULLET"
Monster's bullet
Id = "MBULLET"
Collide: "HERO"
Hero
Id = "HERO"
Collide: "MONSTER, MBULLET"
Hero's bullet
Id = "HBULLET"
Collide: "MONSTER"
With this set up, when the hero fires a bullet, it triggers WM_COLLIDE because the bullet starts out touching the hero. Strange
Strange, I will have to test this out. Send a little piece of working code that I can play with.
I am going to PM you the PPL file with .bmp
Upon further testing, it only seems to trigger a collide on the KEYUP event. Please let me know what you find. I am anxious to keep moving.
ps. Sample4 only places SO_CHECKCOLLIDE and not SO_COLLIDE. What good is SO_COLLIDE? if I comment it out, it still causes collisions.
The post just seems to be sitting in my outbox. Did you get it, or is there something else I need to do?
Yep I got it.
I did some fixing. However the SO_COLLIDE is only used to call the WM_COLLIDE event on the sprite procedure and not the global procedure.
In the case of the Simple4.ppl demo, the WM_COLLIDE is in the game procedure not the sprite's procedure. Therefore the WM_COLLIDE event is always called even if the SO_COLLIDE is not defined for each sprite.
1) so regardless of what you code, the main WM_COLLIDE will fire no matter what? Can this be tuned off to stop unnecessary processing?
2) Also, wouldn't it be better to always have the collisions handled in the Sprite proc?
3) was it a bug that caused the collision to fire on the Key up event?
1) Yes you can turn it off by specifying a false in the GameCollide() function. GameCollide(False);
2) It's better but I offer both ways.
3) I didn't try your code yet. I just fixed the bug with the game api not analyzing collision for manual movements of sprites.
Thanks.
If you get a chance, take a look at my code, and see if you can figure out why it is causing a collision on KeyUP with the bullet. Thanks
boy, I am completely scratching my head. For the last day or two I have tried to do what you mentioned and create a sprite proc with the WM_COLLIDE. Once again, even after adding CO_COLLIDE and even SETSPRITEAISPEED (though I don't know if this effects the WM_COLLIDE at all).
Nothing fires. I put a ShowMessage() in the WM_COLLIDE but it never is called.