New collision, just for fun.

You must understand the Game Editor concepts, before post here.

New collision, just for fun.

Postby Fuzzy » Wed Apr 16, 2008 11:44 am

DST and I sat up all night and talked about a new way of doing collisions. Here is the function I came up with. Hes probably using a modified version of this. I hope he will post his too.

Note that this does exactly the same thing as a wireframe or the other actors. its just a different way of doing it. Make of it what you will

Code: Select all
int BoxCollide(float ActX, float ActY, int ULX, int ULY, int LRX, int LRY){
int tmp = 0;
if((ActX > ULX) && (ActX < LRX) && (ActY > ULY) && (ActY < LRY))
{tmp = 1; }
return tmp;
};


float ActX and float ActY are the actor x and y. ULX and ULY are x and y coordinates for an invisible box(the upper left corner) LRX and LRY are the lower right corner values. tmp is a temp value to store a return number that indicates true or false.

What it does is check that player x is more than ULX, and less than LRX. then it checks the same with y values. if any is false, then the function returns zero. Otherwise, it returns 1, which means the actor is inside the invisible box.

use it like this:

Code: Select all
if (BoxCollide(player.x, player.y, -50, -50, 50, 50) == 1)
{
    do something here;
}
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: New collision, just for fun.

Postby Bee-Ant » Wed Apr 16, 2008 11:56 am

:roll:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: New collision, just for fun.

Postby Fuzzy » Wed Apr 16, 2008 12:01 pm

Here is one to check if an actor is inside a circle.

Code: Select all
// A function to find whether a given point is inside a circular area
int CircleCollide(float ActX,float ActY,int r)
{
  int tmp = 0;
  if( pow(x,2)+pow(y,2)-pow(r,2) < 0){ tmp=1;}
  return tmp;
};


The variables are the same, except for r, which is a radius.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: New collision, just for fun.

Postby Bee-Ant » Sat Apr 19, 2008 8:39 am

I was frustrated about NON-SOLID physical response...
I thought about the solution...and this is the outcome...
I dont really advanced about array thing, so I made this simple solution
Attachments
SolidCollisionDemo.zip
(8.35 KiB) Downloaded 145 times
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: New collision, just for fun.

Postby Bee-Ant » Sat Apr 19, 2008 11:03 am

"Just For Fun" I made "Fake Physical Response" where I dont use real physical response
Attachments
FakePhysicalResponse.zip
(4.1 KiB) Downloaded 136 times
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: New collision, just for fun.

Postby DST » Sun Apr 20, 2008 4:05 am

I'm still experimenting with implementing the boxcollide, the largest problem being that the only way i can think to program the ULX etc. values for a collide object is (collide.x-collide.width*.5)....and that's just for ONE UL value! happening in a repeating collision is a lot of work for the cpu. But I am sure there is a simpler way.

I think the best way to use the returned tmp variable is basically to write your own physical response; one that only affects player's y. The existing physical response in GE was designed as a general purpose response for any shape or use; and it takes angle into account and shoves the player back at whatever angle/energy. What we are trying to do is create a very simple, solid one for collisions with tops of platforms only. This response needs to do two things:

1. Counter the effect of gravity
2. Shove the player back to the top of the platform if he happened to fall partially thru it.

I am sure we can make this work!
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: New collision, just for fun.

Postby Bee-Ant » Sun Apr 20, 2008 11:24 am

DST wrote:1. Counter the effect of gravity
2. Shove the player back to the top of the platform if he happened to fall partially thru it.

That's what I'd tried with that Fake Physical Response, but I failed...
I hope makslane could fix the collision...
esp foor physical response to be more more more and more solid :roll:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: New collision, just for fun.

Postby Fuzzy » Mon Apr 21, 2008 5:58 am

I gave it some thought:

how much force does it take to stop a falling box? Exactly as much force as it is exerting but in an opposite direction. Physical response handles this well by allowing us to multiply by 0.0. But it affects both x and y axis.

This only affects the event actor. For that reason I also left out mass. Platforms dont move anyway.

I was going to call it WhimsicalResponse, but thats a little too whimsical. Perhaps EgotisticalResponse would work too. Please, give it a home and a decent name.

Its going to be problematic with a directional velocity too, but we can convert that.

Code: Select all
void FuzzicalResponse(float event_mult_x, float event_mult_y, float f_velocity_x, float f_velocity_y)
{
    xvelocity = event_mult_x*f_velocity_x;
    yvelocity = event_mult_y*f_velocity_y;
}


now if you use this and jump on a platform, you will possibly continue sliding, at least until you press the opposite direction key.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest