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

📄 matrix.hh

📁 一个机器人平台
💻 HH
字号:
// ==================================================================// Filename:	CMatrix.h//// $Id: matrix.hh,v 1.4 2002/11/01 19:12:29 rtv Exp $// RTV// ==================================================================#ifndef _MATRIX_CLASS_#define _MATRIX_CLASS_#include <stdio.h>#include <stdlib.h>#include <string.h>#include "entity.hh"class CMatrix{  public:  int	width;  int	height;  private:  CEntity***  data;  unsigned char* used_slots;  unsigned char* available_slots;    public:  CMatrix(int w, int h, int default_buf_size);  ~CMatrix(void);      inline int get_width(void) {return width;}  inline int get_height(void) {return height;}  inline int get_size(void) {return width*height;}    // MUST BE IN-BOUNDS!  // get a pixel color by its x,y coordinate  inline CEntity** get_cell(int x, int y)    {       //if (x<0 || x>=width || y<0 || y>=height)       //{      //fputs("Stage: WARNING: CEntity::get_cell(int,int) out-of-bounds\n",      //stderr);      //return 0;      //}            return data[x+(y*width)];     }    // get a pixel color by its position in the array  inline CEntity** get_cell( int i)    {       if( i<0 || i > width*height )       {        fputs("Stage: WARNING: CEntity::get_cell(int) out-of-bounds\n",stderr);        return 0;      }      return data[i];     }    // is there an object of this type here?  inline bool is_type( int x, int y, int type )    {       //if( i<0 || i > width*height ) return 0;          CEntity** cell = data[x+(y*width)];          while( *cell )      {        if( (*cell)->lib_entry->type_num == type ) return true;        cell++;      }          return false;    }    inline void set_cell(int x, int y, CEntity* ent );  inline void unset_cell(int x, int y, CEntity* ent );    void	copy_from(CMatrix* img);  void	draw_line(int x1, int y1, int x2, int y2, CEntity* ent, bool add);  void	draw_rect( const Rect& t, CEntity* ent, bool add );  void	draw_circle(int x, int y, int r, CEntity* ent, bool add);    CEntity** line_detect(int x1,int y1,int x2,int y2);  CEntity** rect_detect( const Rect& r);    void	clear( void );// utilities for visualizing the matrix  void dump( void );#ifdef INCLUDE_RTK2  rtk_fig_t* fig;  void render( CWorld* world );  void unrender( void );#endif  void PrintCell( int cell );  void CheckCell( int cell );  };#endif

⌨️ 快捷键说明

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