Jump to content
  • Advertisement

ICanC

Member
  • Content Count

    35
  • Joined

  • Last visited

Community Reputation

147 Neutral

About ICanC

  • Rank
    Member

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm using enums for the first time to and I'm wondering how best to use them for classes. At the moment I'm encapsulating the meaning within classes (and duplicating for classes that will share it) - but I've run into a problem when assigning a enum type: class mast { enum signal { E, G, H, HPLUS, FOURG }; private: signal capability; signal current_broadcast; bool power{ true }; public: mast(); ~mast() = default; signal getCapability(); signal getBroadcast(); void printCapability(); void printBroadcast(); void setCapability(signal s) {capability = s;} void setBroadcast(signal s) { current_broadcast = s; } bool getPower() { return power; } void setPower(bool b) { power = b; } }; /*====================================================================================*/ class phone { enum signal { E, G, H, HPLUS, FOURG }; private: std::map<std::string,std::string> contacts; std::map<std::string, std::string> messages; signal signal_strength; bool wifi; public: phone(); ~phone() = default; void boot(mast& m); void addContact(std::pair<std::string,std::string>); bool removeContact(std::string); void getContacts() { for (auto& it : contacts) { std::cout << "\nName: " << it.first << "\nNumber: " << it.second << std::endl; for (int i = 0; i < 20; ++i) std::cout << "-"; } } void setSignal(signal s) { signal_strength = s; } void setWifi(bool b) { wifi = b; } bool getWifi() { return wifi; } void searchWifi() {}; }; //========================================================================================== Are my 2 classes, however in the phone constructor (see error line below) I get the following errors : error C3867: 'mast::getBroadcast': non-standard syntax; use '&' to create a pointer to member error C2440: '=': cannot convert from 'mast::signal (__thiscall mast::* )(void)' to 'phone::signal' #include "phone.h" #include "mast.h" #include "rand_eng.h" phone::phone() { wifi = false; } void phone::boot(mast& m) { signal_strength = m.getBroadcast; // THIS FLAGS ERROR } void phone::addContact(std::pair<std::string, std::string> entry) { contacts.insert(entry); } bool phone::removeContact(std::string entry) { std::map<std::string, std::string>::iterator it; it = contacts.find(entry); if (it != contacts.end()) { contacts.erase(it); return true; } return false; } Any by the way the code for mast::getBroadcast is: mast::signal mast::getBroadcast() { return current_broadcast; } I've also tried putting the enum definition outside of the classes but it still says error C2440: '=': cannot convert from 'signal (__thiscall mast::* )(void)' to 'signal'
  2. ICanC

    blackjack game

    I'm a complete amateur but just in case you know less than I do, here is some example code from a text based blackjack I attempted to make which may give you some ideas: class blackjack { private: std::vector<card> deck; int minBet; int maxBet; int decks; public: blackjack(int minBet, int maxBet, int decks); ~blackjack() {}; void shuffle(); void reshuffle(); int getValue(std::vector<card> hand) const; card deal(); void play(std::shared_ptr<player> p); bool check_for_blackjack(std::vector<card> hand); bool bust(std::vector<card> hand); }; blackjack::blackjack(int minBet, int maxBet, int decks) { this->minBet = minBet; this->maxBet = maxBet; this->decks = decks; this->reshuffle(); } void blackjack::shuffle() { static std::random_device rd; std::shuffle(this->deck.begin(), this->deck.end(), std::mt19937(rd())); } void blackjack::reshuffle() { this->deck.clear(); for (int i = 1; i < 14; ++i) { for (int j = 1; j < 5; ++j) { if (i == 1) { card c1("Ace", i, j); this->deck.push_back(c1); } else if (i == 11) { card c1("Jack", i - 1, j); this->deck.push_back(c1); } else if (i == 12) { card c1("Queen", i - 2, j); this->deck.push_back(c1); } else if (i == 13) { card c1("King", i - 3, j); this->deck.push_back(c1); } else { card c1(std::to_string(i), i, j); this->deck.push_back(c1); } } } } card blackjack::deal() { card dealCard = this->deck[this->deck.size() - 1]; this->deck.pop_back(); return dealCard; } int blackjack::getValue(std::vector<card> hand) const { int value = 0; for (card &c : hand) { value += c.value; } return value; } bool blackjack::check_for_blackjack(std::vector<card> hand) { int value = 0; for (auto &i : hand) { value += i.value; } if (value == 21) { return true; } else return false; } bool blackjack::bust(std::vector<card> hand) { int value = 0; for (auto &i : hand) { value += i.value; } if (value > 21) { return true; } else return false; } /*-------------------------------------------------------------------------------------------------------*/ class card { public: std::string name; int value; int suit; card(std::string name, int value, int suit); card() {}; ~card() {}; std::string getSuit() const; void display() const; }; card::card(std::string name, int value, int suit) { this->name = name; this->value = value; this->suit = suit; } void card::display() const { print(this->name); if (suit == 1) { print(" of Hearts\n"); } if (suit == 2) { print(" of Diamonds\n"); } if (suit == 3) { print(" of Clubs\n"); } if (suit == 4) { print(" of Spades\n"); } } std::string card::getSuit() const { if (this->suit == 1) { return "Hearts"; } if (this->suit == 2) { return "Diamonds"; } if (this->suit == 3) { return "Clubs"; } if (this->suit == 4) { return "Spades"; } else return "Something went wrong"; }
  3. the stock class now looks like this, but it generates the same error: #pragma once #include <iostream> #include <iomanip> #include <string> class stock { private: std::pair<std::string,float> company; public: stock(std::string name, float price); ~stock() = default; void display() const { std::cout << company.first << std::endl << std::fixed << std::setprecision(2) << company.second << std::endl; } const float getPrice() { return company.second; } const std::string getName() { return company.first; } bool operator==(stock n) { return this->company.first == n.company.first; } }; stock::stock(std::string name, float price) { company.first = name; company.second = price; }
  4. I've decided to change the code slightly and work with a vector of pairs instead. However now I'm having problems getting std::find to work again, please see the following code: void sell_stock(std::shared_ptr<stock> shares, int quantity) { std::vector<std::pair<stock, int>>::iterator it = std::find(std::begin(investments), std::end(investments), shares->getName()); if (it == std::end(investments)) { std::cout << "\n\nERROR - person.sell_stock tried to sell shares not in portfolio" << std::endl; char exit; std::cin >> exit; } else { investments.erase(it); cash += (shares->getPrice() * quantity); } } }; // ==================================================================================================================================== and the overload in the stock class : bool operator==(std::pair<std::string,float> n) { return this->company.first == n.first; } gives me error: c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3579): error C2678: binary '==': no operator found which takes a left-hand operand of type 'std::pair<stock,int>' (or there is no acceptable conversion) 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\random(2557): note: could be 'bool std::operator ==(const std::bernoulli_distribution &,const std::bernoulli_distribution &)' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(284): note: or 'bool std::operator ==(const std::error_condition &,const std::error_condition &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(278): note: or 'bool std::operator ==(const std::error_condition &,const std::error_code &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(272): note: or 'bool std::operator ==(const std::error_code &,const std::error_condition &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(266): note: or 'bool std::operator ==(const std::error_code &,const std::error_code &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(330): note: or 'bool std::operator ==(const std::exception_ptr &,std::nullptr_t) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(325): note: or 'bool std::operator ==(std::nullptr_t,const std::exception_ptr &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(320): note: or 'bool std::operator ==(const std::exception_ptr &,const std::exception_ptr &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3579): note: while trying to match the argument list '(std::pair<stock,int>, const std::string)' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3592): note: see reference to function template instantiation '_InIt std::_Find_unchecked1<_InIt,_Ty>(_InIt,const _InIt,const _Ty &,std::false_type)' being compiled
  5. Thanks, fixed it searching for shares->getName() instead of the object itself and adding: bool operator==(std::string n) { return this->name == n; } not too sure how to compare 2 objects yet, so just looking at the name will do for now
  6. 1>------ Build started: Project: stock-simulator, Configuration: Debug Win32 ------ 1>main.cpp 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\memory(1772): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\memory(1836): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const char(&)[9],double>(const char (&)[9],double &&)' being compiled 1> with 1> [ 1> _Ty=stock 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\memory(1837): note: see reference to function template instantiation 'std::_Ref_count_obj<_Ty>::_Ref_count_obj<const char(&)[9],double>(const char (&)[9],double &&)' being compiled 1> with 1> [ 1> _Ty=stock 1> ] 1>c:\users\jonathan\documents\projects\stock-simulator\main.cpp(22): note: see reference to function template instantiation 'std::shared_ptr<stock> std::make_shared<stock,const char(&)[9],double>(const char (&)[9],double &&)' being compiled 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3579): error C2678: binary '==': no operator found which takes a left-hand operand of type 'stock' (or there is no acceptable conversion) 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(284): note: could be 'bool std::operator ==(const std::error_condition &,const std::error_condition &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(278): note: or 'bool std::operator ==(const std::error_condition &,const std::error_code &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(272): note: or 'bool std::operator ==(const std::error_code &,const std::error_condition &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(266): note: or 'bool std::operator ==(const std::error_code &,const std::error_code &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(330): note: or 'bool std::operator ==(const std::exception_ptr &,std::nullptr_t) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(325): note: or 'bool std::operator ==(std::nullptr_t,const std::exception_ptr &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\exception(320): note: or 'bool std::operator ==(const std::exception_ptr &,const std::exception_ptr &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\memory(1621): note: or 'bool std::operator ==<stock>(std::nullptr_t,const std::shared_ptr<stock> &) noexcept' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3579): note: while trying to match the argument list '(stock, const std::shared_ptr<stock>)' 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3592): note: see reference to function template instantiation '_InIt std::_Find_unchecked1<_InIt,_Ty>(_InIt,const _InIt,const _Ty &,std::false_type)' being compiled 1> with 1> [ 1> _InIt=stock *, 1> _Ty=std::shared_ptr<stock> 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xutility(3601): note: see reference to function template instantiation '_InIt std::_Find_unchecked<stock*,_Ty>(const _InIt,const _InIt,const _Ty &)' being compiled 1> with 1> [ 1> _InIt=stock *, 1> _Ty=std::shared_ptr<stock> 1> ] 1>c:\users\jonathan\documents\projects\stock-simulator\person.hpp(22): note: see reference to function template instantiation '_InIt std::find<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::shared_ptr<_Ty>>(_InIt,const _InIt,const std::shared_ptr<_Ty> &)' being compiled 1> with 1> [ 1> _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<stock>>>, 1> _Ty=stock 1> ] 1>Done building project "stock-simulator.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  7. #pragma once #include <string> #include <algorithm> #include "stock.hpp" class person { private: std::string name; float cash; std::vector<stock> investments; public: person(std::string name, float cash) { this->name = name; this->cash = cash; } ~person() = default; void buy_stock(std::shared_ptr<stock> shares, int quantity) { cash -= (shares->getPrice() * quantity); //quantity TODO investments.push_back(*shares); } void sell_stock(std::shared_ptr<stock> shares, int quantity) { std::vector<stock>::iterator it = std::find(std::begin(investments), std::end(investments), shares); if (it == std::end(investments)) { std::cout << "\n\nERROR - person.sell_stock tried to sell shares not in portfolio" << std::endl; char exit; std::cin >> exit; } else { ptrdiff_t index = std::distance(std::begin(investments), it); investments.erase(it); cash += (shares->getPrice() * quantity); } } }; The void sell_stock function won't compile but I can't understand the compiler errors that come out, please can someone advise? Is it something to do with the fact I don't have an overload for ==? by the way the ptrdiff_t index = std::distance I know is doing nothing note: see reference to function template instantiation '_InIt std::_Find_unchecked<stock*,_Ty>(const _InIt,const _InIt,const _Ty &)' being compiled 1> with 1> [ 1> _InIt=stock *, 1> _Ty=std::shared_ptr<stock> 1> ]
  8. ICanC

    C++ and SDL loop

    I'm a C++ and SDL beginner and I'm trying to make my first 2d game (blackjack) but I'm struggling to get an elegant loop in place to control the images, animations and input. in my rush and excitement to get graphics on the screen I ended up with a massive function handling everything, which just 2 'player decisions' in, has become a monstrous unmaintainable mess, e.g.: bool decision_one = true; bool decision_two = false; card playercard3 = this->deal(); while (decision_one) { SDL_PollEvent(&e); if (e.type == SDL_KEYDOWN) { if (e.key.keysym.sym == SDLK_h) { while (playersource3.x != playerdestination3.x) { playersource3.x += 10; playersource3.y += 10; SDL_BlitSurface(background, NULL, screenSurface, NULL); SDL_BlitSurface(this->getImage(playercard1.image_number), NULL, screenSurface, &playersource1); SDL_BlitSurface(redback, NULL, screenSurface, &dealersource1); SDL_BlitSurface(this->getImage(playercard2.image_number), NULL, screenSurface, &playersource2); SDL_BlitSurface(this->getImage(dealercard2.image_number), NULL, screenSurface, &dealersource2); SDL_BlitSurface(this->getImage(playercard3.image_number), NULL, screenSurface, &playersource3); SDL_UpdateWindowSurface(window); decision_one = false; decision_two = true; } } else if (e.key.keysym.sym == SDLK_s) { card dealercard1 = this->deal(); SDL_BlitSurface(this->getImage(dealercard1.image_number), NULL, screenSurface, &dealersource1); SDL_UpdateWindowSurface(window); decision_one = false; } } SDL_Delay(80); } So I'm trying break it up into smaller chunks like this: class card { private: std::string name; int value; int suit; public: int image_number; SDL_Rect source; SDL_Rect dest; int vel; card(std::string name, int value, int suit, int image_number); card() {}; ~card() {}; void display() const; }; class blackjack { private: std::vector<card> deck; int minBet; int maxBet; int decks; public: blackjack(int minBet, int maxBet, int decks); ~blackjack() {}; SDL_Surface* getImage(int i); void play_hand(std::shared_ptr<player> p); void getinput(std::shared_ptr<player> p); void create_card(card c, int sourceX, int sourceY, int destX, int destY, int vel); void animate_card(card c); void shuffle(); void reshuffle(); void render(); card deal(); void play(std::shared_ptr<player> p); }; card blackjack::deal() { card dealCard = this->deck[this->deck.size() - 1]; this->deck.pop_back(); return dealCard; } void blackjack::create_card(card c, int sourceX, int sourceY, int destX, int destY, int vel) { SDL_Surface* newCard = this->getImage(c.image_number); entities.push_back(*newCard); c.source.x = sourceX; c.source.y = sourceY; c.dest.x = destX; c.dest.y = destY; c.vel = vel; } void blackjack::animate_card(card c) { while (c.source.x != c.dest.x) { c.source.x += c.vel; c.source.x += c.vel; for (auto i : entities) { SDL_Surface *s = &i; SDL_BlitSurface(background, NULL, screenSurface, NULL); SDL_BlitSurface(s, NULL, screenSurface, //HOW TO GET IMAGE POS HERE?); SDL_UpdateWindowSurface(window); } } } void blackjack::render() { } void blackjack::play(std::shared_ptr<player> p) { this->shuffle(); init_graphics(); this->getinput(p); } The main problem I'm struggling to get my head around is rendering all current images in the game and animating them until they reach their destination. I've created a global variable std::vector<SDL_Surface> entities to hold all images in a hand, and I've gotten to the animate card function above but can't understand how i'm going to pass in the location of all the sdl_surface entities for the blitsurface function - any advise on a simple way to add images, animate them from a source to a dest, and keep track of all of this in one 'render' function would be great
  9. ICanC

    C++ comparing 2 floats

    thanks haegarr, that fixed it. and thanks Bregma, my logic was backwards, when writing that code I was wrongly thinking that 'return 0' indicates a 'true' and successful end to the program, when it is infact true values that indicate failure
  10. hi all, I'm testing with floats for the first time and have discovered that you can't compare 2 floats due to rounding errors. I've read online that you must use an epsilon and test for less than, however I don't seem to be able to get it working with the below code. - when running the code below it it is looping through 6 floats testing for equality with f entered by the player, but even if I put something totally different from the options, the message "not a valid position" is never executed void locks::try_lock() { print("\nEnter lock position: "); float f; cin >> f; int fexists = 1; float epsilon = 0.0000001; // Not sure what the best value to put here is? for (float &a : this->answers) { if ((a - f) < epsilon) { fexists = 0; } } if (fexists == 1) { cout << endl << f << " is not a valid position\n\n"; Sleep(2000); return; } }
  11. ICanC

    C++ buffer or vector issue

    Thanks for all the replies. I've fixed the iterator issue, and the actual cause of the problem was something to do with the messages not being properly conditioned, adding in a few ifs below fixed the issue void merchant::buyfrom(character *a) { print("\nItem to buy: "); string item1; getline(cin, item1); vector<item>::iterator it; unsigned vector_size = this->items.size(); int check = 0; // to handle merchant does not have msg with not enough gold msg for (it = this->items.begin(); it != this->items.end();) { if (it->name == item1) { if (it->price > a->gold) { print("\n\nYou don't have enough gold to buy the "); cout << it->name; check = 1; break; } print("\n\nYou bought "); std::cout << item1; print(" for "); std::cout << it->price; print(" gold"); a->inventory.push_back(*it); a->gold -= it->price; this->gold += it->price; this->items.erase(it); break; } else { ++it; } } if (this->items.size() == vector_size && check == 0) { print("\n\nMerchant does not have a "); std::cout << item1; print(" to sell"); } print("\n\n\n1. Back\n\n\n> "); char c; std::cin >> c; } void merchant::sellto(character *a) { print("\nItem to sell: "); string item1; getline(cin, item1); vector<item>::iterator it; unsigned vector_size = a->inventory.size(); for (it = a->inventory.begin(); it != a->inventory.end();) { if (it->name == item1) { print("\n\nYou sold "); std::cout << item1; print(" for "); std::cout << it->price; print(" gold"); this->items.push_back(*it); a->gold += it->price; this->gold -= it->price; a->inventory.erase(it); break; } else { ++it; } } if (a->inventory.size() == vector_size) { print("\nYou do not have "); std::cout << item1; print(" to sell"); } /* int increase = (it->price * 1.2+1); vector<item>::iterator it2; for (it2 = this->items.begin(); it2 != this->items.end(); ++it2) { if (it2->name == it->name) { it2->price = increase; } } */ print("\n\n\n1. Back\n\n\n> "); char c; std::cin >> c; }
  12. ICanC

    C++ buffer or vector issue

    Thanks, i've put the erase just before the break but the problem still occurs. I guess if there isn't anything obviously wrong the bug must be on the menu function which calls the above 2 functions? Or possibly the item struct?
  13. I'm looking for a bit of help please, I have a merchant class that you can buy from and sell to. The merchant has his own vector of struct 'items' as does the player. To begin the transactions, a merchants menu function is called, passing in the address of a player (character class) The below code works perfectly as expected, (e.g. if you haven't got enough gold, it states it correctly, or if either person doesn't have the item, etc) but as soon as a transaction occurs, like the player selling something, any attempts to sell anything else will show no message and just show the ".1. Back" option, or trying to buy something will say twice the merchant doesn't have it, or if he does, it will say he doesn't have it, but then say you bought it... it's probably something really simple and bad design on my part, but I can't figure it out void merchant::buyfrom(character *a) { print("\nItem to buy: "); string item1; fflush(stdin); getline(cin, item1); vector<item>::iterator it; for (it = this->items.begin(); it != this->items.end(); ++it) { if (it->name == item1) { if (it->price > a->gold) { print("\n\nYou don't have enough gold to buy the "); cout << it->name; break; } print("\n\nYou bought "); std::cout << item1; print(" for "); std::cout << it->price; print(" gold"); this->items.erase(it); a->inventory.push_back(*it); a->gold -= it->price; this->gold += it->price; break; } else { print("\n\nMerchant does not have a "); std::cout << item1; print(" to sell"); } } print("\n\n\n1. Back\n\n\n> "); char c; std::cin >> c; } void merchant::sellto(character *a) { print("\nItem to sell: "); string item1; fflush(stdin); getline(cin, item1); vector<item>::iterator it; for (it = a->inventory.begin(); it != a->inventory.end(); ++it) { if (it->name == item1) { print("\n\nYou sold "); std::cout << item1; print(" for "); std::cout << it->price; print(" gold"); a->inventory.erase(it); this->items.push_back(*it); a->gold += it->price; this->gold -= it->price; break; } else { print("\nYou do not have "); std::cout << item1; print(" to sell"); } } print("\n\n\n1. Back\n\n\n> "); char c; std::cin >> c; }
  14. ICanC

    C++ Random number issue

    Thanks TheChubu, that's exactly what I needed
  15. I'm struggling to get random numbers, in the below code, If I take out the time seed, I get different random numbers each roll, however they are the same on each play through. If I leave the time seed in, the rolls are always 1 and 1. Please can someone advise what I am doing wrong? I've tried making the game sleep a few seconds to change the results of time time seed call void dicegame::battle(character *a, character *b) { int rollone = this->roll(); int rolltwo = this->roll(); int total1 = rollone+rolltwo; Sleep(5000); int rollone2 = this->roll(); int rolltwo2 = this->roll(); int total2 = rollone2+rolltwo2; Sleep(5000); } int dicegame::roll() { static std::uniform_int_distribution<int> u(1, 6); static std::default_random_engine e; e.seed(time(0)); int roll = (u(e)); return roll; }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!