Search found 393 matches

by darkfrei
Mon Sep 20, 2021 2:20 pm
Forum: Support and Development
Topic: [Fixed] Simple sine/radians problem - I think
Replies: 5
Views: 92

Re: [Fixed] Simple sine/radians problem - I think

pgimeno wrote: Mon Sep 20, 2021 1:31 pm That's more like engine power anyway, not speed, since it applies to the force. Naming the variables appropriately can protect you from some bugs.
It can be something like specific impulse, that is like-a-speed and has unit as m/s (or just in seconds in other notation).
by darkfrei
Sun Sep 19, 2021 4:05 pm
Forum: Games and Creations
Topic: Railway Track
Replies: 5
Views: 186

Re: Railway Track

You can always add another canvas for order and instead of painting you can erase pixels too. A quick hack in of my approach: main.lua.zip Nice! Didn't know that you can erase by writing with the color {0,0,0,0} with color replacing. -- new canvas tmp = love.graphics.newCanvas() love.graphics.setCa...
by darkfrei
Sun Sep 19, 2021 10:19 am
Forum: Games and Creations
Topic: Railway Track
Replies: 5
Views: 186

Re: Railway Track

Is it necessary to get this offset? You could just draw two lines of different width on top of each other i would say. For the ties it is also possible to draw them short and thick, may be faster. This would have been a use case for stipple lines, but that setting was removed. But rails must be abo...
by darkfrei
Sat Sep 18, 2021 8:59 pm
Forum: Games and Creations
Topic: Railway Track
Replies: 5
Views: 186

Railway Track

Hi all! There is my try to make railway track, where it's path is defined as love.graphics's line. Used functions: Get offset polyline - the right and left rails are just the same line as defined, but with offset :) Get Points Along Line - every tie must be on the same distance, but the defined poly...
by darkfrei
Sat Sep 18, 2021 11:25 am
Forum: Support and Development
Topic: [SOLVED] Math: Shortest distance from point to line (EDITED)
Replies: 18
Views: 3187

Re: [SOLVED] Math: Shortest distance from point to line (EDITED)

So, if the drawn line has different colors along the it's length, we can set to every point in window the color of the nearest sector of this line: The gradient function: function get_red_blue_gradient_color (t) -- t is between 0 as red to 1 as blue local r = 2-4*t local g = t < 1/2 and 4*t or 4-4*t...
by darkfrei
Fri Sep 17, 2021 11:16 pm
Forum: Support and Development
Topic: [SOLVED] Math: Shortest distance from point to line (EDITED)
Replies: 18
Views: 3187

Re: [SOLVED] Math: Shortest distance from point to line (EDITED)

I've googled it a lot of times, my solution: function distPointToLine(px,py,x1,y1,x2,y2) -- point, start and end of the segment local dx,dy = x2-x1,y2-y1 local length = math.sqrt(dx*dx+dy*dy) dx,dy = dx/length,dy/length local p = dx*(px-x1)+dy*(py-y1) if p < 0 then dx,dy = px-x1,py-y1 return math.sq...
by darkfrei
Fri Sep 17, 2021 3:38 pm
Forum: Support and Development
Topic: wait() doesn't work
Replies: 5
Views: 179

Re: wait() doesn't work

guys how to use wait() :oops: function love.update (dt) if waiting then waiting = waiting - dt if waiting < 0 then waiting = nil end else -- your update code -- set "waiting = 3" here to wait 3 seconds to next updating: if need_wait_3_seconds then waiting = 3 end end end Or set 3 seconds ...
by darkfrei
Sun Sep 12, 2021 10:02 pm
Forum: Support and Development
Topic: Help with jumping
Replies: 8
Views: 627

Re: Help with jumping

Code: Select all

if state == flying then -- free falling
  vx=vx -- no changing :)
  vy=vy+dt*g
else
-- input controls code here
end
x=x+dt*vx
y=y+dt*vy
--collision code here, check if not more flying 
by darkfrei
Sun Sep 12, 2021 9:54 pm
Forum: Support and Development
Topic: Optimal way for wasd movement, no diagonals?
Replies: 3
Views: 568

Re: Optimal way for wasd movement, no diagonals?

Normally it's enough to make something like:
if up then move_up()
elseif down then move_down()
elseif left then move_left()
elseif right then move_right()
else move_as_before() end
by darkfrei
Sat Sep 11, 2021 12:11 pm
Forum: Support and Development
Topic: Help drawing a Polygon with RayCasting
Replies: 6
Views: 1370

Re: Help drawing a Polygon with RayCasting

For the full hd you are need 2x(1920+1080) rays, not more. Just targeted to every pixel on the every screen side.