Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mvid={}
- mvrx={}
- mvry={}
- rindex=0
- function updatevars()
- x = tpt.get_property("x", centerpt)
- y = tpt.get_property("y", centerpt)
- end
- function particles()
- updatevars()
- add_particle(x,y)
- if rindex > 0 then
- for tmpid = 1, rindex, 1 do
- add_particle(x - mvrx[tmpid], y - mvry[tmpid])
- tpt.set_property("x", x - mvrx[tmpid], mvid[tmpid])
- tpt.set_property("y", y - mvry[tmpid], mvid[tmpid])
- tpt.set_property("vx", tpt.get_property("vx", centerpt), mvid[tmpid])
- tpt.set_property("vy", tpt.get_property("vy", centerpt), mvid[tmpid])
- end
- end
- end
- function add_particle(CDx, CDy)
- if tpt.get_property("type", CDx, CDy - 1) == 1 then add_particle_sub(CDx, CDy - 1) end
- if tpt.get_property("type", CDx + 1, CDy - 1) == 1 then add_particle_sub(CDx + 1, CDy - 1) end
- if tpt.get_property("type", CDx + 1, CDy) == 1 then add_particle_sub(CDx + 1, CDy) end
- if tpt.get_property("type", CDx + 1, CDy + 1) == 1 then add_particle_sub(CDx + 1, CDy + 1) end
- if tpt.get_property("type", CDx, CDy + 1) == 1 then add_particle_sub(CDx, CDy + 1) end
- if tpt.get_property("type", CDx - 1, CDy + 1) == 1 then add_particle_sub(CDx - 1, CDy + 1) end
- if tpt.get_property("type", CDx - 1, CDy) == 1 then add_particle_sub(CDx - 1, CDy) end
- if tpt.get_property("type", CDx - 1, CDy - 1) == 1 then add_particle_sub(CDx - 1, CDy - 1) end
- tpt.drawpixel(CDx, CDy, 0, 192, 127, 127)
- end
- function add_particle_sub(apx, apy)
- rindex = rindex + 1
- tpt.delete(apx, apy)
- mvid[rindex] = tpt.create(apx, apy, "grav")
- mvrx[rindex] = x - apx
- mvry[rindex] = y - apy
- end
- function reset_moving()
- if rindex > 0 then
- for tmpid = 1, rindex, 1 do
- tpt.delete(tmpid)
- end
- rindex = 0
- end
- tpt.unregister_step(particles)
- tpt.register_mouseevent(click)
- end
- function click(x, y)
- if tpt.get_property("type",x, y) == 1 then
- tpt.delete(x, y)
- -- Setting up
- centerpt = tpt.create(x, y, "grav")
- mvid={}
- mvrx={}
- mvry={}
- rindex=0
- updatevars()
- -- Setup Complete!
- tpt.register_step(particles)
- tpt.unregister_mouseevent(click)
- end
- end
- tpt.register_mouseevent(click)
Add Comment
Please, Sign In to add comment