How to write a play. Volume 3
Part One
(C) Konstantin Dronov
"The way the pillars on the ears"
If you talk to God
a prayer, and if
God speaks to you, then
is schizophrenia.
Preface
What you see is an article spelling on the request of the
"flock mates" with pleading in his eyes, with crooked fingers
clinging to his arm and shouting: "A
Well shared experiences # la-I-I, and then Zaksor !!!". Well he
likes, not likes, but must share. This article is based on
personal experience and is of interest primarily to
designers and programerov. Basically it
will be useful for game developers such as
ACTION or on kraynyak, RTS, but limited for others. There will
be no ready procedures, but only hints of how to do this or
that, and how to do it is up to you, based on personal
experience. The choice of programming is not essential, so the
choice is relevant only SPECCY, since except for
ASSEMBLER'e do something worthwhile is impossible. For modern
systems it choice is not relevant since here everything can be
blamed on the power of the processor.
"How to start writing a game?"
The most frequently asked question is displayed
at the top of this article. The answer is as
simple as it is strange: "I Know!". Y
Everyone should receive their own approach. Personally, I
ponder the first idea, which certainly must have infected, make
you think, good and in every detail to provide future
project. Take for example that a
from an existing example for my game "PROJECT X" in this
prototype was a series of "ALIEN BREED", and for "CYBEREAL"
Series "STAR DUST". There is no need to reinvent
every time the bike, since it is rather difficult, in my view
the existing level of technology simply impossible. All the
so-called new items there are remixes of old games, but
improved graphics and sound are nothing new. For me personally,
it seems interesting to impress each individual
the player with something in your game: so in
"PROJECT X" it was 50FPS and powerful
design (later I realized the error, 50 FPS
far the most important thing), in "CYBEREAL"
this is the game with beautiful graphics and sound plus a very
global nature of what is happening. So, you have an idea, but
start just too early, it is important to assess the ability to
create on your computer platform of the future masterpiece ;-).
Here, you will need all the experience that
You certainly should be, because
if you have no programming experience
then from napisniya game no good would come. Ideal experience
demomaker'a this experience will allow you to approach to
writing Games with great knowledge and ready bibleotek
procedures. You need to understand, to submit all of your
program so good to a point where you sit
for the computer you would have complete
an idea of what you do.
"You started ..."
Developed all neobhodimye you
program, for example: a level editor and
etc. What are the opportunities he should
be up to you, I can say that my
editor for the game "Incubation Period"
has a download feature sprites, sliced
Sprites from the large maps, download palette editor block
attributes, editor of large images, animation editor for
blocks, map editor, editor image overlays the second-level
descriptor editor, working with files and pre- Finally the
compiler the file level. But writing such a topic for another
editor call or can take advantage of any other, ready-made, for
example, for my SPECCY and AMIGA, they will soon be posted on
the page LASER DREAMS in network INTERNET. But this is not an
option, as they are calculated on an individual case.
Sign a basic notebook, notebook, divide into two parts, where
you will store data on the variables in their place
location and on the procedures with data on
input and output. Make all possible variables that come to
mind. K example: life, energy charges for weapons, weapon type,
time, debugging and etc. Separately allocate space for internal
variables play such as: what screen is active, the address of
the open libraries, etc. And leave as soon as possible
more space for future changes. Determine how you want to work
to screen, evaluate performance, determine how you display
graphics on screen. My advice: forget the possibility of
Drawing directly on the screen, use the clipboard, or operates
in two screens otherwise there are problems with the timing of
displaying. For example, in AMIGA is possible to organize a
screen anywhere in memory, allowing you use the scheme:
check
count <
is 0 / / equals 1
/ \
show show
the screen 0 screen 1
Draw Draw
in Figure 1 in the screen 0
\ /
\ /
increase the count by 1
Of course the counter can be optimized. So on SPECCY can be
arranged work with two screens and use
Unit:
BWRITE LD A, 23
XOR 10
LD (BWRITE +1), A
LD BC, 32765
OUT (C), A
Of course it has known limitations and difficulties when
working with pages, but also provide an opportunity not to
waste time on the transfer of the screen. Therefore, appreciate
the opportunities and see if volumes of data is larger than
32kb, then perhaps it makes sense to spend CPU
time to organize a programmatic transfer. Although I, for
example, in the game PROJECT X did: switch pages of memory
tossed the required data in the buffer, and
worked on two screens.
At AMIGe when working directly with the chipset, you can
simply change the pointer to BITPLAN'y in COOPER LIST. And when
working with graphics functions can to Use
system, a library, but you can
familiarize yourself with the video cards and run on a straight
line, but it will require more time and nerves. For example,
vospolzovatsya transfer function block memory, but in my
opinion very rude and there are more elegant ways, for example,
open two screens and vospolzovatsya function to switch between
screens: -252 ScreenToFront of intuition.library
But this is somewhat non-standard way and
it is not necessary to use it, it's only example of a peculiar
approach. Generally there a lot of ways to work with two
screens, just look at the list of features libraries.
If you want to have as
Fewer problems with debugging and C
IRON, WHAT WOULD YOUR GAME
INTACT SUPPORTS ALL NEW IRON UNDER THE SYSTEM, WRITE OS-FRENDLY
PROGRAM
But again, no need to completely rest against the system, not
all features of the system are ideal, they are designed for
obshy case, why put in the program to operate in different
modes, that is, provide an opportunity choice: the system or
your procedure.
Initially create a main loop
which will display the block diagram, but
instead of "display" can make a subroutine call to the
procedure output to screen. In general, try everywhere (where
it does not affect the speed) to introduce
routines, and do not use any public
"Perverse" practices in the main loop
program, it will be easier to understand. In
each cycle of the ones above scheme is desirable to apply to
the synchronization process. To have a team SPECCY CPU HALT,
which is synchronized to the top of the screen drawing, and for
AMMY it may be a function: -270 WaitTOF of graphics.library
Promptly inserted the main loop, you nozhete start to write
separate procedures. Then you could divide the writing of each
procedure on a few people agreeing with the data from your
notebook.
"East is fine ..."
Top desirable to have been at least
part of the graphics in the game. Also need a map
game.
We turn to the particulars. Well, for example,
how to make the procedure of drawing graphics
a buffer is needed to watch some games
2D or 3D graphics it uses.
We first 2D. Your task is confined ...
1. change the map to your sootvetstenno
descriptors animation
2. print the map in the buffer
3. put objects on top
4. special effects
5. end
Item 1: is not mandatory,
but ... In general up to you. How to be simpler
organize all the animation unit at
map? It's very simple! You can for example set in the memory of
this structure:
the first block of memory a second memory block
data from the first number of the next
sprite sprite
data of the second number of the next
sprite sprite
:::
. . .
. . .
:::
data NNNNNNN number of the next
sprite sprite
data NNNNN +1 number of the next
sprite sprite
:::
. . .
. . .
:::
data KKKKKKK number of the next
sprite sprite
data KKKKK +1 number of the next
sprite sprite
:::
. . .
Here, each block is assigned
serial number. Thus you will need to create a structure where
each segment contains a pointer on the next
segment, and the last segment fixated on
first. So if the unit is not animated, then fixated on herself.
This way to avoid unnecessary costs
memory and speed, as well as avoiding of unnecessary
inspections. In principle you can do without changing cards. So
You can organize a cycle and follow these steps:
N = data count
A = block number of the card-level
A = number of the block following the
A block from the table <
repeat N times
:
.
But remember, the counter should be
cycle is greater than or equal to the largest
number of phases of the animation block. Others
changes are disposable and can be
be entered directly into the card game. Can
also change the map using a specially written by SCRIPT, but
about it later ...
Item 2: Here, even explain anything
not necessary, just make
print buffer sequentially for each
block. The only advice try
to do so in the block sizes were
proportional to 8, 16, 32, etc. Himself
will be easier. But I was just because of STE and
Hedgehog clear ;-) ...
Item 3: Here, too, all in the park
day. Just everything is clear. The problem is the
much is circumcision (;-)) objects
boundaries of the screen, in a scientific clipping. Solutions
may be different, well For example, if you copy the buffer, then
you may well make such a buffer,
that he was a kind of border, then
there is a space where you can not
problems to write the entire object. Type:
AAAA-object
X1, Y1 AAAA
region spreads
to screen
border X2, Y2
This makes sense only if the objects
are independent of the card-level
that is not defined by blocks, otherwise the whole
The problem is reduced to checking the output
beyond the domain of the type:
X, Y-top-left corner
object XD = X
No
X <X2
yes
No
Y <Y2
yes
No
X> X1
yes
No
Y> Y1
yes
block lies within
Screen
X = X +1
No
X = max
size of X
yes
Y = Y +1
X = XD
No
Y = max
size of the Y
yes
all end
:
.
This technique can be applied to
independent objects, but you need to modify it, because
otherwise you'll need to check every point of the object, and
it draws unnecessary time CPU. Yes, free advice, no need to try
optimize this scheme, if you write
on ASM'e, the attempt to optimize a number of comparisons is
similar to the suicide, of course you can, but nerves and the
mat will be many.
Continued in the next section.