Page 2 of 2

Re: Missle Dogfight minigame made in Game Maker

Posted: Sun Jul 29, 2012 8:39 pm
by Rayrobi
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.
oh my gawd i thought the big title instead of the thread title... :confus:

Re: Missile Dogfight minigame made in Game Maker

Posted: Sun Jul 29, 2012 8:43 pm
by Master
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

Posted: Sun Jul 29, 2012 8:45 pm
by Rayrobi
Master4lyf1 wrote:So, with the first post changed, all of the posts starting with this one will have the right spelling of the title.
Now that i got my brain working and found out that the thread title was what Rulez and Rayfan was talking about.

Re: Missile Dogfight minigame made in Game Maker

Posted: Sun Jul 29, 2012 8:47 pm
by Master
I see, not to nitpick further, but the link to the game is still misspelt.

Re: Missile Dogfight minigame made in Game Maker

Posted: Sun Jul 29, 2012 8:54 pm
by Rayrobi
Master4lyf1 wrote:I see, not to nitpick further, but the link to the game is still misspelt.
OKay, so... is there any more problems?

Re: Missile Dogfight minigame made in Game Maker

Posted: Tue Jul 31, 2012 1:13 am
by Shrooblord
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.

Code: Select all

var newbullet;
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!

Re: Missile Dogfight minigame made in Game Maker

Posted: Tue Jul 31, 2012 11:04 am
by Rayrobi
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;
Ok, i will test it.
Shrooblord wrote:

Code: Select all

newbullet = instance_create(x,y+8,bullet_s1);
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.
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.

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.
And it will move in a straight line, as you said, OK.
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!
Without it i wouldn't have been able to do so many things in my games.

Thanks, for telling me this, it works perfectly!