Sorry for posting so much...
BlitzPlus Forums/BlitzPlus Beginners Area/Sorry for posting so much...
| ||
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? |
| ||
Try something like bullet\x=ship\x+10.0*dx bullet\y=ship\y+10.0*dy |
| ||
Will do. |
| ||
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. |
| ||
This at least works a little better: bullet\x# = ship\x# + (bullet\dx# + 1) * 30 bullet\y# = ship\y# + (bullet\dy# + 1) * 30 |
| ||
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. |
| ||
I used something like this in my last programif 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 |
| ||
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. |