lundi 20 juillet 2015

It's my first question on Stack Exchange, so correct me if I done something wrong with writing this question.

Basically I'm trying to make random level generator that uses mersenne twister. Here's the code (it's just begginig, so it doesn't make much sense):

Generator.h:

//Level generator

#pragma once

class GameMap
{
public:


    static int bgmap[256][256];
    static int fg1map[256][256];
    static int fg2map[256][256];
    static int genposx, genposy, width, height;


    static std::mt19937 twister(int);
    static std::uniform_int_distribution<int> dist1(int, int);
    static std::uniform_int_distribution<int> dist2(int, int);
    static std::random_device rd;
    void Generate(int sizex, int sizey, int seed);

    GameMap();
    ~GameMap();
};

Generator.cpp:

//#include <SFML/Graphics.hpp>
#include <random>
#include "Generator.h"

GameMap::GameMap()
{
    dist1(1, 8);
    dist2(1, 248);
}


void GameMap::Generate(int sizex, int sizey, int seed = rd())
{
    twister(seed);

    genposx = 1;
    genposy = 1;

    do
    {
        genposx = dist2(twister);
        genposy = dist2(twister);
        width = dist1(twister);
        height = dist1(twister);

    } while (whatever);
}

The problem is that I can't convert uniform_int_distrubution to int. I get Intellisense error messages:

no suitable conversion from unifgorm_int_distribution<int>" to "int" exists

argument of type "std::mt19937 (*)(int)" is incompatible with parameter of type "int"

too few arguments in function call

All of those are on these lines:

genposx = dist2(twister);
genposy = dist2(twister);
width = dist1(twister);
height = dist1(twister);

I've lost many hours by searching in web an answer, but I couldn't find anything. Please help.




Aucun commentaire:

Enregistrer un commentaire