Creating a manic boss with multiple patterns (Game Maker)
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
Creating a manic boss with multiple patterns (Game Maker)
I'm fooling around making a shooter of sorts. Right now it's just a boss fight, that's what I'm working on.
As of now the boss has health, can be damaged and killed, and shoots a few things.
What I want to do is have different sets of attacks based on the health the boss has. I think I need to use timelines for this, but I can't figure out how to use them effectively for this purpose. Can someone explain the variables and values associated with a timeline and how to use them in this way?
Currently I have several attacks that are each placed at certain locations of the boss sprite so it looks like it's firing them. They just start firing immediately since I can't figure out how to delay and then start things in a timely manner.
Also, I'm using the "dice" action so bullets are fired randomly and repeatedly. How can I fire bullets at intervals (not randomly)? For example, firing a burst or stream of a certain amount of bullets, then a gap, then another burst.
Thanks in advance for any help.
As of now the boss has health, can be damaged and killed, and shoots a few things.
What I want to do is have different sets of attacks based on the health the boss has. I think I need to use timelines for this, but I can't figure out how to use them effectively for this purpose. Can someone explain the variables and values associated with a timeline and how to use them in this way?
Currently I have several attacks that are each placed at certain locations of the boss sprite so it looks like it's firing them. They just start firing immediately since I can't figure out how to delay and then start things in a timely manner.
Also, I'm using the "dice" action so bullets are fired randomly and repeatedly. How can I fire bullets at intervals (not randomly)? For example, firing a burst or stream of a certain amount of bullets, then a gap, then another burst.
Thanks in advance for any help.
-
Shatterhand
- Posts: 4044
- Joined: Wed Jan 26, 2005 3:01 am
- Location: Rio de Janeiro - Brazil
- Contact:
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
there is a bulletML library for gamemaker, but really.. you can program all kinds of patterns just as you can program all sorts of patterns in c++
cigs, are you writing the program in code or using the standard modules?
in code you can set from where in the timeline you want to play. a timeline can have time events where it jumps back to a previous position. so you can make different loops and control which is played by checking the energy of the boss.
i write my bulletpatterns in scripts. that way it becomes more flexible
cigs, are you writing the program in code or using the standard modules?
in code you can set from where in the timeline you want to play. a timeline can have time events where it jumps back to a previous position. so you can make different loops and control which is played by checking the energy of the boss.
i write my bulletpatterns in scripts. that way it becomes more flexible
-
Shatterhand
- Posts: 4044
- Joined: Wed Jan 26, 2005 3:01 am
- Location: Rio de Janeiro - Brazil
- Contact:
I don't know how you could do complex patterns if not in code.
I must admit I NEVER worked with timelines, so I don't know how it works.
That's what I usually do (It's a lot of work, but it's simple and easy to backtrack errors)... there are many others way to do that we can discuss here, but this is a good start point.
In the CREATE, add this snipet of code:
{
counter = 0
}
in the STEP event, add this code: (Bullet should be the boss bullet object)
{
counter += 1
if counter = 10 then
{
shot=instance_create(x,y,bullet)
shot.direction = 270
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 300
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 240
shot.speed = 10
}
if counter = 50 then
{
shot=instance_create(x,y,bullet)
shot.direction = 200
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 230
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 260
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 290
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 310
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 340
shot.speed = 10
}
if counter = 80 then
counter = 0
I hope you can see the logic behind this. Play around with it. (Try change directions, speed, add more stuff of your own)
I usually make scripts for certain bullet patterns. Unfortunately, right now I don't have access at any of my gamemaker stuff (I just installed Linux, and I am having some headache to make it access the Windows partition) .. As soon as I sort this out, I'll post some of my bullet scripts.
I must admit I NEVER worked with timelines, so I don't know how it works.
That's what I usually do (It's a lot of work, but it's simple and easy to backtrack errors)... there are many others way to do that we can discuss here, but this is a good start point.
In the CREATE, add this snipet of code:
{
counter = 0
}
in the STEP event, add this code: (Bullet should be the boss bullet object)
{
counter += 1
if counter = 10 then
{
shot=instance_create(x,y,bullet)
shot.direction = 270
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 300
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 240
shot.speed = 10
}
if counter = 50 then
{
shot=instance_create(x,y,bullet)
shot.direction = 200
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 230
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 260
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 290
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 310
shot.speed = 10
shot=instance_create(x,y,bullet)
shot.direction = 340
shot.speed = 10
}
if counter = 80 then
counter = 0
I hope you can see the logic behind this. Play around with it. (Try change directions, speed, add more stuff of your own)
I usually make scripts for certain bullet patterns. Unfortunately, right now I don't have access at any of my gamemaker stuff (I just installed Linux, and I am having some headache to make it access the Windows partition) .. As soon as I sort this out, I'll post some of my bullet scripts.
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
i can share some of my scripts too. need to get them from another computer though. perhaps we can get our own little bulletML going
you could define the position as x+15,y for instance if you want it to be offset by 15pixels to the right.
instance_create(x-20,y+5,bullet); if you want it to be 20 pix left and 5 down
oh, and check your sprite to see that it is centered.
you could define the position as x+15,y for instance if you want it to be offset by 15pixels to the right.
instance_create(x-20,y+5,bullet); if you want it to be 20 pix left and 5 down
oh, and check your sprite to see that it is centered.
Another way to control a boss is via the timeline. This actually makes it a bit easier to do what you want to do, as you don't have to keep checking a step variable in the boss. Timelines basically let you create a series of events that happen at specific points...So at step 1 of the timeline, you could have the boss shoot one pattern, and at step 30, shoot another.
It looks like everything else you need to know is already covered, however.
It looks like everything else you need to know is already covered, however.
YOU ARE APPROACHING THE TARGET OF ATTACK! THE MISSION STARTS NOW! ARE YOU READY?!
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
Thanks very much. This will help a lot.mrMagenta wrote:i can share some of my scripts too. need to get them from another computer though. perhaps we can get our own little bulletML going
you could define the position as x+15,y for instance if you want it to be offset by 15pixels to the right.
instance_create(x-20,y+5,bullet)
When my boss dies, I have a little animated explosion. I placed three of them at different locations and they all go off at once. How can I set it up so that the explosions happen at slightly different points? I know this is probably a timeline thing, but I get really weird errors happening when I try to set it up. Can you explain how to do this? Hopefully from a little example I can understand how they work.Another way to control a boss is via the timeline. This actually makes it a bit easier to do what you want to do, as you don't have to keep checking a step variable in the boss. Timelines basically let you create a series of events that happen at specific points...So at step 1 of the timeline, you could have the boss shoot one pattern, and at step 30, shoot another.
Also: when using code like Shatterhand showed to fire bullets, how can I fire a bullet at the player?
Is there a way to fire an aimed "pattern"? Meaning a formation of bullets where the leading bullet aims the pattern at the player's current position.
I know I'm just nothing but questions here but I'm learning a lot. I really appreciate all the help from everyone.
Aiming at the player is easy. All you need is the point_direction function. When entering the direction of a bullet you're creating...Example
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
This basically points the bullet in a direction where X and Y of the enemy are the starting point, and the Player's X and Y are the endpoint. If you want to fire a spead in this fashion, add or subtract degrees after the point_direction function. For example, how to make a three way spread aimed at players:
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)+10
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)-10
Now, when you're placing bullets at a location not equal to the center of an enemy (IE, if you want bullets to fire from their sides) things work a bit differently.
For example, if you use the point_direction function the way I showed it above, but a bullet is fired from the enemy's X location +20? It still has the bullet move in the direction determinefd by checking the location of the enemy's center and the player. If you wanted a bullet fired from a point that is not the center of the enemy, but still wanted it aimed at the player, you need to take the offset into mind, like this:
bullet=instance_create(x+20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x+20,y-5,objPlayer.x,objPlayer.y)
This would cause the bullet to be created 20 pixels to the right and 5 above the boss' center (Assuming the boss sprite's origin is their center, which I think it should be, personally) and then aim at the player. However, this doesn't mean you can't place bullets at an offset, and then not use the offset in the bullet.direction statement. For example, you could have bullets fired from offsets, but have their direction based on the player's location from the boss' center. Why would you want to do this? Well, if the boss fires bullets from two offsets like x-20 and x+20 rapidly, you could use point_direction to have it fire them in a 'cage' manner.
If you're having trouble understanding what i'm saying, try something like this, and you'll see what I mean:
bullet=instance_create(x+20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
bullet=instance_create(x-20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
As for why you get errors making the boss explode, I don't know. I'd need to see what you're doing to really have an idea of the problem.
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
This basically points the bullet in a direction where X and Y of the enemy are the starting point, and the Player's X and Y are the endpoint. If you want to fire a spead in this fashion, add or subtract degrees after the point_direction function. For example, how to make a three way spread aimed at players:
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)+10
bullet=instance_create(x,y,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)-10
Now, when you're placing bullets at a location not equal to the center of an enemy (IE, if you want bullets to fire from their sides) things work a bit differently.
For example, if you use the point_direction function the way I showed it above, but a bullet is fired from the enemy's X location +20? It still has the bullet move in the direction determinefd by checking the location of the enemy's center and the player. If you wanted a bullet fired from a point that is not the center of the enemy, but still wanted it aimed at the player, you need to take the offset into mind, like this:
bullet=instance_create(x+20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x+20,y-5,objPlayer.x,objPlayer.y)
This would cause the bullet to be created 20 pixels to the right and 5 above the boss' center (Assuming the boss sprite's origin is their center, which I think it should be, personally) and then aim at the player. However, this doesn't mean you can't place bullets at an offset, and then not use the offset in the bullet.direction statement. For example, you could have bullets fired from offsets, but have their direction based on the player's location from the boss' center. Why would you want to do this? Well, if the boss fires bullets from two offsets like x-20 and x+20 rapidly, you could use point_direction to have it fire them in a 'cage' manner.
If you're having trouble understanding what i'm saying, try something like this, and you'll see what I mean:
bullet=instance_create(x+20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
bullet=instance_create(x-20,y-5,objBullet)
bullet.speed=5
bullet.direction=point_direction(x,y,objPlayer.x,objPlayer.y)
As for why you get errors making the boss explode, I don't know. I'd need to see what you're doing to really have an idea of the problem.
YOU ARE APPROACHING THE TARGET OF ATTACK! THE MISSION STARTS NOW! ARE YOU READY?!
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
Great info.
If I'm flying inside of the red triangle area (approx.), your 3-way spread aims at me and works great. Outside that are it no longer aims at me- it trys, but becomes increasingly off as I move out and up the screen. Is there a way to change this?
edit- SOLVED! Thanks to Charleh over on th GM forums. Since I had a view moving over a room at a certain speed the aimed bullets were affected. He made this code which solves the problem:
Don't quite understand all of what he did there, but hey. Now the fun begins...
If I'm flying inside of the red triangle area (approx.), your 3-way spread aims at me and works great. Outside that are it no longer aims at me- it trys, but becomes increasingly off as I move out and up the screen. Is there a way to change this?
edit- SOLVED! Thanks to Charleh over on th GM forums. Since I had a view moving over a room at a certain speed the aimed bullets were affected. He made this code which solves the problem:
Code: Select all
{
counter += 1
if counter = 20 then
{
theplane = instance_nearest(x,y, obj_myplane);
bullet = instance_create(x,y,obj_newenemybullet);
bullet.hspeed = lengthdir_x(5, point_direction(x,y,theplane.x,theplane.y));
bullet.vspeed = lengthdir_y(5, point_direction(x,y,theplane.x,theplane.y)) - 2;
bullet=instance_create(x,y,obj_newenemybullet);
bullet.hspeed = lengthdir_x(5, point_direction(x,y,theplane.x,theplane.y)+10);
bullet.vspeed = lengthdir_y(5, point_direction(x,y,theplane.x,theplane.y)+10) - 2;
bullet=instance_create(x,y,obj_newenemybullet);
bullet.hspeed = lengthdir_x(5, point_direction(x,y,theplane.x,theplane.y)-10);
bullet.vspeed = lengthdir_y(5, point_direction(x,y,theplane.x,theplane.y)-10) - 2;
}
if counter = 40 then
counter = 0
Last edited by cigsthecat on Wed Oct 19, 2005 9:33 pm, edited 2 times in total.
-
captain ahar
- Posts: 3182
- Joined: Wed Jan 26, 2005 10:03 pm
- Location: #50 Bitch!
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
-
- Posts: 8
- Joined: Tue Nov 15, 2005 11:20 am
- Location: Pite, Sweden
- Contact:
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
-
Shatterhand
- Posts: 4044
- Joined: Wed Jan 26, 2005 3:01 am
- Location: Rio de Janeiro - Brazil
- Contact:
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA