C
C#6mo ago
Erek Hai

More like a mathematical problem than code I guess

So for my school project I’m creating a plane shooter game in Windows Forms .Net Framework. Name is called “Battle of Britain” In the game you take sorties against na*i flight formations. I wanted to make it more like a career so in career windows you list for the mission, and after a while if enemy formation is dedected you sortie. When you sortie game chooses random enemy formations composed of max 10 planes. What I want to simulate is approach angles. Plane will approach from random angle and then switch to another angle. If you’re approaching from right planes will go from left to right, if you’re approaching from right, planes will go from right to left, if you’re approaching from back planes will go from top to bottom etc. You’re approaching the same formation if you down one plane he is hidden and moved to another place. Since some aspects of the formations are random ( spaceing and location on window) I can’t find a solution to mirror the formation in a way that it will be the same in comparison to other enemy planes but you’re just approaching from another side so it’s sideways. Any Ideas ?
6 Replies
Erek Hai
Erek Hai6mo ago
this is the way formations are set simplification of what im trying to do (rotate it 90* or 180*or 270 )
VLADLEN
VLADLEN6mo ago
u can just rotate 2 vectors from which ur ship is constructed https://stackoverflow.com/questions/22818531/how-to-rotate-2d-vector
Stack Overflow
How to rotate 2d vector?
I have this: static double[] RotateVector2d(double x, double y, double degrees) { double[] result = new double[2]; result[0] = x * Math.Cos(degrees) - y * Math.Sin(degrees); result[1] ...
VLADLEN
VLADLEN6mo ago
i guess there is should be a build in function in some lib
VLADLEN
VLADLEN6mo ago
thats it i guess https://learn.microsoft.com/en-us/dotnet/api/system.numerics.vector3.transform?view=net-8.0, u can just use third coord as 0 (x,y, 0) coz u are on a plane and create matrix for rotation
VLADLEN
VLADLEN6mo ago
90* rotation matrix should look like this ( 0 1 ) (-1 0 )
Erek Hai
Erek Hai6mo ago
Thanks !