Code:

Now, I do many changes to the code that we can comment.1- Eliminated the monsters of type 4 and 5. Cause? Our future shoot will have a eight of 4 dots, and we calculate the collision using the coordinates of the shot and the monsters. Monsters 4 and 5 can allow a shot without collision:

Also the margin inside the surface of the sprite was eliminated, now is specified in a number variable.

2- Set a nomenclature name: for the objects we use abbreviations:sfce (surface)inv (invader) (this is used as prefix for the invaders).mon (monster) (this is used as sprite).exp (explode) (this is used as sprite).sau (saucer) (this is used as sprite).nav (nave) (this is used as sprite).

3- Added more properties of the sprite:width, eight, lmargin, rmargin.lmargin means left margin.rmargin means right margin.

Our most bigger monster have a width of 12 pixels, then for align the smaller monsters, we use left and right margin. In the example, 12 - 8 are 4 pixels, then we use 2 to the left and 2 to the right.

4- Added coordinates for each invader. top, right, botom, left. We use this for detect the collisions of the shots.For example our shot will have a width of 1 pixel and a eight of 4 pixels. If it have a x top coordinate of 48 and left coordiante of 15, and one monster have a bottom coordinate of 49 and a right coordinate of 16 it means a collision.

5- Eliminated the link of the sprites. Now it not use letters, it use numbers. How we link it?Using a arithmetic operation.

we have a frame that is composed of surface 1, surface 2.this frame have a index of 1 for use the surface 1.we always add 1 to the index.

1+1=22+1=3

we have a max index of 2.

how convert the 3 in 1?One option can use a if:if frame equ 3 frame=1

but the arithmetic uses modulo: %% max2 % 2 = 03 % 2 = 1

then we uses modulo and sum 1 for convert the 0 in 1, and the 1 in 2. Then we always have index 1 or 2 and 2 link to 1 and 1 to 2.

6- For reference to near invader we use : invader.near.east (now we not use invader.right because it is a property of the coordinate of the invader), invader.near.west, invader.near.north, invader.near.south.

7- Now we use the sprite2 function of bg. That is your syntax:

Code:

Bg.exe Sprite2 row column width eight color var_surface

The argument number 8 is a variable name that hold the surface. And because we specify the width and eight of the surface, we not use anymore the \n at the end of each surface of the sprite.

For test this new function use:

Code:

bg sprite2 10 10 9 1 c windir

8- Using a original snapshots of the original space invader game I draw more surface of a sprite like the explodes, the nave and the ir saucer.

::create 55 monsters::every 11 monsters we change the type of monster::each monster is separated of the next by INVADER.SEPARATION.::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"::coords for the first monsterSet "x=10"::Set "y=10"::r variable is for reference to a imaginary row and allow select the color.Set "r=5"For %%T In (3,2,2,1,1) Do ( Set "y=10" For /L %%# In (1,1,11) Do ( Set /A "id+=1" Set /A "inv_!id!.near.north=id-11" Set /A "inv_!id!.near.east=id+1" Set /A "inv_!id!.near.south=id+11" Set /A "inv_!id!.near.west=id-1" Set "inv_!id!.live=1" Set "inv_!id!.type=%%T" Set "inv_!id!.frame=1" For %%C In (row.!r!.clr) Do Set "inv_!id!.color=!%%C!" Set /A "inv_!id!.width=mon.%%T.width" Set /A "inv_!id!.eight=mon.%%T.eight" Set /A "inv_!id!.left=y+mon.%%T.lmargin" Set /A "inv_!id!.right=inv_!id!.left+inv_!id!.width" Set /A "inv_!id!.top=x" Set /A "inv_!id!.bottom=inv_!id!.top+inv_!id!.eight" Set /A "y=inv_!id!.right+mon.%%T.rmargin+%INVADER.SEPARATION.Y%" ) Set /A "x=inv_!id!.bottom+%INVADER.SEPARATION.X%" Set /a "r-=1")

::set the references to 0For /L %%# In (1,1,11) Do Set "inv_%%#.near.north=0"For /L %%# In (11,11,55) Do Set inv_%%#.near.east=0"For /L %%# In (45,1,55) Do Set "inv_%%#.near.south=0"For /L %%# In (1,11,45) Do Set "inv_%%#.near.west=0"

hello!I do not understand (but this) tutorial!But I feel that bg improves the display speed!I think you could integrate my bg-Sprite DangerouSpace to a concrete example!Furthermore, the main problem of my game iis its slowness, adding BG could be remedied(Source: Google: Translation)