当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: shell游戏:贪吃蛇 期待各位帮忙测试,如有BUG,请
 

 

 ·用awk数组处理两个文件的例子    »显示摘要«
    摘要: 收了本论坛的三个例子 [quote:b425e56bf6]1、用某一文件的一个域替换另一个文件中的的特定域? http://bbs.chinaunix.net/forum/viewtopic.php?t=500015 文件passwd: s2002408030068:x:527:527::/home/dz02/s2002408030068:/bin/pw s2002408032819......
 ·查看世界主要城市时间的程序    »显示摘要«
    摘要: #!/bin/bash tz=utc-8 beijing=`date +%h:%m` echo -n "请输入您想差看的城市名称:" read city_name city=`cat city.txt |grep $city_name` gap=`echo $city |awk {print $3}` echo echo -n "$city_name现在的时间是:`date --date "......


shell游戏:贪吃蛇 修正版

shell游戏:贪吃蛇 【程序编程相关:3D游戏引擎设计与实现(18)

【推荐阅读:AboutFish

【扩展信息:关于IBR的一点想法

期待各位帮忙测试,如有bug,请及时告知,谢谢

转载请保持版权声明完整,十分感谢

下载代码:

[url]http://bitbull.cn/works/snake[/url]

六关卡屏幕截图:

[url]http://bitbull.cn/pic/blog/2005072801.jpg[/url]

[url]http://bitbull.cn/pic/blog/2005072802.jpg[/url]

[url]http://bitbull.cn/pic/blog/2005072803.jpg[/url]

[url]http://bitbull.cn/pic/blog/2005072804.jpg[/url]

[url]http://bitbull.cn/pic/blog/2005072805.jpg[/url]

[url]http://bitbull.cn/pic/blog/2005072806.jpg[/url]

[color=red:14850b6c0a]由于程序运行过程中会产生己个临时文件,

请先确定/tmp目录可写可读..如果权限不够或无此目录,请把游戏

cpath="/tmp/snake_ctrl_pid.tmp"

dpath="/tmp/snake_disply_pid.tmp"

vartmp="/tmp/snake_var_tmpfile.tmp"

改到有权限读写的目录[/color:14850b6c0a]

测试环境:

rhel4 as

bash 3.0

80x24终端

usage:

w上 s下 a左 d右

p暂停

n新游戏

q退出

规则:

吃完屏幕上所有的红色果实即可过关,共有6个关卡.碰到任何障碍蛇都将死亡,玩家有4次生命.

代码:

[code:1:14850b6c0a]#!/bin/bash

#-------------copyright-------------

#   name:snake

#   version number:1.00

#   type:game

#   language:bash shell

#   date:2005-07-28

#   author:bitbull

#   email:wengjianyi@tom.com

#------------environment------------

#   terminal: column 80 line 24

#   linux 2.6.9 i686

#   gnu bash 3.00.15

#-----------------------------------

#--------------variable--------------

#game variable

level=1

score=0

life=3

length=8

runtime=0.15

fruitspare=8

#game kernel variable

x=2 #init snake x=2 y=2

y=2

direction=0

shead=1 #snakes head in snake[]

stail=1 #snakes tail in snake[]

mappoint=1 #point exactmap[] bottom

state=on #snake run or stop

run=off  #if run=on,snake shadow is working

displaypid=""

controlpid=""

#game temp file;if your systems /tmp unwrite or unread, you can change to home

cpath="/tmp/snake_ctrl_pid.tmp"

dpath="/tmp/snake_disply_pid.tmp"

vartmp="/tmp/snake_var_tmpfile.tmp"

#rename kill sign

pause=23

newgame=24

gameover=25

gameexit=26

up=27

down=28

left=29

right=22

#---------------array---------------                                           

#init exactmap

exactmap=()

#map format: y x howlong "-- or |" ( 1=| 2=-- )

map1=("6 14 6 2" "6 50 6 2" "14 14 6 2" "14 50 6 2")


...   下一页
 ·about shell    »显示摘要«
    摘要: [color=blue:c9aab565de]什么是 shell? [/color:c9aab565de] [quote:c9aab565de] shell是一种具备特殊功能的程序,它是介于使用者和 unix/linux 操作系统之核心程序(kernel)间的一个接口。为什么我们说 shell 是一种介于系统核心程序与使用者间的中介者呢?读过操作系统概论的读者们都知道操作系统是一个系统资源的......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE