Sling Shot & Character Code ( Game Maker )

I started to play about with the code in game maker and looked for more research to help me throughout the process and from doing this I was then able to create the sling shot that works as well as being able to have the character spawn within the sling at the start and once it is out of the room.

Player : 

1.

I create a create event and inserted code :

mass =1
clicked =false

2.

I then created a Left Pressed Event and inserted code :

clicked = true

3.

I then create a Glob Left Button Event and inserted code :

if global.sling =true && clicked=true{
x=mouse_x
y=mouse_y

}

4.

I then created a Glob Left Released Event and Inserted code :

if global.sling=true && clicked=true {

clicked=false
global.sling=false
hspeed=((obj__sling.x-x)*.15)/mass
vspeed=((obj__sling.y-y)*.15)/mass

}

5.

I then created a Outside Room Event with code :

room_restart()

 

Sling : 

1.

For the Sling I created a Create Event with Code :

global.sling=true

2.

I then Created a Draw Event with code

draw_sprite(sprite_index,image_index,x,y)
//draw_self()

if global.sling=true{
draw_line(x14,y,obj_player.x,obj_player.y)
draw_line(x+14,y,obj_player.x,obj_player.y)

}

Jack Reed ( Team Leader / Artist / Sound / Code ) 

Leave a comment