a proper ellipsoid
This commit is contained in:
parent
9124fe464b
commit
e26284910f
|
@ -1,12 +1,10 @@
|
||||||
# python who ate an elephant
|
class Ellipsoid
|
||||||
|
|
||||||
class Python
|
|
||||||
attr_reader :columns, :rows
|
attr_reader :columns, :rows
|
||||||
|
|
||||||
def initialize radius
|
def initialize radius
|
||||||
@columns = @rows = radius * 2
|
@columns = @rows = radius * 2
|
||||||
lower_half = (0...radius).map do |y|
|
lower_half = (0...radius).map do |y|
|
||||||
x = Math.sqrt(radius**2 - y**2).round
|
x = Math.sqrt(1 - y**2/radius**2)
|
||||||
right_half = "#{"\xff" * x}#{"\x00" * (radius - x)}"
|
right_half = "#{"\xff" * x}#{"\x00" * (radius - x)}"
|
||||||
"#{right_half.reverse}#{right_half}"
|
"#{right_half.reverse}#{right_half}"
|
||||||
end.join
|
end.join
|
|
@ -1,4 +1,4 @@
|
||||||
require './python.rb'
|
require './ellipsoid.rb'
|
||||||
|
|
||||||
# One particle is basically a sprite, that moves itself by speed every tick along an angle.
|
# One particle is basically a sprite, that moves itself by speed every tick along an angle.
|
||||||
# It also has a concept of decay, in how quickly the particle dies. In this case, the draw
|
# It also has a concept of decay, in how quickly the particle dies. In this case, the draw
|
||||||
|
@ -15,7 +15,7 @@ class Particle
|
||||||
@decay = decay
|
@decay = decay
|
||||||
|
|
||||||
radius = (rand * 10).floor
|
radius = (rand * 10).floor
|
||||||
@img = Gosu::Image.new(window, Python.new(radius), false)
|
@img = Gosu::Image.new(window, Ellipsoid.new(radius), false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
Reference in a new issue