Example #1
0
void initCartesian ( ) {
    static bool uninitialized = true;
    if (uninitialized) {
        initAxis();
        initGrid();
    }
    else {
        initGrid();
        initAxis();
    }
    uninitialized = not uninitialized;
}
Example #2
0
File: Grid.cpp Project: PennTao/GPU
int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowSize(1027, 768);
	glutCreateWindow("Meshes with Shaders");
	glewInit();
	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
		/* Problem: glewInit failed, something is seriously wrong. */
		std::cout << "glewInit failed, aborting." << std::endl;
		exit (1);
	}
	std::cout << "Status: Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
	std::cout << "OpenGL version " << glGetString(GL_VERSION) << " supported" << std::endl;
    
    init();
	initGrid();
    initShader();
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);	
    glutKeyboardFunc(keyboard);
	
	
	glutMainLoop();
	return 0;
}
Example #3
0
REAL   value(   PrivGlobs    globs,
                const REAL s0,
                const REAL strike,
                const REAL t,
                const REAL alpha,
                const REAL nu,
                const REAL beta,
                const unsigned int numX,
                const unsigned int numY,
                const unsigned int numT
) {
    initGrid(s0,alpha,nu,t, numX, numY, numT, globs);
    initOperator(globs.myX,globs.myDxx);
    initOperator(globs.myY,globs.myDyy);

    setPayoff(strike, globs);
    // globs is global and cannot be privatized thus this loop cannot be
    // parallelized yet.
    // If updateParams and rollback is independent on i and globs, loop can be
    // parallelized by privatization of initGrid, initOperator and setPayoff calls.
    // If they write indepedently to globs, privatization is not needed.
    for(int i = globs.myTimeline.size()-2;i>=0;--i) // seq
    {
        updateParams(i,alpha,beta,nu,globs);
        rollback(i, globs);
    }

    return globs.myResult[globs.myXindex][globs.myYindex];
}
Example #4
0
File: t2048.c Project: 1cook/t2048
//initializes initial values of the save structure
void makeSave(SAVE *saveFile){
	saveFile->score = 0;
	saveFile->bscore = 0;
	strncpy(saveFile->name,"...",10);
	saveFile->animations = 1;
	initGrid(saveFile->grid);
}
void Schrodinger::solveEquation()
{
    initGrid();

    cout << "schrodinger equation" << endl;

    double gamma = time_step / (coor_step * coor_step);
    grid_t g(0, -gamma / 2);
    grid_t im_time(0, time_step), im_gamma(1, gamma);

    for (int t = 1; t < gridRow; t++) {
        (*grid)[t][0] = leftBoundaryFunction(t * time_step);
        (*grid)[t][gridCol - 1] = rightBoundaryFunction(t * time_step);

        vector< grid_t > c(gridCol - 2, 0), f(gridCol - 2, 0);

        for (int x = 0; x < gridCol - 2; x++)
            c[x] = im_gamma - im_time * schrodingerFunction(left + (x + 1) * coor_step,
                                                                       t   * time_step);
        f[0] = -g * (*grid)[t][0];
        f[gridCol - 3] = -g * (*grid)[t][gridCol - 1];

        for (int x = 0; x < gridCol - 2; x++)
            f[x] += (*grid)[t - 1][x + 1];

        for (int x = 1; x < gridCol - 2; x++) {
            c[x] -= g * g / c[x - 1];
            f[x] -= g * f[x - 1] / c[x - 1];
        }

        (*grid)[t][gridCol - 2] = f[gridCol - 3] / c[gridCol - 3];
        for (int x = gridCol - 3; x > 0; x--)
            (*grid)[t][x] = (f[x - 1] - g * (*grid)[t][x + 1]) / c[x - 1];
    }
}
Example #6
0
	void AdaBoostMDPClassifier::createGridWorld() 
	{
		start_values = new std::set<char>();
		target_values = new std::set<char>();
		prohibited_values = new std::set<char>();
		grid = new std::vector<char *>();
		this->size_x = _weakHypotheses.size() + 1; // for initial and end state
		this->size_y = 1;
		initGrid();
		
		
		//addStartValue('0');
		
		start_values->insert('0');
		target_values->insert('2');
		prohibited_values->insert('3');
		
		grid->push_back(new char[size_x]);
		for (int j =0; j < size_x; ++j)
		{
			(*grid)[0][j] = '1';
		}
		
		(*grid)[0][0] = '0';
		(*grid)[0][size_x-1] = '2';
		
		parseGrid();
		
		is_allocated = true;
	}		
Example #7
0
REAL
value(const unsigned i,
      const REAL s0,
      const REAL t,
      const REAL alpha,
      const REAL nu,
      const REAL beta,
      const unsigned int numX,
      const unsigned int numY,
      const unsigned int numT)
{
  REAL strike;
  PrivGlobs    globs(numX, numY, numT);
  strike = 0.001*i;
  initGrid(s0, alpha, nu, t, numX, numY, numT, globs);
  initOperator(globs.myX, globs.myDxx);
  initOperator(globs.myY, globs.myDyy);

  setPayoff(strike, globs);
  for(int i = globs.myTimeline.size()-2; i >= 0; i--) {
    updateParams(i,alpha,beta,nu,globs);
    rollback(i, globs);
  }

  return globs.myResult[globs.myXindex][globs.myYindex];
}
Example #8
0
File: gol.c Project: brugalter/gol
int main()

{
    srand((unsigned int) time(NULL));
    int grid[ROWS][COLS];
    initGrid(ROWS, COLS, grid);
    printGrid(ROWS, COLS, grid);

    int i, g;

    g = getUserInput();
    for(i = 0; i < g; i++)
    {
        generation++;
        proccessGeneration(ROWS, COLS, grid);
        printGrid(ROWS, COLS, grid);
        sleep(99999);
        putchar('\n');
    }



    return 0;

}
Example #9
0
/**
* @brief Verify that the initGrid function correctly initialize the grid in order to break the walls between the cells.
*/
void verifyInitGrid() {
    GRID grid;
    grid.height = 5;
    grid.width = 5;

    int matrix[5][5] = {
        {WALL, WALL, WALL, WALL, WALL},
        {WALL, WALL, WALL, WALL, WALL},
        {WALL, WALL, WALL, WALL, WALL},
        {WALL, WALL, WALL, WALL, WALL},
        {WALL, WALL, WALL, WALL, WALL}
    };

    grid.matrix = (int**) matrix;

    initGrid(&grid);

    CU_ASSERT(grid.height == 5);
    CU_ASSERT(grid.width == 5);
    CU_ASSERT(grid.matrix[1][1] == 1);
    CU_ASSERT(grid.matrix[1][3] == 2);
    CU_ASSERT(grid.matrix[2][1] == 3);
    CU_ASSERT(grid.matrix[2][3] == 4);
    CU_ASSERT(grid.matrix[3][1] == 5);
    CU_ASSERT(grid.matrix[3][3] == 6);
}
Example #10
0
void CHumanGrid::init()
{
  human_grid_pub_ = n_.advertise<nav_msgs::OccupancyGrid>("human/grid", 10);
  highest_point_pub_ = n_.advertise<geometry_msgs::PointStamped>("human/maximum_probability", 10) ;
  local_maxima_pub_ = n_.advertise<geometry_msgs::PoseArray>("human/local_maxima", 10);
  proj_pub_ = n_.advertise<geometry_msgs::PoseArray>("human/projection", 10);


  initGrid();
  calculateProbabilityThreshold();
  leg_prob_.poses.resize(1600); //TODO: FIX THIS
  sound_prob_.poses.resize(1600);
  torso_prob_.poses.resize(1600);
  occupancy_grid_.data.resize(grid_->grid_size, 0.0);
  occupancy_grid_.info.height = occupancy_grid_.info.width = 40;
  occupancy_grid_.info.resolution = 0.5;
  occupancy_grid_.info.origin.position.x = (float) 40 * 0.5 / -2.0;
  occupancy_grid_.info.origin.position.y = (float) 40 * 0.5 / -2.0;
  occupancy_grid_.header.frame_id = "base_footprint";
  hp_.header.frame_id = "base_footprint";
  tracked_hp_.point.z = hp_.point.z = 0.0;
  tracked_hp_.point.x = tracked_hp_.point.y = -10.0;
  hp_.point.x = hp_.point.y = -10.0;
  last_time_ = ros::Time::now();
  state_time_ = ros::Time::now();
}
Example #11
0
void View3D::initializeGL()
{
    if (glewInit() != GLEW_OK)
    {
        g_logger.error("%s", "Failed to initialize GLEW");
        m_badOpenGL = true;
        return;
    }

    g_logger.info("OpenGL implementation:\n"
                  "  GL_VENDOR    = %s\n"
                  "  GL_RENDERER  = %s\n"
                  "  GL_VERSION   = %s\n"
                  "  GLSL_VERSION = %s\n"
                  "  GLEW_VERSION = %s",
                  (const char*)glGetString(GL_VENDOR),
                  (const char*)glGetString(GL_RENDERER),
                  (const char*)glGetString(GL_VERSION),
                  (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION),
                  (const char*)glewGetString(GLEW_VERSION));

    // GL_CHECK has to be defined for this to actually do something
    glCheckError();

    initCursor(10, 1);
    initAxes();
    initGrid(2.0f);

    glCheckError();

    m_boundingBoxShader.reset(new ShaderProgram());
    m_boundingBoxShader->setShaderFromSourceFile("shaders:bounding_box.glsl");

    m_meshFaceShader.reset(new ShaderProgram());
    m_meshFaceShader->setShaderFromSourceFile("shaders:meshface.glsl");

    m_meshEdgeShader.reset(new ShaderProgram());
    m_meshEdgeShader->setShaderFromSourceFile("shaders:meshedge.glsl");

    m_annotationShader.reset(new ShaderProgram());
    m_annotationShader->setShaderFromSourceFile("shaders:annotation.glsl");

    double dPR = getDevicePixelRatio();
    int w = width() * dPR;
    int h = height() * dPR;

    m_incrementalFramebuffer.init(w, h);

    initializeGLGeometry(0, m_geometries->get().size());

    // FIXME: Do something about this mess.  The shader editor widget needs to
    // be initialized with the default shader, but View3D can only compile
    // shaders after it has a valid OpenGL context.
    PointViewerMainWindow * pv_parent = dynamic_cast<PointViewerMainWindow *>(parentWidget());
    if (pv_parent)
        pv_parent->openShaderFile("shaders:las_points.glsl");

    setFocus();
}
Example #12
0
void newGame(S_game* aGame, char* playerName1, E_pawn pawnType1, char* playerName2, E_pawn pawnType2)
{
  initGrid(aGame);
  aGame->nbPlayers = 0;
  aGame->whoMustPlay = P1;
  addPlayer(aGame, playerName1, pawnType1);
  addPlayer(aGame, playerName2, pawnType2);
}
Example #13
0
/*******************************************************
* resizeGL()
*
* Description: Handles the UI resize event.
*
* Inputs: New dimensions of the OpenGL Widget.
*
* Outputs: none.
*
* Return: none.
*******************************************************/
void GLWidget::resizeGL(int width, int height)
{
    // Never divide by zero.
    if (height == 0)
    {
        height=1;
    }

    // (Re)Calculate the OpenGL object dimensions.
    fullWidth = width;
    fullHeight = height * battleMap.gridHeight;
    statusWidth = (fullWidth / battleMap.cellsWide) * 0.05f;
    cellWidth = fullWidth / battleMap.cellsWide;
    cellHeight = fullHeight / battleMap.cellsTall;

    mouseClick.hLoc = 0;
    mouseClick.vLoc = 0;

    if (!isBattle)
    {
        // Setup the 2d perspective.
        glViewport(0, 0, width, height);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, width, 0, height, -1000, 1000);

        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity();

        updateGL();

        // Reload and resize the background image.
        bkImage.load(backgroundList[titleIndex]);
        bkImage = bkImage.scaled(GLWidget::width(), GLWidget::height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
        glBkImage = QGLWidget::convertToGLFormat(bkImage);
    }
    else
    {
        // Reset grid locations and dimensions.
        initGrid();

        // Setup the 2d perspective.
        glViewport(0, 0, width, height);
        glMatrixMode (GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, width, 0, height, -1000, 1000);

        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity();

        updateGL();

        // Reload and resize the background image.
        bkImage.load(battleMap.imageFileName);
        bkImage = bkImage.scaled(GLWidget::width(), GLWidget::height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
        glBkImage = QGLWidget::convertToGLFormat(bkImage);
    }
}
Example #14
0
void FluidSystem::reset(FluidConfig config) //回到初始状态
{
	uint s = (int)ceilf(powf((float)m_numParticles, 1.0f / 3.0f));

	float jitter = m_params.particleRadius*0.01f;
	switch (config)
	{
	default:
	case CONFIG_RANDOM:
	{
		for (uint z = 0; z < s; z++)
		{
			for (uint y = 0; y < s; y++)
			{
				for (uint x = 0; x < s; x++)
				{
					uint i = (z*s * s) + (y*s) + x;

					if (i < m_numParticles)
					{
						m_hPos[i * 4] = (3 * x) + m_params.particleRadius - 128.0f /*+ (frand()*2.0f-1.0f)*jitter*/;
						m_hPos[i * 4 + 1] = (3 * y) + m_params.particleRadius - 31.0f /*+ (frand()*2.0f-1.0f)*jitter*/;
						m_hPos[i * 4 + 2] = (3 * z) + m_params.particleRadius - 64.0f /*+ (frand()*2.0f-1.0f)*jitter*/;
						m_hPos[i * 4 + 3] = 1.0f;

						m_hVel[i * 4] = 0.0f;
						m_hVel[i * 4 + 1] = 0.0f;
						m_hVel[i * 4 + 2] = 0.0f;
						m_hVel[i * 4 + 3] = 0.0f;

						m_hDen[i] = 0.0f;
						m_hPre[i] = 0.0f;
						m_hColorf[i] = 0.0f;
					}
				}
			}
		}
	}
	break;

	case CONFIG_GRID:
	{
		uint gridSize[3];
		gridSize[0] = gridSize[1] = gridSize[2] = s;



		initGrid(gridSize, m_params.particleRadius*2.0f, jitter, m_numParticles);
	}
	break;
	}

	setArray(POSITION, m_hPos, 0, m_numParticles);
	setArray(VELOCITY, m_hVel, 0, m_numParticles);
	setArray(DENSITY, m_hDen, 0, m_numParticles);
	setArray(PRESSURE, m_hPre, 0, m_numParticles);
	setArray(COLORFIELD, m_hColorf, 0, m_numParticles);
}
Example #15
0
int main(int argc, char *argv[]) {
	SDL_Window* window = NULL;
	SDL_GLContext context = NULL;
	SDL_Event event;
	const char * title = "SDL2 OpenGL";
	const int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN;
	bool done = false;

	time_t time, utime, dirtime;
	int dirx=0, diry=1, dirz=0;
	const float speed = 0.5;

	SDL_Init(SDL_INIT_VIDEO);

	window = SDL_CreateWindow(title,
		SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		SCREEN_WIDTH, SCREEN_HEIGHT, flags);

	SDL_SetRelativeMouseMode(SDL_TRUE);
	context = SDL_GL_CreateContext(window);

	initGL();
	initGrid();

	utime = dirtime = SDL_GetTicks();
	render();
	SDL_GL_SwapWindow(window);

	while (!done) {
		if (SDL_PollEvent(&event)) {
			if (event.type == SDL_KEYDOWN) {
				done = true;
			}
		}

		time = SDL_GetTicks();
		if (time - utime > 100) {
			update();
			utime = time;
		}
		else if (time - dirtime > 5000) {
			dirx = random();
			diry = random();
			dirz = random();
			dirtime = time;
		}

		glRotatef(speed, dirx, diry, dirz);
		render();
		SDL_GL_SwapWindow(window);
	}

	SDL_GL_DeleteContext(context);
	SDL_DestroyWindow(window);
	SDL_Quit();
	return 0;
}
Example #16
0
/*******************************************************
* LoadContent()
*
* Description: Loads the battle map content passed from
* the user interface (with some hard coded).
*
* Inputs: none
*
* Outputs: none
*
* Return: none
*******************************************************/
void GLWidget::LoadContent(Database db)
{
    // Get the active user.
    User myUser =  db.loadActiveUser();

    // Get the selected level (battle map).
    int levelMapIndex = myUser.level;
    battleMap.imageFileName = db.mapFileName(levelMapIndex);
    battleMap.audioFileName = "sounds/Battle_02.mp3";
    battleMap.cellsTall = 6;
    battleMap.cellsWide = 9;
    battleMap.gridHeight = 0.58;

    // Add units.
    unitTest_AddUnits();

    for (int i = 0; i < 4; i++)
    {
        // Get unit images from UI selection.
        unit[i].imageFileName = myUser.units[i].imageFileName;

        QStringList splitString = unit[i].imageFileName.split("/");
        QString maskFileName;
        maskFileName.append(splitString[0]);
        maskFileName.append("/mask_");
        maskFileName.append(splitString[1]);

        unit[i].maskFileName = maskFileName;
        unit[i].name = myUser.units[i].name;

        // Load the actual sprite images.
        unit[i].image.load(unit[i].imageFileName);
        unit[i].mask_image.load(unit[i].maskFileName);
        unit[i].faceLeft = false;

        // Load data (if it makes sense).
        unit[i].movementRange = myUser.units[i].movementRange;
    }

    // Load a background image.
    bkImage.load(battleMap.imageFileName);
    bkImage = bkImage.scaled(GLWidget::width(), GLWidget::height(), Qt::KeepAspectRatio, Qt::SmoothTransformation );
    glBkImage = QGLWidget::convertToGLFormat(bkImage);

    // Initialize the grid.
    initGrid();

    musicTrack = battleMap.audioFileName;
    playBackgroundTrack();

    // Start the battle.
    isBattle = true;

    // Ensure proper graphics scaling.
    resizeGL(GLWidget::width(), GLWidget::height());
}
void GLVertexGridDirect::init(int sW, int sH, int dW, int dH, int resX, int resY)
{
	srcW = sW;
	srcH = sH;
	destW = dW;
	destH = dH;
	this->resX = resX;
	this->resY = resY;
	initGrid();
}
Example #18
0
BOOL CGoldDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//初始化GridCtrl控件
	initGrid();
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Example #19
0
 UniformGrid3D::UniformGrid3D(const UniformGrid3D &other){
   PRECONDITION(other.dp_storage,"cannot copy an unintialized grid");
   RDKit::DiscreteValueVect *data=new RDKit::DiscreteValueVect(*other.dp_storage);
   initGrid(other.d_numX*other.d_spacing,
            other.d_numY*other.d_spacing,
            other.d_numZ*other.d_spacing,
            other.d_spacing,
            other.dp_storage->getValueType(),
            other.d_offSet,
            data);
 }
int ccFastMarchingForNormsDirection::init(ccGenericPointCloud* aList,
                                            NormsIndexesTableType* theNorms,
                                            CCLib::DgmOctree* _theOctree,
                                            uchar level)
{
	//on commence par créer une grille 3D
	theOctree = _theOctree;
	gridLevel = level;

	int result = initGrid();

	if (result<0) return result;

	//printf("cellSize=%f\n",cellSize);

	//on remplit la grille
	CCLib::DgmOctree::cellCodesContainer cellCodes;
	theOctree->getCellCodes(gridLevel,cellCodes,true);

	int cellPos[3];

	while (!cellCodes.empty())
	{
		//on transforme le code de cellule en position
		theOctree->getCellPos(cellCodes.back(),gridLevel,cellPos,true);

		//on renseigne la grille
		unsigned gridPos = FM_pos2index(cellPos);

		DirectionCell* aCell = new DirectionCell;
		aCell->state = CCLib::FastMarching::Cell::FAR_CELL;
		aCell->T = FM_INF;
		aCell->treated = false;
		aCell->v = 0.0;
		aCell->cellCode = cellCodes.back();

		CCLib::ReferenceCloud* Yk = theOctree->getPointsInCell(cellCodes.back(),gridLevel,true);
		if (Yk)
		{
			ccOctree::ComputeRobustAverageNorm(Yk,aList,aCell->N);
			//Yk->clear(); //inutile

			//printf("code %i -> cell(%i,%i,%i) --> %i\n",cellCodes.back(),cellPos[0],cellPos[1],cellPos[2],gridPos);
			theGrid[gridPos] = (CCLib::FastMarching::Cell*)aCell;
		}

		cellCodes.pop_back();
	}

	initialized = true;

	return 0;
}
Example #21
0
void generate(int dim, const char* filename)
{
	if (dim==1) {
		int L=1024;
		GRID1D initGrid(0,0,L);

		for (int i=0; i<nodes(initGrid); i++)
			initGrid(i) = 0.0;

		output(initGrid,filename);
	}

	if (dim==2) {
		int L=256;
		GRID2D initGrid(0,0,2*L,0,L);

		for (int i=0; i<nodes(initGrid); i++)
			initGrid(i) = 0.0;

		output(initGrid,filename);
	}

	if (dim==3) {
		int L=64;
		GRID3D initGrid(0,0,2*L,0,L,0,L/4);

		for (int i=0; i<nodes(initGrid); i++)
			initGrid(i) = 0.0;

		output(initGrid,filename);
	}
}
ControlAlgorithm::ControlAlgorithm(QObject *parent) :
    QObject(parent)
{

    //TODO: point to already created kiteColorTracker instead of making new one
    // kiteColorTracker = new KiteColorTracker(this);

    imageProcessingWindow = new ImageProcessing();


    kiteColorTracker = imageProcessingWindow->getColorTracker();
    kiteColorTracker->setSampleRate(1);

    // call update whenever a new position computed by kiteColorTracker
    connect(kiteColorTracker,SIGNAL(dataUpdated()),this,SLOT(update()));


    // initialize start and end points for left/right paths



    //set quadrant parameters
    OUTER_GRID_OFFSET_X=50;
    OUTER_GRID_OFFSET_Y=25;
    POWER_ZONE_X=100;
    POWER_ZONE_Y=100;
    initGrid();

    // initialize PID controller
    Kp = 1.0;
    Ki =  0.0;
    Kd = 0.0;
    interval = 0.01; // in seconds

    pid = new PID(Kp,Ki,Kd,interval);
    pid->setMode(1.0); // 1 Automatic, 0 Manual
    pid->setSetPoint(0.0);    // setpoint will always be 0 degrees relative to current heading
    pid->setInputLimits(-45.0,45.0);
    pid->setOutputLimits(0.0,30.0); // turning values
    pid->setProcessValue(10.0); // initialize input to be 0 so no error


    // timer for pid loop
    // timer will be started by a user input that we are now tracking the kite
    pidTimer = new QTimer;
    pidTimer->setInterval(interval*1000);   // convert from s to ms
    connect(pidTimer,SIGNAL(timeout()),this,SLOT(updatePID()));
    //pidTimer->start();

    autoPilotOn = false;

}
Example #23
0
void initGame(Game *game){
  game->totalTime = 0;
  game->levelTime = 0;
  game->inGame = TRUE;
  game->score = 0;
  game->selectedTowerType = TRIANGLE;
  game->lives = 20;
  game->rStored = 3000;
  game->gStored = 3000;
  game->bStored = 3000;
  game->rRatio = 20;
  game->gRatio = 20;
  game->bRatio = 20;
  
  int i;
  for(i=0;i<NUM_GAME_KEYS;i++)
    game->keys[i] = FALSE;
  
  game->towerPrices[TRIANGLE] = TRIANGLE_PRICE;
  game->towerPrices[SQUARE] = SQUARE_PRICE;
  game->towerPrices[PENTAGON] = PENTAGON_PRICE;
  game->towerPrices[HEXAGON] = HEXAGON_PRICE;

  initInputGame(game);
  initEnemyGenerator(game);
  game->towers = NULL;
  game->enemies = NULL;
  game->bullets = NULL;

  game->sprites[gBACKGROUND].image = loadImage("img/GameBackground.png");
  game->sprites[GRID_TILE].image = loadImage("img/Grid_Tile.png");
  game->sprites[ENEMY1].image = loadImage("img/Alien1.png");
  game->sprites[ENEMY2].image = loadImage("img/Alien2.png");
  game->sprites[TRIANGLE].image = loadImage("img/TriangleTower.png");
  game->sprites[SQUARE].image = loadImage("img/SquareTower.png");
  game->sprites[PENTAGON].image = loadImage("img/PentagonTower.png");
  game->sprites[HEXAGON].image = loadImage("img/HexagonTower.png");  

  game->font = TTF_OpenFont("fonts/blackWolf.ttf", 16);
  game->fontColor.r = 200;
  game->fontColor.g = 200;
  game->fontColor.b = 200;
  game->fontBGColor.r = 30;
  game->fontBGColor.g = 30;
  game->fontBGColor.b = 30;

  game->grid = malloc(sizeof(Grid));
  game->grid->dimensionX = 7;
  game->grid->dimensionY = 12;
  game->grid->tiles = (Grid_Tile**)malloc(game->grid->dimensionX*sizeof(Grid_Tile));
  initGrid(game->grid, 75, 50);
};
Example #24
0
int TEST_initGrid()
{
  cell grid[H][W];
  initGrid(grid);
  if(grid[5][5].foreground!=NULL||grid[5][5].background!=NULL){
    printf("%25s %s\n",__func__, FAIL );
    return ERROR;
  }
  else{
    printf("%25s %s\n",__func__, PASS );
    return SUCCESS;
  }
}
Example #25
0
ParticleSystem::ParticleSystem()
: m_numActive(0)
{
    const int32_t N = GRID_RESOLUTION;
    m_count = N * N * N;

    m_pos = new nv::vec3f [m_count];
    m_zs = new float [m_count];
    m_sortedIndices16 = new GLushort [m_count];

    initGrid(N);
    addNoise(1.9, 1.0);
}
Example #26
0
void CLegGrid::init()
{
    last_time_ = ros::Time::now();
    last_seen_leg_ = ros::Time::now();

    initKF();
    initTfListener();
    initGrid();

    predicted_leg_pub_ = n_.advertise<geometry_msgs::PoseArray>("predicted_legs",10);
    grid_pub_ = n_.advertise<nav_msgs::OccupancyGrid>("leg/grid",10);
    prob_pub_ = n_.advertise<geometry_msgs::PoseArray>("leg/probability",10);
    proj_pub_ = n_.advertise<geometry_msgs::PoseArray>("leg/projection",10);
}
Example #27
0
// Testing grid.c
int TEST_fillGrid()
{
  cell grid[H][W];
  initGrid(grid);
  fillGrid(grid);
  if(grid[rand()%H][rand()%W].background->ispassable!=passable){
    printf("%25s %s\n",__func__, FAIL );
    return ERROR;
  }
  else{
    printf("%25s %s\n",__func__, PASS );
    return SUCCESS;
  }
}
Example #28
0
void
GridAnim::init ()
{
    initGrid ();

    CompRect outRect (mAWindow->savedRectsValid () ?
		      mAWindow->savedOutRect () :
		      mWindow->outputRect ());

    mModel = new GridModel (mWindow, mCurWindowEvent,
			    outRect.height (),
			    mGridWidth, mGridHeight,
			    mDecorTopHeight, mDecorBottomHeight);
}
Example #29
0
/** 
 * Représente une grille.
 * @param grid Grille à remplir
 * @param argc Nombres d'arguments du main
 * @param gridStr Grille sous forme de chaîne
 */
void Grille(t_Case grid[N][N],int argc, char * gridStr[]){
    int i, j;
    int nb_bonus[2] = {0};

    initRand();
    initGrid(grid);

    // Affichage grille aléatoire ou définis par l'utilisateur
    printf("----------------------------------------------------\n");
    printf("|");
    if(argc == 1){
    
        for (i = 0; i < N; i++)
        {
            for (j = 0; j < N; j++)
            {   
                getCase(grid, i, j, nb_bonus);
            }
            printf("\n----------------------------------------------------\n");
            if(i < N-1 )printf("|");
        }
    }else if(argc == 2){

        if(strlen(gridStr[1]) >= 16){
            gridStr[16] = '\0';

            for (i = 0; i < 16; i++)
            {   
                // Vérifie que le caractère courant est valide
                if(!isalpha(gridStr[1][i])){
                    printf("\nErreur caractère invalide !\n");
                    exit(0);
                }

                getCaseFromStr(grid, nb_bonus, gridStr[1], i);
                if((i - 3) % 4 == 0){ 
                    printf("\n----------------------------------------------------\n");
                     if(i < 12)printf("|");
                }
            }

        }else{
            printf("Chaîne de caractère trop courte.");
        }

    }else{
        printf("Erreur nombre d'arguments incorrect !\nNormal usage: ./bin/ruzzleSolver [a-z]*16\n");
        exit(0);
    }
}
Example #30
0
int TEST_newBulb(){
  cell grid[H][W];
  int x=0, y=0;
  entity *bulb=newBulb(grid, x, y);
  initGrid(grid);
  fillGrid(grid);
  if(bulb->ispassable!=1 || bulb->x!=x || bulb->y !=y){
    printf("%25s %s\n",__func__, FAIL );
    return ERROR;
  }
  else{
    printf("%25s %s\n",__func__, PASS );
    return SUCCESS;
  }
}