Amiga Computing - Commodore Is Awesome
Amiga Computing - Commodore Is Awesome
Amiga Computing - Commodore Is Awesome
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
HI South shows you<br />
ow to emulate<br />
ore arcade game<br />
chniques using the<br />
of so cheesy Amos<br />
logs, eh? I bet you don't think about them<br />
or give them a second thought, do you?<br />
You don't have the slightest idea what I'm<br />
talking about, do you? Well, o flog, for<br />
the purposes of this discourse, is a vanwhich<br />
is set to indicate to a program that a<br />
in state exists So when the flog is set, some.<br />
ng has happened that the program should know<br />
, and more importantly doesn't need to check<br />
again. Until, that is, the state changes, in which<br />
se the flag is changed and the program then<br />
s checking for that state again. Confused?<br />
y iers use on example.<br />
In arcade games, you fire a bullet from your<br />
ship/loser/whatever. The program checks the<br />
buton and if its on it activates and moves a<br />
sprite across the screen away from the gun, ii<br />
let the sound effect of the gun going off, and<br />
ks the bullet across the screen until it hits<br />
ing.<br />
So you make o loop to check for the button on<br />
joystick being pressed. Simple enough, yes?<br />
el, the first thing you notice when you write a<br />
ine like this from scratch is that when you press<br />
Duton the loop checking for the button press<br />
round about 50 times a second, so when you<br />
t you get a horrible staccato buzzing noise<br />
the bullet doesn't ocivaly leave or the buzzing<br />
se stop) until you've released the button.<br />
The buzzing noise is the bullet sound, the bong,<br />
lig played many times over and over very fast,<br />
reason the bullet doesn't leave the barrel is that<br />
skirts its journey every time the button is sensed to<br />
ir the down position. So how do you moke the<br />
If you ca re fully<br />
hallow Phil South's If Tire(I) And MISSFLAI4 Then Sol Ploy 1<br />
instructions you will NISSFLASal : Ildb 2,SX,S1,2 : NIzSX : NY.SY<br />
soon ha y. ships If 1I55ILIG=1 Then Add OX,S : Bob 2,10,17,2 : If<br />
shooting trom lb. hip<br />
- or some whe re<br />
/DOWN Then lob Off 2 : RIS5U6.0<br />
ton press once and only once? Now you're<br />
MEM I N N<br />
•<br />
t<br />
-AMIGA COMPUTING<br />
FEBRUARY 1996<br />
Nol with<br />
a bullet<br />
OVER TO YOU<br />
Why not send me your examples of Hags, and interesting uses to which they can be<br />
put. Making a process easier, showing the program that states have changed, even<br />
some interesting flip-flop effects (('II be going into those another time) - anything<br />
really as long as it's about 10 lines of code or less and it Mcludes a flag or two. I'm<br />
particularly interested in graphic elleas, but timing and more mundane task are<br />
acceptable. Perhaps there is on interface problem you can solve with these flags?<br />
Look into it. I'll look at the best in a month or two. In the meantime see you<br />
next month for another arcade game routine which you'll find handy when you<br />
design your own version of an arcade classic.<br />
getting the idea You use a flog Take the following<br />
example:<br />
If firt(l) Then Sao Play 1 : lob 2,SI,STa<br />
MPH : POW<br />
Add O0,5 : lob 2,<br />
11<br />
Oft 2<br />
IoNT,<br />
2 :<br />
I f<br />
O U P I T<br />
T I D O<br />
T h<br />
e n<br />
B<br />
h<br />
a<br />
That's simple enough Sense the joystick, make a<br />
bang [in this case a nice sample], then move the<br />
sprite Iwo pixels at a time from the barrel to the<br />
edge of the screen in a straight line. If it gets 100<br />
pixels away from the ship without hitting something<br />
it gets turned off. But this routine suffers from<br />
buzzing and no bulets. The better way of doing it<br />
is:<br />
In this version, when the button is pressed the flag<br />
•<br />
•<br />
MISSFLAG is set from 0 to 1. In the next line the missile<br />
is moved only if MISSFLAG is still 1. Until the missile<br />
moves 100 pixels away from the barrel, the flag is<br />
stil set, so the fire button is dead. You only fire one<br />
shot. When the first missile vanishes [you could<br />
explode it, but in this case it just vanishes), you con<br />
then shoot another. Obviously, you could vary the timing<br />
so that you can add a multiple shot, perhaps, or<br />
make it a second (or 50/50ths of a second' or even<br />
half a second between shots, enabling the player to<br />
get his finger off the button.<br />
This is an extremely useful technique and one<br />
which answers a lot of those questions you ask, like<br />
'how do you do that? Nine times Out of ten the<br />
answer is either flogs, subroutines or vectors. A side<br />
benefit of using flogs in your Amos programming is<br />
that these techniques ore used quite a lot in the worlds<br />
of C and assembly programming. So as and when<br />
you move on to those languages, as you might in the<br />
course of time, you will be prepared for at least one<br />
cool trick.<br />
WRITE STUFF<br />
If you have any other Amos programs or<br />
queries about Amos, please write to the<br />
usual address, which is: Phil South, Amos<br />
Column, <strong>Amiga</strong> <strong>Computing</strong>, Media House,<br />
Adlington Park, Macclesfield SKI° ANP.<br />
Please send routines on an <strong>Amiga</strong> disk<br />
with notes on how the program works<br />
on paper, not as text files on the disk.<br />
,Make the routines short enough to<br />
appear in print, i.e. no more than about<br />
30-40 lines of code and, if possible,<br />
make them use no external graphics, or<br />
if they can't be used without them then<br />
be sure to provide them on the disk in<br />
native f FF formal, and the same goes for<br />
sound files. Follow these guidelines and<br />
you'll be sure of making me a happy<br />
man if nothing else.<br />
113