| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2020-7-27 |
| 在线时间 | 1379 小时 |
- 梦石
- 0
- 星屑
- 76
- 在线时间
- 1379 小时
- 注册时间
- 2012-7-5
- 回帖
- 1643

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
(不是指MVC之类完整的"UI"概念, 只是按内建Window类的原理创建任意大小的窗口背景图, 还请各位大触不要在UI概念上触窝)
正确的食用姿势- def Color.sample(alpha=255)
- Color.new([0,120,255][rand(3)],[0,120,255][rand(3)],[0,120,255][rand(3)],alpha)
- end
- def sp(*args)
- s = Sprite.new
- b = Bitmap.new(*args)
- yield b if block_given?
- s.bitmap = b
- return s
- end
- def rgss_run(*objs)
- loop do
- Graphics.update
- Input.update
- objs.each(&:update)
- end
- end
- class M_M
- attr_accessor :x, :y, :width, :height
- def initialize
- [url=home.php?mod=space&uid=90764]@hash[/url] = get_pieces(Bitmap.new("Resources/title_line.png"),12,198,34,56)
- end
- def update
- update_positions
- if Input.trigger?(Input::C)
- @x = rand 320
- @y = rand 240
- @width = rand 480
- [url=home.php?mod=space&uid=291977]@height[/url] = rand 320
- end
- end
- def update_positions
- w0 = @width-@hash[:corner0].bitmap.width-@hash[:corner1].bitmap.width
- h0 = @height-@hash[:corner0].bitmap.height-@hash[:corner2].bitmap.height
- @hash[:corner0].x += dynamic_distance(@x, @hash[:corner0].x, 7)
- @hash[:corner0].y += dynamic_distance(@y, @hash[:corner0].y, 7)
- @hash[:side0].src_rect.width += dynamic_distance(
- w0,@hash[:side0].src_rect.width,7)
- @hash[:side1].src_rect.height += dynamic_distance(
- h0,@hash[:side1].src_rect.height,7)
- @hash[:side2].src_rect.height += dynamic_distance(
- h0,@hash[:side2].src_rect.height,7)
- @hash[:side3].src_rect.width += dynamic_distance(
- w0,@hash[:side3].src_rect.width,7)
- @hash[:back].src_rect.width += dynamic_distance(
- w0,@hash[:back].src_rect.width,7)
- @hash[:back].src_rect.height += dynamic_distance(
- h0,@hash[:back].src_rect.height,7)
- w1 = @hash[:corner0].bitmap.width
- w2 = @hash[:side0].src_rect.width+w1
- h1 = @hash[:corner0].bitmap.height
- h2 = @hash[:side1].src_rect.height+h1
- @hash[:corner1].x = @hash[:corner0].x + w2
- @hash[:corner2].x = @hash[:corner0].x
- @hash[:corner3].x = @hash[:corner0].x + w2
- @hash[:corner1].y = @hash[:corner0].y
- @hash[:corner2].y = @hash[:corner0].y + h2
- @hash[:corner3].y = @hash[:corner0].y + h2
- @hash[:side0].x = @hash[:corner0].x + w1
- @hash[:side1].x = @hash[:corner0].x
- @hash[:side2].x = @hash[:corner0].x + w2
- @hash[:side3].x = @hash[:corner0].x + w1
- @hash[:side0].y = @hash[:corner0].y
- @hash[:side1].y = @hash[:corner0].y + h1
- @hash[:side2].y = @hash[:corner0].y + h1
- @hash[:side3].y = @hash[:corner0].y + h2
- @hash[:back].x = @hash[:corner0].x + w1
- @hash[:back].y = @hash[:corner0].y + h1
- end
- def set(x, y, w, h)
- @x, @y, @width, @height = x, y, w, h
- end
- def get_pieces(bitmap, x1, x2, y1, y2)
- w, h = bitmap.width, bitmap.height
- return {
- :back => miao(bitmap, Rect.new(x1,y1,x2-x1,y2-y1), 640, 480), # 中间
- :corner0 => miao(bitmap, Rect.new( 0, 0, x1, y1), x1, y1), # 左上
- :corner1 => miao(bitmap, Rect.new(x2, 0, w-x2, y1),w-x2, y1), # 右上
- :corner2 => miao(bitmap, Rect.new( 0,y2, x1, h-y2), x1,h-y2), # 左下
- :corner3 => miao(bitmap, Rect.new(x2,y2, w-x2, h-y2),w-x2,h-y2), # 右下
- :side0 => miao(bitmap, Rect.new(x1, 0,x2-x1, y1), 640, y1), # 上部
- :side1 => miao(bitmap, Rect.new( 0,y1, x1,y2-y1), x1, 480), # 左部
- :side2 => miao(bitmap, Rect.new(x2,y1, w-x2,y2-y1),w-x2, 480), # 右部
- :side3 => miao(bitmap, Rect.new(x1,y2,x2-x1, h-y2), 640,h-y2), # 下部
- }
- end
- def miao(*args)
- return new_sprite(pick_bitmap(*args))
- end
- def new_sprite(bitmap)
- s = Sprite.new
- s.bitmap = bitmap
- s.z = 2333333
- return s
- end
- def pick_bitmap(bitmap, src_rect, w, h)
- b = Bitmap.new w, h
- b.stretch_blt b.rect, bitmap, src_rect
- return b
- end
- # a 目标值 b 基础值 c 速度的倒数【啥
- def dynamic_distance(a, b, c)
- (a - b).abs < c ? (a - b) == 0 ? 0 : (a - b).abs / (a - b) : (a - b) / c
- end
- end
- m = M_M.new
- m.x = m.y = m.width = m.height = 200
- sp(640, 480){|b| b.fill_rect b.rect, Color.sample }
- rgss_run m
复制代码
资源:
喵喵喵~ |
评分
-
查看全部评分
|