- - - - - --- ---- - - - - --- --- - - - - -
eї ° √ ¤ ¤ √ ° ўeE Chunk'ovaya game ... lamer and teapots eї °
√ ¤ ¤ √ ∙ ўeE - - - - - --- ---- - - - - --- --- - - - - -
$% CyberJack'LFG
'Open Your Eyes'
Guano Apes
Hey, dude! Not waiting for? And in vain ... As I promised
in the previous room today, we'll be with you to write a real
game! Primitive of course, but certainly not too difficult even
for you:) So, open your eyes wide and begins to read ...
Little introduction. Though it is written that 'we are with
you We do din ', in fact, all of which I coded almost
year ago:) And today, simply repeat the process
especially for you ... Therefore, complaints about 'coolness'
and 'Original' games are not accepted! Read more at
PostScriptum'e ...
Kodit you and I will toy logical ... Think
why the sinter them so much? Precisely because of their coded
can be any lamer [similar to Murphy's law: 'Create a program
which will be able to enjoy even a fool, and only a fool would
it use '], how do you like least at the moment is.
Therefore, (yet?) Reserves thoughts about any RTS or FPS years
five ...
How to start a game, or rather its creation? With the
emergence of ideas. Concerning the Spectrum is not a problem
because, as he was commanded to the beginning of time, we must
not suffer himself on the issue, but simply from the thread it
borrowed. 99 percent of games written in ex-Soviet Union would
work that way.
I will not break me, do not wound the tradition ... Take
as the object of imitation GameBoy'evskuyu game 'Chunk Out'.
Say, not what this game, but GameBoy never in my life
seen? No matter, the main thing that I saw:) In a nutshell, the
game similar to the already existing on the Spectrum of Optical
Clickmania Brothers or demo toys Kovrova Kluxer ... And in
appendix to this paper should be already written a game
can first look. Moreover, it is even necessary, because
I do not feel like paint on the game rules ...
So, the idea is there. It is necessary to first think about
whether you potyanesh this game, jot down in my mind the
rudiments of the algorithms and all that. For external
simplicity is not always true - until the pile of toys on the
case rather complicated to implement. With regards to this same
Chunk_Out'a external simplicity is not cheating, I coded it for
five hours ... True, if you really kettle, count on a
two to three times longer work:)
Getting really creative work ... It will be so
detail is painted like it's all done, I already disgusted
becomes. But if you still really nothing ever
a good man did, they might be useful to you all ...
First and foremost, think over the basic game plan. Toy
obtained as it is not too big and complicated:), so
and plan appropriate. So, the game loop something like this:
[Home game]
--- Initialize the game
; Field generation, discharge points to 0, and of all that ...
[Main loop]
-Check the possibility of further games
And if there were only single cells, the 'Game Over'
--- Processing Action Gamer
The poll buttons, move the cursor
And if pressed 'fire', then go to sled.punkt, or repeat ...
--- Change the playing field (maybe)
And if the cursor is on an empty spot, then go to pred.punkt
-Counting of harvested cells [number]
And if number = 1, then go to 'processing of action Gamer'
-Erasure of cells harvested
Adding a score proportional to the number of harvested cells
-Optimization of the playing field (the shift to the left and
down)
-Test for the passage level
Transition to the 'main loop'
[End Game]
-Output table of records
-Comparison of the number of points and a table of records
And if a player hit the table, then the name and changing table
This is not quite complete, but Bole-less detailed plan,
which well, you can use ... Tell you a secret that in writing
I enjoyed the game much more simplified version to the same
component, as supplemented, and correct the course and in my
mind:)
Begin to torment with assembler. A few words on the subject
... Now I'll lick the main problems and tasks, and in
This time I will refer to the source ... Discharge the same are
in applications available to everyone, but will only be fully
understood happy users Storm'a:) The other occurred at
need to give a wonderful opportunity
work out in the manual conversion of texts' out '>>' to
you have to '... I'm not going to agitate for a total
transition to Storm, just ...
So, get started. I just uploaded my little debut
which already have procedures for installing and interrupt
handling, some procedures, plus blank registration of the
source code (as I conveniently). Nothing complicated, even for
you, just me crowbars each time to write such small things. At
the initial stage, I just changing the project name and correct
date:) [See file GAME_1.C]
Let me explain a bit the structure of the mine source code,
it is useful:
Initially attending a short description of the source code
+ date of its creation. When there is 5.6 jam clogged the
working discs such information saves a lot of time helping to
restore files from killed discs, plus just improve readability
...
Block - Equ 's - Here we are given addresses of procedures
and data, ie the addresses that are specified in advance by the
encoder. At first, here only address of the interrupt so the
start address of code.
Block - Variables - contains predefined
variables. For example, a color screen, the size of the game
screen, cursor speed - in short, things that can be
changed without rewriting code.
Block - Main - and is the game ... Almost. Here
located just a game logic, all of the same run
challenge procedures. This part is the main
and rather complicated by the logic with regards to a purely
coding very, very simple - a simple cycle of comparison and
branch:)
- Subroutines - Procedures as they are. It is these routines
do all the dirty work, painted in our plan. Each
procedure performs a complete effect. I always point
to the procedure, its input and output parameters (if any)
here in the comments ... and advise you.
In a block - Used Data - made all that is described
assembler, but not a pure code, ie all variables
(DB, DW), various text messages, pre-redundant
place in the data sets (DS). Removal of these things in a
separate block helps to avoid confusion.
- Interputs - consists of a single procedure -
interrupt handler, the one thing that holds each
interruption - 50 times a second:) At the beginning here only
storing / restoring registers, so a poll click 'Enter', to
clicked, will exit the program. Because
remembers the initial value of the stack, then included
interrupt output is possible at any time of the program.
- Must Die !!!-- So I had called the initial procedure
installation - things being done only once at the beginning of
program. Just sometimes sorely lacking memory and
have to use the vacated space, overwriting
unused routine ...
And at the end of the program is labeled Eall, with which
You can find out how many kilobytes you have already written ...
As I promised - nothing complex. In the end, I will not
Exploder, a simple thick country boy:)
It's time to get down to work and write for a start though
something ... Develop the structure of the board and write
routine output of the field on the screen. The structure is
simple - each cell is described by the respective byte, which
can contain the value 0 ... 4. 0 means that the cell is empty,
any other value is the color of the cell. For faster
work procedures for harvested cells and optimization of field
(Which we will write later) sacrifice memory - is reserved for
game_map 11 sectors, each of which will be used
total of 16 bytes. Wasteful of course, but to move on
vertical enough to do inc / dec_h, horizontal -
inc / dec_l (if hl register indicates the cell field). This
little chip that speeds up the work procedures, so more and
greatly simplifies them!
First, write down the procedure for the generation of the
playing field (so not will have to suffer with validation of
the routine Output field on the screen). The task before idiocy
is simple - it is necessary fill all the numbers from 1 to 4.
Obtain rnd-number, leaving two bits, increased by 1 and put in
map. Everything! Of course, everything is so simple because of
the fact that we have only 4 colors:)))
The procedure for withdrawal of the playing field on the
screen is very simple. Takes value field of the cell, the color
table gets really visible color, and set in a square 2 * 2
familiarity appropriate color. Of course, I'm helluva lot
shalyavnichal, abandoning painting playing field as usual,
confining only to the change of color paper ... This is done
for reasons of haste (I had to do This Gift as the maximum of
two days), plus I really think it is good because the cursor
does not change color when peremeschinii on the screen (just
like on GameBoy:). Make print playing field sprites will not
make any problems for this have to rewrite a few procedures -
and this procedure movement direction.
One might ask - why we need a color table, if
You can simply just specify in the field of play the real
color? In Basically, yes, but in reality it is not very
convenient, especially if it is necessary change the number of
colors and the flowers themselves. And what for yourself create
problems?
So, we wrote a procedure for deriving the field on the
screen (I already ranged to repeat these words:). By the way
... Although I have some reason counts the time of constructing
the field (see on the curb), on practice it is almost
immaterial, because the field we will rebuild Not every frame,
but only after changing it. Although if the field will be tuned
for very long, it is necessary to avoid problems with beam ULA
... [See file GAME_2.C]
Field, we can draw ... Now get down arrow.
Writing process printing arrows in an arbitrary position on
the screen, restoration of the background under it (because of
my khalyavnykh map fields need only to erase the sprite:), the
poll buttons, draw an arrow (I now felt like a square:). This
simple routine ... Much more complex primary procedure for
handling moving arrow. It should move the arrow on the screen,
not allowing her to leave behind the screen. Plus I made more
complex (with respect to standard, already existing) driver -
the arrow at me moves while pixel by pixel, but stops only at
exact locations (at grid 16 * 11). Wishing
advise on their own to deal with this routine. [See file
GAME_3.C]
Externally, the game is ready - on the field can drive the
arrow:) True by pressing the fire exits in assembler. Now
begin to remedy the Gluck ...
Remember the plan ... Now we have to write routines that
handle change the playing field, where quite a lot and they are
all needed almost simultaneously. They, like everything else in
this game, it is not complicated, just need a little brain
strain ...
We write the routine determination of harvested cells. In
principle, this quite a complicated thing. We use the standard
algorithm fill his Latency on such a small box will not have
time appear:) algorithm is as follows:
-Set the coordinates (x, y) of the initial cells in the buffer
;
--- --- The algorithm if the buffer is empty, the job is done
-Take the coordinates of the cell from the buffer
-Check its neighbors in the vertical and horizontal
-If they have the same color as the original, then put
their coordinates to clipboard
-If the color does not match, then go to sled.sosedu
Transition at the beginning of the cycle
It's simple ... For more convenient work (and faster) in
as a buffer, I use a stack: to put into the buffer _push_, take
_pop_.
If after work 'fill', we learn that 'shaded' was
only one point, and even that the initial, it means that the
point was a single, ie, remove it is not necessary. Because This
algorithm erases the cell, it is necessary to restore the old
value. No problem ... [See file GAME_4.C]
Now it would be nice to write the optimizer field ... At
the same time done at last and enter the normal scoring, and
concluded this value on the screen. Let's do that ...
Optimizer field - something not very complicated. First
shift all possible cells down, and then subject to availability
columns are shifted to the part of the field to the left. In
the source file is looks much simpler and clearer:)
Scoring ... In the original game points are awarded for
the following formula: points = (n-1) ^ 2, where n - the number
of harvested cells. You can certainly write a routine
multiplication, but much easier just to Generate a table of
squares and take the result of it. At least I think so ... So I
did.
Print the number of points ... To do this, I wrote two
procedures - print a text line on the screen and print a
decimal number to arbitrary position (conversion of five
numbers and enters them into five subsequent memory cells).
Basically, for me it is already waste reception, so I did it
purely mechanically. Again well, it's pretty simple.
Well, we must also draw the font 8 * 8 ... I took my old
one, you you can draw your own. This font will be the first
(but not last) file that is uploaded in our source code. By the
way ... I certainly understand that the constant Podgruzka to
drive a little annoying, but strongly recommend to continue to
load all files through the INCB through AFM! Very often,
beginners start load the file handles after STS ... Moreover,
it maetno, so even then it is very difficult to understand what
to load and why (usually this tactic was accompanied by total
the lack of comments). Like everything in this article - check
personally:)
You can see it all in ASME ... [See file GAME_5.C]
Now write a procedure for checking the possibility of
further games like quite all - the game is ready, you can begin
gamitsya! Check this, too primitive, at least in my
implementation. I first check for the presence of identical
adjacent cells horizontally and then vertically - and if they
were nowhere to No, no further play is impossible ... [See file
GAME_6.C]
With coding games as such an end ... Now we have to somehow
all this business issue, to give its presentation so to speak.
By the way, all further completely absent in the original
Chunk_Out'e and is spontaneously ...
First things first, prisobachim tune. Because all known (and
Available:) I write in musicians Pro_Tracker_3.x, then in all
his work is just such a tune. Much of a difference of course
between the various editors of the encoder is no no
the only thing that needs to be corrected - the entry point in
pleer. Campiglio Muzychka under # C000 (feature PT3.x -
mandatory round address xx00!!!) and connect it to the game.
Will mimic the normal game - we introduce the similarity
saver message Game_Over'e and table of records. I took
advantage of creation of Delirium Tremens by significant title
ChrPrint_x.x to create two prompts. Font potyren from the demo
Insane ^ 3SC. I drew two sprites 1932 * 8 familiarity, bring
them to as part of a simple screen. Come on ... [See file
GAME_7.C]
And as the most difficult - table of records. Its just a
little display, one also has to check if the player got into
it, or no, and if hit, the worst thing - to allow him to enter
their name! In fact, writing all this takes more time
than writing the game itself:)))
While all that I have just outlined, pure truth, in fact I
dealt with this for 10 more minutes. I just have already been
pre- written procedure for entering a line of text:) I had only
a little easier and to change the routine ... Of course, you
should not hope for a freebie, especially if you yourself begin
to write their din. Just never be afraid to write complex (for
you at this moment) procedures - to gain experience, and useful
someday.
Yet a couple comments on the routine of entering a name ...
Look which button is pressed (scans all poluryady), and
then the table is determined by the input character codes.
Tables these three pieces, switching to them is made by
pressing the Caps / Symbol shift. Their depression is tracked
separately (not to issue left code). Again, if you think about
it, then nothing complex. [See file GAME_8.C]
By the way ... Rang out from asma on pressing Enter, for
prevent us from introducing the name ...
Well, the last finishing touches ...
Start scrolling in start menu - it is necessary to somehow
to convey congratulations and best wishes:) Begushku make a very
just - in my time Zx-Review is very long and diligently on this
worked:) The only thing that I 'not', so this is what
scroll I made in memory, and then buffer
discarded on the screen.
It seemed to me that oblomno in the start menu to display
scores table white ink'om and crowbars to fix prog:)
So I put a piece of code that changes the white ink on black.
Come and bring a couple of extra buttons. Clicking on the
'E' entails access to the startup screen. Sometimes reluctant
come to grief on lazhovom field:)
And make another otklyuchalku music. There appeared little
problem - the music should be off in the main menu, and in
the game itself. If, however, put the check on its push to
interrupt, then type in the table records the letter 'M' will
turn off the music:) exits some, it seemed easier
just do a check separate procedure that is called
in two places. [See file GAME_FIN.C]
With regards to the conservation table of records to disk.
Here generally no problem ... True, the version of the source
available to you, deprived of such opportunities, because once
I almost managed to ruin your drive. So now this thing
commented out ... And for its actual use should only
determine the location on the disk where to save and substitute
This unit ...
You see? Game is ready to complete. For her 'release' it is
only necessary pack all the blocks so write a new loader. Since
I took _polnostyu_ tell you about the processing of writing the
game, then touch and these 'problems' ...
I do not know as before, but now, when there Hrust, a minute
delay without any difficulty. Different parts of the code and
data can be scattered on the memory as you wish, the result of
packing it's almost (10-15 bytes) does not affect. It is only
necessary make sure that the rest of memory is pretty empty ...
Because This game is fully working in 48-second memory (not
used by any one bank), then it packs a
block. Plus, in the end have to load a single sector -
nepakovannuyu table of records. Incidentally ... When you do
your game - as a scrambled this table, Do not be like me:)
In the Appendix you will find the source loader. I do not
think that he'll handy, just to keep the collection. [See file
LOADER.C]
Everything! The game is ready - you can go show everyone
how are you cool. True, it would be better if you can write
your very the game should not be limited to changing text ticker
:) And if the data is 21K of text to you in this handy, I'll
almost happy ...
*
P.S. This processing did take place to be in October
last year ... True, all this nonsense I was writing now. As
could try, but sometimes there may be some discrepancies and
lining, but I really tried:)
I had a very tempting thought to rewrite everything in
side of coolness (not you think you are, it's the ceiling for
me as coder? If you think a good reason:), since this code is
very din weird places. When I began to paint, the very few
just wondered:))) but refused it because: The game already runs
on hand, despite its status as a 'just for our own':) - this
time, but Secondly, the game in such a really unpretentious and
clear each Lameroo - with my comments and without them ...
Okay, people, it happens. In sled.raz we're still something
thread do ... Maybe one more game ... :)
P.P.S. Dude! If you are interested / not-interesting, there are
complaints / suggestions, you can throw me a couple of words.
By and large account, of course I was not up to you, but I
really try to take note of your words ... I will try:)