Esempio n. 1
0
File: STG.cpp Progetto: Rosalila/STG
void STG::deletePatterns()
{
    std::list<Pattern*>* active_patterns=player->active_patterns;
    std::list<Pattern*>::iterator i = active_patterns->begin();
    while (i != active_patterns->end())
    {
        Pattern*p=(Pattern*)*i;
        if (isOutOfBounds(p->x,p->y) || p->destroyFlag())
        {
            active_patterns->erase(i++);
            delete p;
        }
        else
        {
            ++i;
        }
    }

    active_patterns=enemy->active_patterns;
    i = active_patterns->begin();
    while (i != active_patterns->end())
    {
        Pattern*p=(Pattern*)*i;
        if (isOutOfBounds(p->x,p->y) || p->destroyFlag())
        {
            active_patterns->erase(i++);
            delete p;
        }
        else
        {
            ++i;
        }
    }
}
void LedMatrixMAX7219Driver::setRow(unsigned char row, unsigned char value) {
    if (!isOutOfBounds(0, row)) {
        for (unsigned char i = 0; i < rows; i++) {
            setLed(row, i, value);
        }
    }
}
Esempio n. 3
0
static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr) {
	int offset = atoi(offsetStr);
	if (absI(offset) == absI(ERROR_CODE)) {
		scheduleMsg(&logger, "invalid offset [%s]", offsetStr);
		return;
	}
	if (isOutOfBounds(offset)) {
		return;
	}
	int bit = atoi(bitStr);
	if (absI(bit) == absI(ERROR_CODE)) {
		scheduleMsg(&logger, "invalid bit [%s]", bitStr);
		return;
	}
	int value = atoi(valueStr);
	if (absI(value) == absI(ERROR_CODE)) {
		scheduleMsg(&logger, "invalid value [%s]", valueStr);
		return;
	}
	int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
	*ptr ^= (-value ^ *ptr) & (1 << bit);
	/**
	 * this response is part of dev console API
	 */
	scheduleMsg(&logger, "bit @%d/%d is %d", offset, bit, value);
	incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_F);
}
Esempio n. 4
0
/// <summary>
/// Processes the bullet
/// </summary>
void Bullet::process()
{

	// Checks if its deleted
	if (!getDeleted())
	{

		// If degrees is set (not -1), do rotational movement
		if (deg != -1) // Rotational movement
		{
			double move_x = timeStep.asSeconds() * speedX * cos(deg) - sin(deg);
			double move_y = timeStep.asSeconds() *  speedY * sin(deg) + cos(deg);
			this->sprite->move(move_x, move_y);
		}
		else // Linear movement.
		{
			this->sprite->setPosition(
				sprite->getPosition().x + (timeStep.asSeconds() * speedX),
				sprite->getPosition().y + (timeStep.asSeconds() * speedY));

		}

		// If the bullet is out of bounds, we set delete flag
		if (isOutOfBounds())
		{
			setDeleted(true);
		}
	}
}
void LedMatrixMAX7219Driver::shiftRow(unsigned char row,
        unsigned char direction) {
    if (!isOutOfBounds(0, row)) {
        for (unsigned char i = 0; i < cols; i++) {
            shiftLed(i, row, direction);
        }
    }
}
Esempio n. 6
0
CrosswordCell *CrosswordGrid::getCell( const int row, const int col ) const
{
    // Check bounds conditions
    if( isOutOfBounds( row, col ) )
        return 0;

    return dynamic_cast<CrosswordCell*>( item( row, col ) );
}
Esempio n. 7
0
static void setInt(const int offset, const int value) {
	if (isOutOfBounds(offset))
		return;
	int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
	*ptr = value;
	getInt(offset);
	incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_F);
}
Esempio n. 8
0
/*
=================================================================================================================================================================
logic() performs logical stuff on the ghost
=================================================================================================================================================================
*/
void Ghost::logic(const sf::Vector2i mousePos, const int maxWidth, const int maxHeight, const sf::RenderWindow& window)
{
    xPos = mGhostRect.getPosition().x / 40;    //Set a variable for y position that is relative to the "tile map" (1px = 40px)
    yPos = mGhostRect.getPosition().y / 40;    //Set a variable that x position  is relative to the "tile map" (1px = 40px)

    goToMouse(mousePos, maxWidth, maxHeight, window);   //Sets the sprites position to the mouse position (if possible)
    isOutOfBounds(maxWidth, maxHeight);    //Checks if the ghost somehow got out of bounds :/
    snapToMap();                                //Snaps the ghost to the tile grid

}
Esempio n. 9
0
static void getFloat(int offset) {
	if (isOutOfBounds(offset))
		return;
	float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
	float value = *ptr;
	/**
	 * this response is part of dev console API
	 */
	scheduleMsg(&logger, "float @%d is %..100000f", offset, value);
}
Esempio n. 10
0
static void getBit(int offset, int bit) {
	if (isOutOfBounds(offset))
		return;
	int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
	int value = (*ptr >> bit) & 1;
	/**
	 * this response is part of dev console API
	 */
	scheduleMsg(&logger, "bit @%d/%d is %d", offset, bit, value);
}
Esempio n. 11
0
static void getShort(int offset) {
	if (isOutOfBounds(offset))
		return;
	uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
	uint16_t value = *ptr;
	/**
	 * this response is part of dev console API
	 */
	scheduleMsg(&logger, "short @%d is %d", offset, value);
}
Esempio n. 12
0
/* Checks if direction is OK for moving (no collision, stc.) */
int dbDirSucceeded(t_Direction dir)
{
    switch(dir)
    {
        case DIR_UP:
            return  (isCollision(   currentLevel.DrunkenBots[0].posX,
                                    currentLevel.DrunkenBots[0].posY-STEP) |
                                    isOutOfBounds(currentLevel.DrunkenBots[0].posX,
                                                  currentLevel.DrunkenBots[0].posY-STEP)) ?
                                                        0 : 1;
                                                        break;

        case DIR_RIGHT:
            return  (isCollision(   currentLevel.DrunkenBots[0].posX+STEP,
                                    currentLevel.DrunkenBots[0].posY) |
                                    isOutOfBounds(currentLevel.DrunkenBots[0].posX+STEP,
                                                  currentLevel.DrunkenBots[0].posY)) ?
                                                        0 : 1;
                                                        break;

        case DIR_DOWN:
            return  (isCollision(   currentLevel.DrunkenBots[0].posX,
                                    currentLevel.DrunkenBots[0].posY+STEP) |
                                    isOutOfBounds(currentLevel.DrunkenBots[0].posX,
                                                  currentLevel.DrunkenBots[0].posY+STEP)) ?
                                                        0 : 1;
                                                        break;

        case DIR_LEFT:
            return  (isCollision(   currentLevel.DrunkenBots[0].posX-STEP,
                                    currentLevel.DrunkenBots[0].posY) |
                                    isOutOfBounds(currentLevel.DrunkenBots[0].posX-STEP,
                                                  currentLevel.DrunkenBots[0].posY)) ?
                                                        0 : 1;
                                                        break;

        default: return 1;
    }

    return 1;
}
Esempio n. 13
0
    void TileMap::setTileColor(const glm::uvec2& pos, const fea::Color& color)
    {
        FEA_ASSERT(!isOutOfBounds(pos), "Trying to set color outside of the bounds of the tilemap! Setting at " + std::to_string(pos.x) + " " + std::to_string(pos.y) + ".");
        uint32_t x = pos.x;
        uint32_t y = pos.y;

        uint32_t chunkX = x / mChunkSize.x;
        uint32_t chunkY = y / mChunkSize.y;
        uint32_t chunkIndex = chunkX + chunkY * mChunkGridSize.x;

        mChunks[chunkIndex].setTileColors(x - chunkX * mChunkSize.x, y - chunkY * mChunkSize.y, color);
    }
Esempio n. 14
0
void Tiger::vectorTraceBack() {
	// a predicate for removing nodes that lie off the grid

	struct isOutOfBounds {
		bool operator () (const Node& node) {
			return ((node.x > GRID_WIDTH) || (node.y > GRID_HEIGHT));
		}
	};

	do {
		Uint16 currentX = path.top().x;
		Uint16 currentY = path.top().y;
		// initialise the vector with the points of the compass
		std::vector<Node> adjNodes{
			Node( currentX - 1, currentY ),     // west
			Node( currentX - 1, currentY - 1 ), // north west
			Node( currentX, currentY - 1 ),     // north
			Node( currentX + 1, currentY - 1 ), // north east
			Node( currentX + 1, currentY ),     // east
			Node( currentX + 1, currentY + 1 ), // south east
			Node( currentX, currentY + 1 ),     // south
			Node( currentX - 1, currentY + 1 ), // south west
		};
		// remove all Nodes that lie outside the board
		adjNodes.erase(std::remove_if(adjNodes.begin(), adjNodes.end(), isOutOfBounds()), adjNodes.end());
		// get the indexes from the board
		for (auto& node : adjNodes) { world->assignIndexTo(node); }
		// remove nodes that are skiping over wall corners diagonaly
		for (auto node = adjNodes.begin(); node != adjNodes.end();) {
			if (skipsWallDiagonaly(*node))  {
				node = adjNodes.erase(node);
			} else {
				node++;
			}
		}
		// check if the start node is present
		for (const auto& node : adjNodes) {
			if (node.i == START) {
				path.push(node);
				break;
			}
		}
		// find the Node with the lowest index
		// assign if lower and valid ensures Nodes are not out of bounds
		Node lowest = path.top();
		for (const auto& node : adjNodes) { assignIfLowerAndWithinBounds(lowest, node); }

		path.push(lowest);
	} while (path.top().i != START && path.size() < MAX_PATH_SIZE);
}
/**
 * Each row is a register
 */
void LedMatrixMAX7219Driver::setLed(unsigned char col, unsigned char row,
        unsigned char value) {
    unsigned char entry, mask = 0;
    if (!isOutOfBounds(col, row)) {
        entry = matrixData[col];
        mask = 0x01 << row;
        if (value) {
            entry |= mask;
        } else {
            entry &= ~mask;
        }
        matrixData[col] = entry;
        driver->writeRegister(registerMap[col], entry);
    }
}
void LedMatrixMAX7219Driver::shiftCol(unsigned char col,
        unsigned char direction) {
    if (!isOutOfBounds(col, 0)) {
        unsigned char current = matrixData[col];
        matrixData[col] = ~current;
        driver->writeRegister(registerMap[col], matrixData[col]);
        if (direction == RIGHT) {
            col++;
        } else {
            col--;
        }
        col %= cols;
        matrixData[col] = current;
        driver->writeRegister(registerMap[col], matrixData[col]);
    }
}
Esempio n. 17
0
static void setFloat(const char *offsetStr, const char *valueStr) {
	int offset = atoi(offsetStr);
	if (absI(offset) == absI(ERROR_CODE)) {
		scheduleMsg(&logger, "invalid offset [%s]", offsetStr);
		return;
	}
	if (isOutOfBounds(offset))
		return;
	float value = atoff(valueStr);
	if (cisnan(value)) {
		scheduleMsg(&logger, "invalid value [%s]", valueStr);
		return;
	}
	float *ptr = (float *) (&((char *) engine->engineConfiguration)[offset]);
	*ptr = value;
	getFloat(offset);
}
Esempio n. 18
0
/// <summary>
/// Processes the powerup
/// </summary>
void Powerup::process()
{

	// Check if the powerup is deleted or not, if it is, we do not want to move it.
	if (!getDeleted())
	{
		this->sprite->setPosition(
			sprite->getPosition().x + (timeStep.asSeconds() * speedX),
			sprite->getPosition().y + (timeStep.asSeconds() * speedY));

	}

	// Check if the powerup is out of bounds
	if (isOutOfBounds())
	{
		setDeleted(true);
	}
}
Esempio n. 19
0
    void TileMap::unsetTile(const glm::uvec2& pos)
    {
        FEA_ASSERT(!isOutOfBounds(pos), "Trying to unset tile outside of the bounds of the tilemap! Setting at " + std::to_string(pos.x) + " " + std::to_string(pos.y) + ".");

        uint32_t x = pos.x;
        uint32_t y = pos.y;

        uint32_t chunkX = x / mChunkSize.x;
        uint32_t chunkY = y / mChunkSize.y;
        uint32_t chunkIndex = chunkX + chunkY * mChunkGridSize.x;

        mChunks[chunkIndex].unsetTileTexCoords(x - chunkX * mChunkSize.x, y - chunkY * mChunkSize.y);

        if(mAnimatedTiles.find(glm::uvec2(x, y)) != mAnimatedTiles.end())
        {
            mAnimatedTiles.erase(glm::uvec2(x, y));
        }
    }
void LedMatrixMAX7219Driver::shiftLed(unsigned char col, unsigned char row,
        unsigned char direction) {
    unsigned char led;
    if (!isOutOfBounds(col, row)) {
        led = getLed(col, row);
        setLed(col, row, (led ? LedMatrixDriver::OFF : LedMatrixDriver::ON));
        if (direction == LEFT) {
            col--;
        } else if (direction == RIGHT) {
            col++;
        } else if (direction == UP) {
            row++;
        } else {
            row--;
        }
        setLed((col % cols), (row % rows), (
                led ? LedMatrixDriver::ON : LedMatrixDriver::OFF));
    }
}
void walkOfAKingInductiveStep(int x,int y,int energy)
{
    int max_prize_found_yet = MINUS_INFINITY;
    int direction_of_max_prize = NONE;

    int cell_x;
    int cell_y;
    int cell_prize;
    int cell_cost;
    int cell_max_prize;
    for(int direction=UP_LEFT; direction<=BOT_RIGHT; direction++)
    {
        cell_x = x + dx[direction];
        cell_y = y + dy[direction];

        if(isOutOfBounds(cell_x,cell_y))
        {
            continue;
        }

        cell_prize = prize[cell_x][cell_y];
        cell_cost = cost[cell_x][cell_y];

        if(cell_cost > energy)
        {
            continue;
        }

        cell_max_prize = add(cell_prize,max_prize[cell_x][cell_y][energy-cell_cost]);

        if(cell_max_prize > max_prize_found_yet)
        {
            max_prize_found_yet = cell_max_prize;
            direction_of_max_prize = direction;
        }
    }

    max_prize[x][y][energy] = max_prize_found_yet;
    path[x][y][energy] = direction_of_max_prize;
}
Esempio n. 22
0
    void TileMap::setTile(const glm::uvec2& pos, TileId id, int32_t orientation)
    {
        FEA_ASSERT(!isOutOfBounds(pos), "Trying to set tile outside of the bounds of the tilemap! Setting at " + std::to_string(pos.x) + " " + std::to_string(pos.y) + ".");
        FEA_ASSERT(orientation <= 16, "Cannot pass other flags with the PRESERVE flag!");
        uint32_t x = pos.x;
        uint32_t y = pos.y;

        uint32_t chunkX = x / mChunkSize.x;
        uint32_t chunkY = y / mChunkSize.y;
        uint32_t chunkIndex = chunkX + chunkY * mChunkGridSize.x;

        FEA_ASSERT(mTileDefs.find(id) != mTileDefs.end(), "Trying to set tile '" + std::to_string(id) + "' which doesn't exist!");

        const TileDefinition& tileDef = mTileDefs.at(id);

        glm::vec2 texPos = (glm::vec2)tileDef.mTileTexPosition * mTextureTileSize;

        float startX = texPos.x;
        float startY = texPos.y;
        float endX   = texPos.x + mTextureTileSize.x;
        float endY   = texPos.y + mTextureTileSize.y;

        mChunks[chunkIndex].setTileTexCoords(x - chunkX * mChunkSize.x, y - chunkY * mChunkSize.y, 
                glm::vec2(startX , startY),
                glm::vec2(endX   , endY  ), orientation);

        if(mAnimatedTiles.find(glm::uvec2(x, y)) != mAnimatedTiles.end())
        {
            mAnimatedTiles.erase(glm::uvec2(x, y));
        }

        if(tileDef.mTicksUntilChange > 0)
        {
            AnimatedTile animation(tileDef.mNextTile, tileDef.mTicksUntilChange);
            mAnimatedTiles.emplace(glm::uvec2(x, y), animation);
        }
    }
Esempio n. 23
0
	// -------------------------------------------------------
	// 
	// -------------------------------------------------------
	void MoveByAction::update(SpriteArray& array,float dt,ActionEventBuffer& buffer) {	
		if (_buffer.size > 0) {
			for (int i = 0; i < _buffer.size; ++i) {
				Vector2f p = array.getPosition(_ids[i]);
				p += _velocities[i] * dt;
				if (isOutOfBounds(p, _velocities[i])) {
					if (_bounce[i]) {
						if (p.y < m_BoundingRect.bottom || p.y > m_BoundingRect.top) {
							_velocities[i].y *= -1.0f;
						}
						if (p.x < m_BoundingRect.left || p.x > m_BoundingRect.right ) {
							_velocities[i].x *= -1.0f;
						}
						rotateTo(array, i);
						p += _velocities[i] * dt * 1.5f;
					}
					else {
						buffer.add(_ids[i], AT_MOVE_BY, array.getType(_ids[i]));
					}
				}
				array.setPosition(_ids[i], p);
			}
		}
	}
Esempio n. 24
0
bool Pig::update(std::vector<ZombiePig>& zombiePigs) {

	bool avoidWall = false;
	{ // Check if we are going out of bounds.
		// Position of the next frame

		const float MULT = 3.0f;
		glm::vec2 nextPos = pos + vel * MULT;
		const float ROTATE_ANGLE = 0.1f;
		float angle = ROTATE_ANGLE;
		
		//Out of bounds check on next frames position
		if (isOutOfBounds(nextPos, screenWidth, screenHeight)) {		
			avoidWall = true;
			// Run the algorithm that points us away from the wall
			while (true) {
				glm::vec2 clockwiseVel = glm::rotate(vel, angle);
				glm::vec2 counterClockwiseVel = glm::rotate(vel, -angle);

				if (isOutOfBounds(pos + clockwiseVel * MULT, screenWidth, screenHeight) == false) {
					vel = clockwiseVel;
					break;
				}
				if (isOutOfBounds(pos + counterClockwiseVel * MULT, screenWidth, screenHeight) == false) {
					vel = counterClockwiseVel;
					break;
				}
				// Rotate them some more and try again
				angle += ROTATE_ANGLE;
				// If angle went in a full circle, break
				//if (angle > 2.0 * 3.14159265) break;
			}
		}

	}

	// Update position
	pos += vel;
	collideWithEdge();


	float closestDistance2 = pow(300.0f, 2.0f);
	ZombiePig* closestZombie = nullptr;
	for (auto& zombie : zombiePigs) {
		// Get X and Y distance
		float dx = zombie.pos.x - pos.x;
		float dy = zombie.pos.y - pos.y;
		float adx = abs(dx);
		float ady = abs(dy);

		// Check if its the closest zombie.
		float distance2 = adx * adx + ady * ady;
		if (distance2 < closestDistance2) {
			closestZombie = &zombie;
			closestDistance2 = distance2;
		}

		// If pigs and zombie pigs have different size, need to change this.
		if (adx <= zombie.width && ady <= zombie.height) {
			// We have a collision
			return true;
		}
	}

	// Run away from closest zombie
	if (!avoidWall && closestZombie) {
		glm::vec2 dirVec = glm::normalize(pos - closestZombie->pos);
		vel = glm::length(vel) * dirVec;
	}

	return false;
}
Esempio n. 25
0
int loadTraps(int which)
{
    FILE *f;
    char *f_name = getFileName(which, FYPE_TRAPS);

    if(f_name == NULL)
    {
        fprintf(stderr, "%s: f_name == NULL? (attempt to load something unknown)\n", __FUNCTION__);
        return 1;
    }

    fprintf(stderr, " > In progress: %s\n", f_name);

    if((f = fopen(f_name, "r")) == NULL)
    {
        fprintf(stderr, "%s: fopen failure\n", __FUNCTION__);
        free(f_name);
        return 1;
    }

    // It`s horrible, yeah. But i should be sure to be fully compatible
    // with old 1.x Test Stuff content.
    if(fscanf(f,
              "[Idiots]\n%i:%i:%i:%i:%i:%i:%i:%i\n%i:%i:%i:%i:%i:%i:%i:%i\n\n[Drunken"
              "Bot]\n%i:%i\n\n[Portals]\n%i:%i:%i:%i:%i:%i\n%i:%i:%i:%i:%i:%i\n\n[Tur"
              "rets]\n%i:%i:%i\n%i:%i:%i",

              &currentLevel.Idiots[0].posX, &currentLevel.Idiots[1].posX,
              &currentLevel.Idiots[2].posX, &currentLevel.Idiots[3].posX,
              &currentLevel.Idiots[4].posX, &currentLevel.Idiots[5].posX,
              &currentLevel.Idiots[6].posX, &currentLevel.Idiots[7].posX,

              &currentLevel.Idiots[0].posY, &currentLevel.Idiots[1].posY,
              &currentLevel.Idiots[2].posY, &currentLevel.Idiots[3].posY,
              &currentLevel.Idiots[4].posY, &currentLevel.Idiots[5].posY,
              &currentLevel.Idiots[6].posY, &currentLevel.Idiots[7].posY,

              &currentLevel.DrunkenBots[0].posX,
              &currentLevel.DrunkenBots[0].posY,

              &currentLevel.Portals[0].posX,     &currentLevel.Portals[1].posX,   &currentLevel.Portals[2].posX,   &currentLevel.Portals[0].destX,
              &currentLevel.Portals[1].destX,    &currentLevel.Portals[2].destX,  &currentLevel.Portals[0].posY,   &currentLevel.Portals[1].posY,
              &currentLevel.Portals[2].posY,     &currentLevel.Portals[0].destY,  &currentLevel.Portals[1].destY,  &currentLevel.Portals[2].destY,

              &currentLevel.Turrets[0].posX,
              &currentLevel.Turrets[1].posX,
              &currentLevel.Turrets[2].posX,

              &currentLevel.Turrets[0].posY,
              &currentLevel.Turrets[1].posY,
              &currentLevel.Turrets[2].posY
              ) != 36)
              {
                  fprintf(stderr, "%s: fscanf: arguments mismatch\n", __FUNCTION__);
                  free(f_name);
                  return 1;
              }

    /* And enabling `em all (surely, if isn`t OBJ_DISABLED) */
    int i = 0;
    while(i < MAX_IDIOTS)
    {
        currentLevel.Idiots[i].posX *= STEP;
        currentLevel.Idiots[i].posY *= STEP;

        if(!isOutOfBounds(currentLevel.Idiots[i].posX,
                          currentLevel.Idiots[i].posY)) currentLevel.Idiots[i].isEnabled = 1;

        i++;
    }

    i = 0;

    while(i < MAX_PORTALS)
    {
        currentLevel.Portals[i].posX *= STEP;
        currentLevel.Portals[i].posY *= STEP;

        currentLevel.Portals[i].destX *= STEP;
        currentLevel.Portals[i].destY *= STEP;

        if(!isOutOfBounds(currentLevel.Portals[i].posX,
                          currentLevel.Portals[i].posY)) currentLevel.Portals[i].isEnabled = 1;

        i++;
    }

    i = 0;

    while(i < MAX_TURRETS)
    {
        currentLevel.Turrets[i].posX *= STEP;
        currentLevel.Turrets[i].posY *= STEP;

        if(!isOutOfBounds(currentLevel.Turrets[i].posX,
                          currentLevel.Turrets[i].posY)) currentLevel.Turrets[i].isEnabled = 1;

        i++;
    }

    currentLevel.DrunkenBots[0].posX *= STEP;
    currentLevel.DrunkenBots[0].posY *= STEP;

    if(!isOutOfBounds(currentLevel.DrunkenBots[0].posX,
                          currentLevel.DrunkenBots[0].posY)) currentLevel.DrunkenBots[0].isEnabled = 1;

    /* Finish it. */
    free(f_name);
    fclose(f);
    return 0;
}
Esempio n. 26
0
int loadItems(int which)
{
    FILE *f;
    char *f_name = getFileName(which, FYPE_ITEMS);

    if(f_name == NULL)
    {
        fprintf(stderr, "%s: f_name == NULL? (attempt to load something unknown)\n", __FUNCTION__);
        return 1;
    }

    fprintf(stderr, " > In progress: %s\n", f_name);

    if((f = fopen(f_name, "r")) == NULL)
    {
        fprintf(stderr, "%s: fopen failure\n", __FUNCTION__);
        free(f_name);
        return 1;
    }

    if(
    fscanf(f,
           "[Keys]\n Key1X = %i\n Key1Y = %i\n Key2X = %i\n Key2Y = %i\n Key3X = %i\n "
           "Key3Y = %i\n\n[1UP]\n 1UP1X = %i\n 1UP1Y = %i\n 1UP2X = %i\n 1UP2Y = %i\n 1UP3X = %i\n 1UP3Y = %i",

           &currentLevel.Keys[0].posX, &currentLevel.Keys[0].posY,
           &currentLevel.Keys[1].posX, &currentLevel.Keys[1].posY,
           &currentLevel.Keys[2].posX, &currentLevel.Keys[2].posY,

           &currentLevel._1UPs[0].posX, &currentLevel._1UPs[0].posY,
           &currentLevel._1UPs[1].posX, &currentLevel._1UPs[1].posY,
           &currentLevel._1UPs[2].posX, &currentLevel._1UPs[2].posY) != 12)
           {
               fprintf(stderr, "%s: fscanf: arguments mismatch\n", __FUNCTION__);
               free(f_name);
               return 1;
           }

    /* 'Enabling' objects */
    int i = 0;
    while(i < MAX_1UPS)
    {
        currentLevel.Keys[i].posX *= STEP;
        currentLevel.Keys[i].posY *= STEP;

        currentLevel._1UPs[i].posX *= STEP;
        currentLevel._1UPs[i].posY *= STEP;

        if(!isOutOfBounds(currentLevel.Keys[i].posX,
                          currentLevel.Keys[i].posY)) currentLevel.Keys[i].isEnabled = 1;

        if(!isOutOfBounds(currentLevel._1UPs[i].posX,
                          currentLevel._1UPs[i].posY)) currentLevel._1UPs[i].isEnabled = 1;

        i++;
    }

    free(f_name);
    fclose(f);
    return 0;
}
void LedMatrixMAX7219Driver::setCol(unsigned char col, unsigned char value) {
    if (!isOutOfBounds(col, 0)) {
        matrixData[col] = value;
        driver->writeRegister(registerMap[col], value);
    }
}