📜 ⬆️ ⬇️

School crafts: Battlecruiser & DeathCraft

CAUTION! Concentrated nostalgia! Described here is morally obsolete many, many years ago. Moreover, it was outdated before it was implemented. From the article you will not learn anything new.
In the long, old days, when Embarcadero CodeGear Borland Delphi RAD Studio C ++ Builder was version 4, when Autodesk 3ds Max Discreet 3dsmax 3D Studio Max was version 3, when 80 GB and 200 MHz were not in refrigerators, but in computers, when the Internet was an unknown and mysterious creature, every touch to which was magical ... I studied in high school and learned to program. And also to model. And all sorts of different things.
Suspicious screenshot:




Dad was a cop programmer (now just a cop cop). And he bought a computer - theoretically for a part-time job, but the helicopter plant somehow dried out too sharply, and the computer was used (as intended) rarely. Several times I watched the picture: all sorts of buttons, molds, various things were pressed, and then it worked (it was C ++ Builder). The eyes lit up: it's cool - you draw buttons, and then it does something! I was allowed to draw molds.
However, a problem arose: the buttons are drawn, but they don’t want to work! Suddenly it turned out that in a miracle program, by simply drawing a button, the buttons do not move, you need to write some strange incomprehensible code. I shoved a book on Bilder. It became apparent that it was very useful to know C at least a little before reading it ... I was shoved with a book on C.
It turned out strange: a book on C with programs that do not work in Bilder (it is clear that you can run with skill, but I was not trained in this kind of shamanism), and a book on Bilder, which requires knowledge of the Pros (here’s the class, method, here is the header file ...). But something was starting to move. Reprinting the code from the book is not a job for the faint of heart (later I learned that the book also relied on the book ...), but I craved the thirst for knowledge. And the most interesting: at the very end of the book on the Builder was a program that works with graphics. Sprites were displayed! Color pictures, figure cropped, with animation! (Everyone probably already understood what kind of book I had - in those days, its crooked scan was attached to each pirated CD with Bilder.)
The essence of the method: we take a picture, fill the future transparent area with black, next we place the mask: the object is black, the background is white. We first print the mask in SrcAnd mode, then the image in SrcPaint mode. So that all this does not die, at first we draw everything into a picture in memory, then put it on an outline on the form. The secret of magic has been revealed! And it started ...

Battlecruiser


')
Summary:
Genre: side-scroller
Graphics: StarCraft dashboard (units), Motoracer dashboard (victory screen)
Sounds: a jerked fool knows where it comes from (I had a lot of sounds scooped up from games)
Music: fucked up the jester knows where it comes from (does anyone know where hitgm.mid could come from?)
Used software: C ++ Builder, Sound Recorder, MS Paint

Screen from the game:

I tried C ++ Builder 6 - this program started! The truth is in compatibility mode with a pig (the old TMediaPlayer is covered with a copper basin without compatibility mode). Despite the availability of detailed instructions for each level, it was not really possible to pass ... difficult.
Download the game Battlecruiser (770 KB, sorts and executable file attached, run in compatibility mode)
However, my favorite genre was RTS, so pretty soon I sat down to write my own version, guess what ...

Deathcraft



Summary:
Genre: real-time strategy
Graphics: damned from StarCraft, drawn by yourself
Sounds: Fucked The jester knows where
Speech: recorded their own
Music: fucked jester knows where
Used software: C ++ Builder, 3D Studio Max, MS Paint, Sound Forge
In the process of writing a game, I learned 3D modeling.
Familiar screenshot?

Have you ever tried to use 3D Studio Max on a Pentium 200 MHz, 32 MB RAM? I tell you, the process trains your nerves well. The studio only loads 10-15 minutes ... rendering of the simplest models by the minute ... rendering one frame of a space flight from the enclosed example for ten minutes ... some things like the weights brush of a skin modifier just hung up the computer ... But! You can draw cool stuff!
Initially, a splash roller with two robots, walking with barrels at each other, was attached to the toy. Before showing to the respectable public, I decided to re-render the video, but I did not find it. Found a scene with another robot, about the same era. Now on the screen saver this robot.
Last frame of animation, hit Start.

