这只是一个利用零散时间 学习Ruby Shoes和面向对象的方式来组纪织代码的过程,我希望通过这样一个方式来加强我的面向对象架零件的能力。
我打算做一个可以用键盘控件小飞机的游戏,目前这个是0.0001版啦,很多shoes的api还不怎么会用,目前的这个可以实现利用空格键和点击“开始”键启动飞机向右边飞行。
我要作造一个飞机,这个飞机有状态(停止,飞行中等状态),然后我给它一些行为,让它飞。
class Plane
def initialize(app)
@app = app
@running = false
@image = @app.image "resources/0001.gif"
@x = 1
end
def start
@running = true
end
def running?
@running
end
def go(x)
@x += x
@image.displace @x,30
end
end
Shoes.app :height => 500 do
stack do
background("#1744BF", "#FFFFFF")
banner("Plane Game")
end
stack :height => 400 do
@plane = Plane.new(self)
end
stack do
button("Start Game"){ @plane.start }
end
animate(1) do
@plane.go(20) if @plane.running?
end
keypress do |k|
@plane.start if k == " "
end
end
好玩吧。(待续...)
- 大小: 9.6 KB
分享到:
相关推荐
最有 ruby 味道的gui库 shoes
sell Jordan air force1 shoes
happy every day, 无奈用这个上传共享,google邮箱太慢了。
shoes, 用于 ruby的微型图形应用程序工具包 ((( |||_|///[[[_ ((( ))) || | \/[[_ ))) an artsy any-platform app kit http://shoesrb.com关于鞋子对于跨
belle shoes fashion belle shoes fashion belle shoes fashion
wholesale adidas puma shoes,cheap brand sneakers from China,custom brand sneakers for sale.
shoes.csv
047 The Red Shoes.doc
shoes购物商城主要完成用户购物及商家开网店的相关工作,具体包括: 1.前台: 用户模块管理 商品模块管理 订单模块管理 购物车模块管理 分类模块管理 2.后台 管理员模块管理 商品模块管理 分类模块管理 订单模块管理
New style discount Christian Louboutin shoes on sale, quality guaranteed and cheapest Christian Louboutin boots, more kinds of Christian Louboutin pumps onlouboutinshoes.com
Shoes
专卖店通用管理系统 v1.0_shoes 专卖店通用管理系统 v1.0_shoes
Shoes-site:我是按照教程做的
magik shoes magento 模板, magento 1.7 模板
We are glad to tell you that we supply all styles of shoes, cloth, handbags, jerseys, Jewelry. Any products u like is ok ,We offer retail and wholesale pricing as well as drop shipping. We are very ...
Shoes是用于跨平台(Mac,Windows和Linux)GUI编程的一种DSL。 感觉就像是真正的Ruby,而不仅仅是另一个C ++库包装器。 有关某些样本,手册和免费书籍,请访问。 基本用法 想看看鞋子是什么样的吗? 好吧,你去! ...
大班英语教案:shoes大班英语教案.doc
shoes_shop_online是一个基于Python开发的在线运动鞋商店,包含155个文件,其中包括68个JPG图片文件、31个Python源文件、19个Python编译文件、14个PNG图片文件、7个JavaScript文件、6个HTML文件、4个CSS文件、3个DS_...
大班英文教案《shoes》润新教育.txt
用ASP和SQL Server数据库做的一个网上商城,有前台和后台全代码!欢迎下载···