Wrap Behavior Problem

For questions about using Classic.

Post » Fri Dec 17, 2010 1:10 am

I have a problem with the wrap behavior.

When a player's ship approaches the edge of the playfield at a shallow angle, say 15 degrees or less, and at low speed -- the ship refuses to wrap to the other side of the screen and instead just "bumps" off the edge over and over again.

I've tried to change a bunch of settings. Even turned the collision mask OFF. Nothing worked.

I've attached the cap file here. Hoping someone could try it out and tell me what I'm doing wrong.

[url:a2fpi7s4]http://www.mediafire.com/file/jn7hq04u5hz9zrb/WrapProblem.cap[/url:a2fpi7s4]

P.S. Left and Right arrows to rotate. Up arrow to thrust.
B
4
S
1
G
2
Posts: 64
Reputation: 980

Post » Fri Dec 17, 2010 1:53 am

Why not just roll your own wrap code?
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Fri Dec 17, 2010 9:03 am

[quote="Davioware":2hj9g7z5]Why not just roll your own wrap code?[/quote:2hj9g7z5]

I did exactly that. Set up a compare:

ship x greater than 1024 > set ship x to 0.
ship x less than 0 > set ship x to 1024.

Did the same for the y coordinates....

And I ended up with the exact same problem. Ship would hit the edge and then keep bouncing off.

So instead I did it by building in a 5 pixel margin a little off screen like so:

ship x greater than 1034 > set ship x to -5
ship x less than -10 > set ship x to 1029

Works like a charm now. Strange... Must have something to do with the sprites? The way they're drawn, they seem to read as being at less than y=0 and more than y=1024 simultaneously (or very nearly simultaneously, anyway.) So construct just keeps bouncing them back and forth to fast to register, turning the edge into a virtual wall... Does that make sense?

Anyway, thought I mention the work-around in case anyone else ever runs into this.

Also, thanks to Davioware -- I keep forgetting that sometimes I can just solve these problems with a few lines of code... I never think to do my own version if the behavior already exists. I always think that someone else programed the behavior the "right" way, and my version is just gonna screw it up somehow. :D
B
4
S
1
G
2
Posts: 64
Reputation: 980


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests