⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 floor.cpp

📁 一个三维打斗游戏
💻 CPP
字号:
// (C) Copyright 1996 by Anthony J. Carin.  All Rights Reserved.

#include <stdafx.h>
#include "floor.h"
#include <3dtools.h>

extern CString& getpath(CString& filename);


const float FLOORRANGE = 6.0f;
const float FLOORHIGHT = -.3f;

floortype::floortype()
{
   m_surface = new surfs();
   tilesize = FLOORRANGE*2;
   m_surface->setcolor(RGB(148,148,40));
}

floortype::floortype(CString& c)
{
   m_surface = new bmpsurf(c);
   tilesize = FLOORRANGE*2;
   ((bmpsurf*)m_surface)->ExemptFromIntersect();
}

floortype::~floortype()
{
   delete m_surface;
}

static float Material[] = {0.7f, 0.7f, 0.7f, 1.0f};

void floortype::draw(coordinate& coord)
{
   float cx,cz;
   tccolor color = m_surface->color();
   coordinate t_a,t_b,t_c,t_d;
   getentirearea(coord);
   Game->Tool3d()->material(color);
   for (float x = m_a.x(); x < m_b.x(); x += tilesize)
   {
      for (float z = m_a.z(); z < m_c.z(); z += tilesize)
      {
         cx = x;
         cz = z;
         t_a.setto(cx, FLOORHIGHT, cz);
         cx += tilesize;
         t_b.setto(cx, FLOORHIGHT, cz);
         cz += tilesize;
         t_c.setto(cx, FLOORHIGHT, cz);
         cx -= tilesize;
         t_d.setto(cx, FLOORHIGHT, cz);
         m_surface->setto(t_a,t_b,t_c,t_d);
         m_surface->draw();
      }
   }
}

void floortype::getentirearea(coordinate& coord)
{
   int tmpx, tmpz;
   tmpx = (int) (coord.x() - FLOORRANGE);
   tmpz = (int) (coord.z() - FLOORRANGE);
   m_a.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
   tmpx = (int) (coord.x() + FLOORRANGE);
   m_b.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
   tmpz = (int) (coord.z() + FLOORRANGE);
   m_c.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
   tmpx = (int) (coord.x() - FLOORRANGE);
   m_d.setto((float) tmpx, FLOORHIGHT, (float) tmpz);
}

void floortype::settexture(CString& c)
{
   delete m_surface;
   m_surface = new bmpsurf(getpath(c));
   tilesize = FLOORRANGE*2;
   ((bmpsurf*)m_surface)->ExemptFromIntersect();
}

void floortype::cleartexture()
{
   delete m_surface;
   m_surface = new surfs();
   tilesize = FLOORRANGE*2;
   m_surface->setcolor(RGB(148,148,40));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -