Download Resources Web Applications Games Recycle Bin

rope swings | gml



Add a new object objRope and set sprite origin Middle Left:



Set up in room with enough room for a decent jump and swing:



objRope Create

force = 0;
direction = 180;
time_to_attach = 30;
let_go_timer = 0;

objRope Step

if (direction > 90 && direction < 270){
  force = force + 0.25;
  if (force > 6) force = 6;
}
else{
  force = force - 0.25;	
  if (force < -6) force = -6;
}
direction += force;
image_angle = direction;

if let_go_timer > 0 let_go_timer -= 1;

objRope Collision event with objPlayer

time_to_attach -= 1;
if (let_go_timer < 1){
  //if sprPlayer top left origin you would have to additionally: -sprite_width/2;
	objPlayer.x = x+lengthdir_x(sprite_width,direction);
	objPlayer.y = bbox_bottom;
	objPlayer.vert = 0;
	if keyboard_check(vk_up) and (time_to_attach < 1){
		let_go_timer = room_speed div 2; //half a sec to get off rope
		objPlayer.vert = objPlayer.jump_speed
		time_to_attach = 30;
	}
}



activities
1. Implement the above code

2. The rope in the sprite above is 200px long. Try this with a shorter and longer rope.

3. Find an actual rope sprite from the internet to use for this sprite.

4. Can you add some ropes to the previous tutorial you did with up / down / left / right moving platforms? Again, make it increasingly difficult for me (with timed jumps) to get to the end BUT NOT IMPOSSIBLE!