what's wrond with radians?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
BenVlad
Prole
Posts: 1
Joined: Sun Oct 30, 2016 7:10 am

what's wrond with radians?

Post by BenVlad »

so, i decided to create a simple space shooter, where you drive you space ship. In development process, i had a problem with this engine's strange radian system:
er1.png
er1.png (85.54 KiB) Viewed 2799 times
When i install radian manually, all is good:

Code: Select all

if love.keyboard.isDown('r') then
		player.x = height/2
		player.y = width/2
		player.XYspeed.X = 0
		player.XYspeed.Y = 0
		player.deg = math.pi
	end
So, what i should do in this case, gues?
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: what's wrond with radians?

Post by ivan »

Hello, can you post some more code so we can take a look?
You can convert between radians and degrees using:

Code: Select all

degrees = math.deg(math.pi)
radians = math.rad(degrees)
Once you know the heading of your ship you can use:

Code: Select all

velocityX = math.cos(headingInRadians)*velocity
velocityY = math.sin(headingInRadians)*velocity
Also, a while ago I wrote a short tutorial on vector math that you might find useful:
http://2dengine.com/doc/gs_vector.html
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests