I would just like to say, I have a game design class in school, and you are going to bring me leagues ahead of everyone in the class. Learning this stuff from you is going to make doing my work in the class that much faster, and make my games that much better when it comes to creating my own for the class. Thanks a ton!
Great tutorial Shaun! These are easily the best Game Maker tutorials on the internet. They're great because they are thoroughly covering the basics. Keep up the good work!
good job , i'm new to making games been watching other tutorials for a while it's nice to find tutorials that actually teach something, most are just too long and don't really contain any real info, you actually stick to one thing on each video
Lol it's not bizarre, it's how we use it in Math and Engineering. Thank God. What's weird is the coordinate system. Why is negative y down and why is the origin points to the top left?
+prepareuranus It's because the game draws everything from the top left, like reading. It's just more convenient than having to put "-" after every y value in code.
CompletelyGarbage Oh that makes sense. I still always have to go back and change vertical speed and position values because it just doesn't stick in my brain.
+prepareuranus Yeah, it's definitely weird compared to most math and sciences. I kind of just like to think that the positive y going down is similar to a force vector in physics in that it's heading towards the direction of gravity.
just wanted to say, you're tutorials are amazing.. very detailed and you explain what you're doing with the codes very well.. much better than the F1 help. please do keep these tutorials coming. well done!
Thank you for the videos. They are really helpful in getting a feel for the program. Regarding the "bizarro angles", they just correspond to regular trigonometry, where x is right and y is up. Sin() is the y component of a vector and cos() is the x component. Sin(90) is therefore 1 and cos(90) = 0.
Awesome video! However, if you add the event "Key Release" with the code "alarm[0] = -1" the shooting will stop as soon as you release the assigned key. This is very helpful when having bigger values on your alarm, e.g. if you want to "charge" a bigger weapon. I hope i'm making any sense at all!
Great tutorials, Shaun, these are really helpful. I altered things a bit here, because I didn't like that there was a delay (the duration of the alarm) between pressing space and the bullet creation. For an instant shot, move the instance_create function from the Alarm 0 event into the 'if' statement of your 'space' event code. You can delete the code action from the Alarm 0 event, but an action must be there for the alarm to reset properly. I just used the "Exit this event" action.
It's great to see your keeping the series going !! I think your doing a great job at explaining the events etc.. Keep up the good work and look forward to following your tutorials !! ps thanks for making the effort to keep the keyboard noise down.. many thanks.. as it would be a great shame,as these are VERY GOOD tutorials. pps could we suggest ideas we would like to see you implement? and you show us how?
Tthis must be fate! from the last 5 hours we found your videos. nice to see i am up to date already with more to come! Friday my friend and I decided we wanted to make a game! Now on my second program and I must say that Game maker is way better you make things simple, and challenging us to try different things with what we have seen so far! Great videos will be watching to see what elements we could try next!
Shaun, thanks for all the great videos. I've learned so much from you, but I think I have a much better way of doing this. I find using your technique that it creates a delay because the alarm is starts when you trigger the space event. So, inside the create event I set a variable can_shoot = 0. In my space event I use the code if(can_shoot = 0) { instance_create(x,y,obj_player_bullet); alarm[0] = 15; can_shoot = 1; } Then in the alarm event I reset the variable can_shoot = 0.
The main reason the directions are done in the counterclockwise is because in Trigonometry, degrees are done with a coordinate plain. So the quarters of the circle, 0 to 90 (quadrant I), 90 to 180 (quadrant II), 180 to 270 (quadrant III), 270 to 360 (quadrant IV) all relate to a grid. So the perceived notion is that positive angle measures start by heading upward, and negative head downward.
The direction numbers aren't weird. They're based on the 360° on a circle, being 180° a straight horizontal line. I guess they didn't want to change it because that's the direction people is used to think when they hear those numbers. As long as you're aware it's based on a circumference's rotation, the numbers aren't weird at all.
Zarkin 02 Are you sure about that? I'm pretty sure every country has 0° at the right and 90° when it's aiming straight up. Although, I wouldn't be surprised if some countries decided to change math. I mean, the United States likes having a different measure system from the rest of the world.
TKS for this tutorial, friend! I replace spacebar by "Z" for set shootkey, because spacebar causes a crash when pressed together arrows. Most of indie developers now use the "Z,X,C" scheme foraction keys on their games. The only problem is with german keyboards, because their keyboard layout is different, but it is'nt the end of the world :D
I'm fairly certain good sir, that the mathematical world at large shares this software's "bizarro direction angles." However I would be remiss if I failed to say that each person is entitled, even though it be opposed to the unit circle, to his own opinion.
Great tutorial dude. I was wondering if you have done any tutorial for animating sprites(using gml to set conditions if possible), and tips on android devices like press/click vs long press/hold click functions
Quick question about the idea of an alarm being set to 9 whenever you press spacebar... does that not mean that you have a frame delay from hitting spacebar to shooting? Which for 60fps is 15ms of latency built into your game?
Hey, love the tutorials, could you explain how to make an 'power-up' appear then disappear after your ship hits it and how to make your power-up only last for a certain amount of time.
Thanks for your tutorials ... much appreciated ... If I may ... I would like to suggest a tutorial, How to touch / swipe the object to get it to move / jump / throw the obj... thanks
I'm following basically the same thing he's doing in these videos but with my own little sprites and backgrounds. Right now it's literally a moving grass background with 3 giant trees, and the player is a smaller blue tree that fires tiny green trees. It's a very interesting concept.
Not sure if I'm saying this right, but set a certain number for the amount of bullets (let's say 5) and then make it so that when it shoots that amount goes down by one. Then, once it's at 0, make it do whatever, reload or something.
any possible way you can direct me to some help i'm trying to make it where after certain score objects spawn time increases lets say first ten points of the score an object spawns every 30 seconds but after 10 points the objects spawns every 45 seconds.
In these videos, he gives you the tools to create any game you want! This isn't just a tutorial on how to make spaceship games, but how to use gamemaker to make any game you want! It will just take a little thinking out, and you will be all set!
Premium Fallout There are some things in an RPG that Shaun HASN'T gone over in his tutorials, example health bars, AI enemies, weapon coding, ect. I agree, with lee iff, Shaun should do a RGP tutorial.
First of all thanks for these great tutorials! They are thorough and easy to understand! I have a question though that really confuses me. When creating 3 instances of bullets and setting the direction, we're like creating the instance first, and then set the direction of the bullets. That to me is confusing because normally I would preset the desired direction first, and then create the instance of the object with that direction. It seems the sequence of how the codes execute is not as straightforward. Can you explain this part a bit more? Thank!
this is a very late response for you but I'll say it anyways, in any programming language/coding something has to exist first before you apply any changes to it otherwise it wont know what you are talking about. if it was just 1 bullet going in 1 direction then yea you could initialize the direction at the beginning but in this example he's making it so that when you get a powerup you suddenly create 2 extra bullets going in their own unique directions that don't follow the original straight up bullet so you have to set their directions individually.
In "press A" event add "execute code" action and write: "direction = 180;" Then go to your "press B" event and do the same but write: "direction = 0;" instead. I hope that you understand all of this. If you did it right your player should shoot in left direction whenever he is facing left (after you pressed A), and shoot in right direction whenever you are facing right (after you pressed D).
The reason the direction is counterclockwise starting at straight to the right is due to unfortunate common mathematical tradition. In directional math like physics and calculus degrees are built around making triangles in circles(confusing, I know). One side of the triangle is the closest axis to the angle, another is at the angle, and the last just connects them. So, for example at 0 degrees the first side is the x axis, the second is also at the x axis, and the third doesn't exist. At 30 degrees, the first side is the x axis, the second goes from the origin out at 30 degrees, and since the triangle is in a circle the third side connects the two points where the other sides hit the circle. It is pretty confusing, but this is common procedure so at least it always works the same way.
The placing of 0 degrees to the right is normal in geometry and engineering. This stems from the X coordinate (the first one in most 2d and 3d coordinate systems, and the only one used in a linear coordinate system) increasing to the right, making that the 'default' direction. Both it and the 'inverted' Y coordinates stem from comparing the data to text (because it really is just a long string of 1s and 0s). Just like the default reading direction is from left-to-right, the default angle is from left-to-right. Just like line numbers increase as you move down the sheet, Y coordinates increase as you move down.
Sooo i think you can change that to 3 bullets shooting in different directions like shown in the video or shooting 3 bullets in 1 direction by just changing the x coordinate to for example -5 and 5 for the 2 things!
So, do you think that using time from frame rate is the best practice here? The normal best practice for game creation is to set a generic time(something like time.deltaTime in Unity or a timer function) that is outside of your frame rate so that the varying frame rates between processors can have a consistent behavior.
once assigning a direction you no longer need the " - " symbol in the speed variable. the negative direction tells the game which direction on the x or y coordinates you want to travel. instead of assigning VSPEED = -8, try just setting SPEED = 8. This will allow the object to travel in the DIRECTION you have set first. now for example if you set speed to -8 it will travel OPPOSITE the direction you set
Shaun, When you set an instance to a variable, I notice you didn't declare the variable first... your code compiled, so that must be okay, but can you provide some insight on when to declare a variable and when GM will just infer such when you first set one?
I seem to have encountered a bit of an error. I changed the vspeed =- 8; in the bullet code to speed =- 8; like you said to do after specifying the cone shot directions, but for some reason the right most shot flies directly right, instead of up and right. I have the directions set to 100 & 80,so I'm not sure what went wrong.
By setting the alarm to 9 any time the space bar is pressed, doesn't this mean there is a delay of 9 frames anytime you stop and then start shooting again?
Yeah. To avoid this, put your bullet create code into the if statement before the alarm[0] = 5;. Then delete the code from the timer event, but dont delete the event.
One thing I need to point out is that, with this method, there seems to be a delay before that first shot is released. I have a hunch that it starts counting down from 5 after any fire-button press, including the first shot. I'd welcome introduction to a way to make it so that the first shot emerges on contact of the button press, with subsequent shots following the alarm delay.
Hey, awesome tutorial, just a quick question. If I wanted to create an "overheat" meter, where firing too many shots would jam the weapon, but cooldown over time, how would I do that and have you already covered something similar to this? Thanks!
Hey ***** - I noticed that with this method there is a delay when pressing space equal to the alarm counter you set. So if you set it to 20 (1/3 of a second at 60 frames), it's quite noticeable when you press space that it's there. How would you fix this?
If anyone else is still wondering the same thing. I used the alarm only as a timer. So all the code goes in the if sentence in the space pressed event. But the alarm still has to be set up as an event (you can put an empty piece of code, becouse it can't be blank).
Still fantastic, i would also appriciate if you coverd the how ot use the game maker actions such as the Alarms etc.. along with just the scripts. As they can be more flexible when you want to do more complex things with them down the line (and don't know the code to do so). But otherwise fantastic.
Thanks for these videos man, never thought making games would be interesting but i got a nice game set up from your videos, theres no point to it yet but its kinda like astroids from atari
The negative sign was to make the bullet travel straight up but since he gave each bullet a specific direction (or angle), the negative sign wasn't necessary anymore.
I missed him setting bullet1 to 90, so my speed was 8 but the direction was still set to 0. My angled bullets were going perfect, and the main bullet was shooting straight to the right.
when I do if (alarm [0] = -1) it works fine but when I add an alarm and do if (alarm [1] = -1) it does not work instead it does what alarm[0] is supposed to do help
In my country,we are teach that the direction angles go counter-clockwise from the right like in the video. So it will only be weird if it goes the other way around for me.
I have a question, i have a top down shooter but with 4 directional shooting so i really dont know how to make this "infinite string" of bullets. I wonder if you could explain it in the step event like you mentioned in the vid. Thank you for your videos!
Hey, thanks for the tutorials. Is there a way to have a button press combo do a certain animation. for example ASDF does a special move and hurts a enemy more
There is an odd side-effect of this code. When I release the button pressed projectiles continue to stream out for a very short time, depending upon the alarm value. How can I 'tighten' up this code; meaning that when the button is released projectiles stop firing instantly. Here is the code I used: if (keyboard_check(vk_up)) if (alarm[0] = -1) alarm [0] = 5;
When you put a delay between each bullet, the bullet apears only (for example) 5 frames after you press the command. Is there a way to make the bullets apear as soon as you press space bar?
when I pressed the up and left arrows (to move diagonally) and tried to shoot at the same time, i wasn't able to shoot. And when I started to shoot by holding the space bar, I wasn't able to move diagonally by pressing the left and up arrows. is there any explanation for this? PS: i had no problems trying to move diagonally using the up and right arrows while shooting, but for some reason I can't do it to the left.
I'm having an issue here. I followed the instructions, only making the minor changes appropriate for my game. One such change is the ship having multiple weapons. But when I set the different weapon functions to the alarm none of them work anymore. The ship simply won't fire any of them. The only way I can have all my weapons is by having it fire only when the button is pressed. Is there another method to firing a stream without alarms?
You should try to create one alarm for each weapon, with a var that say wich weapon will fire . then, each alarm trigger if you selected the right weapon ?
Eh, it's okay. After the issues I was having and my partner on the project passing away. I had the whole game structured differently to compensate. It happens.
hi there, I am having a problem were my instance_create is not a code apart of the software, but a variable I have created myself is there a fix for this, please help
I ran into the issue that if I hit 2 directions at the same time such as up and right, down and right, and down and left I can fire the beams. However, if I hold up and left (diagonal) and hit the space button it will not let me fire. Besides this one issue everything works, Any suggestions on why it might be doing this?
Hey, does anyone know a way to start each shot at a different animation frame? Like, if the animation has 4 frames, shot 1 starts on frame 1, then frame 2, then 3, etc. I tried setting the image index of the shot on it's creation to a value based on how many time i've shot, but that doesn't seem to work. Is there another variable/property that I should use?
hi , i set the airplane to be able to fire at any direction as i rotate the airplane but the only problem is when i start the game it fires at the right direction .how can i set it to start fire at the upper direction first.
hey, i'm just starting to watch these. i want to make a game with movement and combat like A link to the past. will i be able to learn that with your tutorials? keep up the good work :D
I'd just like to point out that game maker actually had a good idea when making the angle system so "weird", because the way they made it is the way that angles in radians are measured (from right, counterclockwise), so the system would help alot with trigonometric calculations
so i have a question? In regards to speed caps can they be set to relative positions, ie. when pressing the up key the speed cap is if (Speed > 2, and down, Speed > 6? i am trying to create the illusion of drag and physics with out actually programming physics.
I'm trying to adjust this for a platformer. I can get the bullet to appear on the right spot when facing right, but when facing left the bullet appears as if facing right (it travels left, just appears behind the player). I was using drag and drop features to set bullet speed and direction, but I'd rather do it in code. Anyone have any suggestions?
Quick question. I want a bullet object to check the image_xscale of the object_player, so I an tell it which way to go (left or right, the game is a platformer). Is there a way to do this and what is the code to check another object's variable?
Since there are so many smart people around here, im trying to make a shooter where i can shoot both ways. By using the horizontal speed i can get the bullet to go left and right but if i stand still it will not have a speed at all (since hsp = 0 ). What can i do to make it go my last looked way. So f.ex if i look left and sprite is left and im standing still, how can i get it to shoot towards the left?
LOZMV I had a similar problem a while back. I think how I solved it was by creating a new variable: last_direction. In the Step event, last_direction would become 0 if hspeed was 0. If hspeed was 0, last_direction wouldn't change. You can then have a bullet go left if last_direction is 0 and right if last_direction is 1. I hope that helps!
LOZMV Hello, i actually did get an answer from Shaun on another video. He said: Make another variable to track which direction you're currently facing. Set it to 1 when your hsp is positive and set it to -1 when your hsp is negative. Initialize it as whichever direction your sprite faces by default. Then when you make your bullet multiply its speed by this variable to get it to go the right way. I replied with : Ok, i see what you are getting at. I assume that the If function is not the choice i want here.. My code is (in the step function): //direction if(hsp > 0){ dirplayer = 1; image_xscale = dirplayer; } if(hsp < 0){ dirplayer = -1; image_xscale = dirplayer; } //Shooting //shooting if not invulnerable if(invulnerable != 1){ if (key_shoot){ sprite_index = spr_playershoot; image_speed = 0.25 * dirplayer; instance_create(x,y+4,obj_playerbullet); alarm[0] = 15; } } Dirplayer is a variable defined in the create player event with a value of 1. (since the character starts by looking right). As mentioned above it probably has to do with if(hsp < 0) and if (hsp >0), since hsp is 0 it doesn't know what to do and all i would need is a set command? if one even exists. Did not get an answer for this, so i never got it to work... This is bevause when hsp = 0, it does not know what to set the Dirplayer as, it assumes it is just in standard position, so if you fix that, you would probably be good to go.
+Jonas “Sir” Thoresen I had some success with left-right facing and shooting in my test, though i didn't follow so closely. A handy code is "sign". Here in obj_player's step event, it returns -1 or 1 depending if hspeed is negative or positive: if hspeed != 0 { image_xscale = sign(hspeed); } and in my bullet's create event (sends bullet in direction based on player's image_xscale): hspeed = obj_player.image_xscale * 7; (7 is the variable bullet speed) maybe that helps someone out there lol.
got it to work now :) do you know how to do the following > if (sprite_index == spr_man_right_idle) { if (keyboard_check_pressed(ord('F'))) sprite_index = spr_right_fire; } i want to only show this sprite_index for 1 second or less? thanks!!
Hi, i don't know if its the way i did my game, but, how do you get your character to be able to move around 360? at the minute I'm restricted to up down left and right, but if i was to press the up and left button, it doesn't travel diagonally to the top left corner..? Great tuts!
an actual thought that ran though my head when seeing this for the first time: "that's odd why's this labled in the Education catogory this is about learning things not about schools... ... Ooo" yer it may be that the "education" system in my area isn't entirly fit for purpose. And with the realisation Shaun is doing a better job than the IT department of my (quite expensive) school i'm off to Patrion.
I guess it uses the "Unit Circle" as a way to calculate gradients, where for instance 90 degrees would be equal to PI/2, 180 degrees to PI, and so forth.
I would just like to say, I have a game design class in school, and you are going to bring me leagues ahead of everyone in the class. Learning this stuff from you is going to make doing my work in the class that much faster, and make my games that much better when it comes to creating my own for the class. Thanks a ton!
Great tutorial Shaun! These are easily the best Game Maker tutorials on the internet. They're great because they are thoroughly covering the basics. Keep up the good work!
good job , i'm new to making games been watching other tutorials for a while it's nice to find tutorials that actually teach something, most are just too long and don't really contain any real info, you actually stick to one thing on each video
Lol it's not bizarre, it's how we use it in Math and Engineering. Thank God. What's weird is the coordinate system. Why is negative y down and why is the origin points to the top left?
I meant why is positive* Y down
+prepareuranus
It's because the game draws everything from the top left, like reading. It's just more convenient than having to put "-" after every y value in code.
CompletelyGarbage
Oh that makes sense. I still always have to go back and change vertical speed and position values because it just doesn't stick in my brain.
+prepareuranus
Yeah, it's definitely weird compared to most math and sciences. I kind of just like to think that the positive y going down is similar to a force vector in physics in that it's heading towards the direction of gravity.
i feel u xD
just wanted to say, you're tutorials are amazing.. very detailed and you explain what you're doing with the codes very well.. much better than the F1 help. please do keep these tutorials coming. well done!
Thank you for making fantastic, easy to follow tutorials! My game is taking shape all thanks to your videos!
DaMarque8 Gaming Studio Same here :)
Thank you for making these! They're very clear and thorough. As a beginner I'm eternally grateful haha
Keep making the videos, they are the most useful and informative on RUclips for game maker that I have seen.
Thank you for the videos. They are really helpful in getting a feel for the program.
Regarding the "bizarro angles", they just correspond to regular trigonometry, where x is right and y is up. Sin() is the y component of a vector and cos() is the x component. Sin(90) is therefore 1 and cos(90) = 0.
Awesome video! However, if you add the event "Key Release" with the code "alarm[0] = -1" the shooting will stop as soon as you release the assigned key. This is very helpful when having bigger values on your alarm, e.g. if you want to "charge" a bigger weapon. I hope i'm making any sense at all!
Great tutorials, Shaun, these are really helpful. I altered things a bit here, because I didn't like that there was a delay (the duration of the alarm) between pressing space and the bullet creation.
For an instant shot, move the instance_create function from the Alarm 0 event into the 'if' statement of your 'space' event code. You can delete the code action from the Alarm 0 event, but an action must be there for the alarm to reset properly. I just used the "Exit this event" action.
It's great to see your keeping the series going !!
I think your doing a great job at explaining the events etc..
Keep up the good work and look forward to following your tutorials !!
ps thanks for making the effort to keep the keyboard noise down.. many thanks..
as it would be a great shame,as these are VERY GOOD tutorials.
pps could we suggest ideas we would like to see you implement? and you show us how?
Thanks for these tutorials!
They're definitely better put together then other tutorials I've see on youtube!
Tthis must be fate! from the last 5 hours we found your videos. nice to see i am up to date already with more to come! Friday my friend and I decided we wanted to make a game! Now on my second program and I must say that Game maker is way better you make things simple, and challenging us to try different things with what we have seen so far! Great videos will be watching to see what elements we could try next!
the circle is laid out in the way of the unit circle for calculus
Shaun, thanks for all the great videos. I've learned so much from you, but I think I have a much better way of doing this. I find using your technique that it creates a delay because the alarm is starts when you trigger the space event. So, inside the create event I set a variable can_shoot = 0. In my space event I use the code
if(can_shoot = 0)
{
instance_create(x,y,obj_player_bullet);
alarm[0] = 15;
can_shoot = 1;
}
Then in the alarm event I reset the variable can_shoot = 0.
Those "bizarro direction angles" are just the way math always lays out degrees.
bro those bizarro direction angles made my day don't @ them
sorry this comment is 7 years late :/
I find your tutorials very informative slow and descriptive. Thank you so much!
can you make a playlist with all space game tutorials?
The main reason the directions are done in the counterclockwise is because in Trigonometry, degrees are done with a coordinate plain. So the quarters of the circle, 0 to 90 (quadrant I), 90 to 180 (quadrant II), 180 to 270 (quadrant III), 270 to 360 (quadrant IV) all relate to a grid. So the perceived notion is that positive angle measures start by heading upward, and negative head downward.
Great tutorials Shaun, hope you keep doing more of this.
Shaun i had a great Christmas and i love your tutorials keep up the good work :)
best gm tutorials on youtube! Thanks man!
The direction numbers aren't weird. They're based on the 360° on a circle, being 180° a straight horizontal line.
I guess they didn't want to change it because that's the direction people is used to think when they hear those numbers. As long as you're aware it's based on a circumference's rotation, the numbers aren't weird at all.
Zarkin 02 Are you sure about that? I'm pretty sure every country has 0° at the right and 90° when it's aiming straight up.
Although, I wouldn't be surprised if some countries decided to change math. I mean, the United States likes having a different measure system from the rest of the world.
Zarkin 02 I live in Chile and here it's just like Guillermo said... 90 means up and 0 = right.
TKS for this tutorial, friend! I replace spacebar by "Z" for set shootkey, because spacebar causes a crash when pressed together arrows. Most of indie developers now use the "Z,X,C" scheme foraction keys on their games. The only problem is with german keyboards, because their keyboard layout is different, but it is'nt the end of the world :D
I'm fairly certain good sir, that the mathematical world at large shares this software's "bizarro direction angles." However I would be remiss if I failed to say that each person is entitled, even though it be opposed to the unit circle, to his own opinion.
+TheMightyBoolean you from the turn of the century, old chap?
Alas, I did not quite make it.
en.wikipedia.org/wiki/George_Boole
Thanks Shaun Spalding, i'm learning how to make my game very easily thanks to you!
I just want to thank you for your videos, they're very informative and I appreciate your taking the time to do them :)
Great tutorial dude. I was wondering if you have done any tutorial for animating sprites(using gml to set conditions if possible), and tips on android devices like press/click vs long press/hold click functions
Quick question about the idea of an alarm being set to 9 whenever you press spacebar... does that not mean that you have a frame delay from hitting spacebar to shooting? Which for 60fps is 15ms of latency built into your game?
when i use the alarm there is a delay after i press spacebar then the ship shoots the bullets. Is there a way to remove that delay?
The layout of the angles is basic trigonometric conventions. Be thankful it isn't on radians! Other than that, great video, very helpful!
I just noticed that, cuz i'm studying that right now at school.
I didn't know the god of death was interested in programming!
terrific videos! i do have a small request, could you do a tutorial on particles and other effects?
Thank you for putting these out!!!
Hey, love the tutorials, could you explain how to make an 'power-up' appear then disappear after your ship hits it and how to make your power-up only last for a certain amount of time.
Thanks for your tutorials ... much appreciated ...
If I may ... I would like to suggest a tutorial,
How to touch / swipe the object to get it to move / jump / throw the obj... thanks
Thanks Shaun. Happy holidays to you as well.
I'm following basically the same thing he's doing in these videos but with my own little sprites and backgrounds.
Right now it's literally a moving grass background with 3 giant trees, and the player is a smaller blue tree that fires tiny green trees.
It's a very interesting concept.
Very good tut! Could I use "alarms" to pause a string of virtual key movements/inputs then press "go" any the player moves?
Not sure if I'm saying this right, but set a certain number for the amount of bullets (let's say 5) and then make it so that when it shoots that amount goes down by one. Then, once it's at 0, make it do whatever, reload or something.
any possible way you can direct me to some help i'm trying to make it where after certain score objects spawn time increases lets say first ten points of the score an object spawns every 30 seconds but after 10 points the objects spawns every 45 seconds.
can you make this basic playlist only with an rpg
In these videos, he gives you the tools to create any game you want! This isn't just a tutorial on how to make spaceship games, but how to use gamemaker to make any game you want! It will just take a little thinking out, and you will be all set!
Premium Fallout There are some things in an RPG that Shaun HASN'T gone over in his tutorials, example health bars, AI enemies, weapon coding, ect. I agree, with lee iff, Shaun should do a RGP tutorial.
First of all thanks for these great tutorials! They are thorough and easy to understand!
I have a question though that really confuses me. When creating 3 instances of bullets and setting the direction, we're like creating the instance first, and then set the direction of the bullets. That to me is confusing because normally I would preset the desired direction first, and then create the instance of the object with that direction. It seems the sequence of how the codes execute is not as straightforward. Can you explain this part a bit more? Thank!
this is a very late response for you but I'll say it anyways, in any programming language/coding something has to exist first before you apply any changes to it otherwise it wont know what you are talking about. if it was just 1 bullet going in 1 direction then yea you could initialize the direction at the beginning but in this example he's making it so that when you get a powerup you suddenly create 2 extra bullets going in their own unique directions that don't follow the original straight up bullet so you have to set their directions individually.
In "press A" event add "execute code" action and write: "direction = 180;"
Then go to your "press B" event and do the same but write: "direction = 0;" instead. I hope that you understand all of this. If you did it right your player should shoot in left direction whenever he is facing left (after you pressed A), and shoot in right direction whenever you are facing right (after you pressed D).
The reason the direction is counterclockwise starting at straight to the right is due to unfortunate common mathematical tradition. In directional math like physics and calculus degrees are built around making triangles in circles(confusing, I know). One side of the triangle is the closest axis to the angle, another is at the angle, and the last just connects them. So, for example at 0 degrees the first side is the x axis, the second is also at the x axis, and the third doesn't exist. At 30 degrees, the first side is the x axis, the second goes from the origin out at 30 degrees, and since the triangle is in a circle the third side connects the two points where the other sides hit the circle. It is pretty confusing, but this is common procedure so at least it always works the same way.
The placing of 0 degrees to the right is normal in geometry and engineering. This stems from the X coordinate (the first one in most 2d and 3d coordinate systems, and the only one used in a linear coordinate system) increasing to the right, making that the 'default' direction.
Both it and the 'inverted' Y coordinates stem from comparing the data to text (because it really is just a long string of 1s and 0s). Just like the default reading direction is from left-to-right, the default angle is from left-to-right. Just like line numbers increase as you move down the sheet, Y coordinates increase as you move down.
I saw your tutorials for construct, they're pretty awesome!!!
I assume the weird angles are due to a focus on platformer games. Running right is direction 0, running left is direction 180. :)
Sooo i think you can change that to 3 bullets shooting in different directions like shown in the video or shooting 3 bullets in 1 direction by just changing the x coordinate to for example -5 and 5 for the 2 things!
So, do you think that using time from frame rate is the best practice here? The normal best practice for game creation is to set a generic time(something like time.deltaTime in Unity or a timer function) that is outside of your frame rate so that the varying frame rates between processors can have a consistent behavior.
I wrote if (alarm[0] = -1) alarm = 5; in space and instance_create(x,y,shadow_kick_obj); in alarm 0 but it only shoots one bullet
once assigning a direction you no longer need the " - " symbol in the speed variable. the negative direction tells the game which direction on the x or y coordinates you want to travel. instead of assigning VSPEED = -8, try just setting SPEED = 8. This will allow the object to travel in the DIRECTION you have set first. now for example if you set speed to -8 it will travel OPPOSITE the direction you set
Shaun,
When you set an instance to a variable, I notice you didn't declare the variable first... your code compiled, so that must be okay, but can you provide some insight on when to declare a variable and when GM will just infer such when you first set one?
I seem to have encountered a bit of an error. I changed the vspeed =- 8; in the bullet code to speed =- 8; like you said to do after specifying the cone shot directions, but for some reason the right most shot flies directly right, instead of up and right. I have the directions set to 100 & 80,so I'm not sure what went wrong.
Love your tutorials, theyre the only helpful ones for understanding code and not just relying on dumb in-game buttons. TT___TT
By setting the alarm to 9 any time the space bar is pressed, doesn't this mean there is a delay of 9 frames anytime you stop and then start shooting again?
Yeah. To avoid this, put your bullet create code into the if statement before the alarm[0] = 5;.
Then delete the code from the timer event, but dont delete the event.
One thing I need to point out is that, with this method, there seems to be a delay before that first shot is released. I have a hunch that it starts counting down from 5 after any fire-button press, including the first shot.
I'd welcome introduction to a way to make it so that the first shot emerges on contact of the button press, with subsequent shots following the alarm delay.
for some reason the alarm doesn't work
Hey, awesome tutorial, just a quick question. If I wanted to create an "overheat" meter, where firing too many shots would jam the weapon, but cooldown over time, how would I do that and have you already covered something similar to this? Thanks!
This is really good. Thanks for these informative tutorials.
Hey ***** - I noticed that with this method there is a delay when pressing space equal to the alarm counter you set. So if you set it to 20 (1/3 of a second at 60 frames), it's quite noticeable when you press space that it's there. How would you fix this?
If anyone else is still wondering the same thing. I used the alarm only as a timer. So all the code goes in the if sentence in the space pressed event. But the alarm still has to be set up as an event (you can put an empty piece of code, becouse it can't be blank).
if(alarm[0] = -1){
create_instance(x, y-16, obj_bullet);
alarm[0] = 5;
}
Still fantastic, i would also appriciate if you coverd the how ot use the game maker actions such as the Alarms etc.. along with just the scripts. As they can be more flexible when you want to do more complex things with them down the line (and don't know the code to do so). But otherwise fantastic.
Thanks for these videos man, never thought making games would be interesting but i got a nice game set up from your videos, theres no point to it yet but its kinda like astroids from atari
could anybody be nice and please explain why on 13:00 he changed it from vspeed =-8; to speed=8? why did he remove the - sign? Thanks!
The negative sign was to make the bullet travel straight up but since he gave each bullet a specific direction (or angle), the negative sign wasn't necessary anymore.
I missed him setting bullet1 to 90, so my speed was 8 but the direction was still set to 0. My angled bullets were going perfect, and the main bullet was shooting straight to the right.
Can you make a tutorial for a player fire power up where you start shooting spread shots and homing missles using drag and drop.
when I do if (alarm [0] = -1) it works fine
but when I add an alarm and do if (alarm [1] = -1) it does not work
instead it does what alarm[0] is supposed to do
help
Same here
SR Keego you are supposed to do
(alarm[0] = -1)
not
(alarm[1] = -1)
hoped this helped
not sure here but I think you should first use the alarm[0], and then if you're using it but you need another alarm you use alarm[1]
In my country,we are teach that the direction angles go counter-clockwise from the right like in the video. So it will only be weird if it goes the other way around for me.
I have a question, i have a top down shooter but with 4 directional shooting so i really dont know how to make this "infinite string" of bullets.
I wonder if you could explain it in the step event like you mentioned in the vid.
Thank you for your videos!
Hey, thanks for the tutorials. Is there a way to have a button press combo do a certain animation. for example ASDF does a special move and hurts a enemy more
There is an odd side-effect of this code. When I release the button pressed projectiles continue to stream out for a very short time, depending upon the alarm value. How can I 'tighten' up this code; meaning that when the button is released projectiles stop firing instantly. Here is the code I used:
if (keyboard_check(vk_up)) if (alarm[0] = -1) alarm [0] = 5;
When you put a delay between each bullet, the bullet apears only (for example) 5 frames after you press the command. Is there a way to make the bullets apear as soon as you press space bar?
Or a way to put a bullet limit that can be on screen.
+Jerr Cyr You can watch the last episode about this, he mentions it there
Thanks Alan Alvarado
How would I go about making a power up that once taken gives you the ability to shoot 3 bullets?
when I pressed the up and left arrows (to move diagonally) and tried to shoot at the same time, i wasn't able to shoot.
And when I started to shoot by holding the space bar, I wasn't able to move diagonally by pressing the left and up arrows.
is there any explanation for this?
PS: i had no problems trying to move diagonally using the up and right arrows while shooting, but for some reason I can't do it to the left.
I'm having an issue here. I followed the instructions, only making the minor changes appropriate for my game. One such change is the ship having multiple weapons. But when I set the different weapon functions to the alarm none of them work anymore. The ship simply won't fire any of them. The only way I can have all my weapons is by having it fire only when the button is pressed. Is there another method to firing a stream without alarms?
You should try to create one alarm for each weapon, with a var that say wich weapon will fire . then, each alarm trigger if you selected the right weapon ?
Yeah that didn't pan out either. The same results as before actually. Thanks anyways.
Arf, my bad, sorry then, maybe if you give me the code i can help you ?
Eh, it's okay. After the issues I was having and my partner on the project passing away. I had the whole game structured differently to compensate. It happens.
I saw, good luck then :)
This is a good way to shoot, but I don't want an initial delay when the first bullet is shot. Do you know to fix this?
gamemaker direction constants follow a unit circle, that makes 0 degrees directly right in the x direction
im trying to use the alarm method to create enemy random generator, how would you go about creating an enemy random generator?
hi there, I am having a problem were my instance_create is not a code apart of the software, but a variable I have created myself is there a fix for this, please help
The angle system is based on how circles and angles are actually used in Trigonometry and general math. Regardless, awesome tutorials!
If you don't set the vspeed to speed and switch the number to positive, the game engine does the exact same thing, am I missing something?
I ran into the issue that if I hit 2 directions at the same time such as up and right, down and right, and down and left I can fire the beams. However, if I hold up and left (diagonal) and hit the space button it will not let me fire. Besides this one issue everything works, Any suggestions on why it might be doing this?
Hey, does anyone know a way to start each shot at a different animation frame? Like, if the animation has 4 frames, shot 1 starts on frame 1, then frame 2, then 3, etc.
I tried setting the image index of the shot on it's creation to a value based on how many time i've shot, but that doesn't seem to work. Is there another variable/property that I should use?
Thanks a bunch, got confused by how the alarms work, now I know, thank you!
When I do my voding, x+=2 p to stop my charecter from moving, when I am not holding any key, it says it can't work. Why?
hi , i set the airplane to be able to fire at any direction as i rotate the airplane but the only problem is when i start the game it fires at the right direction .how can i set it to start fire at the upper direction first.
Regarding about the bullet1.directions...just base your measurements of the angles on a protractor. 0 would be straight right.
hey, i'm just starting to watch these.
i want to make a game with movement and combat like A link to the past. will i be able to learn that with your tutorials?
keep up the good work :D
how would i make it were it goes forward for a certain distance?
Why does a sound effect (explosion) cut the background music?
I'd just like to point out that game maker actually had a good idea when making the angle system so "weird", because the way they made it is the way that angles in radians are measured (from right, counterclockwise), so the system would help alot with trigonometric calculations
so i have a question?
In regards to speed caps can they be set to relative positions, ie. when pressing the up key the speed cap is if (Speed > 2, and down, Speed > 6?
i am trying to create the illusion of drag and physics with out actually programming physics.
I'm trying to adjust this for a platformer. I can get the bullet to appear on the right spot when facing right, but when facing left the bullet appears as if facing right (it travels left, just appears behind the player). I was using drag and drop features to set bullet speed and direction, but I'd rather do it in code. Anyone have any suggestions?
Quick question. I want a bullet object to check the image_xscale of the object_player, so I an tell it which way to go (left or right, the game is a platformer). Is there a way to do this and what is the code to check another object's variable?
Since there are so many smart people around here, im trying to make a shooter where i can shoot both ways. By using the horizontal speed i can get the bullet to go left and right but if i stand still it will not have a speed at all (since hsp = 0 ). What can i do to make it go my last looked way. So f.ex if i look left and sprite is left and im standing still, how can i get it to shoot towards the left?
wow your comment has gone an entire month without a reply, I'm having a similar issue so if someone could help that would be great.
LOZMV
I had a similar problem a while back. I think how I solved it was by creating a new variable: last_direction. In the Step event, last_direction would become 0 if hspeed was 0. If hspeed was 0, last_direction wouldn't change. You can then have a bullet go left if last_direction is 0 and right if last_direction is 1. I hope that helps!
LOZMV Hello, i actually did get an answer from Shaun on another video. He said: Make another variable to track which direction you're currently facing. Set it to 1 when your hsp is positive and set it to -1 when your hsp is negative. Initialize it as whichever direction your sprite faces by default. Then when you make your bullet multiply its speed by this variable to get it to go the right way.
I replied with :
Ok, i see what you are getting at. I assume that the If function is not the choice i want here.. My code is (in the step function):
//direction
if(hsp > 0){
dirplayer = 1;
image_xscale = dirplayer;
}
if(hsp < 0){
dirplayer = -1;
image_xscale = dirplayer;
}
//Shooting
//shooting if not invulnerable
if(invulnerable != 1){
if (key_shoot){
sprite_index = spr_playershoot;
image_speed = 0.25 * dirplayer;
instance_create(x,y+4,obj_playerbullet);
alarm[0] = 15;
}
}
Dirplayer is a variable defined in the create player event with a value of 1. (since the character starts by looking right).
As mentioned above it probably has to do with if(hsp < 0) and if (hsp >0), since hsp is 0 it doesn't know what to do and all i would need is a set command? if one even exists.
Did not get an answer for this, so i never got it to work... This is bevause when hsp = 0, it does not know what to set the Dirplayer as, it assumes it is just in standard position, so if you fix that, you would probably be good to go.
+Jonas “Sir” Thoresen
I had some success with left-right facing and shooting in my test, though i didn't follow so closely.
A handy code is "sign". Here in obj_player's step event, it returns -1 or 1 depending if hspeed is negative or positive:
if hspeed != 0
{
image_xscale = sign(hspeed);
}
and in my bullet's create event (sends bullet in direction based on player's image_xscale):
hspeed = obj_player.image_xscale * 7;
(7 is the variable bullet speed)
maybe that helps someone out there lol.
+Haywood Jablome
It actually helped a lot, thanks!!
how can i say when guys looks left bullet left is shot when pressing space and right bullet is shot when guy looks to the right? many thanks!!!
got it to work now :) do you know how to do the following >
if (sprite_index == spr_man_right_idle) {
if (keyboard_check_pressed(ord('F')))
sprite_index = spr_right_fire;
}
i want to only show this sprite_index for 1 second or less? thanks!!
how do i make my characters projectiles follow my mouse's direction?
Hi, i don't know if its the way i did my game, but, how do you get your character to be able to move around 360? at the minute I'm restricted to up down left and right, but if i was to press the up and left button, it doesn't travel diagonally to the top left corner..? Great tuts!
an actual thought that ran though my head when seeing this for the first time:
"that's odd why's this labled in the Education catogory this is about learning things not about schools... ... Ooo"
yer it may be that the "education" system in my area isn't entirly fit for purpose.
And with the realisation Shaun is doing a better job than the IT department of my (quite expensive) school i'm off to Patrion.
I guess it uses the "Unit Circle" as a way to calculate gradients, where for instance 90 degrees would be equal to PI/2, 180 degrees to PI, and so forth.