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.