Irrlicht (Cross platform 3d game engine) Client

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Changed view rotation and added more tile types.

Code: Select all

#include <irrlicht.h>
#include <IGUIButton.h>
#include "driverChoice.h"
#include <IGUIEnvironment.h>
#include <list>
#include <random>
#include <algorithm>
#include <iostream>
#include<tuple>

using namespace irr;
using namespace std;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#include <Windows.h>
#else
#include <unistd.h>
#endif

// Define some values that we'll use to identify individual GUI controls.
enum
{
    GUI_ID_NEW_GAME_BUTTON = 101,
    GUI_ID_LOAD_GAME_BUTTON,
    GUI_ID_LOAD_SCENARIO_BUTTON,
    GUI_ID_NET_GAME_BUTTON,
    GUI_ID_SETTINGS_BUTTON,
    GUI_ID_QUIT_BUTTON,
    GUI_ID_LAUNCH_BUTTON,
    GUI_ID_MENU_BUTTON,
    GUI_ID_SETTINGS_SAVE_BUTTON,
    GUI_ID_DRIVER_BOX
};
int view_window = 0;
//set up settings

struct SAppContext
{
    IrrlichtDevice* device;
    s32             counter;
    IGUIListBox* listbox;
    IGUIListBox* ListboxDriver;
};

/*uncomment for random map
std::list<tuple <int, int, int>> map_gen()
{
    int x;
    int y;
    std::list<tuple <int, int, int>> map;
    x = 256;
    y = 128;
    random_device rd;     // only used once to initialise (seed) engine
    srand(rd());    // random-number engine used
    uniform_int_distribution<int> uni(1,5); // guaranteed unbiased
    for (int tile_y = 1; tile_y <= y; ++tile_y)
    {
        //std::cout << "new Y row" << std::endl;
        for (int tile_x = 1; tile_x <= x; ++tile_x)
        {
            uncomment for random map
            //std::cout << "new X row" << std::endl;
            tuple<int, int, int> tile;
            int max;
            int tile_type;
            max = 5; //set the upper bound to generate the random number
            tile_type = rand()%max;
            tile = make_tuple(tile_x, tile_y, tile_type);
            map.push_back(tile);

        }     
    }
    return map;
}
*/

