aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simplegame/main.cpp
blob: 895fce51ff69f2fbb86113f08339860885c7ee1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/** ---------------------------------------------------------------------------
 * @file: simplegame.cpp
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#include <yage.cpp>

#include <iostream>

using std::cout;

using namespace yage;

int main()
{
    Window window;
    window.create("Simple Game", 800, 640);

    Shader textureProgram("examples/resources/learnopenglshader.vert",
                          "examples/resources/learnopenglshader.frag");
    SpriteBatch sp;

    Texture fountain = ResourceManager::getTexture(
        "examples/resources/dngn_blood_fountain.png");
    Texture breast_plate =
        ResourceManager::getTexture("examples/resources/breast_black.png");

    Texture brick = ResourceManager::getTexture("examples/resources/wall.png");

    cout << "texture: " << brick.width << ", " << brick.height << '\n';

    Camera camera(800, 640);
    textureProgram.use();
    textureProgram.setUniform("ourTexture", 0);

    while (!window.shouldClose()) {
        window.clearBuffer();
        Texture texture = fountain;

        window.pollEvents();
        if (window.keyPressed(yage::key::SPACE)) {
            cout << "Pressed A" << '\n';
        }
        if (window.keyPressed(yage::key::E)) {
            texture = breast_plate;
        }

        sp.draw({-0.5, -0.5, 1, 1}, {0, 0, 1, 1}, brick.id, Colour(255, 255, 255, 255), 0);

        sp.render();

        window.swapBuffer();
    }
}