aboutsummaryrefslogtreecommitdiff
path: root/Simulation/SimBase_CreateNew.cpp
blob: de752aa4d7de1b3e98a7a032f2478438cf2fc87c (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
#include "SimBase.hpp"

bool SimBase::createNew(const Params &usrPrms)
{
    prms = usrPrms;

    seedRand();

    sf::VideoMode vmd = sf::VideoMode(prms.WIN_WIDTH, prms.WIN_HEIGHT);
    sf::ContextSettings ctx = sf::ContextSettings(0, 0, prms.ANTIALIAS, 2, 0);
    window.create(vmd, "Neural Guppies - 0.1 beta", sf::Style::Default, ctx);
    window.setVerticalSyncEnabled(vSync);

    sf::Image icon;
    icon.loadFromFile("gfx/icon.png");
    window.setIcon(32, 32, icon.getPixelsPtr());

    prepareGraphics();

    camera.create(this);
    tank.create(this);

    zappers.resize(prms.zapperQtty);
    for (auto &i : zappers)
    {
        i.startup(this);
        i.create();
    }

    pellets.resize(prms.pelletQtty);
    for (auto &i : pellets)
    {
        i.startup(this);
    }
    if (!prms.startScarce)
    {
        for (auto &i : pellets)
        {
            i.create();
        }
    }

    if (!startSpecs())
    {
        return false;
    }

    return true;
}