📄 ldrawgam.cpp
字号:
/*********************************************************************
* - GAME SUPPORT *
*********************************************************************/
#include <ldraw.h>
#include <stdio.h>
#include <malloc.h>
///////////////////////////////////////////////////////////////////////
void lenvironment::set_blitport(short x1,short y1,short x2,short y2,short start,short end)
{ short i;
for (i=start;i<=end && i<LMAX_LAYERS;i++)
{ datas[i].left=x1, datas[i].top=y1;
datas[i].right=x2, datas[i].bottom=y2;
}
}
void lenvironment::blit_to_scr(short double_buf)
{ short i=double_buf,len,wid;
len=datas[i].right-datas[i].left+1;
wid=datas[i].bottom-datas[i].top+1;
lOutToScr(&layers[i], datas[i].left,datas[i].top,
datas[i].x,datas[i].y,datas[i].x+len-1,datas[i].y+wid-1);
}
void lenvironment::blit_all(short double_buf)
{ short i,len,wid;
for (i=0;i<LMAX_LAYERS;i++)
if (i!=double_buf && datas[i].flag==1)
{ len=datas[i].right-datas[i].left+1;
wid=datas[i].bottom-datas[i].top+1;
lBlitFast(&layers[double_buf],datas[i].left,datas[i].top,
datas[i].x,datas[i].y,datas[i].x+len-1,datas[i].y+wid-1,
&layers[i],datas[i].key_color);
}
}
void lenvironment::blit(short double_buf,short i)
{ short len,wid;
if (double_buf<LMAX_LAYERS&&i<LMAX_LAYERS&&
layers[double_buf].mode&&layers[i].mode) {
len=datas[i].right-datas[i].left+1;
wid=datas[i].bottom-datas[i].top+1;
lBlitFast(&layers[double_buf],datas[i].left,datas[i].top,
datas[i].x,datas[i].y,datas[i].x+len-1,datas[i].y+wid-1,
&layers[i],datas[i].key_color);
}
}
void lenvironment::active(short i)
{ if (i>=0&&i<LMAX_LAYERS) lActiveSurface(&layers[i]);
else lActiveSurface(NULL);
}
int lenvironment::create(int i,int len,int wid)
{ if (layers[i].mode) lDeleteSurface(&layers[i]);
lCreateSurface(len,wid,&layers[i],NULL,LSM_MEMORY);
datas[i].left=datas[i].top=0; datas[i].flag=0;
if (layers[i].mode==0) return -1;
datas[i].right=layers[i].len-1;
datas[i].bottom=layers[i].wid-1;
datas[i].flag=1;
return 0;
}
int lenvironment::destroy(int i)
{ datas[i].left=datas[i].top=0; datas[i].flag=0;
datas[i].flag=0;
lDeleteSurface(&layers[i]);
return 0;
}
lenvironment::lenvironment()
{ short i;
for (i=0;i<LMAX_LAYERS;i++) layers[i].mode=0;
}
lenvironment::~lenvironment()
{ short i;
lActiveSurface(NULL);
for (i=0;i<LMAX_LAYERS;i++) destroy(i);
}
///////////////////////////////
void lePImageFade(short x,short y,char *b,short deep)
{ short i,j,len,wid; register short c,ct;
len=*(short*)b; b+=2; wid=*(short*)b; b+=2;
for (j=0;j<wid;j++)
for (i=0;i<len;i++)
{ c=*b; b++;
if (c) {
ct=c&0xf0; if (c<240) c+=deep;
if (c<ct) c=ct; else if (c>ct+15) c=ct+15;
lpixel(x+i,y+j,c);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -