Hello mates,
I'm using SFML to make a basic platformer game, so I can learn some concepts of the library. I run my application I get something beautiful, just look at 1.png (in attached files). When I move the app. to another PC, it doesn't run as well as it run in my laptop (2.png)
I'm trying to see where is my error, or how can I solve this... I think, there are driver problems in the PC... But that's only a conjeture... I hope you guys can give me a hand of help here...
Here is a part of my code:
// main.cpp
#include <iostream>
#include <Box2D/Box2D.h>
#include <SFML/Graphics.hpp>
..
int main() {
......
std::vector<Block> bloques;
// Este vector de bloques va a contener plataformas y objetos
sf::Texture grass;
grass.loadFromFile("grass.png");
grass.setRepeated(true);
grass.setSmooth(true);
bloques.push_back(Block(world, 3000.0f, 50.0f, sf::Vector2f(-200, height - 50.0f), .5f, false, 0, 0, &grass));
//Esto es un suelo!
sf::Texture bricks;
bricks.loadFromFile("bricks.jpg");
bricks.setRepeated(true);
bricks.setSmooth(true);
bloques.push_back(Block(world, 400.0f, 49.0f, sf::Vector2f(300, 300), .5f, false, .5f, 0, &bricks));
bloques.push_back(Block(world, 400.0f, 49.0f, sf::Vector2f(850, 100), .5f, false, .5f, 0, &bricks));
// Inicializamos algunas plataformas
//Agregamos un objeto dinamico...
sf::Texture box;
box.loadFromFile("box.png");
box.setSmooth(true);
bloques.push_back(Block(world, 100.0f, 100.0f, sf::Vector2f(450, 150), .5f, true, .5f, 0.0f, &box));
// Game loop
while (App.isOpen())
{
.....
App.clear();
.....
// Dibuja objetos
for (int i = 0; i < int(bloques.size()); i++)
{
App.draw( bloques[i].GetShape() );
}
......
App.display();
......
}
return 0;
}
And this is the block.cpp (only the constructor and getShape())
Block::Block(b2World *world, float width, float height, sf::Vector2f position, float mu, bool dynamic, float density, float e, sf::Texture *t)
{
rectangle = sf::RectangleShape( sf::Vector2f(width, height) );
rectangle.setPosition(position);
rectangle.setTexture(t);
rectangle.setTextureRect(sf::IntRect(0, 0, width, height));
........
}
sf::Shape & Block::GetShape()
{
return rectangle;
}
The variable "rectangle" is a part of the class "Block". Thanks in advance!
Greetings!