Fixing slingshot coding

A problem that I found with our slingshot was that when the character was fired from our slingshot the string from the slingshot stayed attached to the character and this did not look nice so I decided to look into it

Example for what should be blog one

I found the code inside the slingshot’s code itself and I thought I know how to make this easier and work correctly

Example for what should be blog one show code

I looked at the code and thought it seemed odd to have it all based on this piece of code as this code will be affecting the character

Example for what should be blog one alter code

so I modified the code to make it more simple for the slingshot

Example for what should be blog one add draw

I then added a draw event to the player character so I could recreate the string through his own code

Example for what should be blog one add new coding

this code was added into the draw event with some assistance to understanding what I needed to do from ryan

 

if (!isFired and isClicked) {
draw_line(obj_sling_physics.x-14,obj_sling_physics.y,x,y)
draw_line(obj_sling_physics.x+14,obj_sling_physics.y,x,y)
} else {
if(isFired){
draw_line(obj_sling_physics.x-14,obj_sling_physics.y,obj_sling_physics.x+14,obj_sling_physics.y)
}
if(!isFired and !isClicked){
draw_line(obj_sling_physics.x-14,obj_sling_physics.y,obj_sling_physics.x+14,obj_sling_physics.y)
}
}
draw_self()

 

This code draws the string linking the character to the slingshot and allows the string to stay in place after firing while also allowing the character to be detached from the string itself giving a nicer look and feel to the game

 

Jordan Shepherd

Leave a comment