C
C#14mo ago
Ryerson

❔ help please

I’m try to make a 2d racing game in visual studio 2022 with C# but I’m have trouble figuring out how to rotate the car in the corners then have it go straight in the direction the front in facing.
12 Replies
mtreit
mtreit14mo ago
Might ask in #game-dev
Anchy
Anchy14mo ago
you should share what you have tried
Ryerson
Ryerson14mo ago
I would but I’m not at school the rest of the week and forgot to get it on GitHub
Anchy
Anchy14mo ago
lmfao
mtreit
mtreit14mo ago
So...you need to ask specific questions, preferably with c# code examples, to get help. Nobody here can magically figure out your issue based on the extremely general and non-specific way you framed the problem. Like...I know C#...but I didn't see anything remotely approaching a C# question in your original problem statement. Not trying to be harsh.
Ryerson
Ryerson14mo ago
The first question would be how would you rotate a rectangle from the middle it
mtreit
mtreit14mo ago
That doesn't seem like a C# question to be perfectly honest. Maybe a general graphics programming question? Like I have no idea what "middle" refers to I personally have no experience with graphics programming I know C# language features. But you seem to be asking something else entirely
Ryerson
Ryerson14mo ago
If you have a 10 by 10 square how would you rotate it 30 degrees from the middle point
mtreit
mtreit14mo ago
That seems like a general math : graphics question not related to C#. As suggested earlier, someone in #game-dev might know. Or I could try to summon @std::weak_ptr<Akari> or @MD5 who probably understand this kind of thing
Denis
Denis14mo ago
It also depends on what platform you are developing your game. Is it unity? Or are you trying to use WPF for this?
clxs
clxs14mo ago
Translate so the centre point of the square is at 0,0, rotate, translate back Say your square is 10x10 and is at 6,6 square.Transform = Matrix.Translate2D(-(3 + 5), - (3 + 5)) * Matrix.Rotate2D(30_deg) * Matrix.Translate2D((3 + 5), (3 + 5)) Exact methods you need to use depend what you're doing it in The forward vector for this car, the direction you need to move in is then forwardVector = baseForwardVector * square.Transform Where baseForwardVector is whatever direction is "forwards" for a non translated square
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.