Hello from down under!

Introduce yourself!

Re: Hello from down under!

Postby Prozwolf » Wed Jun 04, 2014 7:26 am

Okay, here is the code for the new system:
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.
User avatar
Prozwolf
 
Posts: 13
Joined: Thu May 29, 2014 11:57 pm
Location: Melbourne, Victoria, Australia

Re: Hello from down under!

Postby treflip » Wed Jun 04, 2014 5:07 pm

Sweet! those are great bases for games (board, rpg)
I'm surprised you didn't incorporate the coloring schemes... It's not quite that useful though.
Oh and I couldn't see where the bow was or how to exchange with sword..
I'm about to wire up my makeshift gamebuino (I already had the components prior to this- just not the inspiration!). I want to get started with the basics during any free time I can find.

Also I have used C and VHDL languages.. but those were for my engineering classes and nothing for game dev. Still should be helpful for mcu hardware parameter stuff... I'd think!
treflip
 
Posts: 83
Joined: Fri May 30, 2014 4:50 pm
Location: Florida

Re: Hello from down under!

Postby Prozwolf » Thu Jun 05, 2014 1:36 am

To switch between a sword and a bow you can press M, however, the bow is quite buggy.

I didn't incorporate any colour schemes because cmd isn't really built for graphics, there's only foreground and background colour. i used 0F to make the text more obvious on the background. all the other colours in CMD are bad though.
User avatar
Prozwolf
 
Posts: 13
Joined: Thu May 29, 2014 11:57 pm
Location: Melbourne, Victoria, Australia

Re: Hello from down under!

Postby HTel » Thu Jun 12, 2014 9:33 pm

You guys know how to extract 1 word from a txt document and print a document in .bat? If your still interested, this may help making save files for your game. You probably already know(using echo and for /f), but if not:
Code: Select all
//save.txt is the document you would like to extract the one word from, have not tested it with 2 yet
//%%a is a token
//That set command is just setting the token to Filloc, you don't need it(obviously),
//I just programmed half of my program with Filloc
for /f "Delims=" %%a in (save.txt) do (
set Filloc=%%a
//The result of the echo will go into %Filnam%.%Ext%, I was making a program that allows you to set a name and extention so you can just rename //that with save.txt or something, this will print %doc1% into the first line of text.
//echo %doc1%>%Filnam%.%Ext%
//To select the next line, just examine this:
echo %doc1%>%Filnam%.%Ext%
echo %doc2%>>%Filnam%.%Ext%
echo %doc3%>>%Filnam%.%Ext%
echo %doc4%>>%Filnam%.%Ext%
//Every ">>" you put will print to the next line selected

I doubt this will be used for much, I just used that to remember custom file location(if %CD% is somehow unreliable) and nicknames. The code will take the first line of save.txt in the current directory and then print "ECHO is off" into ".", better do some editing!!
HTel
 
Posts: 30
Joined: Tue May 27, 2014 4:47 pm

Previous

Return to Presentation

Who is online

Users browsing this forum: No registered users and 19 guests

cron