最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

shell编程俄罗斯方块

IT圈 admin 32浏览 0评论

2024年3月13日发(作者:圭丹亦)

#!/bin/bash

# Tetris Game

# 10.21.2003 xhchen

###############################################################################

# 因为HP 上没有 usleep by CHENCHENG

###############################################################################

# #include

# #include

#

# int main(int argc, char **argv)

# {

# int nRet;

# nRet = usleep(atol(argv[1]));

# //printf("%ld %dn", atol(argv[1]), nRet);

# return 0;

# }

###############################################################################

#color definition

cRed=1

cGreen=2

cYellow=3

cBlue=4

cFuchsia=5

cCyan=6

cWhite=7

colorTable=($cRed $cGreen $cYellow $cBlue $cFuchsia $cCyan $cWhite)

#size & position

iLeft=3

iTop=2

((iTrayLeft = iLeft + 2))

((iTrayTop = iTop + 1))

((iTrayWidth = 10))

((iTrayHeight = 15))

#style definition

cBorder=$cGreen

cScore=$cFuchsia

cScoreValue=$cCyan

#control signal

sigRotate=25

sigLeft=26

sigRight=27

sigDown=28

sigAllDown=29

sigExit=30

box0=(0 0 0 1 1 0 1 1)

box1=(0 2 1 2 2 2 3 2 1 0 1 1 1 2 1 3)

box2=(0 0 0 1 1 1 1 2 0 1 1 0 1 1 2 0)

box3=(0 1 0 2 1 0 1 1 0 0 1 0 1 1 2 1)

box4=(0 1 0 2 1 1 2 1 1 0 1 1 1 2 2 2 0 1 1 1 2 0 2 1 0 0 1 0 1 1 1 2)

box5=(0 1 1 1 2 1 2 2 1 0 1 1 1 2 2 0 0 0 0 1 1 1 2 1 0 2 1 0 1 1 1 2)

box6=(0 1 1 1 1 2 2 1 1 0 1 1 1 2 2 1 0 1 1 0 1 1 2 1 0 1 1 0 1 1 1 2)

box=(${box0[@]} ${box1[@]} ${box2[@]} ${box3[@]} ${box4[@]}

${box6[@]})

countBox=(1 2 2 2 4 4 4)

offsetBox=(0 1 3 5 7 11 15)

iScoreEachLevel=50 #be greater than 7

#Runtime data

sig=0

iScore=0

iLevel=0

boxNew=() #new box

cBoxNew=0 #new box color

iBoxNewType=0 #new box type

iBoxNewRotate=0 #new box rotate degree

boxCur=() #current box

cBoxCur=0 #current box color

iBoxCurType=0 #current box type

iBoxCurRotate=0 #current box rotate degree

boxCurX=-1 #current X position

boxCurY=-1 #current Y position

iMap=()

for ((i = 0; i < iTrayHeight * iTrayWidth; i++)); do iMap[$i]=-1; done

function RunAsKeyReceiver()

{

local pidDisplayer key aKey sig cESC sTTY

pidDisplayer=$1

aKey=(0 0 0)

cESC=`echo -ne "33"`

${box5[@]}

2024年3月13日发(作者:圭丹亦)

#!/bin/bash

# Tetris Game

# 10.21.2003 xhchen

###############################################################################

# 因为HP 上没有 usleep by CHENCHENG

###############################################################################

# #include

# #include

#

# int main(int argc, char **argv)

# {

# int nRet;

# nRet = usleep(atol(argv[1]));

# //printf("%ld %dn", atol(argv[1]), nRet);

# return 0;

# }

###############################################################################

#color definition

cRed=1

cGreen=2

cYellow=3

cBlue=4

cFuchsia=5

cCyan=6

cWhite=7

colorTable=($cRed $cGreen $cYellow $cBlue $cFuchsia $cCyan $cWhite)

#size & position

iLeft=3

iTop=2

((iTrayLeft = iLeft + 2))

((iTrayTop = iTop + 1))

((iTrayWidth = 10))

((iTrayHeight = 15))

#style definition

cBorder=$cGreen

cScore=$cFuchsia

cScoreValue=$cCyan

#control signal

sigRotate=25

sigLeft=26

sigRight=27

sigDown=28

sigAllDown=29

sigExit=30

box0=(0 0 0 1 1 0 1 1)

box1=(0 2 1 2 2 2 3 2 1 0 1 1 1 2 1 3)

box2=(0 0 0 1 1 1 1 2 0 1 1 0 1 1 2 0)

box3=(0 1 0 2 1 0 1 1 0 0 1 0 1 1 2 1)

box4=(0 1 0 2 1 1 2 1 1 0 1 1 1 2 2 2 0 1 1 1 2 0 2 1 0 0 1 0 1 1 1 2)

box5=(0 1 1 1 2 1 2 2 1 0 1 1 1 2 2 0 0 0 0 1 1 1 2 1 0 2 1 0 1 1 1 2)

box6=(0 1 1 1 1 2 2 1 1 0 1 1 1 2 2 1 0 1 1 0 1 1 2 1 0 1 1 0 1 1 1 2)

box=(${box0[@]} ${box1[@]} ${box2[@]} ${box3[@]} ${box4[@]}

${box6[@]})

countBox=(1 2 2 2 4 4 4)

offsetBox=(0 1 3 5 7 11 15)

iScoreEachLevel=50 #be greater than 7

#Runtime data

sig=0

iScore=0

iLevel=0

boxNew=() #new box

cBoxNew=0 #new box color

iBoxNewType=0 #new box type

iBoxNewRotate=0 #new box rotate degree

boxCur=() #current box

cBoxCur=0 #current box color

iBoxCurType=0 #current box type

iBoxCurRotate=0 #current box rotate degree

boxCurX=-1 #current X position

boxCurY=-1 #current Y position

iMap=()

for ((i = 0; i < iTrayHeight * iTrayWidth; i++)); do iMap[$i]=-1; done

function RunAsKeyReceiver()

{

local pidDisplayer key aKey sig cESC sTTY

pidDisplayer=$1

aKey=(0 0 0)

cESC=`echo -ne "33"`

${box5[@]}

发布评论

评论列表 (0)

  1. 暂无评论