Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tristanbox09

Pages: [1]
1
Audio / SoundBuffer error "Incomplete type not allowed"
« on: December 10, 2020, 03:28:39 am »
Hello guys,

I am trying to load a losing sound for minesweeper, and I achieved this in the main window first. I then moved my function to a class and I am getting an incomplete type not allowed on my buffer object. Any ideas? My code is below:

void Board::losingSound(sf::SoundBuffer& buffer, sf::Sound& sound)
{
   buffer.loadFromFile("sound/gameover.wav");


   sound.setBuffer(buffer);

   sound.play();

   soundOff = true;
}

2
Ahhh thank you!!!

3
Yea, So I initially read in a cfg file to have a default game setup


   /* ======== Loading in the board data ======= */
   cfgWindowMaker.ReadingCFGFile("boards/configexpert.cfg");


   /* ======== Creating the MineSweeper Window for gameplay ======== */
   sf::RenderWindow window(sf::VideoMode(cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight()), "Minesweeper!", sf::Style::Close);


I than do my event for resize in the event loop


   sf::View view = window.getDefaultView();


   /* ======== When window is open ..... End of Initializations ======== */
   while (window.isOpen())
   {
      sf::Event event;
      while (window.pollEvent(event))
      {
         if (event.type == sf::Event::Closed)
            window.close();

         if (event.type == sf::Event::Resized) {
            // resize my view
            // update the view to the new size of the window
            sf::FloatRect visibleArea(0, 0, cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight());
            window.setView(sf::View(visibleArea));

            sf::RenderWindow window(sf::VideoMode(cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight()), "Minesweeper!", sf::Style::Close);
         }


and if I left click on beginner button it would load a smaller dimension of the board (including resizing the window)


if (test1Btn.contains(mousePosFloat))
               {
                  boardObject.ResetGame(cfgWindowMaker);
                  cfgWindowMaker.ReadingCFGFile("boards/configbeginner.cfg");
                  boardObject.RandomBombMaker(cfgWindowMaker, window);
                  sf::FloatRect visibleArea(0, 0, cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight());



               }


               if (test2Btn.contains(mousePosFloat))
               {
                  cout << "Test 2" << endl;
                  boardObject.ResetGame(cfgWindowMaker);
                  cfgWindowMaker.ReadingCFGFile("boards/configintermediate.cfg");
                  boardObject.RandomBombMaker(cfgWindowMaker, window);
                  window.setView(view);

               }

As you can see I tried resizing the event two ways (with floatRect and with setView) where both outputs show the result of the image I posted in the above reply

Thank you for the help!

4
When I add that line, I still get the same issue... my window appears like this for a beginner board (seen in image), for some reason the resize on my board works, but the window does not resize

5
Hello, I am using my window from Render Window to be the width and height of a file I input for Minesweeper

sf::RenderWindow window(sf::VideoMode(cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight()), "Minesweeper!", sf::Style::Close);

and when a button is clicked, the window for Render Window would change to whatever the files dimensions are. This seems to draw the board correctly, but my window does not resize. My code is below


if (event.type == sf::Event::Resized) {
            // resize my view
            view.setSize({
                  static_cast<float>(event.size.width),
                  static_cast<float>(event.size.height)
               });

            sf::RenderWindow window(sf::VideoMode(cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight()), "Minesweeper!", sf::Style::Close);
         }


if (test1Btn.contains(mousePosFloat))
               {
                  boardObject.ResetGame(cfgWindowMaker);
                  cfgWindowMaker.ReadingCFGFile("boards/configbeginner.cfg");
                  boardObject.RandomBombMaker(cfgWindowMaker, window);
                  sf::RenderWindow window(sf::VideoMode(cfgWindowMaker.GetWidth(), cfgWindowMaker.GetHeight()), "Minesweeper!", sf::Style::Close);
                  window.setView(view);
                  
               }


Any help is much appreciated. I am trying to have my window actually match the dimensions of my board when the new fie get added

Pages: [1]
anything