[ 9 posts ]  Reply to topicPost new topic 
Author Message
 [us]
 Post subject: Collision problems
PostPosted: Mon Dec 06, 2010 4:03 pm 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

I posted this on Them In Us World last month and got zero replies, so I might as well try again here. If you need the .GMK source to figure this out, I can send it to you.

As you may know, I'm working on a game called Revenge of the Walrus, which runs in GM 8 and uses portions of both the Hello Engine 4 and DeeY Engine (as well as a decent number of features I've added myself). Two things are giving me trouble. One is vertically-moving platforms. Whenever Mario jumps on a vertical lift, there's about a 15% chance he'll fall right through (a higher chance with faster-moving platforms). Here's the End Step event I've been using (a Hello/DeeY combination):

Code:
if collision_rectangle(x,y-2,x+47,y+4,obj_mario,1,1)
and obj_mario.y < y-27
{if vspeed < 0
obj_mario.y = y-32
else
obj_mario.y += vspeed
if not collision_rectangle(obj_mario.x+9,obj_mario.y+5,obj_mario.x+9,obj_mario.y+31,obj_solid,1,1) and hspeed > 0
obj_mario.x += hspeed
if not collision_rectangle(obj_mario.x-9,obj_mario.y+5,obj_mario.x-9,obj_mario.y+31,obj_solid,1,1) and hspeed < 0
obj_mario.x += hspeed}


Another problem I've been having is the classic "get hit even though you stomped the Paratroopa perfectly" glitch that helps make Hello Engine games so much more fun. The DeeY Engine uses the same code, and this classic problem again rears its ugly head every now and then. Any suggestions for improving this mess?

Code:
if instance_exists(obj_invincibility)
exit;
if other.y < y-25-vspeed
and obj_mario.stompstyle = 1
{obj_mario.vspeed = 0
instance_create(x-8,y,obj_spinsmoke)
instance_destroy()
exit;}
if other.isslide = 0
{
if other.y < y-27
{sound_play(snd_stomp)
imdead = instance_create(x,y,obj_koopa); imdead.hspeed = direct/2; imdead.bugfix = 0;
scr_pointscale_silent(x-8,y)
with (other) event_user(1)
instance_destroy()}
//Hurt Code
else if other.invurnerable = 0
{with (other) event_user(0)}
//End Hurt Code
}
else if other.isslide = 1
{event_user(0)
scr_pointscale_slide(x-8,y)
instance_destroy()}

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Collision problems
PostPosted: Tue Dec 07, 2010 10:24 pm 
User avatar
Member
[*]
[*]
Well, I didn't tried a moving platform.But I fix a lot a collisions problems with my engine of project Kirby RPG,that granted intermediate knowledge in the stuff.The only thing that I used from Hello was his collision markers concept and code.
I wanted to know about the Mario's code about the gravity effect.
I think that is weird when the lift's vspeed<0 you give a position to Mario,but when lift's vspeed>0,you add Mario's position.

My suggestion is store the lift's id to object Mario and used his position somehow and you will need a condition like is_in_lift.
I know that my hint is too much but I will test my idea when I have a free time in this week and repost in a more useful form.
I just sketch rough to show you that someone can help you.

 
Top
Offline 
 
 
 [zz]
 Post subject: Re: Collision problems
PostPosted: Fri Dec 10, 2010 11:16 pm 
User avatar
Member
[*]
[*]
Today I made some and finally find a solution to vertical lifters.
In obj_mario ,in the collision event with the lifter

Code:
  if(vspeed>0 and bbox_bottom-vspeed<=other.bbox_top){
  y-=abs(bbox_bottom-other.bbox_top)+1;
  vspeed=0;
  is_on_lifter=true;
  lifter=other.id;
}


in the event end step
Code:
if(is_on_lifter=true){
object.y=lifter.y;
}


in the event step

Code:
if(is_on_lifter==true){
  if(bbox_left>lifter.bbox_right or bbox_right<lifter.bbox_left)is_on_lifter=false;
}

You need create variables "is_on_lifter" and "lifter".
Now I will explain you,when Mario land in lifter, he moving with it.For ,the lifter.id is stored and the condition is_on_lifter is true.You need put a extra condition of "is_on_lifter==false" in piece code of Mario's gravity effect.In mario jump event,you need to put is_on_lifter=false,because he won't moving with the lifter when he jumps.The collision event could be rewritten in other forms put in other places.Ah the lifters aren't parent of obj_block or similar thing.
I remade this code because the original have more elements (I used collsion markers instead Mario himself),so maybe doesn't perfectly or need a very simple tweak.Anyway,I hope that this help you

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Collision problems
PostPosted: Sat Dec 11, 2010 9:10 am 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

Thanks. I'll try this later.

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Collision problems
PostPosted: Sat Dec 11, 2010 11:31 am 
User avatar
Member
[*]
[*]
For the next collision problem,I have some questions:
1-Did Mario get hit by Paratroppa before stomp him or by Troppa after the stomp?
2-Could you give me more information about event_user(0) and event_user(1)?

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Collision problems
PostPosted: Sat Dec 11, 2010 2:13 pm 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

1. I think the hit comes from the Paratroopa. I should check that, though, by creating a bouncing enemy that doesn't turn into something else when stomped.

2. In short:

Paratroopa user(0): Enemy defeated when Mario slides into it (not really a problem).
Mario user(0): Powers-down/defeats Mario depending on whether he's small or powered-up.
Mario user(1): Mario bounces off enemy.

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
 [us]
 Post subject: Re: Collision problems
PostPosted: Sat Dec 11, 2010 4:32 pm 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

I checked and the problem comes from the Paratroopa, not the Koopa the Paratroopa transforms into when stomped.

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
 [zz]
 Post subject: Re: Collision problems
PostPosted: Sat Dec 11, 2010 11:35 pm 
User avatar
Member
[*]
[*]
I think that I find the problem.The issue must be the condition if (other.y < y-270) in the obj Paratroopa.let's say y0 is Mario.y just before collides and y1=y0+Mario.vspeed the next Mario.y position.
other.y0<y-27 ,but because Mario doesn't collide with paratroopa,it doesn't trigger the event.But y1 could be other.y1<y-27 or other.y1>=y-27.Depend of vspeed value.If Mario falls higher on paratropa, he will hurt because the issue.
My guess is changing to if(other.yprevious<y-27).I am thinking in if(other.y-other.vspeed<y-27) ,too,but,because vspeed changes,maybe could create another bug.


PS:I don't know which origin you are using in the sprites.I suppose that is the bottom side.

 
Top
Offline 
 
 
 [us]
 Post subject: Re: Collision problems
PostPosted: Sun Dec 12, 2010 11:07 am 
User avatar
Always have a Shy-Guy in your avatar
Administrator
[A]
[S]
[W]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

[*]
[*]
[*]
[*]
[*]

The "if other.y-other.vspeed < y-27" code works great - I tested it on a few dozen Paratroopas (and some Para-Goombas for good measure), and every single stomp worked perfectly. You'll get a blurb in the credits for this!

I should also go back and use this code to fix up my old Mario's Steroid Adventure game, which uses the same collisions for jumping enemies.

I'll let you know what happens with the lifts.

_________________
Course clear! You got a card.

Image
 
Top
Offline 
 User page at mfgg.net
 
« Previous topic | Next topic »
Display posts from previous:  Sort by  
 [ 9 posts ]  Reply to topicPost new topic 


Who is online

Users browsing this topic: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group