11
« on: August 05, 2009, 07:10:40 pm »
Hey Guys,
I went through the examples and tried displaying an image on the screen, but it won't shop up. My code is right and it compiles without errors, but the window is blank. Here's my code.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <wchar.h>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include "player.h"
#include "vehicle.h"
int main()
{
sf::RenderWindow App(sf::VideoMode(800,600,32), "Car Junker - DarkScar Games");
const sf::Input& Input = App.GetInput();
bool Logo_Screen = true;
bool Title_Screen = false;
sf::Image TitleScr;
sf::Image LogoScr;
if(!TitleScr.LoadFromFile("Title.png"))
{
return EXIT_FAILURE;
}
sf::Sprite TitleSprt(TitleScr);
if(!LogoScr.LoadFromFile("Logo.png"))
{
return EXIT_FAILURE;
}
sf::Sprite LogoSprt(LogoScr);
LogoSprt.SetImage(LogoScr);
bool LeftKeyDown = Input.IsKeyDown(sf::Key::Left);
bool RightKeyDown = Input.IsKeyDown(sf::Key::Right);
bool UpKeyDown = Input.IsKeyDown(sf::Key::Up);
bool DownKeyDown = Input.IsKeyDown(sf::Key::Down);
bool SpaceDown = Input.IsKeyDown(sf::Key::Space);
bool LeftMouseDown = Input.IsMouseButtonDown(sf::Mouse::Left);
bool RightMouseDown = Input.IsMouseButtonDown(sf::Mouse::Right);
unsigned int MouseX = Input.GetMouseX();
unsigned int MouseY = Input.GetMouseY();
Player* gPlayer = new Player();
Vehicle* gVehicle = new Vehicle();
sf::Clock Clock;
while(App.IsOpened())
{
sf::Event Event;
App.SetFramerateLimit(60);
while(App.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
{
App.Close();
}
if(Event.Key.Code == sf::Key::Escape)
{
App.Close();
}
if(Event.Key.Code == sf::Key::Left)
{
LeftKeyDown = true;
gPlayer->X = gPlayer->X - 5;
}
else if(Event.Key.Code == sf::Key::Right)
{
RightKeyDown = true;
gPlayer->X = gPlayer->X + 5;
}
else if(Event.Key.Code == sf::Key::Up)
{
UpKeyDown = true;
gPlayer->Y = gPlayer->Y - 5;
}
else if(Event.Key.Code == sf::Key::Down)
{
DownKeyDown = true;
gPlayer->Y = gPlayer->Y + 5;
}
}
App.Draw(LogoSprt);
App.Clear(sf::Color(0,0,0,0));
App.Display();
}
return EXIT_SUCCESS;
}