std::list<tuple <int, int, int>> map_gen()
{
    int x;
    int y;
    std::list<tuple <int, int, int>> map;
    std::list<std::string> premap;
    premap =
    {
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "  aaaa      aa    aaaaaa    aa    aa        aaaaaaaa        aaaa      aaaaaa      aa      aa  aa      aa    aa        aa            aa    aaaa              aa  ",
        "               ::        ::    ::    ::::::          ::::::      ::::        ::::    ::::        ::::    ::    ::::::    ::::::::::    ::      ::::::::::::     ",
        "             ::::::::::::::::::::::::::  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ",
        "                   :::::::::::::::::::    :::::::::::::   ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  ",
        "                    ::::::::::::::::    t    :::::::::: t  :::::::::::::    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::         ",
        " aaaaaaaaaaaaaa      :::::::::::::::   ttt     :::::::       :::::::::    t   ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::       aaaa   ",
        "aaaaaaaaaaaaaaaaa     :::::::::::::::  t t        ::::          :::::      t       :::::::::        :::::::::::::::::::::::::::::::::::              aa aaaa   a",
        "aaaaaaaaaaaaaaaaaa     :::::::::::::::            ::     tta      :::                 ::::    tt       ::::::::::::::::::::::::::::             t    tataaa   aa",
        "aaaaaaaaaaaaaaaaaa     :::::::::::::::                  tp                tttttt       ::              :::::::::::::::::::::::::        t  t          t at    ta",
        "aaaaaaaaaaaaaaaaat     :::::::::::::::::               tp               ttpptttttt      :               :::::::::::::::::::::::     tt                        tt",
        "tttaaaaaaaaaaaaaat    :::::::::::::::      tttt        pp     tt     tttttppttttt                              ::::::::::::::      tt    t     p  t   ttt      t",
        " tttaaaaaaaaaaaatt  :::::::::::::       pptttttttt           ttt tttttttttfffftt   ttt        ttttt              :::      ::           tttt                     ",
        "  tttaaaaaaaaaatt  ::::::              gppptpppttttt      ff ppt ttttfttftffffttffttttttt   tttftftttt           :::                   tppt           t a       ",
        "   tttaaaaaaaatt :::  ::   h          pphgffggpppttt   pttffffpggpptfftttffffffffffgggpfffffffffffpppttttttt     ::  ttt        tttt                  tttta     ",
        ":   tttaaaaaatt  :t    :       h     gphhgffggppppt   tttffffffggggpffffffffffffffpgggpfffpffffffffpppttpttttt    : ttttttttttttttttt           tttt    ttaa    ",
        "::   tttaaaatt  :: tft       h      gghpff ggg+fpp  ppffffhhfffgppggfffffffpffffffppppppffffggffffffffffgpptpptttt:  ttptttpttpttttpttttttttpttttttp p    ptaa  ",
        ":::   ttaaatt  ::: gg      hhh     hgmhpf   ggffppppppffffhfffggggpgffffpffffffffffpppppffffpgfffffpffffggppppttt :: tttttptttttttppttptttttttttttpp       paaa ",
        "::::  ttaatt  ::::          pg    ffhhfg    g+f+ffpffffffhfffgggppggpfffffgppffpffffpppfffffffppffffffffffffpp    : ttttttttttppffffffppttpttttppp   p    pptp  ",
        "::::  ttttt  :::::::::  gg  gp    ffggg    gggffffffpfffhmffggggppgpppffffgfffffffffpppffffffffpffffffffffff   :::: ttpptpttttppfffffffptpppttttp            pt ",
        ":::::  ttt  :::::::::: fpg  ff     gggg      gffppggppffhmffggggssffppgfffffffffpffpppppffpffgffffgggg  ff   :::::   tppptttppfffffgpfffffffppttpt              ",
        "::::::  tt ::::::::::  hg  hff       g    ggggffggpgggffhmfffggggpgfppggffffffffpppppfppffffffffffgg    ff :::::      tpppttpfffffffffffffffppttppp        tpp  ",
        " ::::::    ::::::::::     gpggg    g      ggffffgpgggfpfhmffffggggpgpppppffpffgggpgpffffffffgggggg     fhh ::::::  pppp p   ppggppffppffffffffffppppttp  t tp   ",
        " :::::::::::::::::::::   gsgggg    gg   ggggfffggggggffffhfffgggggggpfggppffffggg+ggffffffffggg        phh ::::::              gppffgpfffgfffpfffpppttp  pttppp ",
        "  ::::::::::::::::::::          ggggpppgggffffggffggggppffhfggffffggffffgffffffffgpppppppppgg          hpp  ::::::       :::::    ggffffffffffgfffppptttttppfffg",
        "p  :::::::::::::::::::   ggggggggggggpppggffffggffggggppfffhggffffggffffggffffffggppppppppgggg    p     p   :::::::::::::::::::::  ggffffffffffffffpppttttpfffff",
        "pp  :::::::::::::::::::    ggpggggpgggggggggffgpggppggggpppppggggpppppppggffpppgggppdpppppppppgg  p        :::::::::::::::::::::::  pphhfffggfffffffffppggffffff",
        "p     :::::::::::::::::    gpgggghghhgggggggffgggpppggppppppppggpppppppppgfgppppgpppddppppppppgg  p      :::::::::::::::::::::::::  pphhffggggfffgffffppggfffffg",
        "  pp   :::::::::::::::     ggggghmmmhhggpppppfggppppppp ggpppddddpgpppgpppgppppdddddppggppppggg        :::::::::::::::::::::::::::  ggffhhggggppgpgpp+pfffpppf  ",
        "  pp    :::::::::::::     ghggppgghghhggppgppg  ppgppp  ggpp pddpppgppppppppppdddpddppggppppgg    pp  :::::::::::::::::::::::::::: gggffhhppgppppppp+++f++ggggg ",
        "       :::::::::::::: ggppppmg    hg   gppppgg  gp pgg pppppddppppppppgpppgpppddddppggppggggg    ghg  :::::::::::::::::::::::::::  fgpgghhggggppggppggg+ggggggff",
        "f   ::::::::::::::::: ggppppph    gh    pppggg      gg  pppppdpgppppppgppppppppddpppggppgggg         :::::::::::::::::::::::::::: ffggghmhgggggggggpgpg+gggpgggf",
        "   :::::::::::::::::: ppphppg      gh   ggpgp       gg   ppppppppppgppppppppgpppppg   gggg     pm  :::::::::::::::::::::::::::::: fgpghhmmhgppggggpgggggffggggf ",
        "  :::::::::::::   :::  ppppp     h  gh  ggp  gppggppgg   pppgppppppppppppppppgppppgg   gg      pm  :::::::::::::::::::::::::::::: ffgphhmmhgppgggggggpggpfgggg  ",
        " :::::::::::::  g :::: hppp      g  g g gg  pgffppppppppppppppgphhhhppppgggpppppppgg   gg   gpmhp ::::::::::::::::::::::::::::::: fggghhmhpppggggggggggghhgg    ",
        " ::::::::::::::   ::::             gp    g  ggffppppppppppgpppgghhhhhpppggggppppppgg       gppmg  ::::::::::::::::::::::::::::::: pfpghhhpppppgggggggpghhggg    ",
        ":::::::::::::::::::::  hgggggggg              pppppppppppphhphhhhhhhhhppggggpppppgggg      g     ::::::::::::::::::::::::::::::::  fggppppppggggppgggghhgg     :",
        ":::::::::::::::::::   gggppppgggg             pppppppppppppphhhhmmmhhmhhggggpppggpggg        :::::::::::::::::::::::::::::::::::::  gggppphppgggppggghhgg    :::",
        "::::::::::::::::::  ppgppphhhhppgggg   ggggpppppppddpp   ppphhmmmmmmmmhhpgggggggpppggg       ::::::::::::::::::::::::::::::::::::::  pggpppddpppgggggggg   :::::",
        ":::::::::::::::::  ppppppdddddphhppgggggggpgppppppdddp    pphhhhhmmmmmhhppggggggpgppgg      :::::::::::::::::::::::::::::::::::::::: gpggppdddppgggggggg  :::   ",
        "::::::::::::::::: pddppdddddddddddpppppppppp  pddddddddp    ggghhhhhmmhhhggggppggggggg     ::::::::::::::::::::::::::::::::::::::::: pgggpddddppg     gg :::: g ",
        "::::::::::::::::: pppdddddddpddddddpppdpppppp   ddpdddddd    gggghhhhhhhgggpgpppggggg      :::::::::::::::::::::::::::::::::::::::::  gg ppdddpg      jg  :::   ",
        "::::::::::::::::: ppdddpddddddddddddddddpppdpp   dpddddddpdp  pggppgghhggggpppggggg       :::::::::::::::::::::::::   ::::::::::::::: pp  gpdppg       gs  :::::",
        "::::::::::::::::: ppddddddpdppdddpdddddpppddppp   pddddddddd  ppggggggggggggpgggg    g    ::::::::::::::::::::::::  h   ::::::::::::: pp  gpppgg  fj         :::",
        "::::::::::::::::: ppddddppppppppddppdddddppddddd   pdddddp     ghgffgg    ggggg   ::     ::::::::::::::::::::::::::   g  ::::::::::::  pp  ggggg  ff   ppp     :",
        "   :::::::::::::: ppppppppppppppppdpdddddpppddddp   ppdd   ::  gphffgg    ggg  :::: gg  ::::::::::::::::::::::::::::     :::::::::::::      gggggggj ::  gpp    ",
        "gp :::::::::::::: ggggppppppppppppppddpdppppppddpp  p    ::::   phggg     jggp :::: pg  :::::::::::::::::::::::::::::::::::::::::::::::::::   ggjpgg ::   pggp  ",
        "    ::::::::::::: ggggpppppgpgppppppgpdpppppppddpdp   d  :::::  phfg      jjpp :::: j    :::::::::::::::::::::::::::::::::::::::::::::::::::  ggppgg  :::       ",
        ": g :::::::::::::  pppggppgpgpggggggppppggppppdddpppddd  :::::  phgg      g ss ::::    j ::::::::::::::::::::::::::::::::::::::::::::::::::::    gjpg   ::::::::",
        ":   ::::::::::::::  ppggppggggggggggppgpggghgppddddpdd  :::::::  pg       g     ::::      :::::::::::::   ::::::::::::::::::::::::::::::::::::::  ppgg   ::    :",
        "   ::::::::::::::::   ppffjjffffffgggfggfffhhhppddpdd  :::::::::    p     gg           jp ::::::::::::: g :::::::::::::::::::::::::::::::::::::::   ggpp    gg  ",
        "g   :::::::::::::::::   ffjjff  ffggffggpfhhmmppddpp  :::::::::::: pg   p  g      gg   pg :::::::::::::   ::::::::::::::::::::::::::::::::::::::::: g  g  gggg g",
        "ggg   :::::::::::::::::         ggffjjjjffhhmhgppp   :::::::::::::    : jg       ppf      :::::::::::::::    ::::::::::::::::::::::::::::::::::::::    gpgggfffg",
        "ggggg  :::::::::::::::::::::::: ggjjfgfjffhhmhgppp ::::::::::::::::::::  gp    pjjpf      :::::::::::::::: j :::::::::::::::::::::::::::::::::::::::::  ggggfgjj",
        "jfffgg    ::::::::::::::::::::: gggfffjffghhp+gggg :::::::::::::::::::::  gpf   jgg         ::::::::::::::   ::::::::::::::::::::::::::::::::::::::::: ghhgpgggg",
        "jjffggggg    :::::::::::::::::: gggggg+jjhhhpggpgg ::::::::::::::::::::::  jf        gj   g       ::::::::::::::::::::::::::::::::::::::::::::::::::: gghhhggggg",
        "jgjfggppffgg  :::::::::::::::::  gggggjjjjjjgppgf  :::::::::::::::::::::::           g g  gggjpfg :::::::::::::::::::::::::::::::::::::::::::::::::: ggghhpgjjjj",
        "jjgjpjjpffggp  ::::::::::::::::: gggggjjjjjjggggg :::::::::::::::::::::::::: gg         ::   gfjgg   ::::::::::::::::::::::::::::::::::::::::::::::: ggghhpgjjjj",
        "jjggjjffffgggg  ::::::::::::::::  gggpfffgggffgg   :::::::::::::::::::::::::  ggg  g  g ::::  fg gpp   ::::::::::::::::::::::::::::::::::::::::::::: ggghhfffffj",
        "jjgjjjjfffgggpp ::::::::::::::::: ggppffpgggffff     ::::::::::::::::::::::::           :::::               ::::::::::::::::::::::::::::::::::::::::  gghhfffjjf",
        "jgjjjjffgggggpp ::::::::::::::::  ggppppgggghhff   g ::::::::::::::::::::::::::::::         ::  g   ::::  g  ::::::::::::::::::::::::::::::::::::::::  ggghhfffj",
        "fggffffpggggpp  :::::::::::::::: pgpppppgggghhff  gg :::::::::::::::::::::::::::::      gggg    gg   ::::  g :::::::::::::::::::::::::::::::::::::::::  gghhfpfj",
        "ffffgggggpggp  ::::::::::::::::  pppppgggppggf   ppf :::::::::::::::::::::::::::       ppppggg  ggg   :::      :::::::::::::::::::::::::::::::::::::::: ggggmmgg",
        "pffpggggppgg  :::::::::::::::::  dpppppgppgggf   ffp ::::::::::::::::::::::::::       pppppppgggggg   ::        :::::::::::::::::::::::::::::::::::::::   ggmmgg",
        "ggggggpppggg ::::::::::::::::::   ddpppppppggf   gg  ::::::::::::::::::::::::       ppdddddpppggffg       p     :::::::::::::::::::::::::::::::::::::::::  gppdd",
        "gggggpppgggg :::::::::::::::::::  ddpppdppgggf  pp  :::::::::::::::::::::::::    pppppdddddddppgffg             ::::::::::::::::::::::::::::::::::::::::::  ppdd",
        "pgggppfffff  :::::::::::::::::::   ddpdddpppgg    :::::::::::::::::::::::::::   ppddddddddpddddpgfff    ::      ::::::::::::::::::::::::::::::::::::::::::: gghp",
        "ppggppfgff  :::::::::::::::::::::  dpppdddpgg  :::::::::::::::::::::::::::::::  ppdddddpddddddppppfff  :::      ::::::::::::::::::::::::::::::::::::::::::: ghhh",
        "pppgpfffp  ::::::::::::::::::::::   ppppppggf  ::::::::::::::::::::::::::::::    gpddddddddpddppppppgg :::      ::::::::::::::::::::::::::::::::::::::::::: phmh",
        "pppppfff   :::::::::::::::::::::::   pppppgg  :::::::::::::::::::::::::::::::::   ppddpdddddddppppppgg ::::     ::::::::::::::::::::::::::::::::::::::::::: ppmh",
        "pppppggg   :::::::::::::::::::::::   ggg      ::::::::::::::::::::::::::::::::::  gpddddppppppppppggg  ::::     ::::::::::::::::::::::::::::::::::::::::::: ghmh",
        "ppppgggf   ::::::::::::::::::::::::      ::::::::::::::::::::::::::::::::::::::: ggpppddpppppgppppgg  ::::::    ::::::::::::::::::::::::::::::::::::::::::: ghmh",
        "ppggggg   :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: gppgg      ggggggg  ::::::     ::::::::::::::::::::::::::::::::::::::::::: phhg",
        "ppgggg    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::             gg gg  ::::::   gh  :::::::::::::::::::::::::::::::::::::::::  phgg",
        "ppggg     ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::     :::::       ::::       gg   ::::::::::::::::::::::::::::::::::::::  phmpd",
        "ppgggg    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  ff :::        gg       ::::::::::::::::::::::::::::::::::  phmdd",
        "ppgg     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: gg :::     ph p           :::::::::::::::::::::::::::::::  pggpp",
        "ppg     :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::    ::::   php              :::::::::::::::::::::::::::::  ppggpp",
        "gg     ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  pgg               :::::::::::::::::::::::::::::  ggpppp",
        "g     ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ppg             :::::::::::::::::::::::::::::::::  gpppp",
        "      :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::             ::::::::::::::::::::::::::::::::::::: ggppg ",
        "     ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::          :::::::::::::::::::::::::::::::::::::::: gpppgg",
        "     ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::       ::::::::::::::::::::::::::::::::::::::::::: ppgpp ",
        "  g ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   :::::::::::::::::::::::::::::::::::::::::::::: pppp  ",
        "    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  pppf ",
        "  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::   pf ",
        "   :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::    ",
        "   ::::    ::    ::::    ::            ::::::::    ::::    ::::::    ::::        ::::::      ::      ::        ::::::::::::::    ::::::::      ::::::::         ",
        "aa      aa    aa      aa    aaaaaaaaaa          aa      aa        aa      aaaaaa        aaaa    aaaa    aa  aa                aa          aaaa          aaaaaa  ",
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    };
    std::string string;
    char charactor;
    int tile_x;
    int tile_y;
    tile_y = 0;
    tile_x = 0;
    for (std::string string : premap)
    {
        tile_x = 0;
        ++tile_y;
        //std::cout << "new Y row" << std::endl;
        for (char charactor : string)
        {
            --tile_x;
            //std::cout << "new X row" << std::endl;
            tuple<int, int, int> tile;
            int tile_type;
            //std::cout << string << std::endl;
            if (charactor == 'a')
            {
                tile_type = 9;
            }
            else if (charactor == ' ')
            {
                tile_type = 5;
            }
            else if (charactor == ':')
            {
                tile_type = 6;
            }
            else if (charactor == '+')
            {
                tile_type = 4;
            }
            else if (charactor == 'd')
            {
                tile_type = 1;
            }
            else if (charactor == 'f')
            {
                tile_type = 2;
            }
            else if (charactor == 'g')
            {
                tile_type = 0;
            }
            else if (charactor == 'h')
            {
                tile_type = 2;
            }
            else if (charactor == 'j')
            {
                tile_type = 2;
            }
            else if (charactor == 'm')
            {
                tile_type = 3;
            }
            else if (charactor == 'p')
            {
                tile_type = 7;
            }
            else if (charactor == 's')
            {
                tile_type = 0;
            }
            else if (charactor == 't')
            {
                tile_type = 8;
            }
            tile = make_tuple(tile_x, tile_y, tile_type);
            map.push_back(tile);

        }
    }
    return map;
}

