• 大小: 90KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-07-10
  • 语言: C/C++
  • 标签: game  

资源简介

用opengl技术实现3D俄罗斯方块游戏 主要语言是通过使用vc++来实现

资源截图

代码片段和文件信息

//Download by http://www.NewXing.com
// Info.cpp: implementation of the Info class.
//
//////////////////////////////////////////////////////////////////////

#include “Info.h“

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#include “Tetris.h“
extern Tetris m_block;

extern int score;
extern int level;
extern int lines;

Info::Info()
{
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken &gdiplusStartupInput NULL);

m_bkcolor.SetFromCOLORREF(RGB(203040));
SolidBrush brush(m_bkcolor);
Pen pen(m_bkcolor);
m_bkbrush=brush.Clone();
m_bkpen=pen.Clone();
}

Info::~Info()
{
GdiplusShutdown(gdiplusToken);
}

void Info::SetWnd(HWND wnd)
{
infownd=wnd;
infodc=GetDC(infownd);
m_graphics=Graphics::FromHDC(infodc);

RECT rect;
GetClientRect(infownd&rect);

mainrect.X=rect.left;
mainrect.Y=rect.top;
mainrect.Width=rect.right-rect.left;
mainrect.Height=rect.bottom-rect.top;

frect.X=mainrect.X;
frect.Y=mainrect.Width/2;
frect.Width=mainrect.Width/3;
frect.Height=mainrect.Height-mainrect.Width/2;

prect.X=mainrect.X;
prect.Y=mainrect.Y;
prect.Width=mainrect.Width;
prect.Height=mainrect.Width/2;

slrect.X=mainrect.Width/3;
slrect.Y=mainrect.Width/2;
slrect.Width=mainrect.Width*2/3;
slrect.Height=mainrect.Height-mainrect.Width/2;

LoadImage();
}

void Info::DrawDC()
{
m_graphics->Clear(m_bkcolor);

DrawFloor();

DrawPreview();

DrawSL();
}

void Info::LoadImage()
{
m_pre=Image::FromFile(L“Data/gl/b10.bmp“);

m_floor[0]=Image::FromFile(L“Data/info/floor.png“);
int i;
unsigned short filename[50];
for(i=1;i<=10;i++)
{
swprintf(filenameL“Data/info/f%d.png“i);
m_floor[i]=Image::FromFile(filename);
}
}

void Info::DrawFloor()
{
Bitmap floorbmp(m_floor[0]->GetWidth()m_floor[0]->GetHeight());
Graphics floordc(&floorbmp);

floordc.DrawImage(m_floor[0]00m_floor[0]->GetWidth()m_floor[0]->GetHeight());

int i;
int height=m_block.GetAlHeight();
int x=6y=8+(10-height)*18;

if(height!=0)
{
if(height>1)
{
for(i=height;i>=2;i--)
{
floordc.DrawImage(m_floor[i]xy2218);
y+=18;
}
}
floordc.DrawImage(m_floor[1]xy2223);
}


POINT3D* p;
int count=m_block.GetCurrent(&p);

Pen pen(Color(255255255)1);
x=10;
for(i=0;i<=count-1;i++)
{
y=11-(p[i].z+1)*18;
floordc.DrawRectangle(&penxy139);
}

m_graphics->DrawImage(&floorbmpfrect);
}

void Info::DrawPreview()
{
Bitmap prebmp(200100);
Graphics predc(&prebmp);
predc.Clear(m_bkcolor);

int bound=5;
int w=prebmp.GetWidth()-2*bound;
int h=prebmp.GetHeight()-2*bound;
float sizex=w/4;
float sizey=h/2;
float x=sizex+bound;
float y=sizey+bound;

PointF* p;
int i;
int count=m_block.GetPreBlock(&p);
for(i=0;i<=count-1;i++)
{
predc.Draw

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        411  2013-12-02 05:08  www.NewXing.com\all_header.h

     文件       3472  2013-12-02 05:08  www.NewXing.com\GdiPlus.h

     文件        895  2013-12-02 05:08  www.NewXing.com\GdiPlusbase.h

     文件      22366  2013-12-02 05:08  www.NewXing.com\GdiPlusBitmap.h

     文件      30840  2013-12-02 05:08  www.NewXing.com\GdiPlusBrush.h

     文件       1811  2013-12-02 05:08  www.NewXing.com\GdiPlusCachedBitmap.h

     文件       4366  2013-12-02 05:08  www.NewXing.com\GdiPlusColor.h

     文件       1788  2013-12-02 05:08  www.NewXing.com\GdiPlusColorMatrix.h

     文件      55959  2013-12-02 05:08  www.NewXing.com\GdiPlusEnums.h

     文件      87501  2013-12-02 05:08  www.NewXing.com\GdiPlusFlat.h

     文件       6019  2013-12-02 05:08  www.NewXing.com\GdiPlusFont.h

     文件       3439  2013-12-02 05:08  www.NewXing.com\GdiPlusFontCollection.h

     文件       6109  2013-12-02 05:08  www.NewXing.com\GdiPlusFontFamily.h

     文件       2763  2013-12-02 05:08  www.NewXing.com\GdiPlusGpStubs.h

     文件      93915  2013-12-02 05:08  www.NewXing.com\GdiPlusGraphics.h

     文件      22213  2013-12-02 05:08  www.NewXing.com\GdiPlusHeaders.h

     文件      13818  2013-12-02 05:08  www.NewXing.com\GdiPlusimageAttributes.h

     文件       1631  2013-12-02 05:08  www.NewXing.com\GdiPlusImageCodec.h

     文件      24306  2013-12-02 05:08  www.NewXing.com\GdiPlusImaging.h

     文件       3209  2013-12-02 05:08  www.NewXing.com\GdiPlusInit.h

     文件       6333  2013-12-02 05:08  www.NewXing.com\GdiPlusLineCaps.h

     文件       8503  2013-12-02 05:08  www.NewXing.com\GdiPlusMatrix.h

     文件       1121  2013-12-02 05:08  www.NewXing.com\GdiPlusMem.h

     文件      11843  2013-12-02 05:08  www.NewXing.com\GdiPlusmetaFile.h

     文件       8189  2013-12-02 05:08  www.NewXing.com\GdiPlusmetaHeader.h

     文件      50508  2013-12-02 05:08  www.NewXing.com\GdiPlusPath.h

     文件      13673  2013-12-02 05:08  www.NewXing.com\GdiPlusPen.h

     文件       6834  2013-12-02 05:08  www.NewXing.com\GdiPlusPixelFormats.h

     文件      13326  2013-12-02 05:08  www.NewXing.com\GdiPlusRegion.h

     文件       9390  2013-12-02 05:08  www.NewXing.com\GdiPlusStringFormat.h

............此处省略38个文件信息

评论

共有 条评论