A problem with bullets and aiming them (Read for info)
A problem with bullets and aiming them (Read for info)
Okay folks, today I come with a problem that I'm trying to address, only I'm not sure how to do it. Here's the situation in a nutshell
THE PROBLEM:Bullets and aiming them at upward angles. This is a problem because when enemies shoot, they use a direction that points towards the player. The problem is that the screen is constantly scrolling, and thus, the player is constantly moving (IE, you actually 'move up' instead of just sitting idle on a scrolling background). What happens is this, if the player goes to the side of an enemy, and the enemy shoots, the bullet will fire to the side...And be scrolled down, the player however, stays in the same relative spot onscreen, and thus the bullet harmlessly passes under him.
While I COULD simply have bullets move relative to the scrolling, this would result in a more unnatural movement, because the screen would be scrolling, but the bullet would be moving as if it wasn't scrolling. What I'm trying to come up with is a way for bullets to still have that natural scrolling effect, but also be capable of hitting someone when shot at an angle that isn't aimed down.
THE PROBLEM:Bullets and aiming them at upward angles. This is a problem because when enemies shoot, they use a direction that points towards the player. The problem is that the screen is constantly scrolling, and thus, the player is constantly moving (IE, you actually 'move up' instead of just sitting idle on a scrolling background). What happens is this, if the player goes to the side of an enemy, and the enemy shoots, the bullet will fire to the side...And be scrolled down, the player however, stays in the same relative spot onscreen, and thus the bullet harmlessly passes under him.
While I COULD simply have bullets move relative to the scrolling, this would result in a more unnatural movement, because the screen would be scrolling, but the bullet would be moving as if it wasn't scrolling. What I'm trying to come up with is a way for bullets to still have that natural scrolling effect, but also be capable of hitting someone when shot at an angle that isn't aimed down.
YOU ARE APPROACHING THE TARGET OF ATTACK! THE MISSION STARTS NOW! ARE YOU READY?!
hmm. interesting, bullets aren't usually affected by scrolling, or perhaps i haven't paid attention.. well except if they are some sort of special bullets that fire outwards and then loose momentum to rain downwards. nothing wrong with the idea though, just makes things bit trickier to balance.
if they are affected by scroll they will behave as you described unless they are lot faster than scroll speed, or use some sort of aiming that takes acelleration into the math, but if you compensate like that it would prolly mean that bullets get extra nasty when they're fired normally downwards towards you. you could adjust the aim angle so that when you're paralell to the enemy the aim is set higher.. that's how any intelligent beeing would fire at a moving object but it might be a bit too intelligent to feel fair. i'd try it out and see how it feels.
if they are affected by scroll they will behave as you described unless they are lot faster than scroll speed, or use some sort of aiming that takes acelleration into the math, but if you compensate like that it would prolly mean that bullets get extra nasty when they're fired normally downwards towards you. you could adjust the aim angle so that when you're paralell to the enemy the aim is set higher.. that's how any intelligent beeing would fire at a moving object but it might be a bit too intelligent to feel fair. i'd try it out and see how it feels.
aiming at moving objects.. hum. i haven't tried it before but perhaps something like this:
pick a range for the compensation to start and end say 120-240
that's 120 degrees. the compensation should be highest at 60 (actually 180deg)
you need to have the multiplier at 1.0 at 60 and 0 at 0 and 120.
if(aimDir >=120 && aimDir <= 240)
{
//this is a really lazy could be done much more elegantly
mult = (60-abs(60-(aimDir - 120)))/60;
compMax = 20;
aimDir-= multiplier * compMax;
}
the same should be done for the other side.. i just picked the left side cause the right has the jump from 0 to 360 to take into account.
this isn't very good if it doesn't account for the distance to your ship also
and if the scroll speed isn't constant compMax has to be derived mathematically from it.
anyways.. longer distance = more compensation, so the same approach could be used to
determine a multiplier for distance. but it will be tricky to find the right values.
i'm sure there's some excellent ballistic math for this sort of stuff.
pick a range for the compensation to start and end say 120-240
that's 120 degrees. the compensation should be highest at 60 (actually 180deg)
you need to have the multiplier at 1.0 at 60 and 0 at 0 and 120.
if(aimDir >=120 && aimDir <= 240)
{
//this is a really lazy could be done much more elegantly
mult = (60-abs(60-(aimDir - 120)))/60;
compMax = 20;
aimDir-= multiplier * compMax;
}
the same should be done for the other side.. i just picked the left side cause the right has the jump from 0 to 360 to take into account.
this isn't very good if it doesn't account for the distance to your ship also
and if the scroll speed isn't constant compMax has to be derived mathematically from it.
anyways.. longer distance = more compensation, so the same approach could be used to
determine a multiplier for distance. but it will be tricky to find the right values.
i'm sure there's some excellent ballistic math for this sort of stuff.
Unless the scrollspeed changes, just have the bullets aimed as if the scroll did not exist. There's NO way to tell the difference. but when thte scroll speed changes, you then have to compensate for any bulets on screen at the time.
What DOES need to be compensated for "realism" is the inertia of the firing ship. THIS is what actually makes the difference with realistic versus unrealistic bullets. WHen the ship is moving left, it's bullets aimed right should move lsower on that axis, hile the ones aimed left shoudl moe faster on that axis, and they will miss if the aim is not compensated.
What DOES need to be compensated for "realism" is the inertia of the firing ship. THIS is what actually makes the difference with realistic versus unrealistic bullets. WHen the ship is moving left, it's bullets aimed right should move lsower on that axis, hile the ones aimed left shoudl moe faster on that axis, and they will miss if the aim is not compensated.
Re: A problem with bullets and aiming them (Read for info)
You can add the scroll speed (in length) to the y coordinate that they aim for maybe.
This was a real old topic to resurrect...
Just adding the scroll-speed in length wouldn't quite do it, I'm afraid.
You would need to calculate how much the main ship would move upwards within the time it takes for the bullet to reach that (unknown) particular position, depending on the bullet speed as well.
When running such an algo the result might be that, depending on bullet speed, the bullet will never reach that position. Which causes the machine either to hang (well, if poorly implemented) or the bullet missing the player ship.
So getting that "real" feeling you're after, might now be so good after all. Do it like the rest of the world, have a propertie for each object stating that it should either be "connected" to the scrolling, or "not connected".
The ship and bullets and probably most of the air-based enemies would be disconnected while the ground-based enemies (like tanks an such) would be connected.
My 2c on the subject.
Just adding the scroll-speed in length wouldn't quite do it, I'm afraid.
You would need to calculate how much the main ship would move upwards within the time it takes for the bullet to reach that (unknown) particular position, depending on the bullet speed as well.
When running such an algo the result might be that, depending on bullet speed, the bullet will never reach that position. Which causes the machine either to hang (well, if poorly implemented) or the bullet missing the player ship.
So getting that "real" feeling you're after, might now be so good after all. Do it like the rest of the world, have a propertie for each object stating that it should either be "connected" to the scrolling, or "not connected".
The ship and bullets and probably most of the air-based enemies would be disconnected while the ground-based enemies (like tanks an such) would be connected.
My 2c on the subject.
I think most (if not all) arcade shmups the playarea is not actually moving at all. Just the background underneath. Why one would deviate from this proven procedure is beyond me.
Last edited by ptoing on Fri Apr 21, 2006 11:35 pm, edited 1 time in total.
-
cigsthecat
- Posts: 929
- Joined: Wed Jan 26, 2005 12:35 am
- Location: Burbank, CA
I would LOVE to do this, but I don't know how to achieve this in Game Maker. If anyone knows please spill it.ptoing wrote:I think i most (if not all) arcade shmups the playarea is not actually moving at all. Just the background underneath. Why one would deviate from this proven procedure is beyond me.
-
Pixel_Outlaw
- Posts: 2639
- Joined: Sun Mar 26, 2006 3:27 am
I think you would have to store tile maps in 2d arrays.
They dynamically draw the tiles row by row as they become visable. I think most older arcade shooters did this but it might be difficult tio get the formula right.
This is the best way though it is more memory efficient and leads to easy enemy planning. When you start moving the ship at a constant speed you'll encounter some unwanted results.
They dynamically draw the tiles row by row as they become visable. I think most older arcade shooters did this but it might be difficult tio get the formula right.
This is the best way though it is more memory efficient and leads to easy enemy planning. When you start moving the ship at a constant speed you'll encounter some unwanted results.
Some of the best shmups don't actually end in a vowel.
No, this game is not Space Invaders.
No, this game is not Space Invaders.
-
SAM
- Posts: 1788
- Joined: Fri Jun 03, 2005 5:27 am
- Location: A tiny nameless island in South China Sea
Yes, that's nearly all shmups game do it this ways. The only objects scroll are the terrain object wich the player could run into.ptoing wrote:I think most (if not all) arcade shmups the playarea is not actually moving at all. Just the background underneath. Why one would deviate from this proven procedure is beyond me.
*Meow* I am as serious as a cat could possible be. *Meow*
So what it looks like is that all your fired bullets travel in exactly the same path relative to your ship (like the Donpachi laser? But with bullets?)zaphod wrote:What DOES need to be compensated for "realism" is the inertia of the firing ship. THIS is what actually makes the difference with realistic versus unrealistic bullets. WHen the ship is moving left, it's bullets aimed right should move lsower on that axis, hile the ones aimed left shoudl moe faster on that axis, and they will miss if the aim is not compensated.
I think this would be INCREDIBLY annoying. Can you imagine playing a game like Ikaruga, but not being able to shoot straight up the screen unless your ship was motionless or only moving straight up and down?