class MyEventReceiver : public IEventReceiver
{
public:
    MyEventReceiver(SAppContext& context) : Context(context)
    {
        for (u32 i = 0; i < KEY_KEY_CODES_COUNT; ++i)
            KeyIsDown[i] = false;
    }

    virtual bool OnEvent(const SEvent& event)
    {
        if (event.EventType == EET_GUI_EVENT)
        {
            s32 id = event.GUIEvent.Caller->getID();
            IGUIEnvironment* env = Context.device->getGUIEnvironment();
            ISceneManager* smgr = Context.device->getSceneManager();
            IVideoDriver* driver = Context.device->getVideoDriver();

            switch (event.GUIEvent.EventType)
            {
            case EGET_BUTTON_CLICKED:
                switch (id)
                {
                case GUI_ID_QUIT_BUTTON:
                    Context.device->closeDevice();
                    return true;

                case GUI_ID_NEW_GAME_BUTTON:
                {
                    view_window = 1;
                    env->clear();
                    env->addButton(rect<s32>(550, 550, 750, 550 + 32), 0, GUI_ID_LAUNCH_BUTTON,
                        L"Launch!", L"Launch a new game");
                    env->addButton(rect<s32>(300, 550, 500, 550 + 32), 0, GUI_ID_MENU_BUTTON,
                        L"Back", L"Back to main menu");
                }
                return true;

                case GUI_ID_SETTINGS_SAVE_BUTTON:
                {
                    IrrlichtDevice* NullDevice = createDevice(irr::video::EDT_NULL);
                    irr::io::IXMLWriter* xwriter = NullDevice->getFileSystem()->createXMLWriter("client/settings.xml");
                    if (!xwriter)
                        return false;
                    xwriter->writeXMLHeader();
                    xwriter->writeElement(L"client");
                    xwriter->writeLineBreak();
                    xwriter->writeElement(L"video");
                    xwriter->writeLineBreak();
                    if (Context.ListboxDriver->getSelected() == 0)
                    {
                        xwriter->writeElement(L"setting", false, L"driver", L"Software");
                        xwriter->writeLineBreak();
                    }
                    if (Context.ListboxDriver->getSelected() == 1)
                    {
                        xwriter->writeElement(L"setting", false, L"driver", L"OpenGL");
                        xwriter->writeLineBreak();
                    }
                    if (Context.ListboxDriver->getSelected() == 2)
                    {
                        xwriter->writeElement(L"setting", false, L"driver", L"DirectX9");
                        xwriter->writeLineBreak();
                    }
                    if (Context.ListboxDriver->getSelected() == 3)
                    {
                        xwriter->writeElement(L"setting", false, L"driver", L"BurningsVideo");
                        xwriter->writeLineBreak();
                    }
                    xwriter->writeLineBreak();
                    xwriter->writeClosingTag(L"video");
                    xwriter->writeLineBreak();
                    xwriter->writeClosingTag(L"client");
                    xwriter->drop();
                    return true;
                }

                case GUI_ID_MENU_BUTTON:
                {
                    view_window = 0;
                    env->clear();
                    env->addButton(rect<s32>(150, 400, 350, 400 + 32), 0, GUI_ID_NEW_GAME_BUTTON,
                        L"New Game", L"Launch a new game");
                    env->addButton(rect<s32>(150, 440, 350, 440 + 32), 0, GUI_ID_LOAD_GAME_BUTTON,
                        L"Load Game", L"Load a saved game");
                    env->addButton(rect<s32>(150, 480, 350, 480 + 32), 0, GUI_ID_LOAD_SCENARIO_BUTTON,
                        L"Load Scenario", L"Loads a prebuilt map");
                    env->addButton(rect<s32>(450, 400, 650, 400 + 32), 0, GUI_ID_NET_GAME_BUTTON,
                        L"Network Game", L"Join a network game");
                    env->addButton(rect<s32>(450, 440, 650, 440 + 32), 0, GUI_ID_SETTINGS_BUTTON,
                        L"Settings", L"Client Settings");
                    env->addButton(rect<s32>(450, 480, 650, 480 + 32), 0, GUI_ID_QUIT_BUTTON,
                        L"Exit", L"Quit");
                    smgr->clear();
                    ICameraSceneNode* camera = 0;
                    camera = smgr->addCameraSceneNode(0, core::vector3df(0, 0, 50),
                        core::vector3df(0, 0, 0));
                    // create test earth
                    ISceneNode* earth = 0;
                    IAnimatedMesh* earthMesh = smgr->getMesh("client/earth.x");
                    if (earthMesh)
                    {
                        //perform various task with the mesh manipulator
                        scene::IMeshManipulator* manipulator = smgr->getMeshManipulator();

                        // create mesh copy with tangent informations from original earth.x mesh
                        scene::IMesh* tangentSphereMesh =
                            manipulator->createMeshWithTangents(earthMesh->getMesh(0));

                        // scale the mesh by factor 10
                        core::matrix4 m;
                        m.setScale(core::vector3df(20, 20, 20));
                        manipulator->transform(tangentSphereMesh, m);

                        earth = smgr->addMeshSceneNode(tangentSphereMesh);
                        earth->setPosition(core::vector3df(0, 0, 0));

                        earth->setMaterialTexture(0,
                            driver->getTexture("client/earth_intro.jpg"));

                        // load heightmap, create normal map from it and set it
                        /*video::ITexture* earthNormalMap = driver->getTexture("client/earthbump.jpg");
                        if (earthNormalMap)
                        {
                            driver->makeNormalMapTexture(earthNormalMap, 20.0f);
                            earth->setMaterialTexture(1, earthNormalMap);
                            earth->setMaterialType(video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA);
                        }
                        if you want a texured earth, uncomment this code.
                        */

                        // adjust material settings
                        earth->setMaterialFlag(video::EMF_FOG_ENABLE, true);

                        // add rotation animator
                        scene::ISceneNodeAnimator* anim =
                            smgr->createRotationAnimator(core::vector3df(0, 0.1f, 0));
                        earth->addAnimator(anim);
                        anim->drop();

                        // drop mesh because we created it with a create.. call.
                        tangentSphereMesh->drop();
                    }

                    // add white light
                    smgr->addLightSceneNode(0, core::vector3df(-50, 0, 25),
                        video::SColorf(1.0f, 1.0f, 1.0f));

                    // set ambient light
                    smgr->setAmbientLight(video::SColor(0, 100, 100, 100));
                }
                return true;

                case GUI_ID_LOAD_SCENARIO_BUTTON:
                {
                    // There are some options for the file open dialog
                    // We set the title, make it a modal window, and make sure
                    // that the working directory is restored after the dialog
                    // is finished.
                    env->addFileOpenDialog(L"Please choose a scenario map.", true, 0, -1, true);
                    return true;
                }

                case GUI_ID_NET_GAME_BUTTON:
                {
                    Context.counter += 30;
                    if (Context.counter > 200)
                        Context.counter = 0;

                    IGUIWindow* window = env->addWindow(
                        rect<s32>(100 + Context.counter, 100 + Context.counter, 350 + Context.counter, 200 + Context.counter),
                        false, // modal?
                        L"Network Game");

                    env->addStaticText(L"This Feature doesn't work yet .Please close me",
                        rect<s32>(20, 35, 230, 50),
                        true, // border?
                        false, // wordwrap?
                        window);

                }
                return true;

                case GUI_ID_SETTINGS_BUTTON:
                {
                    Context.counter += 30;
                    if (Context.counter > 200)
                        Context.counter = 0;

                    IGUIWindow* window = env->addWindow(
                        rect<s32>(100 + Context.counter, 100 + Context.counter, 350 + Context.counter, 400 + Context.counter),
                        false, // modal?
                        L"Client Settings");

                    env->addStaticText(L"Please select a driver",
                        rect<s32>(20, 35, 230, 50),
                        true, // border?
                        false, // wordwrap?
                        window);

                    Context.ListboxDriver = env->addListBox(rect<s32>(20, 60, 230, 180), window, GUI_ID_DRIVER_BOX, true);

                    //add all available options to the driver choice listbox
                    Context.ListboxDriver->addItem(L"Software");
                    Context.ListboxDriver->addItem(L"OpenGL");
                    Context.ListboxDriver->addItem(L"Directx 9");
                    Context.ListboxDriver->addItem(L"BurningsVideo");

                    env->addButton(rect<s32>(20, 200, 230, 200 + 32), window, GUI_ID_SETTINGS_SAVE_BUTTON,
                        L"Save", L"Save Settings");
                }
                return true;

                case GUI_ID_LOAD_GAME_BUTTON:
                {
                    //Context.listbox->addItem(L"Load Game");
                    // There are some options for the file open dialog
                    // We set the title, make it a modal window, and make sure
                    // that the working directory is restored after the dialog
                    // is finished.
                    env->addFileOpenDialog(L"Please choose a save file.", true, 0, -1, true);
                    return true;
                }

                case GUI_ID_LAUNCH_BUTTON:
                {
                    view_window = 2;
                    env->clear();
                    env->addButton(rect<s32>(550, 550, 750, 550 + 32), 0, GUI_ID_MENU_BUTTON,
                        L"Back", L"Back to main menu");
                    smgr->clear();
                    ICameraSceneNode* camera = smgr->addCameraSceneNode(0, core::vector3df(17, 10, 17),
                        core::vector3df(17, 0, 12.5));
                    std::list<tuple <int, int, int>> game_map;
                    game_map = map_gen();
                    for(auto tile : game_map)//tuple<int, int, int> tile = game_map.begin(); tile != game_map.end(); ++tile)
                    {
                        if (get<2>(tile) == 0)
                        {
                                IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/flat/flat.obj");
                                if (!earthMesh)
                                {
                                    Context.device->drop();
                                    return 1;
                                }
                                IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                                int x = get<0>(tile);
                                int y = get<1>(tile);
                                earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                                earth->setScale(vector3df(0.5, 0.5, 0.5));
                                earth->setMaterialTexture(0, driver->getTexture("art/terrain/flat/flat.png"));
                                earth->setMaterialFlag(video::EMF_LIGHTING, false);
                                //std::cout << "placed tile type flatland" << std::endl;
                        }
                        if (get<2>(tile) == 1)
                        {
                                IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/flat/flat.obj");
                                if (!earthMesh)
                                {
                                    Context.device->drop();
                                    return 1;
                                }
                                IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                                earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                                earth->setScale(vector3df(0.5, 0.5, 0.5));
                                earth->setMaterialTexture(0, driver->getTexture("art/terrain/flat/dunes.png"));
                                earth->setMaterialFlag(video::EMF_LIGHTING, false);
                                //std::cout << "placed tile type dunes" << std::endl;
                        }
                        if (get<2>(tile) == 2)
                        {
                                IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/hill/hill.obj");
                                if (!earthMesh)
                                {
                                    Context.device->drop();
                                    return 1;
                                }
                                IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                                earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                                earth->setScale(vector3df(0.5, 0.5, 0.5));
                                earth->setMaterialTexture(0, driver->getTexture("art/terrain/hill/hill.png"));
                                earth->setMaterialFlag(video::EMF_LIGHTING, false);
                                //std::cout << "placed tile type hill" << std::endl;
                        }
                        if (get<2>(tile) == 3)
                        {
                                IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/mountain/mountain.obj");
                                if (!earthMesh)
                                {
                                    Context.device->drop();
                                    return 1;
                                }
                                IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                                earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                                earth->setScale(vector3df(0.5, 0.5, 0.5));
                                earth->setMaterialTexture(0, driver->getTexture("art/terrain/mountain/mountain.png"));
                                earth->setMaterialFlag(video::EMF_LIGHTING, false);
                                //std::cout << "placed tile type mountain" << std::endl;
                        }
                        if (get<2>(tile) == 4)
                        {
                                IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/water/water.obj");
                                if (!earthMesh)
                                {
                                    Context.device->drop();
                                    return 1;
                                }
                                IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                                earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                                earth->setScale(vector3df(0.5, 0.5, 0.5));
                                earth->setMaterialTexture(0, driver->getTexture("art/terrain/water/water.png"));
                                earth->setMaterialFlag(video::EMF_LIGHTING, false);
                                //std::cout << "placed tile type water" << std::endl;
                        }
                        if (get<2>(tile) == 5)
                        {
                            IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/water/water.obj");
                            if (!earthMesh)
                            {
                                Context.device->drop();
                                return 1;
                            }
                            IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                            earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                            earth->setScale(vector3df(0.5, 0.5, 0.5));
                            earth->setMaterialTexture(0, driver->getTexture("art/terrain/water/ocean.png"));
                            earth->setMaterialFlag(video::EMF_LIGHTING, false);
                            //std::cout << "placed tile type ocean" << std::endl;
                        }
                        if (get<2>(tile) == 6)
                        {
                            IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/water/water.obj");
                            if (!earthMesh)
                            {
                                Context.device->drop();
                                return 1;
                            }
                            IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                            earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                            earth->setScale(vector3df(0.5, 0.5, 0.5));
                            earth->setMaterialTexture(0, driver->getTexture("art/terrain/water/deep_ocean.png"));
                            earth->setMaterialFlag(video::EMF_LIGHTING, false);
                            //std::cout << "placed tile type deep ocean" << std::endl;
                        }
                        if (get<2>(tile) == 7)
                        {
                            IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/flat/flat.obj");
                            if (!earthMesh)
                            {
                                Context.device->drop();
                                return 1;
                            }
                            IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                            earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                            earth->setScale(vector3df(0.5, 0.5, 0.5));
                            earth->setMaterialTexture(0, driver->getTexture("art/terrain/flat/plains.png"));
                            earth->setMaterialFlag(video::EMF_LIGHTING, false);
                            //std::cout << "placed tile type plains" << std::endl;
                        }
                        if (get<2>(tile) == 8)
                        {
                            IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/flat/flat.obj");
                            if (!earthMesh)
                            {
                                Context.device->drop();
                                return 1;
                            }
                            IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                            earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                            earth->setScale(vector3df(0.5, 0.5, 0.5));
                            earth->setMaterialTexture(0, driver->getTexture("art/terrain/flat/tundra.png"));
                            earth->setMaterialFlag(video::EMF_LIGHTING, false);
                            //std::cout << "placed tile type tundra" << std::endl;
                        }
                        if (get<2>(tile) == 9)
                        {
                            IAnimatedMesh* earthMesh = smgr->getMesh("art/terrain/flat/flat.obj");
                            if (!earthMesh)
                            {
                                Context.device->drop();
                                return 1;
                            }
                            IAnimatedMeshSceneNode* earth = smgr->addAnimatedMeshSceneNode(earthMesh);
                            earth->setPosition(core::vector3df(get<0>(tile), 0, get<1>(tile)));
                            earth->setScale(vector3df(0.5, 0.5, 0.5));
                            earth->setMaterialTexture(0, driver->getTexture("art/terrain/flat/ice.png"));
                            earth->setMaterialFlag(video::EMF_LIGHTING, false);
                            //std::cout << "placed tile type tundra" << std::endl;
                        }
                    }
                    //Sleep(10000);
                    return true;
                }


                default:
                    return false;
                
                }
                break;

            case EGET_FILE_SELECTED:
            {
                view_window = 1;
                env->clear();
                env->addButton(rect<s32>(550, 550, 750, 550 + 32), 0, GUI_ID_LAUNCH_BUTTON,
                    L"Launch!", L"Launch a new game");
                env->addButton(rect<s32>(300, 550, 500, 550 + 32), 0, GUI_ID_MENU_BUTTON,
                    L"Back", L"Back to main menu");
                // show the model filename, selected in the file dialog
                //IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller;
            }
            break;

            default:
                break;
            }
        }
        // Remember whether each key is down or up
        if (event.EventType == irr::EET_KEY_INPUT_EVENT)
            KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;

        return false;
    }

    // This is used to check whether a key is being held down
    virtual bool IsKeyDown(EKEY_CODE keyCode) const
    {
        return KeyIsDown[keyCode];
    }
    
private:
    SAppContext& Context;
    // We use this array to store the current state of each key
    bool KeyIsDown[KEY_KEY_CODES_COUNT];
};

int main()
{
    video::E_DRIVER_TYPE driverType = driverChoiceConsole();
    if (driverType == video::EDT_COUNT)
        return 1;

    // create device

    IrrlichtDevice* device = createDevice(driverType,
        core::dimension2d<u32>(800, 600), 64, false, false, true);

    if (device == 0)
        return 1; // could not create selected driver.

    device->setWindowCaption(L"Irrlicht Engine - Freeciv Client Test");
    //set up enviroment
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* env = device->getGUIEnvironment();
    //load images
    ITexture* bg = driver->getTexture("client/bg.png");
    ITexture* intro = 0;//driver->getTexture("client/intro.png");
    intro = driver->addRenderTargetTexture(core::dimension2d<u32>(510, 300), "IntroRT");
    //set up map rendering
    ITexture* map = 0;
    ICameraSceneNode* camera = 0;
    map = driver->addRenderTargetTexture(core::dimension2d<u32>(700, 400), "RTT1");
    camera = smgr->addCameraSceneNode(0, core::vector3df(0, 0, 50),
        core::vector3df(0, 0, 0));
    //set up fonts
    gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
    gui::IGUIFont* font2 =
        device->getGUIEnvironment()->getFont("client/fonthaettenschweiler.bmp");
    IGUISkin* skin = env->getSkin();
    if (font2)
        skin->setFont(font);
    //set up the main menu buttons
    env->addButton(rect<s32>(150, 400, 350, 400 + 32), 0, GUI_ID_NEW_GAME_BUTTON,
        L"New Game", L"Launch a new game");
    env->addButton(rect<s32>(150, 440, 350, 440 + 32), 0, GUI_ID_LOAD_GAME_BUTTON,
        L"Load Game", L"Load a saved game");
    env->addButton(rect<s32>(150, 480, 350, 480 + 32), 0, GUI_ID_LOAD_SCENARIO_BUTTON,
        L"Load Scenario", L"Loads a prebuilt map");
    env->addButton(rect<s32>(450, 400, 650, 400 + 32), 0, GUI_ID_NET_GAME_BUTTON,
        L"Network Game", L"Join a network game");
    env->addButton(rect<s32>(450, 440, 650, 440 + 32), 0, GUI_ID_SETTINGS_BUTTON,
        L"Settings", L"Client Settings");
    env->addButton(rect<s32>(450, 480, 650, 480 + 32), 0, GUI_ID_QUIT_BUTTON,
        L"Exit", L"Quit");

    // Store the appropriate data in a context structure.
    SAppContext context;
    context.device = device;
    context.counter = 0;

    int lastFPS = 0;

    // Then create the event receiver, giving it that context structure.
    MyEventReceiver receiver(context);

    // And tell the device to use our custom event receiver.
    device->setEventReceiver(&receiver);

    // create test earth
    ISceneNode* earth = 0;
    IAnimatedMesh* earthMesh = smgr->getMesh("client/earth.x");
    if (earthMesh)
    {
        //perform various task with the mesh manipulator
        scene::IMeshManipulator* manipulator = smgr->getMeshManipulator();

        // create mesh copy with tangent informations from original earth.x mesh
        scene::IMesh* tangentSphereMesh =
            manipulator->createMeshWithTangents(earthMesh->getMesh(0));

        // scale the mesh by factor 10
        core::matrix4 m;
        m.setScale(core::vector3df(20, 20, 20));
        manipulator->transform(tangentSphereMesh, m);

        earth = smgr->addMeshSceneNode(tangentSphereMesh);
        earth->setPosition(core::vector3df(0, 0, 0));

        earth->setMaterialTexture(0,
            driver->getTexture("client/earth_intro.jpg"));

        // load heightmap, create normal map from it and set it
        /*video::ITexture* earthNormalMap = driver->getTexture("client/earthbump.jpg");
        if (earthNormalMap)
        {
            driver->makeNormalMapTexture(earthNormalMap, 20.0f);
            earth->setMaterialTexture(1, earthNormalMap);
            earth->setMaterialType(video::EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA);
        }
        if you want a texured earth, uncomment this code.
        */

        // adjust material settings
        earth->setMaterialFlag(video::EMF_FOG_ENABLE, true);

        // add rotation animator
        scene::ISceneNodeAnimator* anim =
            smgr->createRotationAnimator(core::vector3df(0, 0.1f, 0));
        earth->addAnimator(anim);
        anim->drop();

        // drop mesh because we created it with a create.. call.
        tangentSphereMesh->drop();
    }

    // add white light
    smgr->addLightSceneNode(0, core::vector3df(-50, 0, 25),
        video::SColorf(1.0f, 1.0f, 1.0f));

    // set ambient light
    smgr->setAmbientLight(video::SColor(0, 100, 100, 100));

    //set up video quality settings
    driver->getMaterial2D().TextureLayer[0].BilinearFilter = true;
    driver->getMaterial2D().AntiAliasing = video::EAAM_FULL_BASIC;
    //set up control settings
    const f32 MOVEMENT_SPEED = 5.f;
    u32 then = device->getTimer()->getTime();

    while (device->run() && driver)
    {
        if (device->isWindowActive())
        {
            u32 time = device->getTimer()->getTime();

            driver->beginScene(true, true, video::SColor(255, 0, 0, 0));
            // draw background
            driver->draw2DImage(bg, core::position2d<s32>(0, 0));
            if (view_window == 0)
            {
                // draw intro image
                //driver->draw2DImage(intro, core::position2d<s32>(145, 50));
                //overwrite intro image with rendered earth
                //set up camera
                driver->setRenderTarget(intro, true, true, SColor(0, 0, 0, 0));
                smgr->setActiveCamera(camera);
                smgr->drawAll();
                driver->setRenderTarget(0, true, true, 0);
                // draw background and map
                driver->draw2DImage(bg, core::position2d<s32>(0, 0));
                driver->draw2DImage(intro, core::position2d<s32>(145, 50));
                //draw buttons
                env->drawAll();

                // draw some other text
                if (font2)
                    font2->draw(L"Welcome to the experimental Irrlicht engine 3D client for freeciv.",
                        core::rect<s32>(250, 20, 650, 80),
                        video::SColor(255, 0, 0, 0));


            }
            if (view_window == 1)
            {
                // draw background and splash
                driver->draw2DImage(bg, core::position2d<s32>(0, 0));
                //draw buttons
                env->drawAll();

                // draw some other text
                if (font2)
                    font2->draw(L"This is the new game page.",
                        core::rect<s32>(20, 20, 650, 80),
                        video::SColor(255, 0, 0, 0));

            }
            if (view_window == 2)
            {
                // Work out a frame delta time.
                const u32 now = device->getTimer()->getTime();
                const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
                then = now;
                core::vector3df nodePosition = camera->getPosition();
                core::vector3df nodeLookat = camera->getTarget();

                if (receiver.IsKeyDown(irr::KEY_SUBTRACT))
                    nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime;
                else if (receiver.IsKeyDown(irr::KEY_ADD))
                    nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime;

                if (receiver.IsKeyDown(irr::KEY_LEFT))
                {
                    nodePosition.X += MOVEMENT_SPEED * frameDeltaTime;
                    nodeLookat.X += MOVEMENT_SPEED * frameDeltaTime;
                }
                else if (receiver.IsKeyDown(irr::KEY_RIGHT))
                {
                    nodePosition.X -= MOVEMENT_SPEED * frameDeltaTime;
                    nodeLookat.X -= MOVEMENT_SPEED * frameDeltaTime;
                }


                if (receiver.IsKeyDown(irr::KEY_UP))
                {
                    nodePosition.Z -= MOVEMENT_SPEED * frameDeltaTime;
                    nodeLookat.Z -= MOVEMENT_SPEED * frameDeltaTime;
                }
                else if (receiver.IsKeyDown(irr::KEY_DOWN))
                {
                    nodePosition.Z += MOVEMENT_SPEED * frameDeltaTime;
                    nodeLookat.Z += MOVEMENT_SPEED * frameDeltaTime;
                }

                camera->setPosition(nodePosition);
                camera->setTarget(nodeLookat);
                //render map
                //set up camera
                driver->setRenderTarget(map, true, true, SColor(0, 0, 0, 0));
                smgr->setActiveCamera(camera);
                smgr->drawAll();
                driver->setRenderTarget(0, true, true, 0);
                // draw background and map
                driver->draw2DImage(bg, core::position2d<s32>(0, 0));
                driver->draw2DImage(map, core::position2d<s32>(50, 50));
                //draw buttons
                env->drawAll();

                // draw some other text
                if (font2)
                    font2->draw(L"This is the game page.",
                        core::rect<s32>(20, 20, 650, 80),
                        video::SColor(255, 0, 0, 0));
                int fps = driver->getFPS();

                if (lastFPS != fps)
                {
                    core::stringw str = L"Irrlicht Engine - Freeciv Client Test [";
                    str += driver->getName();
                    str += "] FPS:";
                    str += fps;

                    device->setWindowCaption(str.c_str());
                    lastFPS = fps;
                }

            }
            driver->endScene();
        }
    }

    device->drop();

    return 0;
}
Attachments
IrrCliCapture12.PNG
IrrCliCapture12.PNG (674.15 KiB) Viewed 6366 times
IrrCliCapture11.PNG
IrrCliCapture11.PNG (636.28 KiB) Viewed 6366 times
IrrCliCapture10.PNG
IrrCliCapture10.PNG (682.25 KiB) Viewed 6366 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Did some more work on the test client. Major changes are added 3D forest and jungle, changed textures to trident tiles, and added directional tile textures.
Note: The tool I use for making the screenshots seems to slow the rendering a lot. On my computer it runs between 15-20 fps.
Attachments
IrrCliCapture15.PNG
IrrCliCapture15.PNG (817.19 KiB) Viewed 6286 times
IrrCliCapture14.PNG
IrrCliCapture14.PNG (879.14 KiB) Viewed 6286 times
IrrCliCapture13.PNG
IrrCliCapture13.PNG (874.21 KiB) Viewed 6286 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
User avatar
Corbeau
Elite
Posts: 1291
Joined: Mon Jan 13, 2014 11:13 pm

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Corbeau »

