Created
April 9, 2024 02:12
-
-
Save luizbills/6281d267717031d4806603169f711fa3 to your computer and use it in GitHub Desktop.
move points towards a angle #litecanvas #gamedev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
litecanvas(); | |
const max = 3 | |
const dist = 360 / max | |
function init () { | |
x = CENTERX | |
y = CENTERY | |
a = 0 | |
} | |
function update (dt) { | |
a += 180 * dt | |
if (TAPPED) { | |
x = TAPX | |
y = TAPY | |
} | |
} | |
function draw () { | |
clear(4) | |
circfill( | |
x, | |
y, | |
5, | |
3 | |
) | |
for (let i = 0; i < max; i++) { | |
circfill( | |
100 * cos(deg2rad(a + dist * i)) + x, | |
100 * sin(deg2rad(a + dist * i)) + y, | |
25, | |
3 | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo:
https://litecanvas.js.org?c=eJx1kDFPwzAQhXf%2FijfaDRJpQ1Gl0gFBVlShDmW0bAedZByUuECE%2Bt85xwmiA8vdffa75zt7is7o8KF7qbZCmDb0EW%2F6CztUE1niwHhb4jpdCdGcgonUBlCgCKnwLYDU8lA%2FHernI9PwSy9MmqkU5z%2Bdp3ero4O0MXdrFDssNyUWsFHwATWQh%2Fv9vn7MgvwAnxxHGDIk8%2FOFse305zyS8U538kYlP0Odach7mb2usktO65wqjqO2aTtI7yIozb3ldJcW56Io5mku%2FYBlmWY3bS%2Bte1112kpeKf%2FdAqQUw%2FTorO0p%2FK8dZu1qPVfVmNW08Q%2Fi62yC