summaryrefslogtreecommitdiff
path: root/themes/src/autumn/AutumnTheme.cpp
blob: 4b7a2e2c4dc1b2a7c377a2402386b4a28d7ac3ba (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "AutumnTheme.hpp"
#include "../shapes_2d.h"
#include <memory>

namespace
{
    const int NUM_HILLS = 3;
}

AutumnTheme::AutumnTheme(WebglContext* context)
{
    renderer.load(context);
    load();
}

AutumnTheme::~AutumnTheme()
{
    unload();
}

void AutumnTheme::load() {
    renderer.clearColor = Vector4(252, 210, 153, 255).toNormalizedColor();
	auto lr = tree.load(&renderer);
	leafParticles.load(&renderer, &lr);
    background = new RectangularGradient(
        renderer,
        Vector4{135, 206, 235, 255}.toNormalizedColor(),
        Vector4(252, 210, 153, 255).toNormalizedColor(),
        renderer.get_width(),
        renderer.get_height(),
        {0, 0});


    background_hill = new Circleish(
        renderer,
        1000,
        Vector4(137, 129, 33, 255).toNormalizedColor(),
        100,
        0,
        50);
    background_hill->mesh.model = background_hill->mesh.model.translateByVec2({1200, -700});
    
    tree_hill = new Circleish(
        renderer,
        500,
        Vector4{ 76, 75, 22, 255 }.toNormalizedColor(),
        100,
        0,
        50);
    tree_hill->mesh.model = tree_hill->mesh.model.translateByVec2(Vector2(300, -290));
}

void AutumnTheme::update(f32 dtSeconds) {
	tree.update(dtSeconds);
	leafParticles.update(dtSeconds);
}

void AutumnTheme::render() {
    renderer.render();
    background->render();
    background_hill->render();
	tree.render(&renderer);
    tree_hill->render();
	leafParticles.render(&renderer);
}

void AutumnTheme::unload()  {
	tree.unload();
	leafParticles.unload();
    delete background;
    delete background_hill;
    delete tree_hill;
}