Any general infor about this? How to play, does it support multoplayer...?
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Unfortunately, it is just a demo of some of the features needed for a 3D client, though I am working to progress it beyond that point. To work with it yourself, you will have to compile it from source. It should compile in an environment set up to compile Irrlicht demos.
The code, models, and textures of the latest version are attached below. Most textures are from trident.
Attachments
v0.9.txt
(74.3 KiB) Downloaded 186 times
art.zip
(933.7 KiB) Downloaded 160 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Changed it so it uses ray tracing to get the tile the cursor is over.
Attachments
IrrCliCapture16.PNG
IrrCliCapture16.PNG (871.39 KiB) Viewed 6177 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

A bit more work on this: it is much faster now, as I optimized it to reduce draw calls/cpu time. I have not reimplemented the cursor hover tile tracer yet, but otherwise it should have all the features of the previous version
Attachments
v1.7Demo.zip
(660.8 KiB) Downloaded 143 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Source for the version with ray tracing cursor hover
Attachments
Main.cpp
(77.75 KiB) Downloaded 113 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

I am using Visual Studio on Windows 10 for a development environment. On Linux with GCC the resulting binaries give segmentation faults.
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Irrlicht (Cross platform 3d game engine) Client

Post by Elefant »

Latest version. Raytracing cursor location reimplemented, as well as map wrapping beyond just the three duplicates in previous versions.
Attachments
Main.cpp
(77.06 KiB) Downloaded 140 times
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Post Reply