Grappling Hook [Script]

msmalik681

OpenBOR Developer
Staff member
I think having a grappling hook in some games would be cool.  I have not scripted it yet but I made a Pendulum Simulation that seems like a step in the right direction.  I just wanted to log my progress.

update.c:
Code:
void main()
{//Pendulum Simulation in Openbor
	float len = 100; // lengh of the rope
	float originX = 160; // X of the top of the rope
	float originY = 0; // Y  of the top of the rope
	float bobX; //X end of the rope
	float bobY; //Y end of the rope
	float angle; //angle of rope
	float angleV; //angle velocity
	float angleA; //angle acceleration
	
	//set inital values
	if (angleA==NULL()){angleA=0.000000;}
	if (angleV==NULL()){angleV=0.00000;}
	if (angle==NULL()){angle=80.00000;}
	
	//work out where end of the rope should be and draw a line to it
	bobX = originX + len * sin(angle);
	bobY = originY + len * cos(angle);
	drawline(originX,originY,bobX,bobY,999,1);
	
	//set the gravity, acceleration and dampening to movement 
	angleA = -0.05 * sin(angle);
	angle += angleV;
	angleV += angleA;
	angleV *= 0.997;
}

if your interested you can download a demo with this in action: https://www.mediafire.com/file/rwzhyd1jq35ng41/Pendulum_Simulation.zip/file
 
Really thanks for the script. I was going to try to make something like that, but with an entity instead.
It won't be too hard to adapt it to a setdrawmethod though.
 
Nice one, malik! The pendulum is so nice especially for making a swing in Castlevania IV style. Love the addition, man. I wonder if I could have one single sprite or entity to play as a role for swing in Vehelits style (ala Bloodbane's or SOR style)
 
Back
Top Bottom