This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef SUPERCLASS_HPP_ | |
| #define SUPERCLASS_HPP_ | |
| // PLEASE IGNORE THE 0 IN THE FILENAME. THIS IS ONLY FOR IT TO SHOW IN THE RIGHT ORDER | |
| // IN THE GIST. | |
| class SuperClass { | |
| public: | |
| SuperClass(int id); | |
| virtual void print_itself() = 0; // Abstract method, a pure virtual function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| void test(int &i){} | |
| int main(){ | |
| int i = 0; | |
| std::cout << "++i + i++: " << ++i + i++ << std::endl; | |
| } | |
| // Compilation: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "game_scene.hpp" | |
| void GameScene::start() { | |
| gs::TextureLoader::set_texture_from_file(texture, "assets/player_t.png"); | |
| player = Player(texture, sf::Vector2f(400, 300)); | |
| time_handlers.push_back(player.get_time_handler()); | |
| } | |
| void GameScene::update() { | |
| player.control_entity(get_delta_time()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "game.hpp" | |
| Game::Game() : window(sf::VideoMode(800, 600), "SFML works!") { | |
| tex.loadFromFile("assets/player_t.png"); | |
| player = Player(tex, sf::seconds(1.f / 10.f)); | |
| player.get_sprite().setPosition(sf::Vector2f(400, 300)); | |
| } | |
| void Game::run() { | |
| while (window.isOpen()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <SFML/Graphics.hpp> | |
| int main() { | |
| sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!"); | |
| sf::Clock clock; | |
| sf::Texture tex; | |
| sf::Time elapsed; | |
| sf::Time animation_time = sf::Time::Zero; | |
| int animation_loop_state; | |
| sf::Time animation_framerate(sf::seconds(1.f / 10.f)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Okay, so suppose we want to create a mechanism to print a string | |
| // in anywhere we want just by creating another class that implements the thing | |
| // we want to do. Here, we'll be checking inheritance and abstract classes. | |
| #include <fstream> | |
| #include <iostream> | |
| #include <string> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "gs2d/core.hpp" | |
| #include "my_scene.hpp" | |
| int main() { | |
| gs::App app(200, 200, "Sample SFML"); | |
| app.app_start(new MyScene()); | |
| } |