Page 1 of 1

Batch Paint

Posted: 03 May 2017 07:30
by batnoob
EDIT: Batch Paint is here! Please comment on it (I'll take constructive criticism)
:::::::::::::::::::::::::::Board.bat::::::::::::::::::::::::::::

Code: Select all

@echo off

set /a "_CLS=%1, _COLS=_CLS+1, _LNS=%2, _LINS=_LNS+1"
set "wall=%3"
set "chr=%4"
set "charsp=%5"
set "portal=%6"
set "popen=%7"
set "char=%8"

:begin
REM Initialize "top" variable just once, before the main FOR loop
set "top="
for /l %%w in (1 1 %_COLS%) do (
   set "top=%wall%!top!"
)

for /l %%h in (1 1 %_LINS%) do (
   for /l %%w in (1 1 %_COLS%) do (
      If NOT defined %%w@%%h (set "%%w@%%h=%chr%")
   )
)

for /l %%h in (1 1 %_LINS%) do (

   if %%h == 1 echo %wall%%top%%wall%

   set "row="
   for /l %%w in (1 1 %_COLS%) do (
      set "row=!row!!%%w@%%h!"
   )
   set "%charsp%=%char%"
   echo %wall%!row!%wall%
   If %charsp%==%portal% (set "%popen%=%char%")

   IF %%h EQU %_LINS% ECHO %wall%%top%%wall%
)
goto:eof


::::::::::::::::::::::::::::::::::BoardPaint.bat:::::::::::::::::::::::::::::::::::

Code: Select all

@echo off
setlocal EnableDelayedExpansion
::Default color is 0E
color 0E
:menu
:::::::::::::::::::::MENU:::::::::::::::::::::::::::::
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º1. How to Playº
echo º2. PLAY       º
echo º3. Load       º
echo º4. Options    º
echo º5. Exit       º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
choice /c 12345
if %ERRORLEVEL%==1 (Call :Instructions) Else if %ERRORLEVEL%==2 (Call :11a1Creator) Else if %ERRORLEVEL%==3 (Call :view) Else if %ERRORLEVEL%==4 (Call :Options) Else if %ERRORLEVEL%==5 (exit)

goto menu
:11a1Creator
cls
if not defined cs (set cs=30)
if not defined ls (set ls=15)
set "ch=±"
set "wl=Û"
echo Type the character to paint with.
echo Type 'D' without the quotes for default.
echo (case sensitive)
set /p "cc=Û is default: "

if %cc%==D (set cc=Û)
set "con=%cc%"

:: _CS and _LS need to be changed during the game
set /a "_CS=cs/2+1, cls=cs+10, _LS=ls/2+1, lns=ls+10"

:: rb and tb need to stay constant
set /a "rb=cs+1, bb=ls+1"

mode con cols=%cls% lines=%lns%
CALL :spinner 15
:game
cls
echo %_CS%@%_LS%>Board%cls%%lns%.txt

CALL board.bat %cs% %ls% %wl% %ch% %_CS%@%_LS% 14@7 7@14 %cc%>>Board%cls%%lns%.txt
type Board%cls%%lns%.txt

choice /c dawsrxcp>nul
set mov=%ERRORLEVEL%

if %mov% == 1 (call :right) else if %mov% == 2 (call :left) else if %mov% == 3 (call :up) else if %mov% == 4 (call :down) else if %ERRORLEVEL%==5 (goto :11a1Creator) else if %ERRORLEVEL%==6 (CALL :exit&Goto:eof) else if %ERRORLEVEL%==7 (set cc=%ch%) else if %ERRORLEVEL%==8 (set cc=%con%)

goto :game

:right
   set /a _CS=%_CS%+1
   if %_CS%==%rb% (set _CS=1)
goto:eof

:left
   set /a _CS=%_CS%-1
   if %_CS%==0 (set _CS=%rb%)
goto:eof

:up
   set /a _LS=%_LS%-1
   if %_LS%==0 (set _LS=%bb%)
goto:eof

:down
   set /a _LS=%_LS%+1
   if %_LS%==%bb% (set _LS=1)
goto:eof





:spinner

set len=%1

for /f %%g in ('"prompt $H &for %%b in (1) do rem"') do set "BS=%%g"

<nul set /p "=Processing Request  "

for /l %%i in (1 1 %len%) do for %%j in (^| / - \) do (
 <nul set /p "=%BS%%%j"
 >nul ping -n 1 localhost
)
echo.
goto:eof

:Instructions
cls
echo Board Painting v1.5
echo.
echo Use WASD keys to move.
echo Use C and P to toggle between erase and draw (respectively).
echo Use R to place your player at the starting position.
echo Use the X key to exit
<nul set /p "=Press any key to Play..."
pause>nul
goto:eof

:exit
   choice /m "Do you want to save the picture you made?"
   if %ERRORLEVEL%==1 (
      set /p "save=Type the filename: "
      type Board%cls%%lns%.txt>!save!.batmp.txt
      attrib +R !save!.batmp.txt
   )
   del Board%cls%%lns%.txt
   start %~n0.bat
   exit
goto:eof

:view
   cls
   set /p "save=Type the filename: "
   cls
   if !save!==dir (dir /R&pause&exit /b)
   type !save!.batmp.txt
   pause
goto:eof

:options
   cls
   echo C - Color
   echo S - Size

   choice /c CS
   if %ERRORLEVEL%==1 (
      set /p "color=New Color: "
      color !color!
   ) else if %ERRORLEVEL%==2 (
      echo Type the number of columns, lines is equal to half that.
      set /p cs=
      set /a ls=!cs!/2
   )


Thanks again to everybody who answered my questions,
BatNoob

Re: Batch Paint

Posted: 03 May 2017 09:54
by PaperTronics
Batch Paint is like a basic version of BPaint. It's not made by me but by Kvc (aka Karanveer Chouhan) who's another great programmer and my friend.

Bpaint : http://www.mediafire.com/file/zxhqlu1bt18395a/Bpaint+by+kvc.zip

I'm not saying that you copied his idea or he did yours, I'm just saying that you'll have a tough competitor for your program. :wink:

Re: Batch Paint

Posted: 11 May 2017 11:16
by batnoob

[UPDATE]
Version 1.5 -- added coloring abilities and choice between drawing and movement.
Previous batmp.txt files will NOT be compatible with current version of batch Paint