It looks like you're new here. If you want to get involved, click one of these buttons!
I was experimenting with repeating gestures (inspired by Blek) and I was able to get repeating gestures pretty easily. However, when I went to get them to bounce off of walls I ran into a problem. I know I am missing something obvious, and was wondering if you guys have any ideas. Here's the code:
-- Gesture
-- Use this function to perform your initial setup
function setup()
points = {}
locked = false
parameter.watch("#points")
parameter.watch("locked")
parameter.watch("1/DeltaTime")
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(255, 255, 255, 255)
-- This sets the line thickness
strokeWidth(5) stroke(0)
if locked then
local c = points[#points].changed
local d = points[#points].dir
if c then d = d * -1 end
local change = (points[2].p - points[1].p)
local newPoint = points[#points].p + change * d
if newPoint.x >= WIDTH or newPoint.x <= 0 or newPoint.y >= HEIGHT or newPoint.y <= 0 then
newPoint = points[#points].p - change
d = d * -1
c = true
end
table.insert(points, { p = newPoint, dir = d, changed = c })
table.remove(points, 1)
end
for i = 1, #points - 1 do
local p = points[i].p
local p2 = points[i + 1].p
line(p.x, p.y, p2.x, p2.y)
end
end
function touched(t)
local tPoint = vec2(t.x, t.y)
if not locked then
table.insert(points, { p = tPoint, dir = 1 })
end
if t.state == ENDED then
locked = true
end
end
Comments
hello @jakattack. I am sorry i didnt try to find the bug in your code, i just rewrote it in 'my style' to do what i think you want to do. It is often easier to rewrite something rather that to understand someone else's thinking. Here it is:
[edit] i've removed a couple unnecessary lines. By the way, this little problem and solution you have posted is quite interesting (i mean how you managed to make the line propagate)
@Jmv38, I understand about understanding peoples thinking. Is the effect I was looking for, thank you. I will have to study and see how it is achieved
P.S. What is "propagate"?
I have also been playing around with gestures. See the video below.
(It seems the parameter panel does not show up in the video).
I have implemented multiple gestures with bouncing off walls or screen wraparound. I am currently working on making the 'wriggles' interact with each other and also with physics bodies. As a working title i thought to call it 'Wriggle Room'. A work in progress and lots of fun!
@piinthesky, is fun stuff
Here is with multiple:
very funny. Thanks for sharing.
@JakAttak very hypnotic - I like it!
Here's a slight mod to add a fade to the trails
This is now available on Codea Community Repository!
The WebRepo project allows easy access to the repo and the projects stored.