A
A
Afafks1231321321652020-03-04 11:40:53
JavaScript
Afafks123132132165, 2020-03-04 11:40:53

How to make a game like wofenshtein 3D?

I would like to make a game like wolfenshtein 3D on js canvas. But I have a problem. I don't know how to rotate the ray that the player throws. Rotate the very coordinate of the end of the ray. I couldn’t implement it. Yes, I know there are lessons on the Internet. But I would like to learn only this part. Then I myself. Thanks to everyone.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-03-04
@Afafks123132132165

First, the beam has no end, only a beginning. You probably have a cut.

x = cos(fi) * R
y = sin(fi) * R

fi - angle in radians: (degrees divided by 180 and multiplied by Pi)
R - radius.
If your player is not at coordinate zero, then add his coordinates:
x = cos(fi) * R + x_игрока
y = sin(fi) * R + y_игрока

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question