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-07-02 00:10
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Discussion]How to Write Game Scripts View 2,163 Replies 16
Original Poster Posted 2009-09-18 22:22 ·  中国 福建 厦门 电信
初级用户
Credits 36
Posts 22
Joined 2009-09-12 00:31
16-year member
UID 151867
Gender Male
From 厦门
Status Offline
Little brother wants to write a game script, don't know where to start. Please ask the expert for guidance, which aspects should start with, what is the general step? Thanks
Floor 2 Posted 2009-09-18 23:05 ·  中国 福建 厦门 电信
初级用户
Credits 36
Posts 22
Joined 2009-09-12 00:31
16-year member
UID 151867
Gender Male
From 厦门
Status Offline
Bump it myself, please ask the experts for guidance
Floor 3 Posted 2009-09-30 20:37 ·  中国 北京 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
@ECHO OFF
COLOR F2
TITLE SYBN#
setlocal ENABLEDELAYEDEXPANSION
mode con cols=35 lines=10
SET M=●&SET N=○&SET K=·
:BEGAIN
SET WZ=22&SET XX=%M%&SET XZ=%M%&SET WIN=%K%&SET XZ2=%N%&set sl=0
for /l %%a in (-20,1,59) do (
SET K%%a=%K%
)
:xz
if %sl% gtr 8 set WIN=Nobody&goto win
CALL :XX
IF %XZ% == %M% (
CALL :LZ
) ELSE (
CALL :LZ
)
CALL :YZ
IF %P% == ERR GOTO XZ
SET XZ3=%XZ%
SET XZ=%XZ2%
SET XZ2=%XZ3%
IF NOT %WIN% == %K% GOTO WIN
GOTO XZ
:WIN
CLS
call :XX
ECHO %win%Wins!
PAUSE
GOTO BEGAIN
:LZ
SET /P P=%XZ%:
IF "%P%" == "" SET LZ=22
for /l %%a in (1,1,3) do (
for /l %%b in (1,1,3) do (
if %p% == %%a%%b SET LZ=%P%&set wz=%p%&goto :eof
)
)
if "%p%" == "cmd" %p%
if %p% == "0" GOTO BEGAIN
if %p% == 1 SET LZ=31&set wz=31&goto :eof
if %p% == 2 SET LZ=32&set wz=32&goto :eof
if %p% == 3 SET LZ=33&set wz=33&goto :eof
if %p% == 4 SET LZ=21&set wz=21&goto :eof
if %p% == 5 SET LZ=22&set wz=22&goto :eof
if %p% == 6 SET LZ=23&set wz=23&goto :eof
if %p% == 7 SET LZ=11&set wz=11&goto :eof
if %p% == 8 SET LZ=12&set wz=12&goto :eof
if %p% == 9 SET LZ=13&set wz=13&goto :eof
set lz=22
GOTO :EOF
:YZ
SET P=0
set q=!K%LZ%!
IF NOT %q% == %K% SET P=ERR&GOTO :EOF
set /a sl=sl+1
SET K%LZ%=%XZ%
call :yz2 1
call :yz2 9
call :yz2 10
call :yz2 11
goto :eof
:yz2
set o=%1
SET /A P1=LZ-2*o&SET /A P2=LZ-1*o&SET /A P3=LZ&SET /A P4=LZ+1*o&SET /A P5=LZ+2*o
set q=!K%p1%!!K%p2%!!K%p3%!
if %q% == %xz%%xz%%xz% SET WIN=%XZ%&&GOTO :EOF
set q=!K%p2%!!K%p3%!!K%p4%!
if %q% == %xz%%xz%%xz% SET WIN=%XZ%&&GOTO :EOF
set q=!K%p3%!!K%p4%!!K%p5%!
if %q% == %xz%%xz%%xz% SET WIN=%XZ%&&GOTO :EOF
GOTO :EOF
:XX
for /l %%a in (1,1,3) do (
for /l %%b in (1,1,4) do (
set H%%b%%a=─
set S%%a%%b=│
)
)
for /l %%a in (1,1,3) do (
for /l %%b in (1,1,3) do (
set /a a=%%a+1&set /a b=%%b+1
IF %WZ% == %%a%%b SET H%%a%%b=━&SET H!a!%%b=━&SET S%%a%%b=┃&SET S%%a!b!=┃
)
)
CLS
ECHO ┌%H11%┬%H12%┬%H13%┐ Can directly enter coordinates
ECHO %S11%%K11%%S12%%K12%%S13%%K13%%S14% Upper left is 11, lower right is 33
ECHO ├%H21%┼%H22%┼%H23%┤ Also can follow the numeric keypad
ECHO %S21%%K21%%S22%%K22%%S23%%K23%%S24% number arrangement control
ECHO ├%H31%┼%H32%┼%H33%┤ Enter 0 to start over
ECHO %S31%%K31%%S32%%K32%%S33%%K33%%S34% Invalid input will enter again
ECHO └%H41%┴%H42%┴%H43%┘ QQ:354324773
GOTO :EOF
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
523066680 +9 2009-10-01 09:36
kirov +4 2009-10-01 14:13
Floor 4 Posted 2009-09-30 22:22 ·  中国 上海 杨浦区 电信
版主
★★
Pfc.YangZJ
Credits 412
Posts 223
Joined 2008-12-31 19:28
17-year member
UID 135466
Gender Male
From 上海杨浦
Status Offline
This seems to be within the scope of the batch processing room, right?
以牙还牙,加倍奉还。

----BH4EAW 杨志杰

Blog:我的blog
Floor 5 Posted 2009-10-01 09:41 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
It's fun to play on the 3rd floor~ If it's a major modification, it can be made more compact.
Floor 6 Posted 2009-10-01 09:43 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
I originally wanted to make a game where a sports car jumps over obstacles after seeing this post. I only did part of it, and since the screen kept flashing, I lost interest.


@echo off
if "%1"=="go" (goto :input) else (start %~s0 go)
mode con cols=20 lines=15
title running~ &setlocal enabledelayedexpansion
for /l %%a in (1,1,12) do (set way%%a=## ##)
for /l %%a in (1,3,12) do (set way%%a=!way%%a:#= !)
set wayb1=%way2%
set wayb2=%way1%
set wayb3=%way2%
set "che7=oiio"
set "che8= ## "
set "che9=O##O"

set /a fa=13
:la
set /a fb=fa-1,act=0
for /l %%a in (%fa%,1,12) do (set /a act+=1 &set ln!act!=!way%%a!)
for /l %%b in (1,1,%fb%) do (set /a act+=1 &set ln!act!=!way%%b!)
::
for %%a in (7,8,9) do (set ln%%a=!ln%%a:~0,4!!che%%a!!ln%%a:~8!)
ping -n 1 127.1>nul
cls
for /l %%a in (1,1,12) do (echo, ║!ln%%a!║)
if %fa% gtr 1 (set /a fa-=1) else (set /a fa=12)
set /a cut=fa,new=cut%%3+1
set way%cut%=!wayb%new%!
goto :la



:input
mode con cols=20 lines=3
set /p inp="输入:"



[ Last edited by 523066680 on 2009-10-1 at 09:47 ]
Floor 7 Posted 2009-10-01 09:57 ·  中国 北京 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
The Tic - Tac - Toe game I posted doesn't have an AI. It's not that I didn't write it, but that I'm still writing it. The current AI is based on my own level, and I'm researching better AI algorithms!
Floor 8 Posted 2009-10-01 09:58 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Uh-huh Uh-huh……
I can hardly imagine that for Tic-Tac-Toe, generally the best result is a draw between the two sides.
Unless the local machine goes first, I remember there is a route with two paths, and if you occupy that point first, it's okay.

But achieving the best result means a draw. So……

[ Last edited by 523066680 on 2009-10-1 at 10:03 ]
Floor 9 Posted 2009-10-01 10:11 ·  中国 北京 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
I have considered all those two paths and all the angle lines using the brute-force method!
Now the research is about making the script calculate like playing chess, calculating all possibilities and then outputting the result. It seems a bit complicated!
===========================================
Regarding the racing game: Since the script operation speed is low, we must find a way to improve it.
We can consider outputting a txt text and then TYPE, but it is estimated that the effect is not very good.
We can also store the content output by n lines into the same variable, and echo it all at once (using the ^ symbol at the end of the line to assign multiple lines of text to the variable).
Finally, the best suggestion is to invert the screen, that is, the car drives from top to bottom. In this way, only one line needs to be output each time, but the car in the game should be placed in the title as much as possible.
Floor 10 Posted 2009-10-01 10:44 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Think carefully, the path can be like this, but the position of the car itself... And the ultimate goal is to make the car movable,刷屏 is inevitable,刷屏 is not good, not doing it.
Floor 11 Posted 2009-10-01 11:44 ·  中国 北京 联通
中级用户
★★
Credits 499
Posts 225
Joined 2008-12-30 22:09
17-year member
UID 135392
Gender Male
Status Offline
Try making the cmd window smaller, for example 20*20 bytes. A smaller window should make screen refreshing faster.
Floor 12 Posted 2009-10-01 12:22 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
Instead of using cls, try to find a way to return the cursor directly to 1.1 and then echo!buff!, where buff is the entire screen. This can solve the "flickering" problem. Reference: http://www.cn-dos.net/forum/viewthread.php?tid=48603&fpage=2

[ Last edited by netbenton on 2009-10-1 at 10:24 ]
精简
=> 个人网志
Floor 13 Posted 2009-10-01 15:18 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
But trying to find a way to get the cursor back to position 1,1 again

Wow, you want us to look at 1000 characters of data...
How to get back to coordinate 1,1 without using Cls, please explain.

Uh, I looked at your subsequent explanation, did you store the entire screen information in str, and then just an echo would work?

[ Last edited by 523066680 on 2009-10-1 at 15:20 ]
Floor 14 Posted 2009-10-01 23:08 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline
The following is the debug code test to make the cursor return to 1.1 and accept keyboard input to give the return code

**The disadvantage of using this method is that the screen can only be 80 characters wide.**

@goto :begin
e 100 cd 16 86 c4 b4 02 cd 10 b4 4C CD 21
g
:begin
@echo off
pushd "%~dp0"
chcp 437 >nul
graftabl 936 >nul
::It is necessary in use.

:loop
echo;
echo;Please press any key at will...
debug <"%~nx0">nul
echo The return code of the just pressed key is: %errorlevel%
goto :loop
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
523066680 +15 2009-10-02 09:34
精简
=> 个人网志
Floor 15 Posted 2009-10-02 09:34 ·  中国 广东 广州 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Another line: "Wow! It feels so good to use!"
Forum Jump: