Code Doodles!

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Zilarrezko
Party member
Posts: 345
Joined: Mon Dec 10, 2012 5:50 am
Location: Oregon

Re: Code Doodles!

Post by Zilarrezko »

davisdude wrote:I see you watch Coding Math.
Great videos. Very informative.
Yeah, Love him. Pretty much what I wake up every morning hoping for. Not very many prosaic programming concepts and "follow along" videos like his.
HugoBDesigner wrote:Do you mean me? Because I never heard of this channel before :/

EDIT: It's a quite interesting channel, so I think I'll check it more often :)
He was talking about my code doodle before your last one there. It was based off his latest video. I try to apply his videos in an application to something more than what he applied it for, like taking it a bit further. I hope you watch more of it, cause I think he deserves the views.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: Code Doodles!

Post by HugoBDesigner »

Well, in case anyone's interested, I updated my "Lights Out" clone. I fixed some stuff there, nothing new...
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: Code Doodles!

Post by veethree »

So after a pretty long hiatus from programming i've returned and made a useless thing that looks kinda neat.
Image

Then i made another useless thing that looks kinda neat just for good measure. This one is contained in main.lua so i'll just post the code.

Code: Select all

local w, h, f = love.window.getMode()
love.window.setMode(800, 800, f)

screen = {
		width = love.graphics.getWidth(),
		height = love.graphics.getHeight()
	}

love.graphics.setLineWidth(1)
love.graphics.setBackgroundColor(0, 0, 0)

local obj = {}
local count = 128
local orbit_radius = screen.width / 2 / 2
local radius = screen.width / 2 / 2

for i=1, count do
	local a = ((math.pi * 2) / count) * i
	local hue = (255 / count) * i
	local o = {
		x = 0,
		y = 0,
		angle = a,
		rad = radius,
		radius = radius,
		orad = orbit_radius,
		orbit_rad = orbit_radius,
		orbit_speed = 0.5,
		orbit_x = screen.width / 2,
		orbit_y = screen.height / 2,
		color = {
			h = hue,
			s = 255,
			l = 126,
			a = 8
		},
		t = math.pi / 2
	}

	obj[#obj + 1] = o
end

function love.update(dt)
	for i,v in ipairs(obj) do
		v.angle = v.angle + v.orbit_speed * dt
		v.t = v.t + (dt / 2)
		--v.radius = math.abs(math.sin(v.t)) * v.rad
		v.orbit_rad = math.abs(math.sin(v.t)) * v.orad
		v.x = math.cos(v.angle) * v.orbit_rad + v.orbit_x
		v.y = math.sin(v.angle) * v.orbit_rad + v.orbit_y
	end
end

function love.draw()
	love.graphics.setBlendMode("additive")
	for i,v in ipairs(obj) do
		love.graphics.setColor(hsl(v.color.h, v.color.s, v.color.l, v.color.a))
		--love.graphics.circle("fill", v.x, v.y, v.radius)
		local a = v.color.a * 4
		if a > 255 then a = 255 end
		love.graphics.setColor(hsl(v.color.h, v.color.s, v.color.l, a))
		love.graphics.circle("line", v.x, v.y, v.radius)
	end
end

function love.keypressed(key)
	if key == "escape" then love.event.push("quit") end
end

function love.mousepressed(x, y, key)

end

function hsl(h, s, l, a)
    if s<=0 then return l,l,l,a end
    h, s, l = h/256*6, s/255, l/255
    local c = (1-math.abs(2*l-1))*s
    local x = (1-math.abs(h%2-1))*c
    local m,r,g,b = (l-.5*c), 0,0,0
    if h < 1     then r,g,b = c,x,0
    elseif h < 2 then r,g,b = x,c,0
    elseif h < 3 then r,g,b = 0,c,x
    elseif h < 4 then r,g,b = 0,x,c
    elseif h < 5 then r,g,b = x,0,c
    else              r,g,b = c,0,x
    end return (r+m)*255,(g+m)*255,(b+m)*255,a
end
Attachments
thing.love
(1.5 KiB) Downloaded 239 times
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Code Doodles!

Post by undef »

It's pretty, I like it :)
twitter | steam | indieDB

Check out quadrant on Steam!
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Code Doodles!

Post by Germanunkol »

That's a very pretty thing you made, veethree!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
BOT-Brad
Citizen
Posts: 87
Joined: Tue Dec 02, 2014 2:17 pm
Location: England

Re: Code Doodles!

Post by BOT-Brad »

I made a fun little bezier/quadratic/cubic/... curve creator and thought I'd share it here. The code is a little messy (not optimized at all, but can run fine with even 300+ static points on my crappy laptop), but there are sporadic comments. I hope someone likes it :)

Image

Instructions
Left-Click to add new points
Right-click to remove points
'SPACE' to start and stop the running of the curve creator.
Mousewheel Up and Down to increase/decrease the time the curve is generated in (Defaults to 1 second).
'v' to hide/show the construction lines and points
'p' to pause the construction (when running only).

pretty much none of the controls work when the curve is being generated. You will need to stop the program with 'SPACE' and then make any changes

Hope you like it! I'd love to hear any feedback!
Attachments
curve-creator.love
For LOVE 0.9.x
(1.38 KiB) Downloaded 200 times
Follow me on GitHub! | Send me a friend request on PSN!
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Code Doodles!

Post by Germanunkol »

I've been learning about mass-spring systems and how to numerically solve them. I decided to try it out...

Try playing with the parameters (keys: q, a, w, s, e, d)!

Image
MassSpringSystem.love
(33.67 KiB) Downloaded 220 times
P.S. This can easily be extended for more complex objects, but I'm lazy at the moment, and should get back to studying...

If anyone finds the time, feel free to expand it...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Code Doodles!

Post by micha »

That is much fun. I am wondering: What constraint hinders the whole box from rotating?
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: Code Doodles!

Post by Germanunkol »

Hm. No constant, just the fact that I implemented it wrong :P

Jokes aside - the example we had in the lecture was only the linear relation between two mass points - I extended it to be 2D, but the two dimensions are currently solved independent of each other. I guess there is a mistake there somewhere.

I'll fiddle around with it some more and if I can't find it, then ask the person giving the lecture.

Thanks for the hint! I hadn't even thought about the fact that it should be rotating.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: Code Doodles!

Post by HugoBDesigner »

I was trying a simple image-to-ascii converter. It didn't look so great, but it works, so if anyone wants to use it/fix it/improve it, feel free (credits appreciated but not required).

Image
(disclaimer: I have no rights over this image. I just chose a random 400x400, black-and-white picture on Google)

(Keys: "tab"/"d"/"right" to switch forwards, "shift+tab"/"a"/"left" to switch backwards)
Attachments
Ascii thing.love
Not the most optimal way of doing this sort of thing...
(129.54 KiB) Downloaded 198 times
@HugoBDesigner - Twitter
HugoBDesigner - Blog
Post Reply

Who is online

Users browsing this forum: sbr2729 and 64 guests