Project1
标题:
环状选项
[打印本页]
作者:
yangff
时间:
2011-6-18 16:09
标题:
环状选项
可以做菜单什么的……欢淫蛋疼
class EccSet
include YMath
attr_reader:index
def _init(commands,x,y,width,height,v=Viewport.new(0,0,1024,768))
@commands=commands
@script_set=[]
@index=0
@v=v
p=360.00/(@commands.size.to_f)
@xita=[]
@xitas=[]
@x=x
@y=y
for i in
[email protected]
@xita[i]=i*p#/360.0#Math::PI/10.0#i*p #* 180 / Math::PI
@xitas[i]=i*p#/360.0#Math::PI/10.0#i*p# * 180 / Math::PI
@script_set[i]=Sprite.new(@v)
@script_set[i].bitmap=@commands[i][1]
end
#p @xitas
#@s=Sprite.new
#@s.bitmap=Bitmap.new(width,height)
#@s.x=x
#@s.y=y
@ecc=Ellipse.new(width,height)
@ss=ScreenSystem.new(width,height)
draw
end
def update
#draw
if Input.press?(Input::LEFT)
for i in
[email protected]
@xitas[i]-=1
@xitas[i]=360 if @xitas[i]<0
end
draw
end
if Input.press?(Input::RIGHT)
for i in
[email protected]
@xitas[i]+=1
@xitas[i]=0 if @xitas[i]>360
end
draw
end
end
def draw
oz=999
for i in
[email protected]
z=draw_command(i)
if z>oz
oz=z
@index=i
end
end
#for xita in 0...360
#
[email protected]
(xita/180.00 * Math::PI).to_ss(@ss)
# @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
#end
=begin
xita=0
[email protected]
(xita/180.00 * Math::PI).to_ss(@ss)
@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
xita=90
[email protected]
(xita/180.00 * Math::PI).to_ss(@ss)
@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
xita=180
[email protected]
(xita/180.00 * Math::PI).to_ss(@ss)
@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
xita=270
[email protected]
(xita/180.00 * Math::PI).to_ss(@ss)
@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
=end
#end
end
def draw_command(i)
xita=@xitas[i] /180.00 * Math::PI
[email protected]
(xita).to_ss(@ss)
#p pos
z=1+0.5*Math.sin(xita)
@script_set[i].x=(pos.x+@x).to_i-@script_set[i].width/2*z
@script_set[i].y=(pos.y+@y).to_i-@script_set[i].height/2*z
#@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
@script_set[i].zoom_x=z
@script_set[i].zoom_y=z
@script_set[i].opacity = 255*z
@script_set[i].z=z*400
return z
end
end
@eccs=EccSet.new
cmd=[["",Cache.battler("Angel")],["",Cache.battler("Angel")],["",Cache.battler("Angel")],["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ]
@eccs._init(cmd,200,200,600,400)
while true
Graphics.update
Input.update
@eccs.update
end
#Graphics.wait(120)
#exit
# sleep(1)
#end
复制代码
module YMath
class MathObject
def self.kind(*args)
if args.size>0
@kind=args[0]
else
return @kind
end
end
end
class ScreenSystem < MathObject
attr_reader:width
attr_reader:height
def initialize(width,height)
@width=width.to_f
@height=height.to_f
end
class Point<MathObject
attr_reader:x
attr_reader:y
attr_reader:ss
def initialize(x,y,ss)
@x=x.to_f
@y=y.to_f
@ss=ss
end
def to_ccs
CartesianCoordinateSystem::Point.new(@
[email protected]
/2.0,@
[email protected]
/2.0)
end
def to_pcs
to_ccs.to_pcs
end
end
end
class PolarCoordinateSystem<MathObject
class Point<MathObject
attr_reader:r
attr_reader:xita
def initialize(r,xita)
@r=r.to_f
@xita=xita.to_f
end
def to_ccs
CartesianCoordinateSystem::Point.new(r*Math.cos(xita),r*Math.sin(xita))
end
def to_ss(ss)
to_ccs.to_ss(ss)
end
end
end
class CartesianCoordinateSystem<MathObject
class Point < MathObject
kind:ccs
attr_reader:x
attr_reader:y
def initialize(x,y)
@x=x.to_f
@y=y.to_f
end
def to_pcs
xita=Math.atan(@y/@x) if x!=0
xita=Math::PI/2.0 if x==0 and y>0
xita=(3*Math::PI)/2.0 if x==0 and y<0
xita=0 if x==0 and y==0
PolarCoordinateSystem::Point.new(Math.sqrt(x**2+y**2),xita)
end
def to_ss(ss)
ScreenSystem::Point.new(ss.width/2.0+@x,ss.height/2.0+@y,ss)
end
end
end
class Ellipse < MathObject
attr_reader :a
attr_reader :b
attr_reader :c
kind :pcs
def initialize(long,short,rotate=0)
@a=long.to_f/2.0
@b=short.to_f/2.0
@c=Math.sqrt(a**2-b**2).to_f
@e=@c/@a
@ee=Math.sqrt(1-b**2/a**2)
@p=@a**2/@c-@c
@rotate=rotate
end
def r(xita)
#return PolarCoordinateSystem::Point.new((@p*@e)/(1-@e*Math.cos(xita+@rotate)),xita)
return PolarCoordinateSystem::Point.new((@b)/Math.sqrt(1-@ee**2*Math.cos(xita)**2),xita)
end
end
class Circle < MathObject
kind :pcs
attr_reader:r
def initialize(r)
@r=r
end
def r(xita)
return @r
end
end
end
复制代码
作者:
s094392
时间:
2011-6-18 18:10
無圖無真相
作者:
糖克鸡
时间:
2011-6-19 18:32
OTL...这种神奇的技术性物品。。。
作者:
冰蓝的马甲
时间:
2011-6-19 18:48
好吧我想起了椭圆参数方程- -
作者:
darkscout3000
时间:
2011-6-21 04:18
- - 好诡异⋯⋯代数都是abc⋯⋯看着好晕⋯⋯
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1