Sorry for posting so much...

BlitzPlus Forums/BlitzPlus Beginners Area/Sorry for posting so much...

Buggy(Posted 2006) [#1]
Just wondering, is there any way to - in a space game - make a bullet's starting point be a certain starting point on a ship without giving it a new point for each possible starting frame?




That's my code so far. The ship has a special gun where I want the bullet to be launched from (and the ship is offcenter in the image to make it look better - but never mind that) so just "bullet\x# = ship\x#" wouldn't work.

This might be confusing, so here's the sum-up:

How can I get a ship to launch a bullet from a specific part of the ship, no matter which way the ship is facing?


Who was John Galt?(Posted 2006) [#2]
Try something like
bullet\x=ship\x+10.0*dx
bullet\y=ship\y+10.0*dy


Buggy(Posted 2006) [#3]
Will do.


Buggy(Posted 2006) [#4]
It was worth a try, but it didn't work. If - for example - the ship is facing up, then it's:

bullet\x# = ship\x# + 0
bullet\y# = ship\y# + -10

See? It's tricky!

Thanks anyway, Nomen.


Buggy(Posted 2006) [#5]
This at least works a little better:

bullet\x# = ship\x# + (bullet\dx# + 1) * 30
bullet\y# = ship\y# + (bullet\dy# + 1) * 30


Who was John Galt?(Posted 2006) [#6]
I was assuming bullet dx and dy where the distnces you need to offset your bullets by in x and y position in each frame to make them fly the way the ship is facing. That being the case, my code would work. I have to guess because you give no info on ship\frame, ship\framehunk etc.

You really need to start posting executable code if you want useful help.

Make sure your ship and bullet images use midhandles for simplicity.


mudcat(Posted 2006) [#7]
I used something like this in my last program
if fired=1
  bulletx=shipx+cos(ship_angle)*half_the_length_of_ship
  bullety=shipy+sin(ship_angle)*half_the_length_of_ship
endif

This would get it out to the nose of my ship,then I started my accelerate and stuff.of course my ship was midhandled.

Later,
mudcat


Buggy(Posted 2006) [#8]
Thanks mudcat, and sorry Nomen. I'm kind of new at this (if you couldn't tell) and I naively assumed everyone uses dx and dy for the same thing.