[ create a new paste ] login | about

Link: http://codepad.org/hCIgIDep    [ raw code | output | fork ]

C++, pasted on Nov 11:
#include <iostream>
#include <SFML/Graphics.hpp>
#include "collision.h"
#include "shoot.h"

using namespace std;

int main()
{

    sf::RenderWindow app(sf::VideoMode(600, 500, 32), "Space Shooter",sf::Style::Close);
	//image
	sf::Image image_shuttle;
	if(!image_shuttle.LoadFromFile("data/space.png"))
	{
		return EXIT_FAILURE;
	}
	//sprite
	sf::Sprite shuttle(image_shuttle);
	shuttle.SetPosition(app.GetWidth()/2-(shuttle.GetSize().x/2), app.GetHeight()-shuttle.GetSize().y);
	//speed
	float Xspeed = 250.f;
	float Yspeed = 250.f;
	//class
	C_Shot shot;
	//loop
    while (app.IsOpened())
    {
		//event
        sf::Event Event;
        while (app.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                app.Close();
        }
		if(app.GetInput().IsKeyDown(sf::Key::Left) && shuttle.GetPosition().x >= 0)
		{
			shuttle.Move(-Xspeed * app.GetFrameTime(),0);
		}else if(app.GetInput().IsKeyDown(sf::Key::Right) && shuttle.GetPosition().x + shuttle.GetSize().x <= app.GetWidth())
		{
			shuttle.Move(Xspeed * app.GetFrameTime(),0);
		}else if(app.GetInput().IsKeyDown(sf::Key::Up) && shuttle.GetPosition().y >= shuttle.GetSize().y*2)
		{
			shuttle.Move(0,-Yspeed * app.GetFrameTime());
		}else if(app.GetInput().IsKeyDown(sf::Key::Down) && shuttle.GetPosition().y + shuttle.GetSize().y <= app.GetHeight())
		{
			shuttle.Move(0,Yspeed * app.GetFrameTime());
		}
		shot.draw(app,shuttle);
		//action
        app.Clear();
		app.Draw(shuttle);
        app.Display();
    }
    return EXIT_SUCCESS;
}


Output:
1
2
3
4
5
6
Line 28: error: SFML/Graphics.hpp: No such file or directory
Line 22: error: collision.h: No such file or directory
Line 18: error: shoot.h: No such file or directory
In function 'int main()':
Line 11: error: 'sf' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: