a proper ellipsoid
This commit is contained in:
parent
9124fe464b
commit
e26284910f
|
@ -1,12 +1,10 @@
|
|||
# python who ate an elephant
|
||||
|
||||
class Python
|
||||
class Ellipsoid
|
||||
attr_reader :columns, :rows
|
||||
|
||||
def initialize radius
|
||||
@columns = @rows = radius * 2
|
||||
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.reverse}#{right_half}"
|
||||
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.
|
||||
# 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
|
||||
|
||||
radius = (rand * 10).floor
|
||||
@img = Gosu::Image.new(window, Python.new(radius), false)
|
||||
@img = Gosu::Image.new(window, Ellipsoid.new(radius), false)
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
Reference in a new issue