设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3404|回复: 4
打印 上一主题 下一主题

[通用发布] 环状选项

[复制链接]

Lv2.观梦者

傻♂逼

梦石
0
星屑
374
在线时间
1606 小时
注册时间
2007-3-13
帖子
6562

烫烫烫开拓者

跳转到指定楼层
1
发表于 2011-6-18 16:09:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
可以做菜单什么的……欢淫蛋疼

  1. class EccSet
  2.   include YMath
  3.   attr_reader:index
  4.   def _init(commands,x,y,width,height,v=Viewport.new(0,0,1024,768))
  5.     @commands=commands
  6.     @script_set=[]
  7.     @index=0
  8.     @v=v
  9.     p=360.00/(@commands.size.to_f)
  10.     @xita=[]
  11.     @xitas=[]
  12.     @x=x
  13.     @y=y
  14.     for i in [email protected]
  15.       @xita[i]=i*p#/360.0#Math::PI/10.0#i*p #* 180 / Math::PI
  16.       @xitas[i]=i*p#/360.0#Math::PI/10.0#i*p# * 180 / Math::PI
  17.       @script_set[i]=Sprite.new(@v)
  18.       @script_set[i].bitmap=@commands[i][1]
  19.     end
  20.     #p @xitas
  21.     #@s=Sprite.new
  22.     #@s.bitmap=Bitmap.new(width,height)
  23.     #@s.x=x
  24.     #@s.y=y
  25.    
  26.     @ecc=Ellipse.new(width,height)
  27.     @ss=ScreenSystem.new(width,height)
  28.     draw
  29.   end
  30.   def update
  31.     #draw
  32.     if Input.press?(Input::LEFT)
  33.       for i in [email protected]
  34.         @xitas[i]-=1
  35.         @xitas[i]=360 if @xitas[i]<0
  36.       end
  37.       draw
  38.     end
  39.     if Input.press?(Input::RIGHT)
  40.       for i in [email protected]
  41.         @xitas[i]+=1
  42.         @xitas[i]=0 if @xitas[i]>360
  43.       end
  44.       draw
  45.     end
  46.   end
  47.   def draw
  48.     oz=999
  49.     for i in [email protected]
  50.       z=draw_command(i)
  51.       if z>oz
  52.         oz=z
  53.         @index=i
  54.       end
  55.     end
  56.     #for xita in 0...360
  57.      # [email protected](xita/180.00 * Math::PI).to_ss(@ss)
  58.      # @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  59.       
  60.     #end
  61. =begin
  62.     xita=0
  63.       [email protected](xita/180.00 * Math::PI).to_ss(@ss)
  64.       @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  65.     xita=90
  66.       [email protected](xita/180.00 * Math::PI).to_ss(@ss)
  67.       @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  68.     xita=180
  69.       [email protected](xita/180.00 * Math::PI).to_ss(@ss)
  70.       @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  71.     xita=270
  72.       [email protected](xita/180.00 * Math::PI).to_ss(@ss)
  73.       @s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  74. =end
  75.     #end
  76.   end
  77.   def draw_command(i)
  78.     xita=@xitas[i] /180.00 * Math::PI
  79.     [email protected](xita).to_ss(@ss)
  80.     #p pos  
  81.    
  82.     z=1+0.5*Math.sin(xita)
  83.     @script_set[i].x=(pos.x+@x).to_i-@script_set[i].width/2*z
  84.     @script_set[i].y=(pos.y+@y).to_i-@script_set[i].height/2*z
  85.    
  86.     #@s.bitmap.set_pixel(pos.x.to_i,pos.y.to_i,Color.new(255,255,255,255))
  87.     @script_set[i].zoom_x=z
  88.     @script_set[i].zoom_y=z
  89.     @script_set[i].opacity = 255*z
  90.     @script_set[i].z=z*400
  91.     return z
  92.   end
  93. end
  94. @eccs=EccSet.new
  95. cmd=[["",Cache.battler("Angel")],["",Cache.battler("Angel")],["",Cache.battler("Angel")],["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ,["",Cache.battler("Angel")] ]
  96. @eccs._init(cmd,200,200,600,400)
  97. while true

  98.   Graphics.update
  99.   Input.update
  100.   @eccs.update
  101. end
  102.   #Graphics.wait(120)
  103.   #exit
  104. # sleep(1)
  105. #end
复制代码
  1. module YMath
  2.   
  3.   class MathObject
  4.     def self.kind(*args)
  5.       if args.size>0
  6.         @kind=args[0]
  7.       else
  8.         return @kind
  9.       end
  10.     end
  11.   end
  12.   class ScreenSystem < MathObject
  13.     attr_reader:width
  14.     attr_reader:height
  15.     def initialize(width,height)
  16.       @width=width.to_f
  17.       @height=height.to_f
  18.     end
  19.     class Point<MathObject
  20.       attr_reader:x
  21.       attr_reader:y
  22.       attr_reader:ss
  23.       def initialize(x,y,ss)
  24.         @x=x.to_f
  25.         @y=y.to_f
  26.         @ss=ss
  27.       end
  28.       def to_ccs
  29.         CartesianCoordinateSystem::Point.new(@[email protected]/2.0,@[email protected]/2.0)
  30.       end
  31.       def to_pcs
  32.         to_ccs.to_pcs
  33.       end
  34.     end   
  35.   end
  36.   class PolarCoordinateSystem<MathObject
  37.     class Point<MathObject
  38.       attr_reader:r
  39.       attr_reader:xita
  40.       def initialize(r,xita)
  41.         @r=r.to_f
  42.         @xita=xita.to_f
  43.       end
  44.       def to_ccs
  45.         CartesianCoordinateSystem::Point.new(r*Math.cos(xita),r*Math.sin(xita))
  46.       end
  47.       def to_ss(ss)
  48.         to_ccs.to_ss(ss)
  49.       end
  50.     end
  51.   end
  52.   class CartesianCoordinateSystem<MathObject
  53.     class Point < MathObject
  54.       kind:ccs
  55.       attr_reader:x
  56.       attr_reader:y
  57.       def initialize(x,y)
  58.         @x=x.to_f
  59.         @y=y.to_f
  60.       end
  61.       def to_pcs
  62.         xita=Math.atan(@y/@x) if x!=0
  63.         xita=Math::PI/2.0 if x==0 and  y>0
  64.         xita=(3*Math::PI)/2.0 if x==0 and y<0
  65.         xita=0 if x==0 and y==0
  66.         PolarCoordinateSystem::Point.new(Math.sqrt(x**2+y**2),xita)
  67.       end
  68.       def to_ss(ss)
  69.         ScreenSystem::Point.new(ss.width/2.0+@x,ss.height/2.0+@y,ss)
  70.       end
  71.         
  72.     end
  73.   end
  74.   class Ellipse < MathObject
  75.     attr_reader :a
  76.     attr_reader :b
  77.     attr_reader :c
  78.     kind :pcs
  79.     def initialize(long,short,rotate=0)
  80.       @a=long.to_f/2.0
  81.       @b=short.to_f/2.0
  82.       @c=Math.sqrt(a**2-b**2).to_f
  83.       @e=@c/@a
  84.       @ee=Math.sqrt(1-b**2/a**2)
  85.       @p=@a**2/@c-@c
  86.       @rotate=rotate
  87.     end
  88.     def r(xita)
  89.       #return PolarCoordinateSystem::Point.new((@p*@e)/(1-@e*Math.cos(xita+@rotate)),xita)
  90.       return PolarCoordinateSystem::Point.new((@b)/Math.sqrt(1-@ee**2*Math.cos(xita)**2),xita)
  91.     end
  92.   end
  93.   class Circle < MathObject
  94.     kind :pcs
  95.     attr_reader:r
  96.     def initialize(r)
  97.       @r=r
  98.     end
  99.     def r(xita)
  100.       return @r
  101.     end
  102.   end
  103. end
复制代码

评分

参与人数 1星屑 +804 收起 理由
夕阳武士 + 804 诡异啊。。

查看全部评分

哎呀,蛋疼什么的最有爱了

Lv1.梦旅人

梦石
0
星屑
60
在线时间
93 小时
注册时间
2010-8-22
帖子
7
2
发表于 2011-6-18 18:10:54 | 只看该作者
無圖無真相

点评

头像……兄弟啊!  发表于 2011-6-21 12:15
↓+1  发表于 2011-6-20 12:20
yangff的东西要截图也没用,纯技术  发表于 2011-6-19 10:36
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
25 小时
注册时间
2011-1-1
帖子
84
3
发表于 2011-6-19 18:32:00 | 只看该作者
OTL...这种神奇的技术性物品。。。
(本消息由该成员通过66rpg发送,体验请登录:   http://rpg.blue/ )  
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
83 小时
注册时间
2008-4-19
帖子
420
4
发表于 2011-6-19 18:48:30 | 只看该作者
好吧我想起了椭圆参数方程- -
好吧这是II让我贴的- -
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
245
在线时间
227 小时
注册时间
2009-7-26
帖子
216
5
发表于 2011-6-21 04:18:50 | 只看该作者
- - 好诡异⋯⋯代数都是abc⋯⋯看着好晕⋯⋯
不要吐槽我⋯⋯
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-21 01:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表