中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 13:15
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Original] Colorful Snake Game Green without 3rd-party files Based on SYBC1.1.31
Printable Version  2,265 / 8
Floor1 sl543001 Posted 2010-03-31 21:12
中级用户 Posts 225 Credits 499
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 (11.31 KiB)
Floor2 sl543001 Posted 2010-03-31 21:12
中级用户 Posts 225 Credits 499
```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%
```
Floor3 sl543001 Posted 2010-03-31 21:16
中级用户 Posts 225 Credits 499
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.
Floor4 yiqingnan Posted 2010-04-01 12:27
初级用户 Posts 24 Credits 38
Floor5 523066680 Posted 2010-04-01 18:14
银牌会员 Posts 1,133 Credits 2,362
So many points... I can't handle this now...
Floor6 zaixinxiangnian Posted 2010-04-01 20:06
初级用户 Posts 106 Credits 151 From 河南省
sl543001 boss,,,,really awesome,,,is this code written by yourself????It would be great to have an explanation
Floor7 pan542 Posted 2010-04-02 09:15
新手上路 Posts 8 Credits 9
That's really amazing. How to play it?
Floor8 sl543001 Posted 2010-04-02 11:59
中级用户 Posts 225 Credits 499
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
Floor9 acaigg Posted 2010-12-28 12:28
初级用户 Posts 92 Credits 115
Hope to be able to control
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023