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 .
BenVlad
Prole
Posts: 1 Joined: Sun Oct 30, 2016 7:10 am
Post
by BenVlad » Tue Nov 01, 2016 8:20 am
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 (85.54 KiB) Viewed 2797 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?
ivan
Party member
Posts: 1915 Joined: Fri Mar 07, 2008 1:39 pm
Contact:
Post
by ivan » Tue Nov 01, 2016 9:31 am
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
Users browsing this forum: Bing [Bot] , Google [Bot] , Semrush [Bot] and 1 guest