首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >夹紧器推力影响

夹紧器推力影响
EN

Stack Overflow用户
提问于 2016-04-18 09:22:54
回答 1查看 145关注 0票数 0

如何:夹紧推力的影响,同时允许其他力是无限的。

火箭可以向旋转的方向推进。只有爆炸才能把它推过最高速度。我在寻找一种理论而不是代码。

任何帮助都将不胜感激。

解决了

编辑:最高速度由推力速度和摩擦力决定.

推力可以叠加在速度上,但当摩擦大于推力速度时,可以达到最高速度。

代码语言:javascript
复制
vx = (vx + fx) *fr -- velocity = (velocity + force) *friction
vy = (vy + fy) *fr

当速度足够高时,附加力将被摩擦力扣除。

fr = .9:很难看到最高速度

fr = .6:很容易看到最高速度

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-19 07:16:57

控件:左、右和推力

推力的最高速度可以通过摩擦来调节。

代码语言:javascript
复制
-- VARIABLES
player = {
    frc = .95, -- friction
    acc = .05, -- acceleration
    max = .5, -- acceleration max
    deg = 0, -- rotation in degree
    rad = 0 -- rotation in radian
    -- rotation is CW and 0 points to the right
}

-- MAIN UPDATE
function love.update()
    control(player)
    applyVelocity(player)
end

-- UPDATE
function control(a)
    if  L then addRotation(a,-5) end
    if  R then addRotation(a, 5) end
    if  U then thrustOn(a) else thrustOff(a) end
end
function applyVelocity(a)
    -- velocity + force
    a.vx = (a.vx + a.fx) *a.fr
    a.vy = (a.vy + a.fy) *a.fr
    -- position + velocity
    a.x = a.x + a.vx
    a.y = a.y + a.vy
end

-- OTHER
function thrustOn(a)
    accelerate(a)
    rotateDist(a)
end
function thrustOff(a)
    a.f = 0 -- integer of force is used to convert to point (x,y) with (rad)
    a.fx = 0
    a.fy = 0
end
function addRotation(a,deg)
    a.deg = a.deg + deg
    a.rad = math.rad(a.deg) -- math.sin/cos functions use radian instead of degree
end
function accelerate(a)
    a.f = a.f + a.acc
    if a.f > a.max then a.f = a.max end
end
function rotateDist(a)
    -- end point of force rotated from player
    a.fx = a.f *math.sin(a.rad)
    a.fy = a.f *math.cos(a.rad)
end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36689979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档