Help - Search - Members - Calendar
Full Version: Swinging And An Arc
Game Maker Community > Working with Game Maker > Advanced Users Only
connor4312
Hi,

So I am making a semi-puzzle/platformer game, and I need some help with wreaking balls. A player controls a ball, and using momentum and gravity, is able to grab onto different pegs. The problem is that I need it to be able to swing in an arcm and use the gathered speed. Here is what I have tried:

CODE
while distance_to_object(at)>dt mp_linear_step(...);


Made it bounce all weird (at is the one attached to, dt is recorded as soon as the ball hooks on, and is the distance to the peg (stays the same))

CODE
var n
while distance_to_object(at)>dt
   {
   mp_linear_step(...);
   n=true;
   }
if n=true speed=0;


Just made the player go very slow (I know why, but not how to fix it)


Any help would be appriciated!

Thanks for looking,
Connor
1dinglenuts1
put the sprite in movement of a parobola

such as Y=X2+2
so
Y | 3 | 6 | 11 |
X | 1 | 2 | 3 |
to implement that incode
CODE
//step
x+=1;
y=(x*x)+2;


then from there add limits

EDIT:
use the squred function if you can find it, i think its quiker

EDIT 2:
woops forgot, but you could have probably thought of this one.
make the line follow the sprite using the same parabola
slayer 64
i made a gmk for you. if you don't want to download it you can look at this code that constrains a ball from an anchor point.
balls on string gmk
CODE
var dx,dy,m;

dx=hook.x-x;
dy=hook.y-y;
m=point_distance(0,0,dx,dy);

if m>length
{
    m/=(m-length);
    m*=elastic;
    dx/=m;
    dy/=m;
    x+=dx;
    y+=dy;
    hspeed+=dx;
    vspeed+=dy;
}
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.