ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Support
 
<< Previous thread | Next thread >>
Sprite collide (PPL 1.42)
Moderators: kornalius, bmanske, PointOfLight
Author Post
Aleksandr
Thu Jun 05 2008, 02:27am
Registered Member #246
Joined: Thu Jan 25 2007, 12:50am
Posts: 71
Hi,
There are three sprites - S1$, S2$ and S3$.
Sprite S1$ can collide with sprite S2$ and sprite S3$.
Speed of sprite S1$>0, speed of sprites S2$ and S3$ is zero.
My code is:
...
WM_COLLIDE:
...
if ((spriteid(wParam$) == "S1") and (spriteid(lParam$)== "S2"))
delsprite(wParam$);
else if ((spriteid(wParam$) == "S1") and (spriteid(lParam$)== "S3"))
delsprite(wParam$);
end;

The sprite S1$ must has collided with sprite S2$ first and with sprite S2$ second.
If running on PC its works, if running on device (! and speed on sprite S1$ more then some number) collide between S1$ and S3$
may be before then collide between S1$ and S2$.

The game speed define as
InitGameAPIEx(h$, &GameProc, Width$, Height$, false, 5, 0);




Aleksandr Mikhaylov
Back to top
zehlein
Thu Jun 05 2008, 12:57pm

Registered Member #30
Joined: Tue Sep 12 2006, 03:00pm
Posts: 449
Did you set the SpriteOption SO_CHECKCOLLIDE? (Used to detect collisions even if VelX and VelY are zero)

There is a crack, a crack in everything. That's how the light gets in. (L. Cohen)
Back to top
Aleksandr
Tue Jun 17 2008, 03:29am
Registered Member #246
Joined: Thu Jan 25 2007, 12:50am
Posts: 71
This sample show how to collides may be lost if sprite speed more then some number.
1213687754_246_FT9586_testcollide.zip

Aleksandr Mikhaylov
Back to top
kornalius
Tue Jun 17 2008, 11:59am


Registered Member #1
Joined: Wed Apr 19 2006, 08:25pm
Posts: 2783
Try using SO_ACCURATECHECK on the sprite moving. Sometime the sprite movement will be too great and the collision detection will not be done as the sprite might move just passed another sprite, SO_ACCURATECHECK will make sure that since the last movement position of the sprite, no collision has happened.

Regards,
Alain Deschenes
President and programmer
ArianeSoft Inc. (http://www.arianesoft.ca)
Back to top
Aleksandr
Wed Jun 18 2008, 08:30am
Registered Member #246
Joined: Thu Jan 25 2007, 12:50am
Posts: 71
Sorry, i must be to find solution in help.
But if i use SO_ACCURATECHECK i have windows error at random time.
I can't to locate error statement.

Pls, see to my project.
Using SO_ACCURATECHECK in line 720.
The program works without SO_ACCURATECHECK in line 720.




1213792228_246_FT9586_runner.zip

Aleksandr Mikhaylov
Back to top
PointOfLight
Wed Jun 18 2008, 11:18am

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
It definitely does not like the SO_ACCURATECHECK option.  The program crashes within about 30 seconds of playing every time if I have that option set.  I'm running it on Win2K professional.  I haven't tried it on the PocketPC yet.

By the way, the game looks cool.  It's one of those simple yet probably addictive type of games.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
kornalius
Wed Jun 18 2008, 01:56pm


Registered Member #1
Joined: Wed Apr 19 2006, 08:25pm
Posts: 2783
Increase the collision grid size. It is too small.

SetCollisionGrid(16, 2048, 2048);

This should be placed right after the game initialization line.

I have fixed a few things with the collision detection at the same time. It should work fine in v1.52.

Btw, FlushSprites() should not be used like you are using it. It causes the game loop to try to process sprites that are not in memory anymore. In version 1.52 when you DelSprite() it will hide the sprite and flush it in the next game loop.


Regards,
Alain Deschenes
President and programmer
ArianeSoft Inc. (http://www.arianesoft.ca)
Back to top
PointOfLight
Wed Jun 18 2008, 04:01pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
I added the SetCollisionGrid line in, and I was able to play for quite some time, but it did eventually crash on me again.  A couple of other things that I noted (this is for you, Aleksandr):

1. When I'm in the box, some flames would pass through the box and others would stop at the box, though none would actually damage me.  Which behavior is correct?

2. Are there any items that you can pick up that injure you?  I didn't think so, but there were a couple of times that I took damage and it didn't seem like there was anything near me.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Aleksandr
Thu Jun 19 2008, 02:20am
Registered Member #246
Joined: Thu Jan 25 2007, 12:50am
Posts: 71
1. When I'm in the box, some flames would pass through the box and others would stop at the box, though none would actually damage me. Which behavior is correct?

This behaviort is incorrect. Exactly because i need SO_ACCURATECHECK.


2. Are there any items that you can pick up that injure you?
There are no any items that you can pick up that injure you. See source code.

Aleksandr Mikhaylov
Back to top
PointOfLight
Thu Jun 19 2008, 08:59am

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
I guess I should have expressed my question better.  What is supposed to happen with the box?  I had SO_ACCURATECHECK on.

As for my other question, I know I could have looked at the code.  I just wanted to have confirmation from you, because there seemed to be a couple of times that I took damage even though there didn't appear to be anything around me.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Aleksandr
Fri Jun 20 2008, 01:16am
Registered Member #246
Joined: Thu Jan 25 2007, 12:50am
Posts: 71
Did you write about green box?
I want the green box would be guard from fire ball.
If the red ball is in green box, the collide between fire and green box must be first, the fire ball will deleted and collide between fire and red ball do not occurred.
(may be i don't understand cillide even and occur both collide delsprite() ignore?)

Without SO_ACCURATECHECK the collide between fire and green box may be first or may be second (random).
With SO_ACCURATECHECK program crashes within 5-40 seconds.

Aleksandr Mikhaylov
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System