Esempio n. 1
0
maze::maze() {
    // open the file
    mazefile = fopen("Maze.txt", "r");

    // get the dimensions of the maze
    ydim = getdimension();
    xdim = getdimension();

    // allocate memory for the maze array
    mazearray = new char*[xdim];
    for (int x = 0; x < xdim; x++) {
        mazearray[x] = new char[ydim];
    }

    // start constructing the maze
    for (int y = 0; y < ydim; y++) {
        for (int x = 0; x < xdim; x++) {
            char c = getcharacter();
            mazearray[x][y] = c;
            // if we found the start point, record it
            if (c == '*') {
                start[0] = x;
                start[1] = y;
                // std::cout << "found the start at location: " << start[0] << ", " << start[1] << std::endl;
            }
        }
    }

    // close the file
    fclose(mazefile);
}
Esempio n. 2
0
void DreamGenContext::calcmapad() {
	uint8 mapXstart, mapYstart;
	uint8 mapXsize, mapYsize;
	getdimension(&mapXstart, &mapYstart, &mapXsize, &mapYsize);
	data.word(kMapadx) = data.word(kMapoffsetx) - 8 * (mapXsize + 2 * mapXstart - 11);
	data.word(kMapady) = data.word(kMapoffsety) - 8 * (mapYsize + 2 * mapYstart - 10);
}
Esempio n. 3
0
void DreamGenContext::getdimension()
{
	uint8 mapXstart, mapYstart;
	uint8 mapXsize, mapYsize;
	getdimension(&mapXstart, &mapYstart, &mapXsize, &mapYsize);
	cl = mapXstart;
	ch = mapYstart;
	dl = mapXsize;
	dh = mapYsize;
}
Esempio n. 4
0
threp::threp(const TH1* hin){
  nbin[0]=0;
  nbin[1]=0;
  nbin[2]=0;
  
  name=hin->GetName();
  title=hin->GetTitle();
  opt=hin->GetOption();
  htype=getkind(hin);
  int ndim=getdimension();
  if(ndim>0){
    nbin[0]=hin->GetNbinsX();
    for (int jj=0;jj<nbin[0];jj++)
      xlim.push_back(hin->GetXaxis()->GetBinLowEdge(jj+1));
    xlim.push_back(hin->GetXaxis()->GetBinUpEdge(nbin[0]));
  }
  if(ndim>1){
    nbin[1]=hin->GetNbinsY();
    for (int jj=0;jj<nbin[1];jj++)
      ylim.push_back(hin->GetYaxis()->GetBinLowEdge(jj+1));
    ylim.push_back(hin->GetYaxis()->GetBinUpEdge(nbin[1]));
  }
  
  if(ndim>2){
    nbin[2]=hin->GetNbinsZ();
    for (int jj=0;jj<nbin[2];jj++)
      zlim.push_back(hin->GetZaxis()->GetBinLowEdge(jj+1));
    zlim.push_back(hin->GetZaxis()->GetBinUpEdge(nbin[2]));
  }

  if(htype==ktprofile){
    double ymin=((TProfile*)hin)->GetYmin();
    double ymax=((TProfile*)hin)->GetYmax();
    if(ymin==ymax) nbin[1]=0;
    else{
      nbin[1]=2;
      ylim.push_back(ymin);
      ylim.push_back(ymax);
    }
  }

  if(htype==ktprofile2d){
    double zmin=((TProfile2D*)hin)->GetZmin();
    double zmax=((TProfile2D*)hin)->GetZmax();
    if(zmin==zmax) nbin[2]=0;
    else{
      nbin[2]=2;
      zlim.push_back(zmin);
      zlim.push_back(zmax);
    }
  }

}