Beispiel #1
0
void Container::onDraw(sf::RenderWindow& render)
{
    sf::View original = render.GetView();
    sf::View view = render.GetView();
    view.Move(-rect.Left,-rect.Top);
    render.SetView(view);
    for(std::list<Widget*>::iterator i = childs.begin(); i != childs.end() ; ++i)
    {
        (*i)->draw(render);
        render.SetView(layout->adjust(render.GetView(),**i));
    }
    render.SetView(original);
}
Beispiel #2
0
void Model::Draw(sf::RenderWindow& Window)
{
    Window.SetView( & CurrentView);
    Window.Draw( mSea);
    Window.Draw( blastList );
    Window.Draw( *player );
    Window.Draw( planeList );
    Window.Draw( bulletList);
    Window.Draw( *cursor );

    Window.SetView(NULL);
    Window.Draw( myHud);
}
void		ObjBackground::draw(sf::RenderWindow& window)
{
	// _sprite loop qui se termine
	window.SetView(window.GetDefaultView());
	const sf::Vector2f position = _sprite.GetPosition();
	window.Draw(_sprite);
	for (unsigned int i = 0; i < 20; ++i)
	{
		_sprite.SetPosition(position.x + (_image->GetWidth() * i), position.y);
		window.Draw(_sprite);
	}
	_sprite.SetPosition(position);
	window.SetView(GGJ::Context::getSingleton().accessView());
}
Beispiel #4
0
void GUI::Menu::Menu::draw(sf::RenderWindow& window) {
	// Make view that is as close to 640x480 as possible and centered.
	view = window.GetDefaultView();
	view.Zoom(std::min(view.GetRect().GetWidth() / 640, view.GetRect().GetHeight() / 480));
	view.SetCenter(320, 240);
	window.SetView(view);

	window.Clear(sf::Color(0xcc, 0x66, 0x33));
	Container::draw(window);
	window.Draw(logoSprite);
}
Beispiel #5
0
void GameScreen::draw (sf::RenderWindow &app)
{
	app.Clear();
	app.SetView(ConfigOptions::getView()); //switching to custom view for easy resizing of the screen

	app.Draw(m_background);
	m_highlighter.draw(app);
	if(m_selectedPiece != NULL_SQUARE)
		app.Draw(m_selectionSprite);
	if(m_selectedTarget != NULL_SQUARE)
		app.Draw(m_targettingSprite);
	app.Draw(m_cursor);
	for(std::map<PiecePtr, PieceSprite>::iterator it = m_pieces.begin(); it != m_pieces.end(); ++it)
		app.Draw(it->second);
	if(!isOver())
	{
		if(m_game.getActivePlayer() == GOLD)
			app.Draw(m_goldTurnIndicator);
		else //SILVER
			app.Draw(m_silverTurnIndicator);
		if(m_game.hasStarted())
		{
			app.Draw(m_movesBackgroundSprite);
			app.Draw(m_nbMovesSprite);
		}
		else //game has not started
		{
			m_placementUI.draw(app, m_game.canEndPlacement());
		}
		m_turnSign.draw(app);
	}
	else //the game is over
		app.Draw(m_victorySign);

	app.SetView(app.GetDefaultView()); //switching back to default view
	app.Display();
}
Beispiel #6
0
void MainMenuHandler::run(sf::RenderWindow& window) {
	ImageCache mainMenuImages;
	const sf::Image& logoImage = mainMenuImages.get(Path::findDataPath("graphics/logo.png"));

	// Entering main menu, no game should be running.
	GameHandler::instance.reset();

	// Make view that is as close to 640x480 as possible and centered.
	view = window.GetDefaultView();
	view.Zoom(std::min(view.GetRect().GetWidth() / 640, view.GetRect().GetHeight() / 480));
	view.SetCenter(view.GetHalfSize());
	window.SetView(view);

	window.SetFramerateLimit(30);

	// Position at the top of the window.
	sf::Sprite logoSprite(logoImage);
	logoSprite.SetCenter(logoImage.GetWidth() / 2, 0);
	logoSprite.SetPosition(window.GetView().GetRect().GetWidth() / 2, 1);

	// Build the main menu GUI.
	GUI::Container gui;
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("New game", 200, 100, 240, 50, boost::bind(&MainMenuHandler::startGame, this))));
	gui.insert(boost::shared_ptr<GUI::Object>(new GUI::Button("Exit", 250, 170, 140, 50, boost::bind(&sf::RenderWindow::Close, boost::ref(window)))));

	menuClosed = false;
	while (window.IsOpened() && !menuClosed) {
		sf::Event e;
		if (window.GetEvent(e)) {
			if (gui.handleEvent(e, window)) {
				continue;
			}
			if (e.Type == sf::Event::Closed || (e.Type == sf::Event::KeyPressed && e.Key.Code == sf::Key::Escape)) {
				window.Close();
				continue;
			}
		} else {
			window.Clear(sf::Color(0xcc, 0x66, 0x33));
			window.Draw(logoSprite);
			gui.draw(window);
			window.Display();
		}
	}
}
Beispiel #7
0
SBI gra_screen::Draw(sf::RenderWindow &App)
{
	App.SetView(view);
	App.Draw(boisko_sp);
	App.Draw(wynik_obl);
	//App.Draw(wynik_obs);
	App.Draw(wynik_obp);
	App.Draw(Timer_ob1);
	//App.Draw(Timer_ob2);
	#ifndef Release
	App.Draw(Techdata);
	#endif
	//for (int i=0; i<6; i++)
	//	App.Draw(lingran[i]);
	for (int i=0; i<obiekty_il; i++)
	{
		(obiekty+i)->Draw(App);
	}
	return SBI();
}
void ProcessAppEvents(sf::RenderWindow &App, sf::View &v, GroupManager &gm)
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        switch (Event.Type)
        {
            case sf::Event::Closed: App.Close(); break;
            case sf::Event::KeyPressed:
            {
                switch (Event.Key.Code)
                {
                    case sf::Key::Escape: App.Close(); break;
                    case sf::Key::Right:
                    case sf::Key::Left:
                    case sf::Key::Up:
                    case sf::Key::Down:
                    {
                        const int step = 5;
                        v = App.GetView();
                        int hor = 0, ver = 0;
                        if (Event.Key.Code == sf::Key::Left)
                            hor+=step;
                        if (Event.Key.Code == sf::Key::Right)
                            hor-=step;
                        if (Event.Key.Code == sf::Key::Up)
                            ver+=step;
                        if (Event.Key.Code == sf::Key::Down)
                            ver-=step;
                        v.Move(hor, ver);
                        App.SetView(v);
                        break;
                    }
                    case sf::Key::S:
                    case sf::Key::D:
                    {
                        //if (Event.Key.Code == sf::Key::S)
                        //    wanna_step_per_second-= wanna_step_per_second/10 - 1;
                        //if (Event.Key.Code == sf::Key::D)
                        //    wanna_step_per_second+= wanna_step_per_second/10 + 1;
                        //if (wanna_step_per_second <= 0)
                        //    step_per_second = 1;
                        //if (wanna_step_per_second >= 250)
                        //    step_per_second = 250;
                        //step_time = 1.0/wanna_step_per_second;
                        break;
                    }
                    case sf::Key::W:
                    case sf::Key::E:
                    {
                        if (Event.Key.Code == sf::Key::E)
                            gm.SetStepSize(gm.GetStepSize() + 0.005);
                        if (Event.Key.Code == sf::Key::W)
                            gm.SetStepSize(gm.GetStepSize() - 0.005);
                        break;
                    }
                    case sf::Key::Z:
                    case sf::Key::X:
                    {
                        if (Event.Key.Code == sf::Key::Z)
                            v.Zoom(1.01);
                        if (Event.Key.Code == sf::Key::X)
                            v.Zoom(1.0/1.01);
                        break;
                    }
                    case sf::Key::A:
                    {
                        step_mode = (STEP_MODE) ((int)SM_HARD_STEPS_CNT + (int)SM_FREE_STEPS_CNT - step_mode);
                        break;
                    }
                    default: break;
                }
                break;
            }
            case sf::Event::Resized:
            {
                int h = Event.Size.Height;
                int w = Event.Size.Width;
                v.SetHalfSize(w/2, h/2);
                break;
            }
            default: break;
        }
    }
}