WSAD to move, IJKL to attack in that specific direction, however, the bow is a bit buggy.
The spawning location for the enemy is also kinda buggy, but i just really can't be stuffed fixing it...
- Code: Select all
@echo off
setlocal EnableDelayedExpansion
color 0F
title Attack Minigame by Wolfe Lumi
set/a xpos=12
set/a ypos=6
set/a expos=0
set/a eypos=0
set/a e.hp=100
set/a weapon=1
set/a score=0
set/a en.random=%random% %% 3 + 1
if %en.random%==1 set _en=@
if %en.random%==2 set _en=J
if %en.random%==3 set _en=X
::weapon: 1 = Short ranged. 2 = Long ranged.
set array[0]=##############################
set array[1]=# #
set array[2]=# #
set array[3]=# #
set array[4]=# #
set array[5]=# #
set array[6]=# #
set array[7]=# #
set array[8]=# #
set array[9]=# #
set array[10]=# #
set array[11]=# #
set array[12]=# #
set array[13]=# #
set array[14]=# #
set array[15]=# #
set array[16]=##############################
::load
::ypos
for /l %%G in (0,1,16) do (
::xpos
for /l %%H in (1,1,30) do (
set c.line=!array[%%G]:~0,%%H!
set c.tile=!c.line:~-1!
set tilepos[%%H.%%G]=!c.tile!
)
)
::init
set/a expos=%random% %% 30 +1
set/a eypos=%random% %% 16 +1
:loop
call:display
call:move
if %e.hp% lss 1 goto:reset
goto:loop
:reset
set/a score+=10
set/a e.hp=100 + (%score% *( %random% %% 5)) + %score%
set tilepos[%expos%.%eypos%]=#
set/a expos=%random% %% 30 +1
set/a eypos=%random% %% 16 +1
set/a en.random=%random% %% 3 + 1
if %en.random%==1 set _en=@
if %en.random%==2 set _en=J
if %en.random%==3 set _en=X
goto:loop
:f.random
::usage call:f.random min max
set/a funct.return=(%random% %% (%2 - %1 + 1)) + %1
goto:eof
:display
cls
set tilepos[%xprev%.%yprev%]=
set tilepos[%xpos%.%ypos%]=+
set tilepos[%expos%.%eypos%]=%_en%
::final process
for /l %%G in (0,1,16) do (
echo. !tilepos[1.%%G]!!tilepos[2.%%G]!!tilepos[3.%%G]!!tilepos[4.%%G]!!tilepos[5.%%G]!!tilepos[6.%%G]!!tilepos[7.%%G]!!tilepos[8.%%G]!!tilepos[9.%%G]!!tilepos[10.%%G]!!tilepos[11.%%G]!!tilepos[12.%%G]!!tilepos[13.%%G]!!tilepos[14.%%G]!!tilepos[15.%%G]!!tilepos[16.%%G]!!tilepos[17.%%G]!!tilepos[18.%%G]!!tilepos[19.%%G]!!tilepos[20.%%G]!!tilepos[21.%%G]!!tilepos[22.%%G]!!tilepos[23.%%G]!!tilepos[24.%%G]!!tilepos[25.%%G]!!tilepos[26.%%G]!!tilepos[27.%%G]!!tilepos[28.%%G]!!tilepos[29.%%G]!!tilepos[30.%%G]!
)
if %weapon%==1 set weapon.w=Sword
if %weapon%==2 set weapon.w=Bow
echo CharX:%xpos%
echo CharY:%ypos%
echo Enemy health: %e.hp%
echo Weapon equiped: %weapon.w%
echo EneX:%expos%
echo EneY:%eypos%
echo Score: %score%
goto:eof
:move
choice /n /c wasdijklm >nul
set label=%errorlevel%
set errorlevel=
set xprev=!xpos!
set yprev=!ypos!
set xatt=!xpos!
set yatt=!ypos!
goto:move[%label%]
:move[1]
set/a ypos-=1
goto:collide
:move[2]
set/a xpos-=1
goto:collide
:move[3]
set/a ypos+=1
goto:collide
:move[4]
set/a xpos+=1
goto:collide
:move[5]
set/a yatt-=1
goto:attcollide
:move[6]
set/a xatt-=1
goto:attcollide
:move[7]
set/a yatt+=1
goto:attcollide
:move[8]
set/a xatt+=1
goto:attcollide
:move[9]
if %weapon%==1 (
set/a weapon=2
goto:eof
)
if %weapon%==2 (
set/a weapon=1
goto:eof
)
:collide
::findtile
::collisionevent - wall
if "!tilepos[%xpos%.%ypos%]!"=="#" (
set xpos=!xprev!
set ypos=!yprev!
set tilepos[%xprev%.%yprev%]=+
goto:eof
)
goto:eof
:attcollide
if %weapon%==2 goto attcollide.r
call:f.random 6 14
if "!tilepos[%xatt%.%yatt%]!"=="%_en%" (
set/a e.hp-=%funct.return%
goto:eof
)
goto:eof
:attcollide.r
call:f.random 2 8
::attack up
if %label%==5 (
for /l %%G in (1,1,%ypos%) do (
if "!tilepos[%xpos%.%%G]!"=="%_en%" (
set/a e.hp-=%funct.return%
goto:eof
)
)
)
::attack left
if %label%==6 (
for /l %%G in (1,1,%xpos%) do (
if "!tilepos[%%G.%ypos%]!"=="%_en%" (
set/a e.hp-=%funct.return%
goto:eof
)
)
)
::attack down
set/a ytocheck=15-%ypos%
if %label%==7 (
for /l %%G in (%ypos%,1,!ytocheck!) do (
if "!tilepos[%xpos%.%%G]!"=="%_en%" (
set/a e.hp-=%funct.return%
goto:eof
)
)
)
::attack right
set/a xtocheck=40-%xpos%
if %label%==8 (
for /l %%G in (%xpos%,1,!xtocheck!) do (
if "!tilepos[%%G.%ypos%]!"=="%_en%" (
set/a e.hp-=%funct.return%
goto:eof
)
)
)
goto:eof
The only reason why i use CMD is because i don't know any other languages, but CMD itself is still pretty interesting.
I'm not 100% sure what you mean by rougelike, so i can't really comment on that.
As for art and coding, that's a tough decision, i do like working with something that looks good, however, in the end, i think i'd go for coding as i can draw, but not too well. I do like drawing though.
Also - something else i made when i got bored. I had a free period today and i whipped this up in 30 minutes or so.
Two weeks ago, it wouldn't have been possible for me to make this because i didn't know about the syntax - but a bit of research and hard work paid off.
(it's a noughts and crosses game)
- Code: Select all
@echo off
setlocal EnableDelayedExpansion
title Noughts and Crosses by Wolfe Lumi
:start
set/a turn=1
for /l %%G in (1,1,3) do (
for /l %%N in (1,1,3) do (
set tilepos[%%G.%%N]=
)
)
::loop
:loop
call:display
call:check
call:move
goto:loop
:display
cls
echo.
echo. 1 2 3
echo. ###########
for /l %%G in (1,1,3) do (
echo. # #
echo. %%G# !tilepos[1.%%G]! !tilepos[2.%%G]! !tilepos[3.%%G]! #%%G
echo. # #
)
echo. ###########
echo. 1 2 3
goto:eof
:move
if %turn%==2 echo. Cross' Turn
if %turn%==1 echo. Nought's Turn
set/p xpos=X:
if %xpos%==e goto:start
set/p ypos=Y:
if %ypos%==e goto:start
set pos=%xpos%.%ypos%
if not "!tilepos[%pos%]!"==" " goto:move
if %turn%==1 goto:turn1
set/a turn=1
set tilepos[%pos%]=X
goto:eof
:turn1
set/a turn=2
set tilepos[%pos%]=O
goto:eof
:check
::check horizontal
for /l %%G in (1,1,3) do (
for %%N in (X,O) do (
if "!tilepos[1.%%G]!!tilepos[2.%%G]!!tilepos[3.%%G]!"=="%%N%%N%%N" goto:%%N.win
)
)
::check vertical
for /l %%G in (1,1,3) do (
for %%N in (X,O) do (
if "!tilepos.[%%G.1]!!tilepos[%%G.2]!!tilepos[%%G.3]!"=="%%N%%N%%N" goto:%%N.win
)
)
::check diagnal
::diagnal down
for %%N in (X,O) do (
if "!tilepos[1.1]!!tilepos[2.2]!!tilepos[3.3]!"=="%%N%%N%%N" goto:%%N.win
)
::diagnal up
for %%N in (X,O) do (
if "!tilepos[3.3]!!tilepos[2.2]!!tilepos[1.1]!"=="%%N%%N%%N" goto:%%N.win
)
goto:eof
:x.win
cls
call:display
echo.
echo. Crosses win!
pause >nul
goto:start
:o.win
cls
call:display
echo.
echo. Noughts win!
pause >nul
goto:start
Thanks, Wolfe.