fileCellSet.cpp
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
/*
*  CellSet.cpp
*
*  Created by Daisuke Nogami on Sep, 05.
*  opyright 2005 Daisuke Nogami [null-null.net]. Some rights reserved.
*/
 
#include "stdafx.h"
#include "CellSet.h"
 
// cell's param
#define X_POS 77
#define Y_POS 95
#define X_DIV 18
#define Y_DIV 11
 
//#define X_POS -35
//#define Y_POS 95
//#define X_DIV 23
//#define Y_DIV 11
 
CellSet::CellSet(){
  this->xpos = X_POS;
  this->ypos = Y_POS;
  this->wdiv = X_DIV;
  this->hdiv = Y_DIV;
 
  // initialize cells
  cells_a = new Cell[wdiv*hdiv];
  cells_b = new Cell[wdiv*hdiv];
  int x, y, i;
  for( y = 0; y < hdiv; y++ ){
    for( x = 0; x < wdiv; x++ ){
      i = x+y*wdiv;
      cells_a[i].init( (float)x*50, (float)y*60, 30, 0 );
      cells_b[i].init( (float)x*50+15, (float)y*60-25, 30, 1 );
    }
  }
}
 
CellSet::~CellSet(){
  delete []this->cells_a;
  delete []this->cells_b;
  this->cells_a = 0;
  this->cells_b = 0;
}
 
void CellSet::update_and_draw(){
  int x, y, i;
 
  glPushMatrix();
  glTranslatef( xpos, ypos, 0.0 );
  for( y = 0; y < hdiv; y++ ){
    for( x = 0; x < wdiv; x++ ){
      i = x+y*wdiv;
      cells_a[i].update();
      cells_b[i].update();
      cells_a[i].draw();
      cells_b[i].draw();
    }
  }
  glPopMatrix();
}
[トップ] [一覧] [最終更新] [検索] [バックアップ]