oh my gawd i thought the big title instead of the thread title...Rulez wrote:I won't. Check the motherfucking title of this thread, it fucking says ''missle''. Thank fuck you changed the first post, but the thread name is important as well.
Missile Dogfight minigame made in Game Maker
Forum rules
Please keep the forum rules and guidelines in mind when creating or replying to a topic.
Please keep the forum rules and guidelines in mind when creating or replying to a topic.
Re: Missle Dogfight minigame made in Game Maker
-
Master

- Posts: 53544
- Joined: Sun Aug 21, 2011 10:14 am
- Location: Somewhere specific, I'd assume.
- Tings: 468320
Re: Missile Dogfight minigame made in Game Maker
So, with the first post changed, all of the posts starting with this one will have the right spelling of the title.
Re: Missile Dogfight minigame made in Game Maker
Now that i got my brain working and found out that the thread title was what Rulez and Rayfan was talking about.Master4lyf1 wrote:So, with the first post changed, all of the posts starting with this one will have the right spelling of the title.
-
Master

- Posts: 53544
- Joined: Sun Aug 21, 2011 10:14 am
- Location: Somewhere specific, I'd assume.
- Tings: 468320
Re: Missile Dogfight minigame made in Game Maker
I see, not to nitpick further, but the link to the game is still misspelt.
Re: Missile Dogfight minigame made in Game Maker
OKay, so... is there any more problems?Master4lyf1 wrote:I see, not to nitpick further, but the link to the game is still misspelt.
-
Shrooblord

- Posts: 15762
- Joined: Tue Sep 07, 2010 5:07 pm
- Location: The Buccaneer MK. II
- Tings: 68850
Re: Missile Dogfight minigame made in Game Maker
The way you handled the flight path of the missiles intrigues me, especially since you're new. It can be done much simpler. Observe:
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,
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.
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!
Code: Select all
// Firing of a bullet
var newbullet;
newbullet = instance_create(x,y,bullet_s1);
newbullet.direction = image_angle;
newbullet.speed = 4;
Code: Select all
var newbullet;Code: Select all
newbullet = instance_create(x,y+8,bullet_s1);Code: Select all
newbullet.direction = image_angle;
newbullet.speed = 4;
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!
Re: Missile Dogfight minigame made in Game Maker
Ok, i will test it.Shrooblord wrote: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;
And it will move in a straight line, as you said, OK.Shrooblord wrote: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 = instance_create(x,y+8,bullet_s1);
Ok, i took a lot of time to tell gm to use shell.x at each bullets, which is the same as x. xD Thanks.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.Code: Select all
newbullet.direction = image_angle; newbullet.speed = 4;
Without it i wouldn't have been able to do so many things in my games.Shrooblord wrote: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!
Thanks, for telling me this, it works perfectly!
