Satellite in 2D Shooter

BlitzPlus Forums/BlitzPlus Programming/Satellite in 2D Shooter

maverick69(Posted 2003) [#1]
Hi!

Im currently coding a 2D Space Shooter. Now I have added a satellite flying around the player ship. The code is something like that:

Satellite\Pos=Satellite\Pos+1
If Satellite\Pos>360 Then Satellite\Pos=Satellite\Pos-360
If Satellite\Pos<0 Then Satellite\Pos=Satellite\Pos+360
		
Satellite\X = Sin(Satellite\Pos)*50
Satellite\Y = Cos(Satellite\Pos)*40
		
Satellite\Frame = (360-Satellite\Pos)*8 / 360
If Satellite\Frame>7 Then Satellite\Frame=Satellite\Frame-8

DrawImage SPR_Satelite,Player\X-Satellite\X,Player\Y-Satellite\Y,Satellite\Frame


Of course, the satellite should fire some shoots in the correct direction and i don't know how to calculate the Shoot\DX and Shoot\DY Values. I move every shoot like this:

Shoot\X=Shoot\X+Shoot\DX
Shoot\Y=Shoot\Y+Shoot\DY

I hope you know what I mean.


Ross C(Posted 2003) [#2]
What direction is the correct direction? I'm not too sure what you mean. I suppose you've got a type collection for bullets tho. Can you give anymore of an explanation?

If you want the bullets to go in a particular direction, use sin and cos again.

bullet_angle=50
bullet_x=bullet_x+(cos(bullet_angle)*bullet_speed)
bullet_y=bullet_y+(sin(bullet_angle)*nullet_speed)


Is that what you mean?


maverick69(Posted 2003) [#3]
Yes, thank you.

Everything works fine now.


maverick69(Posted 2003) [#4]
Yes, thank you.

Everything works fine now.