Batch Index du Forum
S’enregistrerRechercherFAQMembresGroupesConnexion
Répondre au sujet Page 1 sur 1
[Part 3] Tutorial Space Invader
Auteur Message
Répondre en citant
Message [Part 3] Tutorial Space Invader 
Now, I i will update the code for link the monsters like this:



Will have a list of with max elements size of 11 for hold the list of the monsters that can shoot. When a monsters is destroyed will update that list and add the monsters that is up to the monster to the list of monster that can shoot and will reference it to 0. We generate this list evey time that a monster is destroyed, looking all monsters and if its reference to down is 0 and is live I added to the list.

part3.cmd
Code:

@Echo Off
SetLocal EnableExtensions EnableDelayedExpansion

Color 07
Mode Con Cols=200 Lines=110
Bg.exe Font 0
Bg.exe Maximize

::initialize sprite data
call mon.cmd

:margins
Set "MONSTER.MARGIN.X=3"
Set "MONSTER.MARGIN.Y=2"

::coords for the first monster.
Set "x=10"
::Set "y=10"
::create 55 monsters
::every 11 monsters we change the type of monster
::each monster is separated of the next by MARGIN.
::we create the monsters in this order and id:
::
:: 01,02,03,04,05,06,07,08,09,10,11
:: 12,13,14,15,16,17,18,19,20,21,22
:: 23,24,25,26,27,28,29,30,31,32,33
:: 34,35,36,37,38,39,40,41,42,43,44
:: 45,46,47,48,49,50,51,52,53,54,55
::

Set "id=0"
For %%T In (5,4,3,2,1) Do (
   Set "y=10"
   Set "row_%%T.x=!x!"
   For /L %%# In (1,1,11) Do (
      Set /A "id+=1"
      Set "monster_!id!.type=%%T"
      Set "monster_!id!.sprite=%%Tb"
      Set "monster_!id!.color=!mon%%T.color!"
      Set "monster_!id!.live=1"
      Set "monster_!id!.left=!id!-1"
      Set "monster_!id!.right=!id!+1"
      Set "monster_!id!.down=!id!+11"
      Set "monster_!id!.up=!id!-11"
      Set "monster_!id!.x=!x!"
      Set "monster_!id!.y=!y!"
      Set /A "y+=%mon.width%+%MONSTER.MARGIN.Y%"
   )
   Set /A "X+=%mon.eight%+%MONSTER.MARGIN.X%"
)

::set the references to 0
For /L %%I In (1,1,11) Do Set "monster_%%I.up=0"
For /L %%I In (45,1,55) Do Set "monster_%%I.down=0"
For /L %%I In (1,11,45) Do Set "monster_%%I.left=0"
For /L %%I In (11,11,55) Do Set "monster_%%I.right=0"

::set list of monsters that can shoot.
Set "can_shoot.size=0"
For /L %%# in (1,1,55) Do (
   If 0 equ !monster_%%#.down! (
      If 1 equ !monster_%%#.live! (
         Set "can_shoot[!can_shoot.size!]=%%#"
         Set /A "can_shoot.size+=1"
      )
   )
)

:loop
::show in the screen
For %%I In (
45,46,47,48,49,50,51,52,53,54,55
34,35,36,37,38,39,40,41,42,43,44
23,24,25,26,27,28,29,30,31,32,33
12,13,14,15,16,17,18,19,20,21,22
1,2,3,4,5,6,7,8,9,10,11
) Do (
  For %%S In (!monster_%%I.sprite!) Do (
    Bg.exe Sprite !monster_%%I.x! !monster_%%I.y! !monster_%%I.color! !mon%%S!
    Set "monster_%%I.sprite=!sprite.%%S!"
  )
)
goto loop


Pause>Nul




Message Publicité 
PublicitéSupprimer les publicités ?


Répondre en citant
Message [Part 3] Tutorial Space Invader 
What a great job !!! Okay




______________________________________________________
AffPng.exe , StringBetween.exe , Hex2Png.exe
Message [Part 3] Tutorial Space Invader 


Montrer les messages depuis:
Répondre au sujet Page 1 sur 1
  



Index | créer un forum | Forum gratuit d’entraide | Annuaire des forums gratuits | Signaler une violation | Conditions générales d'utilisation
Copyright 2008 - 2016 // Batch