Have you ever tried to use C ++ Builder on a Pentium 200 MHz, 32 MB RAM? This, of course, is not 3D Studio Max, but the compilation of an elementary project of my type (although it then seemed to me completely non-elementary) could take a minute.
C ++ Builder 6 with an old project:

Have you ever ... and although not, Sound Forge worked very quickly on ancient computers. Now to the effects of echo, acceleration, deceleration, reversal from the standard Sound Recorder added effects with obscure names like Flanger and Wah-wah. Sounds could normally be linked one after another. It sounded cool. Even the dinosaur speaks in my voice.
Let's run:

Some units are pulled out of StarCraft. Then I did not know that the graphics could be pulled out using kosher methods, and I used the good old Print Screen. And edited in MS Paint. I tried to print in winter locations to make pixels easier to pick out. You may ask: MS Paint and 3D Studio Max - is it not a strange set? Strange. However, how could I know about other editors - I didn’t even hear about these Internet sites. Well I could not google any solution - either by myself or not. Dad with his databases in my toys, too, is not in the tooth tooth ...
Some units are drawn in 3D Studio Max. Like all software, it was taken on the “Chekhov market” (Kazan version of the “humpback”). My parents bought the book for me. Tutorial to the program is terrible, terrible, in English and without source codes attached (or was it already in the next version? ..). Something nakovyryalsya. Mostly robots.
The game has AI. The enemy builds buildings (as per the list, arranges in a circle relative to the command center), builds collecting units (up to the limit), builds attacking units (up to the limit), attacks the player (while recruiting a minimum of attacking units). AI no, in general, but knows his business, and the player makes a very effective.
An adversary builds barracks with an entire SCV arm and trains reinforcements:

There is no algorithm for finding the path, units rest on the first obstacle, so it’s better to send them diagonally - if all obstacles are rectangular, then they can be circumvented. Units have an unpleasant feature to stick together in one point. For player units, the scatter is set, but the PC sometimes walks in one unkillable pile (Hello Civilization).
Robots to protect the home base:

Sometimes the effects were drawn to the conscience, sometimes it was laziness, and graphic primitives were molded.
Scrambled eggs:

