赞 | 0 |
VIP | 40 |
好人卡 | 2 |
积分 | 1 |
经验 | 10932 |
最后登录 | 2016-5-17 |
在线时间 | 462 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 462 小时
- 注册时间
- 2007-7-30
- 帖子
- 643
|
RGE这样写- include RGE
- RGE.init
- logo = Sprite.new
- logo.bitmap = Bitmap.new("logo.png") #这是一张图
- logo.ox = logo.bitmap.width / 2
- logo.oy = logo.bitmap.height / 2
- logo.x = 50
- logo.y = 50
- logo2 = Sprite.new
- logo2.bitmap = Bitmap.new("logo2.png") #这是另一张图
- logo2.ox = logo.bitmap.width / 2
- logo2.oy = logo.bitmap.height / 2
- logo2.x = 200
- logo2.y = 40
- # 建立映射表
- map = Array.new
- map[0] = Array.new
- map[1] = Array.new
- for i in 0...logo.bitmap.width
- map[0][i] = Array.new
- for j in 0...logo.bitmap.height
- map[0][i][j] = (logo.bitmap.get_pixel(i, j).alpha == 0) #判断是否透明
- end
- end
- for i in 0...logo2.bitmap.width
- map[1][i] = Array.new
- for j in 0...logo2.bitmap.height
- map[1][i][j] = (logo2.bitmap.get_pixel(i, j).alpha == 0) #判断是否透明
- end
- end
- def cover?(map1, x1, y1, map2, x2, y2)
- map1_w = map1.length
- map1_h = map1[0].length
- map2_w = map2.length
- map2_h = map2[0].length
- for i in 0...map1_w
- next unless (i + x1).between?(x2, x2 + map2_w - 1)
- for j in 0...map1_h
- next unless (j + y1).between?(y2, y2 + map2_h - 1)
- return (map1[i][j] && map2[i + x1 - x2][j + y1 - y2])
- end
- end
- return false
- end
- Graphics.update
- if cover?(map[0], logo.x - logo.ox, logo.y - logo.oy, map[1], logo2.x - logo2.ox, logo2.y - logo2.oy)
- p "cover"
- end
- begin
- Graphics.update
- Input.update
- end until Input.press?(13)
复制代码 |
评分
-
查看全部评分
|