Harmonic Motion
Harmonic Motion
Here's a .love file my teacher asked me to code, it has a clock, a line that spins and a graph.
Actually I made this post only to ask you: is there a way to make the graph more 'lightly'? It's waaaaaaaaaay too heavy drawin' it like this...
Actually I made this post only to ask you: is there a way to make the graph more 'lightly'? It's waaaaaaaaaay too heavy drawin' it like this...
- Attachments
-
- Harmonic-0.7.2.love
- (14.23 KiB) Downloaded 215 times
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Harmonic Motion
It's not working for some reason?
- Jasoco
- Inner party member
- Posts: 3725
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Harmonic Motion
Works for me. I just don't understand the question. "Lightly"? You mean line thickness? Or color? Because that's all I can gather.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Harmonic Motion
If you press "alt", apparently it starts showing a graph. It took me a while to find out.
Help us help you: attach a .love.
Re: Harmonic Motion
I don't clearly understand what you mean, but this is what I did:Nixola wrote:is there a way to make the graph more 'lightly'? It's waaaaaaaaaay too heavy drawin' it like this...
The way you draw it:
Code: Select all
for i, v in ipairs(points) do
love.graphics.circle('fill', v.y, (v.x/2)+332, 1, 4)
end
Code: Select all
love.graphics.setLineWidth(2)
.. drawing clock and lines
love.graphics.setLineWidth(1)
for i, v in ipairs(points) do
if i > 1 then
love.graphics.line(v.y, (v.x/2)+332, points[i-1].y, (points[i-1].x/2)+332)
end
end
On the left it's how you draw it, by drawing circle every point,
And on the right it's how I draw it, by drawing line through every current and previous point. Looks better, what you think?
Also I think it would be better to shorten this
Code: Select all
if k == '1' or k == '2' or k == '3' or k == '4' or k == '5' or k == '6' or k == '7' or k == '8' or k == '9' then
speed = tonumber(k)
end
Code: Select all
if type(tonumber(k)) == "number" then
speed = k
end
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Harmonic Motion
That would be:
Also, this includes 0, which might not be what the OP wants.
Alternative suggestion:
Code: Select all
if type(tonumber(k)) == "number" then
speed = tonumber(k)
end
Alternative suggestion:
Code: Select all
local nk = tonumber(k)
if type(nk) == "number" and nk > 0 then
speed = nk
end
Help us help you: attach a .love.
Re: Harmonic Motion
With 'more lightly' I meant a faster way, 'cause on my netbook (and on my school pcs) showing the graph kills the framerate; that's why I hid the graph by default
(with Ctrl you can hide the variables, and with AltGR you toggle both)
@RichApple and Robin: thanks, I forgot it ^^' I think (and hope) that's faster than 9 ifs
@RichApple only: I decided not to use lines 'cause my pc can't show 1px-wide horizontal or vertical lines, and I forgot that it can show 1px-wide non-horizontal nor vertical lines...
(with Ctrl you can hide the variables, and with AltGR you toggle both)
@RichApple and Robin: thanks, I forgot it ^^' I think (and hope) that's faster than 9 ifs
@RichApple only: I decided not to use lines 'cause my pc can't show 1px-wide horizontal or vertical lines, and I forgot that it can show 1px-wide non-horizontal nor vertical lines...
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Harmonic Motion
Code: Select all
local nk = tonumber(k) or k
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Harmonic Motion
As I recall, can't love.graphics.line be given any number of coordinates? (Greater than or equal two, of course.) You could change up how the points table works by a little and then pass the whole thing into a single love.graphics.line call.
Here, I've added an example to the wiki that should help you understand. What you'd need to do specifically is replace this: with this:
And then replace this:
with this:
That should render faster. I'm having trouble telling a difference, but then again, I have a full desktop at my disposal- a netbook might see a dramatic improvement.
Here, I've added an example to the wiki that should help you understand. What you'd need to do specifically is replace this:
Code: Select all
table.insert(points, 1, {x = x, y = rtimer*2})
Code: Select all
points[#points + 1] = rtimer*2
points[#points + 1] = (x / 2) + 332
Code: Select all
for i, v in ipairs(points) do
love.graphics.circle('fill', v.y, (v.x/2)+332, 1, 4)
end
Code: Select all
love.graphics.line(points)
Kurosuke needs beta testers
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Harmonic Motion
You meanbartbes wrote:Code: Select all
local nk = tonumber(k) or k
Code: Select all
speed = tonumber(k) or speed
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 41 guests