31
Network / Re: downloading image for sfml resource use
« on: November 12, 2013, 08:29:06 pm »
OK now though the image is not able to open. It doenst save the image as expected? Is there something else missing that is stopping this?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
/tmp/ccRlWxMK.o: In function `main':
test2.cpp:(.text+0x5f): undefined reference to `sf::Http::Http()'
test2.cpp:(.text+0xae): undefined reference to `sf::Http::Request::Request(std::string const&, sf::Http::Request::Method, std::string const&)'
test2.cpp:(.text+0xf0): undefined reference to `sf::Http::sendRequest(sf::Http::Request const&, sf::Time)'
test2.cpp:(.text+0xff): undefined reference to `sf::Http::Response::getBody() const'
/tmp/ccRlWxMK.o: In function `sf::TcpSocket::~TcpSocket()':
test2.cpp:(.text._ZN2sf9TcpSocketD2Ev[_ZN2sf9TcpSocketD5Ev]+0x2f): undefined reference to `sf::Socket::~Socket()'
/tmp/ccRlWxMK.o:(.rodata._ZTIN2sf9TcpSocketE[_ZTIN2sf9TcpSocketE]+0x10): undefined reference to `typeinfo for sf::Socket'
collect2: error: ld returned 1 exit status
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");
sf::Image Image;
if (!Image.LoadFromFile("ship.png"))
return EXIT_FAILURE;
sf::Sprite ship(Image);
ship.SetColor(sf::Color(50, 50, 50, 255));
ship.SetPosition(200.f, 100.f);
ship.SetScale(0.f,0.f);
ship.Rotate(0.f);
// Start game loop
while (window.IsOpened())
{
// Process events
sf::Event Event;
while (window.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
window.Close();
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::A:
ship.SetRotation(270.f);
ship.Move(-5, 0);
break;
case sf::Key::W:
ship.SetRotation(180.f);
ship.Move(0,-5);
break;
case sf::Key::D:
ship.SetRotation(90.f);
ship.Move(5, 0);
break;
case sf::Key::S:
ship.SetRotation(0.f);
ship.Move(0,5);
break;
}
}
}
window.Clear(sf::Color::White);
window.Draw(ship);
window.Display();
}
return EXIT_SUCCESS;
}
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test");
sf::Image Image;
if (!Image.LoadFromFile("ship.png"))
return EXIT_FAILURE;
sf::Sprite ship(Image);
ship.SetColor(sf::Color(0, 255, 255, 128));
ship.SetPosition(200.f, 100.f);
ship.SetScale(0.f, 0.f);
ship.Rotate(0.f);
// Start game loop
while (window.IsOpened())
{
// Process events
sf::Event Event;
while (window.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
window.Close();
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::A:
ship.Move(-1,0);
break;
}
}
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::W:
ship.Move(0,-1);
break;
}
}
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::D:
ship.Move(1,0);
break;
}
}
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::S:
ship.Move(0,1);
break;
}
}
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::Q:
ship.Rotate(-1.f);
break;
}
}
if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code)
{
case sf::Key::E:
ship.Rotate(1.f);
break;
}
}
}
window.Clear(sf::Color::White);
window.Draw(ship);
window.Display();
}
return EXIT_SUCCESS;
}