The code ... the code is terrible. If a programmer usually sees his code after a couple of years and is terrified, then imagine what it feels like to me ...
for(i=0;i<MAX_BUILD;i++) if(Building[i].alive){ if(Building[i].hits<=0)Building[i].dying=true; if(Building[i].dying){ int boomcount=1; switch(Building[i].type){ case 0: case 1: case 2: boomcount=5; break; case 3: boomcount=1; break; } sndPlaySound("Sound\\Boom\\Boom1",SND_ASYNC+SND_NODEFAULT); for(int k=0;k<boomcount;k++){ for(j=0;j<MAX_BOOM;j++) if(!Boom[j].alive) break; if(boomcount==1){ Boom[j].x=Building[i].x+Building[i].sqleft*16+Building[i].sqwidth*8-22; Boom[j].y=Building[i].y+Building[i].sqtop*16+Building[i].sqheight*8-25; } else{ Boom[j].x=Building[i].x+Building[i].sqleft*16+random(Building[i].sqwidth*16); Boom[j].y=Building[i].y+Building[i].sqtop*16+random(Building[i].sqheight*16); } Boom[j].alive=true; for(int x=Building[i].sqleft;x<Building[i].sqwidth+Building[i].sqleft;x++) for(int y=Building[i].sqtop;y<Building[i].sqheight+Building[i].sqtop;y++) StopGrid->Cells[Building[i].x/16+x][Building[i].y/16+y]="0"; Boom[j].type=0; Boom[j].npic = (boomcount==1)?(0):(random(11)-10); } Building[i].alive=false; } if(Building[i].type==3){ int bx = (Building[i].x+Building[i].sqleft*16+Building[i].sqwidth*8)/16, by = (Building[i].y+Building[i].sqtop*16+Building[i].sqheight*8)/16, ux, uy; if(Building[i].atkunt==-1){ Building[i].atkpos=0; Building[i].npic=0; for(j=0;j<MAX_UNIT;j++) if(Unit[j].player==0&&Unit[j].alive&&Unit[j].visible){ ux = (Unit[j].x+Unit[j].centerx)/16; uy = (Unit[j].y+Unit[j].centery)/16; if(sqrt((bx-ux)*(bx-ux)+(by-uy)*(by-uy))<Building[i].atkr){ Building[i].atking=true; Building[i].atkunt=j; if((Unit[j].atked&&DistUB(i+10000,j)<DistUB(Unit[j].atkedby,j))|| !Unit[j].atked){ Unit[j].atked=true; Unit[j].atkedby=i+10000; } break; } } } else{ j=Building[i].atkunt; ux = (Unit[j].x+Unit[j].centerx)/16; uy = (Unit[j].y+Unit[j].centery)/16; if(sqrt((bx-ux)*(bx-ux)+(by-uy)*(by-uy))>Building[i].atkr|| Unit[j].player!=0||!Unit[j].alive||!Unit[j].visible){ Unit[Building[i].atkunt].atked=false; Building[i].atkunt=-1; Building[i].atking=false; Building[i].atkpos=0; Building[i].npic=0; } } if(Building[i].atkunt!=-1){ Building[i].turn=-1; j=Building[i].atkunt; float x=Unit[j].x+Unit[j].centerx-Building[i].x-Building[i].sqleft*16- Building[i].sqwidth*8, y=Unit[j].y+Unit[j].centery-Building[i].y-Building[i].sqtop*16- Building[i].sqheight*8; int sval=41, lval=241, A=(y==0)?(99999999):(x/y*100); if(y==0)y=0.1; if(A>=-sval && A<=sval && y<=0) Building[i].turn=0.1; if(A>=-lval && A<=-sval && x>=0 && y<=0) Building[i].turn=1.1; if(abs(A)>=lval && x>=0) Building[i].turn=2.1; if(A>=sval && A<=lval && x>=0 && y>=0) Building[i].turn=3.1; if(A>=-sval && A<=sval && y>=0) Building[i].turn=4.1; if(A>=-lval && A<=-sval && x<=0 && y>=0) Building[i].turn=5.1; if(abs(A)>=lval && x<=0) Building[i].turn=6.1; if(A>=sval && A<=lval && x<=0 && y<=0) Building[i].turn=7.1; if(Building[i].turn<=-0.9&&Building[i].turn>=-1.1)Building[i].turn=0.1; } else{ Building[i].turn+=0.25; if((int)Building[i].turn>=8)Building[i].turn=0.1; Building[i].turn = int(Building[i].turn/0.25)*0.25; } if(Building[i].atking){ Building[i].atkpos++; if(Building[i].atkpos>=10) Building[i].atkpos=0; if(Building[i].atkpos==1||Building[i].atkpos==3||Building[i].atkpos==5){ sndPlaySound("Sound\\Special\\Atk1",SND_ASYNC+SND_NODEFAULT); j=Building[i].atkunt; Building[i].npic=1; Unit[j].hits-=Building[i].atkfrc; if(Unit[j].hits<=0){ Unit[j].hits=0; Unit[j].dying=true; } } else Building[i].npic=0; } } ... 


And such a sheet - more than two thousand lines.

DeathCraft: instruction



Units:


Building:


Mouse control: selection of units and buildings with the left click, the command to go and attack with the right click. There is no area selection, but there is a selection of all units of the selected type on the screen using Ctrl.
Keyboard control:


Tips:


Download the game DeathCraft (5.3 MB, sorts and the executable file are attached, run in compatibility mode)
I was also going to write about the platform arcade and the new version of the real-time strategy (both already with their own graphics). But I got tired, and the jester knows whether to write - if this article turns out to be uninteresting to Habr's readers, then you can not waste time.
I will take my leave for this. And you, dear readers, what did you write during school and student years?
UPD 1: Some readers have reported that “No MCI device open” errors are flying out. Reloaded the file. Now, at startup, you can specify the argument - --no-video , then the video file will not be loaded.
UPD 2: Another solution: install the codec from XVid.org .

Source: https://habr.com/ru/post/157377/


All Articles