stop sliding through walls - demo

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

stop sliding through walls - demo

Postby feral » Thu Jun 05, 2008 10:01 pm

a quick demo on how to stop sliding through thin walls
walls.jpg
1 pixel thick wall stops actors


awalls2.zip
(34.05 KiB) Downloaded 396 times

use collision free to check the next x...number of pixels depending on your current speed

the demo has a 1 pixel thick wall, which "always" stops the actor even at velocities of 100 or more

the top demo shows the traditional x=x+10 movement

the bottom demo shows movement using xvelocity

if you have a lot of actors to check I suggest making up a function in the global code.

hope that helps
feral

ps: sorry if this has been done before but there still seems a lot of questions about it.
Last edited by feral on Fri Jun 06, 2008 12:36 am, edited 1 time in total.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: stop sliding through walls - demo

Postby feral » Fri Jun 06, 2008 12:35 am

sorry small update,
I thought I had the traditional x=x+10 type movement in the first example, but i didn't :oops:

just uploaded new version awalls2.zip

feral
note xspeed is set in global ( for the x=x+xspeed example)
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: stop sliding through walls - demo

Postby speckford123 » Fri Jun 06, 2008 12:40 am

nice code, i had him well up in the 500 velocity range (edited) and the pixel wall stopped him dead in his tracks!
good job on that part, now maybe i can make a sonic game, i couldn't before 'cause of speed restrictions :lol:
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Re: stop sliding through walls - demo

Postby pyrometal » Fri Jun 06, 2008 3:20 am

Very nice method! This will be useful for many people out there! +1 pt for you!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: stop sliding through walls - demo

Postby DST » Sat Jun 07, 2008 5:58 am

Thank you! For reminding people that there is a COLLISION FREE in GE!

Collision free is much closer to what is in professional games than physical response is. I wish more people would use it!
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: stop sliding through walls - demo

Postby DocRabbit » Mon Jul 28, 2008 4:38 pm

Went a bit further with this and discovered odd behavior. Created a clone of wall and changed movement via directional_velocity, set starting angle at 0. On collisionfree true section, altered angle+=180; then checked for greater than 180 angle and set back to 0. it starts out bouncing back and forth but speed begins to scrub off after a while until it stops on left wall. Checked collision multipliers and all are set to 1.0, so it should stay constant but it doesn't. Wondering if this happens for anyone else?

Here is the alterations in the code, along with cloning the wall and drag left side of player 2.
Create Actor code for player2
Code: Select all
directional_velocity=10;  //initial velocity ( can change in game and still work with collsion checker
angle=0;


Draw Actor code for player2
Code: Select all
int colcheck=directional_velocity;   ///collsions to check for = the velocity you are travelling at
int i;


for (i=1;i<=colcheck;i++) // for i=1 to current velocity
{
 if (CollisionFree("Event Actor", x+i, y)==0) //check for possible collisions before next redraw
 {
     angle+=180;
     if (angle>180)angle=0;
i=99; //stop checking this draw action
 }
}



***UPDATE****
on further examination and adding a text actor that reflects the directional_velocity of the player2 actor, it does indeed reduce itself. By incrementing it with +.5 to the directional_velocity, it keeps it hovering between 9 and 11, must be an invisible decrementation to the function of directional_velocity.

Here I added a Actor, made it text, initialized it with 000 when I made it, then used the following code to display it.
Setting the directional_velocity to 10 on the routine that bounces it, and you will see the initial deduction that is made to the value.

Code: Select all
int colcheck=directional_velocity;   ///collsions to check for = the velocity you are travelling at
int i;


for (i=1;i<=colcheck;i++) // for i=1 to current velocity
{
 if (CollisionFree("Event Actor", x+i, y)==0) //check for possible collisions before next redraw
 {
     angle+=180;
     if (angle>180)angle=0;
textvelocity.textNumber=player2.directional_velocity;
directional_velocity=10;
i=99; //stop checking this draw action
 }
}



*** Further UPDATE ****
It appears the phenom is caused by using physical response along with the collisionfree method. When removing collision event physical response, numbers stay true. Seems to be a result of mass calculation inaccuracy. I guess this is to perpetuate real world physics as any object over time will degrade its velocity if it has mass. So to have a perpetual machine velocity, don't use physical response collision at all.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Re: stop sliding through walls - demo

Postby edh » Mon Sep 22, 2008 10:16 am

Unfortunately, CollisionFree returns false if there is a wireframe region, too. Has anyone got a good work around for that?
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest

cron