Skip to content

Commit

Permalink
examples: Fix flickering on PC browser
Browse files Browse the repository at this point in the history
788dc30 causes flicker on
PC browsers. This is the correct fix.
  • Loading branch information
yhara committed Jan 30, 2020
1 parent 4af34b4 commit 93d0213
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions examples/multi_touch/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ def random_color
Window.loop do
Window.draw_font(0, 0, "Multi touch demo\n(Open with mobile device)", Font.default)

closing_circles.map!{|(x, y, radius, color)|
Window.draw_circle_fill(x, y, radius, color)
[x, y, radius-1, color]
}
closing_circles.delete_if{|(x, y, radius, color)|
radius <= 0
}

# Mouse support (for PCs)
if Input.mouse_down?(M_LBUTTON)
if mouse_circle
Expand All @@ -45,10 +37,19 @@ def random_color
end
Input.touches.each do |t|
t.data[:radius] += 1
Window.draw_circle_fill(t.x, t.y, t.data[:radius], t.data[:color])
if t.released?
closing_circles << [t.x, t.y, t.data[:radius], t.data[:color]]
else
Window.draw_circle_fill(t.x, t.y, t.data[:radius], t.data[:color])
end
end

closing_circles.map!{|(x, y, radius, color)|
Window.draw_circle_fill(x, y, radius, color)
[x, y, radius-1, color]
}
closing_circles.delete_if{|(x, y, radius, color)|
radius <= 0
}
end
end

0 comments on commit 93d0213

Please sign in to comment.