?? picturegroup.cpp
字號:
// PictureGroup.cpp: implementation of the PictureGroup class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PictureGroup.h"
#include <Mmsystem.h>
#include "log.h"
#include <stdio.h>
#include "EasyDraw.h"
#include "Map.h"
extern EasyDraw theEasyDraw;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
PictureGroup::PictureGroup()
{
frame=1;
Depth=32;
count=0;
lastcount=-1;
}
PictureGroup::~PictureGroup()
{
}
void PictureGroup::Init(char *Filename,int Buildx,int Buildy)
{
this->buildingx=Buildx;
this->buildingy=Buildy;
// busurface.CreateImageSurface("iron_barrier_02.bmp",96,99,DDBLTFAST_NOCOLORKEY);
temp.CreateImageSurface(Filename,false,false,DDBLTFAST_NOCOLORKEY);
for(int i=0;i<8;i++)
for(int j=0;j<15;j++)
{
Surface* npc=new Surface();
npc->CreateNullSurface(74,77,false,false,DDBLTFAST_NOCOLORKEY);
RECT rect={j*74,i*77,(j+1)*74,(i+1)*77};
temp.BltTo(0,0,npc,&rect);
npc->SetSurfaceColorKey(0x0000);
m_SurfaceArray.push_back(npc);
}
lastTick=timeGetTime();
log::instance().dump("pict.cpp","487");
}
inline void BrightnessAndContrast3(int& red,int& green,int& blue,
int contrast,int brightness)
{
static int old_c = 0,old_b = 0;
static int extra_c = 0;
static float ratio = 0;
if( contrast!=old_c )
{
ratio = (float)contrast/100;
extra_c = -127*ratio;
old_c = contrast;
}
if( brightness!=old_b)
{
extra_c += brightness;
old_b = brightness;
}
red -= red*ratio + extra_c;
green -= green*ratio + extra_c;
blue -= blue*ratio + extra_c;
if(red>255) red=255;
if(green>255) green=255;
if(blue>255) blue=255;
if(red<0) red=0;
if(green<0) green=0;
if(blue<0) blue=0;
}
inline void BrightnessAndContrast(int& red,int& green,int& blue,
int contrast,int brightness)
{
static int old_c = 0,old_b = 0;
static int extra_c = 0;
static float ratio = 0;
if( contrast!=old_c )
{
ratio = (float)contrast/100;
extra_c = -127*ratio;
old_c = contrast;
}
if( brightness!=old_b)
{
extra_c += brightness;
old_b = brightness;
}
red += red*ratio + extra_c;
green += green*ratio + extra_c;
blue += blue*ratio + extra_c;
if(red>255) red=255;
if(green>255) green=255;
if(blue>255) blue=255;
if(red<0) red=0;
if(green<0) green=0;
if(blue<0) blue=0;
}
#define _MY16RGB565(r,g,b) ((b>>3) + ( (g>>2)<< 5 ) + ( (r>>3)<<11 ))
void PictureGroup::ShowBuilding(POINT view)
{
LPDIRECTDRAWSURFACE7 temp;
LPDIRECTDRAWSURFACE7 back;
back = GetEasyDrawPointer()->GetBackSurface();
temp = GetEasyDrawPointer()->GetTempSurface();
if((timeGetTime()-lastTick)>50)
{
frame++;
if((frame%4)==0)
{
// buildingy+=10;
}
frame=frame%120;
lastcount=count;
count++;
lastTick=timeGetTime();
// log::instance().dump("pict.cpp",str);
}
// sprintf(str,"y=%d",y);
// log::instance().dump("pict.cpp",str);
if(view.x>(this->buildingx+this->m_SurfaceArray[frame]->GetWidth()))
{
return;
}
if(view.y>(this->buildingy+this->m_SurfaceArray[frame]->GetHeight()))
{
return;
}
int renderx=100;
int rendery=100;
this->m_SurfaceArray[frame]->DrawAlphaShadow(buildingx,buildingy);
this->m_SurfaceArray[frame]->DrawAutoClip(buildingx,buildingy);
//把后臺頁面的矩形拷貝到特效頁面上
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -