1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace sf;
using namespace std;
int main()
{
//VideoMode vm(1360, 768);
VideoMode vm(1920, 1080); //Create VideoMode object & set resolution
RenderWindow window(vm, "Timber!!!", Style::Fullscreen); //Create windows, put title in, & run FullScreen
/*BACKGROUND*/
Texture textureBackground; //Create texture to hold graphics in GPU
textureBackground.loadFromFile("graphics/background.png"); //Load graphic into the texture in GPU
//textureBackground.loadFromFile("graphics/background_1350.png"); //Load graphic into the texture in GPU
Sprite spriteBackground; //Create sprite
spriteBackground.setTexture(textureBackground); //Load texture from GPU into the sprite
spriteBackground.setPosition(0,0); //Set at 0,0 as image is 1920x1080
cout << VideoMode::getDesktopMode().width << endl;
cout << VideoMode::getDesktopMode().height << endl;
cout << "Window x = " << window.getSize().x << endl;
cout << "Window y = " << window.getSize().y << endl;
/**************TREE**************/
Texture textureTree;
textureTree.loadFromFile("graphics/tree.png");
Sprite spriteTree;
spriteTree.setTexture(textureTree);
spriteTree.setPosition(810, 0);
/**************BEE**************/
Texture textureBee;
textureBee.loadFromFile("graphics/bee.png");
Sprite spriteBee;
spriteBee.setTexture(textureBee);
spriteBee.setPosition(0, 800);
bool beeActive = false; //Is bee currently moving
float beeSpeed = 0.0f; //Bee speed
/**************CLOUDS**************/
Texture textureCloud;
textureCloud.loadFromFile("graphics/cloud.png");
Sprite spriteCloud1, spriteCloud2, spriteCloud3;
spriteCloud1.setTexture(textureCloud);
spriteCloud2.setTexture(textureCloud);
spriteCloud3.setTexture(textureCloud);
spriteCloud1.setPosition(0, 0);
spriteCloud2.setPosition(0, 250);
spriteCloud3.setPosition(0, 500);
//Are the clouds currently on the screen?
bool cloud1Active = false;
bool cloud2Active = false;
bool cloud3Active = false;
//How fast is each cloud moving?
float cloud1Speed = 0.0f;
float cloud2Speed = 0.0f;
float cloud3Speed = 0.0f;
while (window.isOpen()) //Main game loop while the window is open
{
/*
**********************************
Handle the players input
**********************************
*/
if (Keyboard::isKeyPressed(Keyboard::Escape))
window.close();
/*
**********************************
Update the scene
**********************************
*/
/*
**********************************
Draw the scene
**********************************
*/
window.clear(); //Clear everything from the last frame
//Draw our games scene here
window.draw(spriteBackground);
window.draw(spriteCloud1);
window.draw(spriteCloud2);
window.draw(spriteCloud3);
window.draw(spriteTree);
window.draw(spriteBee);
window.display(); //Show everything we just drew (double buffering)
}
return 0;
}
| |