129 lines
4.4 KiB
Plaintext
129 lines
4.4 KiB
Plaintext
//$FG,2$These images were created with $FG,4$CTRL-R$FG$
|
|
$FG$//$FG,2$and can be edited by moving the$FG$
|
|
//$FG,2$cursor on top and pressing $FG,4$CTRL-R$FG$
|
|
//$FG,2$again.$FG$
|
|
|
|
//$FG,2$Press $FG,4$CTRL-T$FG,2$ to see the number of$FG$
|
|
//$FG,2$the image and $FG,4$CTRL-T$FG,2$ again to get back.$FG$
|
|
//$FG,2$Numbers are assigned by the editor.$FG$
|
|
|
|
|
|
$PI,"<3>",3$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$PI,"<2>",2$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_TREES 128
|
|
|
|
I8 x=100,y=100;
|
|
I8 trees_x[NUM_TREES],trees_y[NUM_TREES];
|
|
I8 cur_screen_y=0;
|
|
I8 score=0;
|
|
|
|
void DrawIt(TssStruct *tss)
|
|
{
|
|
I8 buf[128];
|
|
I8 i;
|
|
GrBitMap *base=GrAlias(grbase2,tss);
|
|
|
|
//$FG,2$Without this, we see background text.$FG$
|
|
//$FG,2$Change $FG,4$Fs->text_attribute$FG,2$ if you want$FG$
|
|
//$FG,2$to change the background color.$FG$
|
|
ClearWinText(tss);
|
|
|
|
//$FG,2$Press $FG,4$CTLR-T$FG,2$ to see the syntax of the$FG$
|
|
//$FG,2$"Insert Binary" statement in the following.$FG$
|
|
for (i=0;i<NUM_TREES;i++)
|
|
GrElemsPlot(base,trees_x[i],trees_y[i]-cur_screen_y,0,$IB,"<2>",2$);
|
|
|
|
base->collision_cnt=0;
|
|
base->bkcolor=ROP_COLLISION+WHITE;
|
|
GrElemsPlot(base,x,y,0,$IB,"<3>",3$);
|
|
if (base->collision_cnt) {
|
|
Sound(400);
|
|
score++;
|
|
} else
|
|
Sound(0);
|
|
|
|
base->bkcolor=ROP_EQU;
|
|
GrElemsPlot(base,x,y,0,$IB,"<3>",3$);
|
|
GrDel(base);
|
|
|
|
//$FG,2$Text attributes include forground in the$FG$
|
|
//$FG,2$lowest 4 bits and background in the upper 4.$FG$
|
|
SPrintF(buf,"Score:%d",score);
|
|
PlotWinStr(tss,buf,BLACK+WHITE*16,1,1);
|
|
}
|
|
|
|
void InitTrees()
|
|
{
|
|
I8 i;
|
|
for (i=0;i<NUM_TREES;i++) {
|
|
trees_x[i]=RandU4%GR_WIDTH;
|
|
trees_y[i]=RandU4%2048;
|
|
}
|
|
}
|
|
|
|
|
|
void BlackDiamond()
|
|
{
|
|
I8 ch,sc;
|
|
void *old_update=Fs->update_win;
|
|
BoolU4 old_border=WinBorder(OFF);
|
|
WinMax;
|
|
Fs->update_win=&DrawIt;
|
|
InitTrees;
|
|
do {
|
|
if (ScanKey(&ch,&sc)) {
|
|
switch (sc.u1[0]) {
|
|
case SC_CURSOR_RIGHT:
|
|
x+=10;
|
|
if (x>=GR_WIDTH) x-=GR_WIDTH;
|
|
break;
|
|
case SC_CURSOR_LEFT:
|
|
x-=10;
|
|
if (x<0) x+=GR_WIDTH;
|
|
break;
|
|
case SC_CURSOR_UP:
|
|
y-=10;
|
|
if (y<0) y+=GR_HEIGHT;
|
|
break;
|
|
case SC_CURSOR_DOWN:
|
|
y+=10;
|
|
if (y>=GR_HEIGHT) y-=GR_HEIGHT;
|
|
break;
|
|
}
|
|
|
|
//$FG,2$We don't want keystrokes building-up$FG$
|
|
//$FG,2$in the buffer.$FG$
|
|
FlushMsgs;
|
|
}
|
|
y=(y+1)%GR_HEIGHT;
|
|
cur_screen_y=(cur_screen_y+1)%(2048-GR_HEIGHT);
|
|
|
|
Sleep(20);
|
|
} while (ch!=CH_ESC && ch!=CH_CTRLQ);
|
|
Fs->update_win=old_update;
|
|
WinBorder(old_border);
|
|
}
|
|
|
|
//$FG,2$Start game when $FG,4$#include$FG,2$d.$FG$
|
|
BlackDiamond;
|
|
|