Solved How do I add a point system for a batch game?! Please Help!!

March 14, 2018 at 11:53:03
Specs: Windows 7
How would I add a point system/counter for a batch game?? I am making a shooting space alien game, I have the movement for my character done, I just need to learn how to code a button I can press that fires a weapon, and then when I kill an alien ship, I get a point and the points are counted... Please help!

See More: How do I add a point system for a batch game?! Please Help!!

Report •

✔ Best Answer
March 21, 2018 at 07:42:23
ive added being able to shoot, auto refresh & problem handling.

bullets now despawn after they hit a wall & lets say bullets 3 now becomes bullet 2 & 2 becomes 1
this way you wont run out of memory haha

next step is adding entities, will add a single character entity every 20 or so seconds

if you want to chance stuff you still can, again keep it simple.

p.s. without a response i wont continue

current version:

::----start-of-shooter.bat----
::this will not show you command inputs/output, but instead only show echo commands
@echo off
::this wil allow variables to be updated within loops, but they need to be called as !variable!, instead of %variable% & allows easier double or triple variables: !var%count%time%%a!
setlocal enabledelayedexpansion
::title of the cmd window
title Shooter
::mode for example changes window size
mode 45,25
:presets
set char=#
::default location of char is now 10,22
::the value of 10,22=#, this is set on one of the first lines of label :screen
::as a variables thats !10,22!
set charx=12
set chary=22
::bullet presets
set bullet=ø
::actually looks like this on screen:"°"
set bulletcount=0
set lookdir=UP
::making the grid, 1~24,1~43
::these 2 lines create the square surrounding the map
for /l %%a in (1,1,24) do for /l %%A in (1,42,43) do set "%%a,%%A=Û"
for /l %%a in (1,23,24) do for /l %%A in (1,1,43) do set "%%a,%%A=Û"
::this line fill everything else with "ÿ", aka en transparant char, looks like an empty cell or " "
for /l %%a in (2,1,23) do for /l %%A in (2,1,42) do set "%%a,%%A=ÿ"
::preparing an empty variable for the screen-vars
set "temp1="
:screen
if !errorlevel! LSS 6 timeout 1 /NOBREAK >nul
::check if bullets need to be rendered/recalculated
if not !bulletcount!==0 call :renderbullets
::clear the screen
cls
::set charx,chary=#
set !charx!,!chary!=!char!
::loop 24*43 times: on every 43 times echo %%a,1 till 43 to the screen
for /l %%a in (1,1,24) do (
for /l %%A in (1,1,43) do (
if %%A LEQ 43 set "temp1=!temp1!!%%a,%%A!"
if %%A==43 echo !temp1!&set "temp1="
)
)
)
choice /c wasdpm /t 1 /d m /n >nul
::choice if passed will return a value 1 & up, depending on how many symbols you gave it
::reset the variable where char is standing if it passes choice
set !charx!,!chary!=ÿ
::actual button that can be pressed, depending on choice (wasdp in this case), w=errorlevel 1, a=errorlevel 2, etc
if !errorlevel!==1 call :UP
if !errorlevel!==2 call :LEFT
if !errorlevel!==3 call :DOWN
if !errorlevel!==4 call :RIGHT
if !errorlevel!==5 call :PISTOL
goto screen
:UP
::add an if statement if you do not want the character to go off the screen
set/a charx-=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=UP
call :randomspawn
exit/b
:LEFT
set/a chary-=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=LEFT
call :randomspawn
exit/b
:RIGHT
set/a chary+=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=RIGHT
call :randomspawn
exit/b
:DOWN
set/a charx+=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=DOWN
call :randomspawn
exit/b
:PISTOL
::what direction is char looking, blablabla
set/a bulletcount+=1
set "bulletx!bulletcount!=%charx%"
set "bullety!bulletcount!=%chary%"
set "bulletdir!bulletcount!=%lookdir%"
for /l %%a in (!bulletcount!,1,!bulletcount!) do set "bullet%%a=!bulletx%%a!,!bullety%%a!
exit/b
:renderbullets
::just strait up render all !bulletcount! bullets
for /l %%a in (1,1,!bulletcount!) do (
::clear the current bullet%%a charx,y & set it to nothing "ÿ"
set "!bulletx%%a!,!bullety%%a!=ÿ"
if "!bulletdir%%a!"=="UP" if not !bulletx%%a!==2 (
set/a bulletx%%a=!bulletx%%a!-1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="LEFT" if not !bullety%%a!==2 (
set/a bullety%%a=!bullety%%a!-1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="RIGHT" if not !bullety%%a!==42 (
set/a bullety%%a=!bullety%%a!+1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="DOWN" if not !bulletx%%a!==23 (
set/a bulletx%%a=!bulletx%%a!+1
) else (
call :shiftbulletcount
)
if not "!%bulletx%%a%,%bullety%%a%!"=="ÿ" (
set tmp=!bullet%%a!
if not !bulletx%%a!==2 (
if not !bullety%%a!==2 (
if not !bullety%%a!==42 (
if not !bulletx%%a!==23 (
echo.
)
)
)
)
) else (
set "bullet%%a=!bulletx%%a!,!bullety%%a!"
)
set "!bulletx%%a!,!bullety%%a!=!bullet!"
)
::check if bullet x,y equals to an entity, so x,y = not ÿ (then call :collision)
exit/b
:shiftbulletcount
::if a bullet hits the wall or bulletcount=43, rmove the bullet & shift all other bullets to the left
::echo this line is for debugging only&pause>nul
set/a bulletcountPLUSone=!bulletcount!+1
for /l %%a in (1,1,!bulletcount!) do (
set "!bulletx%%a!,!bullety%%a!=ÿ"
set "bulletx%%a=!bulletx%bulletcountPLUSone%!"
set "bullety%%a=!bullety%bulletcountPLUSone%!"
set "!bulletx%%a!,!bullety%%a!=!bullet!"
)
set/a bulletcount-=1
exit/b
:randomspawn
:: random is an integer between 0 & 32767
::1638/32767 is about 5% chance of an enemy spawning
::on average every 20 seconds an enemy spawns
if '%random%' LEQ '1638' (
::spawn an enemy, placeholder
echo this is where i wait for a response from OP, only then continue&pause>nul
)
exit/b
::the screen is layed out like:
:: Y--> that way is Y+(from 1 till 43)
:: !1,1!!1,2!!1,3! --> all the way till !1,43!
:: !2,1!!2,2!!2,3!
:: !3,1!!3,2!!3,3!
:: |
:: |
:: v
::all the way till !24,1! & in the right bottom corner !24,43!
::from top to bottom is X+ (from 1 till 24)
::----end-of-shooter.bat----

message edited by hidde663



#1
March 15, 2018 at 02:59:09
post a link to your code, or post the entire .bat file

maby playing this game, will help you out a bit:
https://pastebin.com/Rmf9t2Js

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375c/1940m BiosMod
VS450

message edited by hidde663


Report •

#2
March 15, 2018 at 04:37:18
You can also try this simple "dodge.bat" game:

@echo off&setlocal EnableDelayedExpansion&mode 44,25&color 07&title Dodge&set chary=21&set n=1&set m=0&set maxM=20&set score=-21&set lives=3&set/a maxN=!maxM!*25&set/a maxB=!maxN!+1&set x=3&set y=2&goto Loadmap
:Map
cls&set/a score+=1
if not "!23,%chary%!"=="Û" (set 23,%chary%=#) else (set 23,%chary%=±&set/a lives-=1)
echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
for /L %%a in (3,1,23) do echo Û!%%a,2!!%%a,3!!%%a,4!!%%a,5!!%%a,6!!%%a,7!!%%a,8!!%%a,9!!%%a,10!!%%a,11!!%%a,12!!%%a,13!!%%a,14!!%%a,15!!%%a,16!!%%a,17!!%%a,18!!%%a,19!!%%a,20!!%%a,21!!%%a,22!!%%a,23!!%%a,24!!%%a,25!!%%a,26!!%%a,27!!%%a,28!!%%a,29!!%%a,30!!%%a,31!!%%a,32!!%%a,33!!%%a,34!!%%a,35!!%%a,36!!%%a,37!!%%a,38!!%%a,39!!%%a,40!!%%a,41!!%%a,42!Û
echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
echo SCORE: %score% LIVES: %lives%&if %lives% equ 0 echo GAME OVER&pause>nul&exit/b
choice /c ad9 /t 1 /d 9 /n>nul
if %errorlevel% equ 1 if %chary% gtr 2 set 23,%chary%=ÿ&set/a chary-=1&goto Spawn
if %errorlevel% equ 2 if %chary% lss 42 set 23,%chary%=ÿ&set/a chary+=1&goto Spawn
if %errorlevel% equ 3 goto Spawn
:Spawn
set/a a=%random%*2/32767*32+%random%*2/32767*16+%random%*2/32767*8+%random%*2/32767*4+%random%*2/32767*2+%random%*2/32767*1
if %a% gtr 42 goto Spawn
if %a% lss 2 goto Spawn
set/a m+=1
if %n% leq %maxN% (set/a n+=1) else (set n=1)
set backcounter=1&set entity%n%=2,%a%
if %m% equ %maxM% set m=0&goto Move
goto Spawn
:Move
if %backcounter% equ %maxB% goto map
set tmp=!entity%backcounter%!
for /f "tokens=1,2 delims=," %%a in ("%tmp%") do set temp=%%a&set tmp1=%%b
if !temp! leq 23 (
set !temp!,%tmp1%=ÿ
set/a temp+=1
set !temp!,%tmp1%=Û
set entity%backcounter%=!temp!,%tmp1%)
set/a backcounter+=1&goto Move
:Loadmap
if !x! equ 24 goto Map
set "%x%,%y%=ÿ"
if !y! equ 43 set/a x+=1&set y=1&goto loadmap
set/a y+=1&goto loadmap

message edited by hidde663


Report •

#3
March 15, 2018 at 08:15:27
hmmm, the game loaded but didn't do anything, did I do something wrong or is that how it is supposed to be?

Report •

Related Solutions

#4
March 15, 2018 at 08:43:18
Oh s--- wrong version, will update my post

its supposed to drop boxes from top to bottom, you can move you character (#), with the A & D key.
Dodge the boxes to increase your score

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450

message edited by hidde663


Report •

#5
March 15, 2018 at 08:49:50
still isn't working, the character (#) stays there even if I press A and D to move, and there are no blocks falling, am I doing something wrong?

Report •

#6
March 15, 2018 at 08:52:36
oh okay, just noticed you said you would update it, Ill wait for a little if you need. I got people helpn me with some other stuff here at school for my batch game.

Report •

#7
March 15, 2018 at 08:53:38
try again, i think you where to fast to respond

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#8
March 15, 2018 at 08:55:20
btw did you you try the first link i gave you?

save that pastebin file as PokeBatch2(D).bat

&run it (disable sound, as it is still work in progress)
i kinda spend a few summers on it :)

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450

message edited by hidde663


Report •

#9
March 15, 2018 at 09:00:03
I cant it wont let me use it, here at my high school, freshman like me have a lot of website blockers, so that sucks! Lol

Report •

#10
March 15, 2018 at 09:02:24
Nvm, it works now, that is a fun game, I like the idea of it!

Report •

#11
March 15, 2018 at 09:03:27
And how do I get my character in my game ([}) to shoot bullets (-)??? That's all I need now

Report •

#12
March 15, 2018 at 09:08:53
well i was thinking, since you do not really have a grid(map) of values, you cant really give them a value.

so i think its best if we start off with a square, lets say 24 height by 43 in lenght(using those number so i can re-use some old code)

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#13
March 15, 2018 at 09:13:13
using a command like this:
for /l %%a in (1,1,24) do for /l %%A in (1,1,43) do echo %%a,%%A=Û

Û is char code:219

here is a lookup table:
http://www.theasciicode.com.ar/

you can generate the variables (using echo here so you can see what i mean)

now lets set the values instead of echoing them to the screen:

for /l %%a in (1,1,24) do for /l %%A in (1,1,43) do set "%%a,%%A=Û"

in my next post ill try to draw the grid alright

after that ill show you how to manipulate the variables, make entity's & then ill let you go make you game ^^

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450

message edited by hidde663


Report •

#14
March 15, 2018 at 09:16:31
damn dude, I have to use basic codes to make my games, so by learning all this, is gonna be so much damn fun!!! Let's do this s---

Report •

#15
March 15, 2018 at 09:30:01
This is my movement:
Use W to go up
Use S to go down

@setlocal enableextensions enabledelayedexpansion
@echo off
color 0a

set length=
set height= a

:var
cls
echo.
for %%a in ( %height% ) do echo.
echo [}
choice /c wasd /n
if %errorlevel% equ 1 call:up
if %errorlevel% equ 2 call:left
if %errorlevel% equ 3 call:down
if %errorlevel% equ 4 call:right

@echo off
:left
set length=!length:~0,-1!
goto var

@echo off
:right
set length=%length%
goto var

@echo off
:up
set height=!height:~0,-2!
goto var

@echo off
:down
set height=%height% a
goto var


Report •

#16
March 15, 2018 at 09:39:04
i, gtg for today, but ill help you out tomorrow, this will let you walk using WASD

edit: use notepad++, so you can see better what what is :)

@echo off&setlocal enabledelayedexpansion
:presets
set char=#
set charx=10
set chary=22
::making the grid, 1~24,1~43
for /l %%a in (1,1,24) do for /l %%A in (1,1,43) do set "%%a,%%A=Û"
:screen
set !charx!,!chary!=!char!
cls
set "temp1="
for /l %%a in (1,1,24) do (
for /l %%A in (1,1,43) do (
if %%A LEQ 43 set "temp1=!temp1!!%%a,%%A!"
if %%A==43 echo !temp1!&set "temp1="
)
)
)
choice /c wasd /n >nul
::choice if passed will return a value 1 & up, depending on how many symbols you gave it
::reset the variable where char is standing if it passes choice
set !charx!,!chary!=Û
if !errorlevel!==1 goto UP
if !errorlevel!==2 goto LEFT
if !errorlevel!==3 goto DOWN
if !errorlevel!==4 goto RIGHT
::if !errorlevel!==5 goto PISTOL
:UP
::add an if statement if you do not want the character to go off the screen
set/a charx-=1
goto screen
:LEFT
set/a chary-=1
goto screen
:RIGHT
set/a chary+=1
goto screen
:DOWN
set/a charx+=1
goto screen
:PISTOL
::what direction is char looking, blablabla
goto screen

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450

message edited by hidde663


Report •

#17
March 15, 2018 at 09:45:55
Damn dude, you're the best, thanks @hidde663 for everything today, im gonna study this code for the rest of my 3rd period at school, and learn as much as possible!

Report •

#18
March 15, 2018 at 09:49:19
And what button do I have to press to use the pistol??

Report •

#19
March 15, 2018 at 14:36:43
p, but there is no subroutine yet, curently just goes back to :screen
also ive made this line a comment:
::if !errorlevel!==5 goto PISTOL

removing :: & changing:
choice /c wasd /n >nul
to choice /c wasdp /n >nul
will let it jump to :Pistol if P is pressed

btw you can look up the "short" explaination by running a command in cmd.exe

for example:

choice /?

will give you this explanation:

CHOICE [/C choices] [/N] [/CS] [/T timeout /D choice] [/M text]

Description:
This tool allows users to select one item from a list
of choices and returns the index of the selected choice.

Parameter List:
/C choices Specifies the list of choices to be created.
Default list is "YN".

/N Hides the list of choices in the prompt.
The message before the prompt is displayed
and the choices are still enabled.

/CS Enables case-sensitive choices to be selected.
By default, the utility is case-insensitive.

/T timeout The number of seconds to pause before a default
choice is made. Acceptable values are from 0 to
9999. If 0 is specified, there will be no pause
and the default choice is selected.

/D choice Specifies the default choice after nnnn seconds.
Character must be in the set of choices specified
by /C option and must also specify nnnn with /T.

/M text Specifies the message to be displayed before
the prompt. If not specified, the utility
displays only a prompt.

/? Displays this help message.

NOTE:
The ERRORLEVEL environment variable is set to the index of the
key that was selected from the set of choices. The first choice
listed returns a value of 1, the second a value of 2, and so on.
If the user presses a key that is not a valid choice, the tool
sounds a warning beep. If tool detects an error condition,
it returns an ERRORLEVEL value of 255. If the user presses
CTRL+BREAK or CTRL+C, the tool returns an ERRORLEVEL value
of 0. When you use ERRORLEVEL parameters in a batch program, list
them in decreasing order.

Examples:
CHOICE /?
CHOICE /C YNC /M "Press Y for Yes, N for No or C for Cancel."
CHOICE /T 10 /C ync /CS /D y
CHOICE /C ab /M "Select a for option 1 and b for option 2."
CHOICE /C ab /N /M "Select a for option 1 and b for option 2."

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#20
March 16, 2018 at 02:15:27
ill add :pistol & some randomly spawned enemies, but first:

at what side do the enemies have to spawn, ill make them move in a strait line to the other side& detect if they hit the border, making you lose a point or something.


btw do you want the bullets to hit immidiatly, or do you want them to be animated(move 1 or more tile at a time)?

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#21
March 16, 2018 at 02:32:51
I've added some comments to the code so you can understand it a little better, not that there is no code in :PISTOL, it just goes back to the screen

::----start-of-shooter.bat----
::this will not show you command inputs/output, but instead only show echo commands
@echo off
::this wil allow variables to be updated within loops, but they need to be called as !variable!, instead of %variable%
setlocal enabledelayedexpansion
::title of the cmd window
title Shooter
::mode for example changes window size
mode 45,25
:presets
set char=#
::default location of char is now 10,22
::the value of 10,22=#, this is set on one of the first lines of label :screen
::as a variables thats !10,22!
set charx=10
set chary=22
::making the grid, 1~24,1~43
for /l %%a in (1,1,24) do for /l %%A in (1,42,43) do set "%%a,%%A=Û"
for /l %%a in (1,23,24) do for /l %%A in (1,1,43) do set "%%a,%%A=Û"
for /l %%a in (1,1,24) do for /l %%A in (2,1,42) do set "%%a,%%A=ÿ"
::preparing an empty variable for the screenvar
set "temp1="
:screen
::clear the screen
cls
::set charx,chary=#
set !charx!,!chary!=!char!
::loop 24*43 times: on every 43 times echo %%a,1 till 43 to the screen
for /l %%a in (1,1,24) do (
for /l %%A in (1,1,43) do (
if %%A LEQ 43 set "temp1=!temp1!!%%a,%%A!"
if %%A==43 echo !temp1!&set "temp1="
)
)
)
choice /c wasdp /n >nul
::choice if passed will return a value 1 & up, depending on how many symbols you gave it
::reset the variable where char is standing if it passes choice
set !charx!,!chary!=ÿ
::actual button that can be pressed, depending on choice (wasdp in this case), w=errorlevel 1, a=errorlevel 2, etc
if !errorlevel!==1 goto UP
if !errorlevel!==2 goto LEFT
if !errorlevel!==3 goto DOWN
if !errorlevel!==4 goto RIGHT
if !errorlevel!==5 goto PISTOL
:UP
::add an if statement if you do not want the character to go off the screen
set/a charx-=1
set lookdir=UP
goto screen
:LEFT
set/a chary-=1
set lookdir=LEFT
goto screen
:RIGHT
set/a chary+=1
set lookdir=RIGHT
goto screen
:DOWN
set/a charx+=1
set lookdir=DOWN
goto screen
:PISTOL
::what direction is char looking, blablabla
goto screen
::the screen is layed out like:
::Y--> that way is Y+(from 1 till 43)
::!1,1!!1,2!!1,3! --> all the way till !1,43!
::!2,1!!2,2!!2,3!
::!3,1!!3,2!!3,3!
:: |
:: |
:: v
::all the way till !24,1! & in the right bottom corner !24,43!
::from top to bottom is X+ (from 1 till 24)
::----end-of-shooter.bat----

message edited by hidde663


Report •

#22
March 16, 2018 at 09:26:45
I think that if you have the bullets move 1 tile at a time, that would make it harder, and look much cooler, so if you can that would be really cool

Report •

#23
March 16, 2018 at 09:37:53
alright, choose a symbol/character for the bullet, ill implement it this weekend if i have some time

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#24
March 16, 2018 at 09:53:24
Yeah, like for example:

the character is,
(-[^]-)
and the bullets it can shoot are like
|
(-[^]-) the laser look type one, and then maybe we can switch to like a turret,
:
:
(-[^]-) so that when you hold like X its the turret blasting multiple bullets (:) at a time, and then C is for the laser you can hold down and shoot, but has to charge or something really lit, that makes the game a banger!

And then we just need the point system, and then just need the little spaceships, and where every round or so, you get like 25 alien spaceships {[-]} and they look like that.

and shoot bullets (!) but slower than ours!
{[-]}
!
!

But we might have to make it to where our ship is only able to move left and right, and then the alien ships move a lot and shoot from the top

{[-]}
{[-]}
{[-]}
{[-]} {[-]} {[-]}

{[-]} {[-]}
{[-]}
{[-]}
!
! :
:
(-[^]-)

message edited by Coding.bat


Report •

#25
March 16, 2018 at 09:55:53
idk why the map drawing i made got messed up

Report •

#26
March 16, 2018 at 13:23:37
lets keep it small for now
ill add a point system & single character enemies
if you want entities to be larger, the game will take a lot longer to make, even for me
(since a single CPU core has to handle tracking the location of every entity times the amount of character it has times the amount of adjacent squares on the grid, while checking if a bullet of any kind is next to it)
so keeling every entity 1 char would save me a lot of time

the drawings are messed up bacause this site removes eccesive spaces & tabs, but i see what you mean.

looks a bit like this in my head, but then with ascii characters:
https://s.uvlist.net/l/y2005/12/634...

i5-6600K[delid]@4.814GHz/4.613GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@12-13-13-28 1T 2708MHz@1.37v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#27
March 21, 2018 at 07:42:23
✔ Best Answer
ive added being able to shoot, auto refresh & problem handling.

bullets now despawn after they hit a wall & lets say bullets 3 now becomes bullet 2 & 2 becomes 1
this way you wont run out of memory haha

next step is adding entities, will add a single character entity every 20 or so seconds

if you want to chance stuff you still can, again keep it simple.

p.s. without a response i wont continue

current version:

::----start-of-shooter.bat----
::this will not show you command inputs/output, but instead only show echo commands
@echo off
::this wil allow variables to be updated within loops, but they need to be called as !variable!, instead of %variable% & allows easier double or triple variables: !var%count%time%%a!
setlocal enabledelayedexpansion
::title of the cmd window
title Shooter
::mode for example changes window size
mode 45,25
:presets
set char=#
::default location of char is now 10,22
::the value of 10,22=#, this is set on one of the first lines of label :screen
::as a variables thats !10,22!
set charx=12
set chary=22
::bullet presets
set bullet=ø
::actually looks like this on screen:"°"
set bulletcount=0
set lookdir=UP
::making the grid, 1~24,1~43
::these 2 lines create the square surrounding the map
for /l %%a in (1,1,24) do for /l %%A in (1,42,43) do set "%%a,%%A=Û"
for /l %%a in (1,23,24) do for /l %%A in (1,1,43) do set "%%a,%%A=Û"
::this line fill everything else with "ÿ", aka en transparant char, looks like an empty cell or " "
for /l %%a in (2,1,23) do for /l %%A in (2,1,42) do set "%%a,%%A=ÿ"
::preparing an empty variable for the screen-vars
set "temp1="
:screen
if !errorlevel! LSS 6 timeout 1 /NOBREAK >nul
::check if bullets need to be rendered/recalculated
if not !bulletcount!==0 call :renderbullets
::clear the screen
cls
::set charx,chary=#
set !charx!,!chary!=!char!
::loop 24*43 times: on every 43 times echo %%a,1 till 43 to the screen
for /l %%a in (1,1,24) do (
for /l %%A in (1,1,43) do (
if %%A LEQ 43 set "temp1=!temp1!!%%a,%%A!"
if %%A==43 echo !temp1!&set "temp1="
)
)
)
choice /c wasdpm /t 1 /d m /n >nul
::choice if passed will return a value 1 & up, depending on how many symbols you gave it
::reset the variable where char is standing if it passes choice
set !charx!,!chary!=ÿ
::actual button that can be pressed, depending on choice (wasdp in this case), w=errorlevel 1, a=errorlevel 2, etc
if !errorlevel!==1 call :UP
if !errorlevel!==2 call :LEFT
if !errorlevel!==3 call :DOWN
if !errorlevel!==4 call :RIGHT
if !errorlevel!==5 call :PISTOL
goto screen
:UP
::add an if statement if you do not want the character to go off the screen
set/a charx-=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=UP
call :randomspawn
exit/b
:LEFT
set/a chary-=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=LEFT
call :randomspawn
exit/b
:RIGHT
set/a chary+=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=RIGHT
call :randomspawn
exit/b
:DOWN
set/a charx+=1
::setting lookdirection, for :pistol /bulletdirection
set lookdir=DOWN
call :randomspawn
exit/b
:PISTOL
::what direction is char looking, blablabla
set/a bulletcount+=1
set "bulletx!bulletcount!=%charx%"
set "bullety!bulletcount!=%chary%"
set "bulletdir!bulletcount!=%lookdir%"
for /l %%a in (!bulletcount!,1,!bulletcount!) do set "bullet%%a=!bulletx%%a!,!bullety%%a!
exit/b
:renderbullets
::just strait up render all !bulletcount! bullets
for /l %%a in (1,1,!bulletcount!) do (
::clear the current bullet%%a charx,y & set it to nothing "ÿ"
set "!bulletx%%a!,!bullety%%a!=ÿ"
if "!bulletdir%%a!"=="UP" if not !bulletx%%a!==2 (
set/a bulletx%%a=!bulletx%%a!-1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="LEFT" if not !bullety%%a!==2 (
set/a bullety%%a=!bullety%%a!-1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="RIGHT" if not !bullety%%a!==42 (
set/a bullety%%a=!bullety%%a!+1
) else (
call :shiftbulletcount
)
if "!bulletdir%%a!"=="DOWN" if not !bulletx%%a!==23 (
set/a bulletx%%a=!bulletx%%a!+1
) else (
call :shiftbulletcount
)
if not "!%bulletx%%a%,%bullety%%a%!"=="ÿ" (
set tmp=!bullet%%a!
if not !bulletx%%a!==2 (
if not !bullety%%a!==2 (
if not !bullety%%a!==42 (
if not !bulletx%%a!==23 (
echo.
)
)
)
)
) else (
set "bullet%%a=!bulletx%%a!,!bullety%%a!"
)
set "!bulletx%%a!,!bullety%%a!=!bullet!"
)
::check if bullet x,y equals to an entity, so x,y = not ÿ (then call :collision)
exit/b
:shiftbulletcount
::if a bullet hits the wall or bulletcount=43, rmove the bullet & shift all other bullets to the left
::echo this line is for debugging only&pause>nul
set/a bulletcountPLUSone=!bulletcount!+1
for /l %%a in (1,1,!bulletcount!) do (
set "!bulletx%%a!,!bullety%%a!=ÿ"
set "bulletx%%a=!bulletx%bulletcountPLUSone%!"
set "bullety%%a=!bullety%bulletcountPLUSone%!"
set "!bulletx%%a!,!bullety%%a!=!bullet!"
)
set/a bulletcount-=1
exit/b
:randomspawn
:: random is an integer between 0 & 32767
::1638/32767 is about 5% chance of an enemy spawning
::on average every 20 seconds an enemy spawns
if '%random%' LEQ '1638' (
::spawn an enemy, placeholder
echo this is where i wait for a response from OP, only then continue&pause>nul
)
exit/b
::the screen is layed out like:
:: Y--> that way is Y+(from 1 till 43)
:: !1,1!!1,2!!1,3! --> all the way till !1,43!
:: !2,1!!2,2!!2,3!
:: !3,1!!3,2!!3,3!
:: |
:: |
:: v
::all the way till !24,1! & in the right bottom corner !24,43!
::from top to bottom is X+ (from 1 till 24)
::----end-of-shooter.bat----

message edited by hidde663


Report •

#28
March 22, 2018 at 02:42:39
updated post #27  

i5-6600K[delid]@4.814GHz/4.713GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@14-14-14-28 1T 2908MHz@1.4v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#29
March 26, 2018 at 08:43:34
@hidde663,

for your updated post on #27 how do I shoot a bullet?


Report •

#30
March 26, 2018 at 08:43:57
how do I shoot bullet?

Report •

#31
March 26, 2018 at 14:11:58
usable keys are wasdp
p shoots a bullet

i5-6600K[delid]@4.814GHz/4.713GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@14-14-14-28 1T 2908MHz@1.4v
ASUS Z170K
Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod
VS450


Report •

#32
March 27, 2018 at 07:58:46
ayyyyeeee, that's awesome, how do you speed up framerate?! If it runs smoothe and faster that would make my game sooo lit, I just gotta add in my point system and then we good tog go!

Report •

#33
March 27, 2018 at 08:30:34
well thats kind of a limitation of batch for the command choice:

choice /c wasdpm /t 1 /d m /n >nul

i set a timeout of 1 second; /t 1 /d m
so that if you do not move, it'll refresh, not that it would be much faster anyways, maby up to 5 times giving 5fps haha
batch does not really have a timeout feature that is lower than 1 second
i could remove the time delay, but that would make the game freeze if you are not holding any keys(wasdpm)
m was put in as default key if no keys are pressed for 1 second, returning to the screen

so Batch is not really a language for fast action games like you are asking for, it's also not designed to do so.

i5-6600K[delid]@4.814GHz/4.713GHz cache@1.385v | 2x4GB Crucial-DDR4-2133CL16@14-14-14-30 1T 2808MHz@1.35v
ASUS Z170K | Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1375/1940 BiosMod


Report •

Ask Question