China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 13:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Colorful Snake Game Green without 3rd-party files Based on SYBC1.1.31 View 2,266 Replies 8
Original Poster Posted 2010-03-31 21:12 ·  中国 河北 廊坊 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
Purely for entertainment, not controllable, green, no third-party files, no temporary files, only for looking... The code is on the second floor

[ Last edited by sl543001 on 2010-4-1 at 14:01 ]
Attachments
tcs.GIF
SYBNQQ:354324773
Floor 2 Posted 2010-03-31 21:12 ·  中国 河北 廊坊 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
```batch
@echo off&color f1&title SYBN 贪吃蛇 主程序&SETLOCAL ENABLEDELAYEDEXPANSION&(CHCP 437&GRAFTABL 936)>NUL
SET SYBCOM=A100`80BE AC00 3C 375 83E9 3C00 ACFF 4275`2CBE AC00 E08A 86AC 50C4 BE1F 0 3CAC`7553 ACFB 593C F675 3CAC 7542 ACF1 433C`EC75 3CAC 7553 ACE7 3D3C E275 14EB 3CAC`743A 3C0F 740D 3C4D 7400 8349 1EE 48EB`54B4 E8AC 93 ADE8 3C00 7F18 8A37 E8F0`87 A1E8 3C00 7F4F 8A2B B0D0 F602 50E2`A0B0 E6F6 35F 57F8 3CAC 7424 E80A 6A`49E8 8A00 EBCA E817 3F CA8A 10EB B0`16CD C48A 4CB4 21CD 815F A0C7 5700 B850`B800 750 2B5A 8AEE ACD1 243C D974 3B3C`8C74 D3C DE74 3C DA74 233C 575 D783`EB01 AA01 C28A EBAA E8E0 1D 3C93 7E39`402 8009 39FB 37E C380 2409 800F FE3`10B2 E2F6 C302 D08A ACC3 203C FB74 D3C`A274 3C 9E74 D88A 3CAC 7420 3CEC 740D`3C93 7400 C38F 2C93 8030 30EB AB4 E4F6`C302 C3`
SET SYBCV=`A80`DB FF``RCX`120`G`Q
ECHO {贪吃蛇 脚本动画} 内含SYBC 1.1.31 初始化,按任意键继续...
SET V=`A80`DB 00``RCX`120`g`Q
(ECHO.%SYBCOM:`=&ECHO.DW %&ECHO.%V:`=&ECHO.%)|DEBUG>nul
SET SYBK=SYBK1=┌─┐│└┘┼;SYBK2=┏━┓┃┗┛╋;SYBK3=╔═╗║╚╝╬;c1=1f;c2=fa;c3=f2;c4=f5;ls=01
SET %SYBK:;=&SET %
set ys=3
:new
cls
for /l %%a in (10000,1,12500) do set s%%a=0
set thf=+1&set tlf=+0&set f1=-1
set /a th=12,tl=15,chang=3,t3=11230,t1=11230,t2=11230,cqs=0,bjs=0,bjx=24,bjz=0,bjy=39,bjh=23,bjl=38,hd=10,changjx=300,ranc=0
for /l %%a in (1,1,100) do title 正在放置食物:%%a/100&&call :rans2
:go
title 小蛇出动咯...
set /a ranc+=1
if %ranc% gtr 40 goto :new
::title %t0%,%BZ0%,%t1%,%BZ1%,%t2%,%BZ2%,%t3%,%BZ3%,%time%,%t%
if %chang% gtr %changjx% goto :new
if %th% gtr %BJx% if %cqs% == 1 (goto over) else set th=%BJs%
if %th% lss %BJs% if %cqs% == 1 (goto over) else set th=%BJx%
if %tl% gtr %BJy% if %cqs% == 1 (goto over) else set tl=%BJz%
if %tl% lss %BJz% if %cqs% == 1 (goto over) else set tl=%BJy%
set /a t=10000+th*100+tl*2
if !S%t%! == 1 set /a tl=tlc,th=thc&&goto ran
set ranc=0
if !S%t%! == 2 call :rans
set s%t%=1
for /l %%a in (1,1,%chang%) do set /a a=%%a-1&set t!a!=!t%%a!&set BZ!a!=!BZ%%a!
set t%chang%=%t%
if not "%t0%" == "" set s%t0%=0&set SYBCS=%t0%f1
set /a BZW=chang-1
set /a BZW2=chang-2
for /l %%a in (2,1,%BZW2%) do set SYBCS=!SYBCS!;:!t%%a!1f!BZ%%a!
set /a thc=th,tlc=tl
set /a tc=10000+thc*100+tlc*2
if %thf% == -0 if %f1% == -1 (set bz=!SYBK%ys%:~0,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~4,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~1,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~1,1!))))
if %thf% == +0 if %f1% == -1 (set bz=!SYBK%ys%:~2,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~5,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~1,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~1,1!))))
if %thf% == -1 if %f1% == -1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~5,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~4,1!))))
if %thf% == +1 if %f1% == -1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~2,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~0,1!))))
set BZ%BZW%=%BZ%
set f1=%thf%
set SYBCS=!SYBCS!;:!to!1f%bz%
set BZ%chang%=%bz%
set to=%tc%
set bz2=%bz%
set SYBCS=!SYBCS!;:!t%chang%!C1:D
::echo %SYBCS%>>sy.txt
call :SYBCS
::pause>nul
:ran
set /a ran=%random%%%%hd%
if %ran% == 0 if not %thf% == -1 set thf=+1&set tlf=-0
if %ran% == 1 if not %thf% == +1 set thf=-1&set tlf=+0
if %ran% == 2 if not %tlf% == -1 set tlf=+1&set thf=-0
if %ran% == 3 if not %tlf% == +1 set tlf=-1&set thf=+0
set /a th=th%thf%,tl=tl%tlf%
goto go
:rans
set !S%t%!=0
set /a chang2=chang,chang+=1
set t%chang%=!t%chang2%!
call :SYBC 12400f0长度: ;
:rans2
set /a rh=%random%%%bjh+bjs,rl=%random%%%bjl+bjz
set /a rt=10000+rh*100+rl*2
if "!s%rt%!" == "1" goto rans2
if "!s%rt%!" == "2" goto rans2
set S%rt%=2
call :SYBC %rt%f2◎
goto :eof
:over
pause
:SYBCS
(ECHO.%SYBCOM:`=&ECHO.DW %&ECHO.%SYBCV:`=&ECHO.%)|DEBUG>NUL
goto :EOF
:SYBC
IF "%1" == "" SET SYBCCD=00&GOTO SYBCC
SET SYBCCD=54
set SYBCC=%*
:SYBCC
SET V=`A80`DB %SYBCCD% 00 "%SYBCC%" 0D``RCX`120`G`Q
(ECHO.%SYBCOM:`=&ECHO.DW %&ECHO.%V:`=&ECHO.%)|DEBUG>NUL
EXIT /B %ERRORLEVEL%
```
SYBNQQ:354324773
Floor 3 Posted 2010-03-31 21:16 ·  中国 河北 廊坊 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
Version 1.1.31 of SYBC can already conveniently run directly in memory using DEBUG. Parameters can also be put into the SYBCS variable, and SYBC can find the parameters in memory by itself without the need for DEBUG to act as an intermediary. Using version 1.1.31 of SYBC to call in memory is much faster than being called as a file in version 1.1.21. In actual measurements, in the斗地主 script, the refresh speed is more than one-third faster.
SYBNQQ:354324773
Floor 4 Posted 2010-04-01 12:27 ·  中国 山东 临沂 联通
初级用户
Credits 38
Posts 24
Joined 2010-03-21 19:42
16-year member
UID 162709
Gender Male
Status Offline
Floor 5 Posted 2010-04-01 18:14 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
So many points... I can't handle this now...
Floor 6 Posted 2010-04-01 20:06 ·  中国 广东 佛山 顺德区 电信
初级用户
★★
Credits 151
Posts 106
Joined 2009-10-09 21:24
16-year member
UID 152856
Gender Male
From 河南省
Status Offline
sl543001 boss,,,,really awesome,,,is this code written by yourself????It would be great to have an explanation
Floor 7 Posted 2010-04-02 09:15 ·  中国 浙江 嘉兴 嘉善县 电信
新手上路
Credits 9
Posts 8
Joined 2006-12-15 10:45
19-year member
UID 73608
Gender Male
Status Offline
That's really amazing. How to play it?
Floor 8 Posted 2010-04-02 11:59 ·  中国 河北 廊坊 电信
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
Note: Currently, this code cannot be controlled; it can only be viewed as an animation. There are several similar codes. They are written just for entertainment and to test the stability of SYBC.
=========================================
Code explanation: [I don't know which part of the code everyone needs the most explanation for, so I'll first explain the general idea of the snake game]
Variables T0-TXXX are the coordinates of each part. 1 is the last one, and 0 is the one that has just expired and needs to be erased.
Variables BZ0-BZXXX are the graphics of each part. Generally, it's a tab character.
changdu is the length of the snake. T%changdu% represents the coordinates of the snake head.
Each time the snake moves forward, several FOR loops are executed to make T(n-1) = T(n) and BZ(n-1) = BZ(n).
=========================================

The following code is used to calculate which tab character the neck position should use
if %thf% == -0 if %f1% == -1 (set bz=!SYBK%ys%:~0,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~4,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~1,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~1,1!))))
if %thf% == +0 if %f1% == -1 (set bz=!SYBK%ys%:~2,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~5,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~1,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~1,1!))))
if %thf% == -1 if %f1% == -1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~5,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~4,1!))))
if %thf% == +1 if %f1% == -1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == +1 (set bz=!SYBK%ys%:~3,1!) else (if %f1% == -0 (set bz=!SYBK%ys%:~2,1!) else (if %f1% == +0 (set bz=!SYBK%ys%:~0,1!))))
===========================================

The :ran label is followed by random movement code. The variable HD controls the activity index of the little snake. The larger it is, the more it likes to go straight.
The :rans2 label is followed by randomly generating food. Initially, many will be generated at once.
bjs=0, bjx=24, bjz=0, bjy=39 are the activity limits of the snake. If it exceeds, it will appear on the opposite side.
bjh=23, bjl=38 are no longer useful.
changjx=300 is the limit length
SYBNQQ:354324773
Floor 9 Posted 2010-12-28 12:28 ·  中国 广东 东莞 中移铁通
初级用户
★★
Credits 115
Posts 92
Joined 2010-12-24 16:57
15-year member
UID 179794
Gender Male
Status Offline
Hope to be able to control
Forum Jump: