The Daily Click ::. Forums ::. Klik Coding Help ::. Problem with Collision Detection - Need Help!
 

Post Reply  Post Oekaki 
 

Posted By Message

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
14th January, 2009 at 22:18:57 -

Okay, I seem to be having a problem with off-screen collision detection.

My goal: Create a platform game demo with a 400x300 display and a Virtual Width of 1200. I have items that need off-screen collision detection so I have to turn that on.

My Problem: Turning on "Handle background collisions even out of window" for some bizarre reason causes my sprite to fall through the floor (as if collision detectio were on for everything else except the main sprite. All I have to do is move the sprite to the center of the level and long before he gets there he goes straight down - like his collision detection only worked in the 400x300 box.

My Settings:

Game Settings:
Image

Frame Settings:
Image

Frame (showing extended Virtual Width):
Image

My MFA file:
http://www.jessandmichelle.com/Platform3.mfa

Any help would be MUCH appreciated...





 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1960

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
14th January, 2009 at 22:51:13 -

In the frame settings, set "size" and "virtual width/height" to 1200x300.
In the game settingss, leave "size" as 400x300.

Nice platform engine btw.

Edited by Sketchy

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
14th January, 2009 at 23:56:18 -

Yup, as Sketchy says.

The reason is that MMF2 handles collisions in the invisible playfield when the option is added, but it still only handles collisions *inside the playfield*. The entire level is represented in MMF2 by a bit array, each pixel being assigned either a 0 or a 1, for being a collision or not (actually a 00, 01, 10, or 11, for non-obstactle, platform, ladder, obstactle). But this array is only the size of the level itself. When you are displaying areas that are not in the level, they will not be saved to the collision mask, and you can't collide with anything


its actually a kind of stupid system, since the collision mask takes up twice the space it should. The platform and ladder settings can only be referenced by the built in movements, so theyre useless in more serious apps, but still double the size

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
15th January, 2009 at 00:47:49 -


Originally Posted by Sketchy
In the frame settings, set "size" and "virtual width/height" to 1200x300.
In the game settingss, leave "size" as 400x300.

Nice platform engine btw.



Thanks! That did the trick. That is *slightly* upsetting, though, because I was hoping to set the Frame Fize to 400x300 and the Game Size to 800x600 (with "Resize display to fill window size" checked) to essentially double the screen size. Is there another way I can do that?

Also, the platform engine is David Newton's. I'm not fully done implementing it, though. It is pretty cool, though.


Originally Posted by Pixelthief
Yup, as Sketchy says.

The reason is that MMF2 handles collisions in the invisible playfield when the option is added, but it still only handles collisions *inside the playfield*. The entire level is represented in MMF2 by a bit array, each pixel being assigned either a 0 or a 1, for being a collision or not (actually a 00, 01, 10, or 11, for non-obstactle, platform, ladder, obstactle). But this array is only the size of the level itself. When you are displaying areas that are not in the level, they will not be saved to the collision mask, and you can't collide with anything

its actually a kind of stupid system, since the collision mask takes up twice the space it should. The platform and ladder settings can only be referenced by the built in movements, so theyre useless in more serious apps, but still double the size



Thanks for the explanation!

 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1960

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
15th January, 2009 at 01:41:10 -


Originally Posted by Pixelthief
The platform and ladder settings can only be referenced by the built in movements, so theyre useless in more serious apps, but still double the size



That's not *totally* true. You can use the collision mask to check for ladders/platforms, but yeah, it would be a lot better if there was a condition for "object is overlapping ladder" (wouldn't have been that hard for clickteam to add either, you wouldn't think).

Jess:
I'd suggest just running fullscreen, and changing the resolution.
Alternatively, you could use the "window control" extension, but it's really slow.

+ start of frame
-> set horizontal size to 800
-> set vertical size to 400

Make sure you tick the "resize display to fill window size" box in game properties, or it won't work.

You might be able to do it using the viewport extension instead, but don't ask me how.

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
15th January, 2009 at 03:09:46 -

Couldn't you load the main game from a separate frame as a sub-application, and then resize that frame?

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
15th January, 2009 at 23:43:56 -


Originally Posted by Sketchy
I'd suggest just running fullscreen, and changing the resolution.



Yeah, I was trying to stay away from that. Not that it wouldn't work, but rather I'm working on a laptop and when I resize the screen (to anything except the optimum) it looks pretty crappy.


Originally Posted by Pixelthief
Couldn't you load the main game from a separate frame as a sub-application, and then resize that frame?



I might be able to do that if I weren't so El Stupido! Haha. I tried sifting through the controls and couldn't figure that out.

And, having said that, I have to say this too: Something is freakin' rotten in the state of Denmark!!!

Why do I say that? Because I have found a resolution... of a sort - which I neither like nor can explain. Who is up to finding out what's up?

First, here is the MFA file:

http://www.jessandmichelle.com/Resolution.mfa

This MFA file contains two frames:
1. Working Frame - which, as the name implies, works!
2. Non-Working Frame - yeah, it doesn't work

In the first frame, the player can walk all the way down the field and NOT drop through the obstacle background. In the second frame, once the player walks past past the initial screen... AAAAAAHHHH!!! ... right through the floor!

Now I swear to you that the settings in these two frames are exactly the same. Check them out and see for yourself. I'm saving up a big "j00 DA man!" for the guy who figures this out. Like I said before, I'm far to El Stupido to do it myself.

Also, you'll note that the first frame accomplishes exactly what I want:
1. Allows me to create a classic-style 320x200 game (although I'm doing it in 400x300)
2. Let's me resize the display to 800x600 without needing to change the resolution
3. Have the game look nice and crisp on a laptop monitor

Who is up for the challenge? Now, if you're curious as to how I created the first frame -- here is how I did it. I knew that David Newton's demo file that came with his excellent tutorial (http://www.clickteam.com/eng/resources/fastloop_plattutorial.zip) did have the "Handle background collisions even out of window" turned on and his sprite didn't drop through the floor straight to Hades. So I:
1. Opened his demo in TGF2
2. Opened my application in TGF2
3. Dragged the last frame from him demo to my app
4. Deleted all of the objects and events from his frame
5. Copied all of the objects and events from my frame into this now blank one

...and, voila, it worked! Weird.

Jess

 

Jess Bowers

Cake > Pie

Registered
  09/01/2009
Points
  310

Has Donated, Thank You!GOTM FEB - 2010 - WINNER!GOTW Winner!
8th May, 2009 at 02:51:52 -

Hey folks,

Sorry about bumping such an old thread but David Newton helped me figure out how to resovle this problem - so I thought I'd post the resolution.

The only difference between the working and non-working frames is that the working frame has an extra layer (which happens to be completely empty). That's it. If you delete that empty layer from the working frame then the background obstacles stop working when the sprite reaches a certain distance from the start. Pretty strange... and sounds like a bug.

Anway, the fix is easy. Just add an empty layer.

Jess

 
   

Post Reply



 



Advertisement

Worth A Click