The way you handled the flight path of the missiles intrigues me, especially since you're new. It can be done much simpler. Observe:
Code: Select all
// Firing of a bullet
var newbullet;
newbullet = instance_create(x,y,bullet_s1);
newbullet.direction = image_angle;
newbullet.speed = 4;
I will now tell you what this all does. If I'm going to quick on any of these matters, just stop me and ask about it. I will explain in great detail.
Creates the temporary variable 'newbullet'. This is important, especially when your game gets bigger, because if it's a temporary variable, it doesn't eat up as much memory as one would if it were initialised in the Create Event. Also important is to realise that a variable that's set up using the term 'var' is only accessable within the code it's defined in. Say you have a 'var' variable somewhere in the create event. That variable cannot be called from within the Step Event, because it simply does not exist anymore as soon as the game has finished dealing with the code in the Create Event. Even more specific, if a 'var' variable is defined within an if statement, it can only be called from within that if statement, not outside of it, even if the code outside of that if statement is in the same Event as the if statement is,
Code: Select all
newbullet = instance_create(x,y+8,bullet_s1);
Now, the new variable is assigned to the instance ID of the newly created object bullet_s1. This means that when newbullet is used later on, it will only affect that one instance of bullet_s1 that was JUST created. If there are already other instances of the object bullet_s1 around, they will not be called, because the variable points to that newly created bullet and to that bullet only. Note how I used different names and x,y coords for things than you did. This is because with this system, you will need only two bullet objects in total: bullet_s1, for 'bullet coming from Shell 1' and bullet_s2, which is the bullet fired by the second player. You can give them whatever name you wish, of course, but I named them this. I removed the 'shell2.' in front of the x and the y, since this code should already be inside that object. If that is the case, then there's no need to specificly tell GM that you're talking about that object. If anywhere in the object it says to use the variable 'x', it will use the x that belongs to that object.
Code: Select all
newbullet.direction = image_angle;
newbullet.speed = 4;
Now, specific variables are set for the newly created bullet. The direction in which the bullet needs to travel is set to the image_angle OF THE SHELL. This is also why there's no 'newbullet.' in front of that variable. This will cause the bullet to travel in the direction the Shell is facing to. Next, the newbullet is given a speed of 4, so it travels with 4 coords a step in that direction.
There, that should simplify your code a lot. Like I said, if you don't understand something, anything at all, just ask. I'll just summarise:
You need only two bullet objects: bullet_s1 and bullet_s2.
You need no paths.
In the code in Shell 1, where a bullet is fired, place the code I gave you. This will create a bullet for that shell at the required position, with a direction and a speed, so it will travel in a straight line.
---
Also, I'm pleased to see you're already trying GML - most new users just stick to Drag 'n Drop.
Good luck; hope it helps!