[ create a new paste ] login | about

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

C++, pasted on Nov 5:
#include "Game.hpp"
#include <iostream>

Game::Game()
{
    _mainwindow.create(sf::VideoMode(800,600), "test");
    _mainwindow.setFramerateLimit(60);
}

void Game::run()
{
    while (_mainwindow.isOpen())
    {
        processEvents();
        update();
        render();
    }
}

void Game::processEvents()
{
    sf::Event event;
    while (_mainwindow.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            _mainwindow.close();
        if (event.type == sf::Event::KeyPressed && sf::Keyboard::isKeyPressed((sf::Keyboard::Escape)))
            _mainwindow.close();
    }
    player.Player::move(5, event);
}

void Game::update()
{
    time = clock.getElapsedTime();
    //player.update(time.asSeconds());
    clock.restart().asSeconds();
}

void Game::render()
{
    _mainwindow.clear();
    player.draw(_mainwindow);
    _mainwindow.display();
}


Create a new paste based on this one


Comments: