![]() |
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-11-16 15:39 |
47,820 topics / 349,936 posts / today 0 new / 48,295 members |
| DOS批处理 & 脚本技术(批处理室) » [Original] Push Box Batch Processing Game |
| Printable Version 14,696 / 63 |
| Floor31 netbenton | Posted 2009-09-10 12:37 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
1. Increase to support the use of super large maps, referring to more than one screen.
2. Add a verification function of the map by the compression conversion program, and prompt when characters other than the map appear. 3. Develop a map editing program hdt.bat. Use this program to quickly edit full-width character maps for maze walking, box pushing, etc. **Please see the attachment enhanced version on the first floor** [ Last edited by netbenton on 2009-9-16 at 09:47 ] |
|
| Floor32 netbenton | Posted 2009-09-16 11:51 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
Add 12 easier levels to the Sokoban game. Just add the following code to the level data after the batch Sokoban program. It is recommended to insert it into the third line of the level data.
|
|
| Floor33 zzybq | Posted 2009-09-17 00:13 |
| 初级用户 Posts 22 Credits 36 From 厦门 | |
| Floor34 plp626 | Posted 2009-09-19 12:40 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
Very good, proficient in assembly, learned...
|
|
| Floor35 netbenton | Posted 2009-09-30 00:24 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
The original has been duplicated, forget it, just correct some typos...
Explanation of Batch Push-Square Source Code: 1. Use of Compact Format for Data Definition First, put the variable definition set into a variable: (Note that the delimiter is unique, here using the ";" sign) set a=a=i75;b=i79;str=abc So the value of variable a is: a=i75;b=i79;str=abc Use variable value replacement during preprocessing: set %a:;=&set % Equivalent to the following statements being executed: set a=i75&set b=i79&set str=abc Or: set a=i75 set b=i79 set str=abc If there are many variables to define, comprehensively considering from the perspective of occupied space and readability, this method has obvious advantages. 2. Implementation Algorithm of Push-Square Program 1). Read the level data into the array: lev(n) Change the value of n, which is to change the level, here n is %lev% 2). Restore the current level map data and store it in the two-dimensional array: r(n).(m) (1) Collect the variable names r(n).(m) with the value "☆" into variable ke, and store the number of "☆" into variable ji, and convert them to "★" at the same time; Note: ke saves the variable name, not the variable value. %ke% expansion later is the real-time value of all two-dimensional variables with the source value "☆"; as long as %ke% is equal to !ji! indicates that the level is passed (2) Store the two-dimensional variable names as an array: r(n) by row, Note: it is the variable name %r(n)% expansion later is the real-time value of all two-dimensional arrays in row n 3). Variable ebuf is used as a display buffer, all content to be displayed is stored in ebuf, and all is displayed at once with echo !ebuf! to achieve fast screen refresh. Because after expansion of for variable %%a, the! number variables in the value will be expanded again, so: for /l %%a in (1,1,!r!) do for %%b in ("!r%%a!") do set ebuf=!ebuf! %%~b!cr! The above sequentially stores the expanded values of the variable name array r(n) from row 1 to!r! into the display buffer ebuf, and adds the newline character!cr! 4). First define the operations for up, down, left and right: "c1=n-;c2=m-;c3=n+;c4=m+" In this way, the following code can be used: set/a sm=m,sn=n,!c%in%!=1,bm=m,bn=n,!c%in%!=1 Respectively obtain the source point: sm.sn, step one: bm.bn, step two: m.n, the values of the three coordinates after pressing up/down/left/right for /f "tokens=1,2" %%a in ("!r%bn%.%bm%! !r%bn%.%bm%!!r%n%.%m%!") do ( Take out the values of the three coordinates and spread them out as: (step one => %%a) (step one + step two =>%%b) For example: %%a=▓ %%b=▓∷ ***Various movable combination types have been variables before*** ***The undefined ones are considered as non-movable combinations*** for %%c in ("!%%a!!%%b!") do ( %%a %%b is re-expanded and grouped to %%c, connected with the previous example:!▓! => empty,!▓∷! =>▓-∷ Then: ▓-∷ => %%c for /f "tokens=1,2 delims=-" %%1 in (%%c) do ( Spread out as: %%1=▓, %%2=∷ Next is the if judgment, and according to various situations, the values of the three points and a "big" standing! source! point are readjusted Note: There is one point, if the value of %%c is empty, such as %%b=▓■, then this for will be idle, that is, even the following if statement will not be executed, making the following set/a m=sm,n=sn be executed, restoring m,n, that is, cannot move 3. Compression and Restoration of Level Data 1). Compression, because full-width is double-byte, using single character conversion can be reduced by half, if ▓=a, zf=▓, then: set zf=!%af%! can be converted back If there is not only one, and there are consecutive ones, then a number is added after the letter to indicate the number of times, such as: a4, if it exceeds 9 times, then another group is started, such as: a11, then split into a9a2 2). Restoration, reference: the advantage of starting with 囧, for /f "tokens=2* delims=囧" %%a in (%~nx0) do (set lev!n!=%%a&set/a n+=1) In this way, when reading, the reading of other non-data lines can be subtracted, and the speed is accelerated Similarly, convert the characters back, and then use for /l counting to repeat to convert all if "!tn:%%2=!" neq "!tn!" (set k=%%2) else (set k=1) for /l %%k in (1,1,!k!) do ( The above!k! is the number of consecutive characters 4. Get rid of choice.exe and no flickering when refreshing the screen That is to use debug.exe instead, but this is usually built into the system, so third-party... debug <%~nx0>nul Call itself as pipeline input, the first line is wrong, only two lines are really useful e 100 cd 16 86 c4 b4 02 cd 10 b4 4C CD 21 Write code g Execute Here, key reading is performed, the current cursor position is set to the first line, first column, and the key data is used as the return code to: %errorlevel% Definition: "a=i83=10;i1=7;i72=1;i80=3;i75=2;i77=4;i73=8;i81=9;i57=5;i79=6" Execute: set in=!i%errorlevel%! You can get the corresponding key according to the definition, if it is not defined, it is empty Usually when writing a batch processing to return to the first line to display, only cls is used, and then display, obviously the speed is also very fast, but still feel a little flickering. Directly reset the cursor to the first line, first column, without clearing the screen, and when displaying again, it is on the original basis, so the feeling of flickering is less If you want to see the assembly source code, it is very simple, remove >nul after debug <%~nx0>nul, and then add a line u between the e line and the g line 5. Player record saving and reading Here, the record is stored in the first line of the batch processing, 1). Reading set/p yg=< %~nx0 >nul Take the first line to variable yg set yg=!yg:~13,52! set lev=%yg:@=&rem % Because the current level record and the passed level record are separated by @, in this way, only the part before @ is given to lev, and the part after @ is commented out by rem set yg= !yg:* =! Take the passed data, and keep that there must be spaces before and after In this way, the data of the current level and the passed levels has been read into the variable [ Last edited by netbenton on 2009-10-5 at 15:46 ] |
|
| Floor36 sl543001 | Posted 2009-10-01 17:17 |
| 中级用户 Posts 225 Credits 499 | |
|
Expert! Great post and expert insights, I've learned a lot! There are many useful things in the script that can be studied. For example, the choice command has always been a big headache, but the LZ has managed to handle it! Who can summarize these useful things? I'm still studying the LZ's code!
|
|
| Floor37 nerfg002 | Posted 2009-10-01 20:59 |
| 初级用户 Posts 24 Credits 24 | |
|
Niu Niu's, there's no way to describe it
|
|
| Floor38 xdjxondaojune | Posted 2009-10-02 22:07 |
| 新手上路 Posts 1 Credits 1 | |
|
The second level is a dead end and cannot be passed. The third level is just numerous and easy to pass. Generally, it is written quite well, and I admire it.
|
|
| Floor39 shenlong | Posted 2009-10-03 20:29 |
| 新手上路 Posts 3 Credits 3 | |
|
Oh my goodness, this level is way too high...................
|
|
| Floor40 livesweet | Posted 2009-10-05 12:27 |
| 初级用户 Posts 45 Credits 86 | |
|
Oh my god, batch processing can also be used to program such a complex game! The thread starter is awesome, I support you!
|
|
| Floor41 voiL | Posted 2009-10-10 07:27 |
| 中级用户 Posts 189 Credits 384 | |
Originally posted by xdjxondaojune at 2009-10-2 22:07: The second level can't be a dead end, brother, think more about it, I reached the third level in less than a minute. |
|
| Floor42 523066680 | Posted 2009-10-10 08:29 |
| 银牌会员 Posts 1,133 Credits 2,361 | |
|
What the 41st floor said is right.
Hey, how could that classmate casually say that was a dead end... |
|
| Floor43 herohdl | Posted 2009-10-12 18:38 |
| 初级用户 Posts 15 Credits 36 | |
| Floor44 RuiIsRui | Posted 2009-10-23 22:22 |
| 新手上路 Posts 13 Credits 14 | |
|
awesome, cool, fun
|
|
| Floor45 zhxy9804 | Posted 2009-10-28 20:31 |
| 中级用户 Posts 97 Credits 208 | |
|
That Tetris is quite awesome, and this one is even more awesome, it's the work of so-called masters
|
|
| Prev 1 2 3 4 5 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |