Hi
I have issue not able to display the whole picture using SFML graphics on my labtop. I am using the Games with C++ by John Horton. I supposed to get the graphic screen as shown in the book shown in the black and while image( the book only have black and white). What I got running the program is shown in the second color image.
You can see in that the lower part and the right size of the black and while picture are cut off compare to the color image generated by my program. I copied the program exactly what the book has, everything works except I cannot get the full size display on the screen. How can I fix it?
I don't know how well to post the code of my program:
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
int main()
{ VideoMode vm(1920, 1080);//set screen resolution 1920 X 1080
RenderWindow window(vm, "Timber!!!", Style::Fullscreen);//create window object
Texture textureBackground;//Create texture to hold graphic on GPU
textureBackground.loadFromFile("graphics/background.png");//load graphic into texture
Sprite spriteBackground;//create a sprite
spriteBackground.setTexture(textureBackground);//attach texture to sprite
spriteBackground.setPosition(0, 0);//set sprite to cover the screen
Texture textureTree;
textureTree.loadFromFile("graphics/tree.png");
Sprite spriteTree;
spriteTree.setTexture(textureTree);
spriteTree.setPosition(810, 0);//810 should put a little left from center
Texture textureBee;
textureBee.loadFromFile("graphics/bee.png");
Sprite spriteBee;
spriteBee.setTexture(textureBee);
spriteBee.setPosition(400, 510);
bool beeActive = false;
float beeSpeed = 0.0f;
Texture textureCloud;
textureCloud.loadFromFile("graphics/cloud.png");
Sprite spriteCloud1;
Sprite spriteCloud2;
Sprite spriteCloud3;
spriteCloud1.setTexture(textureCloud);
spriteCloud2.setTexture(textureCloud);
spriteCloud3.setTexture(textureCloud);
spriteCloud1.setPosition(0, 0);
spriteCloud2.setPosition(0, 250);
spriteCloud3.setPosition(0, 500);
bool cloud1Active = false;
bool cloud2Active = false;
bool cloud3Active = false;
float cloud1Speed = 0.0f;
float cloud2Speed = 0.0f;
float cloud3Speed = 0.0f;
window.clear();
window.draw(spriteBackground);
window.draw(spriteTree);
window.draw(spriteBee);
window.draw(spriteCloud1);
window.draw(spriteCloud2);
window.draw(spriteCloud3);
window.display();//Update screen with new background
while (window.isOpen())//Stay looping until ESC
{ if (Keyboard::isKeyPressed(Keyboard::Escape))
{ window.close(); }//Hit ESC key to exit
}
window.clear();
window.display();
return 0;
}
thanks