Skip to content

Instantly share code, notes, and snippets.

@OhadRon
Last active January 26, 2019 11:29
Show Gist options
  • Save OhadRon/44d1b21a726bb64586c33755e651f5b8 to your computer and use it in GitHub Desktop.
Save OhadRon/44d1b21a726bb64586c33755e651f5b8 to your computer and use it in GitHub Desktop.
SCRIPT-8
// Title: Ugly Fountain
initialState = {
circles: [],
frames: 0
}
const addCircle = (state)=>{
state.circles.push({
x: 64,
y: 64,
direction: random(0,360),
color: Math.floor(random(0,7)),
speed: random(1,2)*0.2
})
}
update = (state, inputs, elapsed) =>{
state.title = Math.floor(elapsed)+'f'
state.frames += 1
state.circles.forEach((circle,i)=>{
circle.x += Math.sin(circle.direction)*circle.speed
circle.y += Math.cos(circle.direction)*circle.speed
if(circle.x>128|| circle.x<0 || circle.y>128|| circle.y<0){
state.circles.splice(i,1)
}
})
if(random(20)>15){
addCircle(state)
}
}
draw = (state) => {
clear()
state.circles.forEach(circle=>{
sprite(circle.x,circle.y,Math.floor((state.frames+circle.color)/20)%4)
})
//print(60,63,state.frames+''.length,4)
}
{
"0": [
" ",
" ",
" ",
" 0533 ",
" 5 33 3",
" 03 3",
" ",
" ",
0
],
"1": [
" ",
" 33 ",
" 333 ",
" 3 0 ",
"03 0 ",
" 3 ",
" 35 ",
" 33 "
],
"2": [
" ",
" 6 ",
" 1 ",
" 6 21 ",
" 5 5 ",
" 0 1 ",
" ",
" "
],
"3": [
" ",
" 1 ",
" 1 0 55",
" 0 0 50",
" 5 ",
" 00 05 ",
" 5 ",
" "
],
"4": [
" ",
" 0 ",
" 0 6 ",
" 6 0 ",
"01 6 1 ",
" 6 ",
" 0 ",
" "
],
"5": [
" ",
" 1 ",
" 0 ",
" 1 11 ",
" ",
" 1 11 ",
" ",
" "
],
"6": [
" ",
" ",
" 0 ",
" 0 ",
" 0 ",
" 0 0 ",
" ",
" "
],
"22": [
" ",
" ",
" 0 0 ",
" ",
" 0 ",
" 0 ",
" ",
" "
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment