A problem with bullets and aiming them (Read for info)

A place for people with an interest in developing new shmups.
Post Reply
User avatar
ForteMP3
Posts: 178
Joined: Tue Feb 01, 2005 3:15 pm
Location: Somewhere in the Midwest.

A problem with bullets and aiming them (Read for info)

Post by ForteMP3 »

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.
YOU ARE APPROACHING THE TARGET OF ATTACK! THE MISSION STARTS NOW! ARE YOU READY?!
User avatar
mrMagenta
Posts: 102
Joined: Tue Jul 19, 2005 1:09 pm
Location: Sweden

Post by mrMagenta »

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.
User avatar
mrMagenta
Posts: 102
Joined: Tue Jul 19, 2005 1:09 pm
Location: Sweden

Post by mrMagenta »

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.
zaphod
Posts: 629
Joined: Wed Feb 09, 2005 7:33 am
Contact:

Post by zaphod »

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.
User avatar
landshark
Posts: 2156
Joined: Wed Jan 26, 2005 5:27 am
Location: Chicago 'Burbs

Post by landshark »

This probably depends upon your engine - but you could do all your calculations in screenspace.
Lupin
Posts: 13
Joined: Sun Oct 16, 2005 10:40 am

Re: A problem with bullets and aiming them (Read for info)

Post by Lupin »

You can add the scroll speed (in length) to the y coordinate that they aim for maybe.
User avatar
mice
Posts: 829
Joined: Tue Apr 26, 2005 2:50 pm
Location: Sweden
Contact:

Post by mice »

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.
Lupin
Posts: 13
Joined: Sun Oct 16, 2005 10:40 am

Post by Lupin »

it wasn't far down the page when I posted/last post was like 2 weeks before. ;) Maybe add the scroll speed to the movement of the bullet in the direction that the game scrolls. To be more realistic the opponents would have to aim where the ship is going to be rather than where it is.
User avatar
ptoing
Posts: 1118
Joined: Wed Jan 11, 2006 10:36 pm
Location: Gurmany
Contact:

Post by ptoing »

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.
User avatar
cigsthecat
Posts: 929
Joined: Wed Jan 26, 2005 12:35 am
Location: Burbank, CA

Post by cigsthecat »

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.
I would LOVE to do this, but I don't know how to achieve this in Game Maker. If anyone knows please spill it.
User avatar
Pixel_Outlaw
Posts: 2639
Joined: Sun Mar 26, 2006 3:27 am

Post by Pixel_Outlaw »

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.
Some of the best shmups don't actually end in a vowel.
No, this game is not Space Invaders.
User avatar
SAM
Posts: 1788
Joined: Fri Jun 03, 2005 5:27 am
Location: A tiny nameless island in South China Sea

Post by SAM »

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.
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.
*Meow* I am as serious as a cat could possible be. *Meow*
User avatar
iatneH
Posts: 3202
Joined: Tue Jan 25, 2005 11:09 pm
Location: Vancouver, BC, Canada

Post by iatneH »

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.
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?)
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?
Post Reply