Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

106 Neutral

About Rohrak

  • Rank
  1. Rohrak

    Code won't compile

    I've fixed the issue.  I never had those "C++ Language Dialect" options in Xcode, so I've updated Xcode to a later version and now all is well.   I didn't need to change those options, so it looks like this version of Xcode supports more C++11 features.   Thanks for all your help!
  2. Rohrak

    Code won't compile

      GameLoop.cpp - Line 26: PlayerOptions chosenOption = PlayerOptions::None; !'None' is not a member of PlayerOptions GameLoop.cpp - Line 30: chosenOption = PlayerOptions::Quit; "!Within this context" & "!From this location" Not too sure what thatt's referring to.   PlayerOptions.h - Lines 3,4,5,6: enum class PlayerOptions { !same as earlier Quit, None }; If I make PlayerOptions public: public enum class PlayerOptions { Quit, None }; I then get an error on GameLoop.h: PlayerOptions EvaluateInput(std::string& playerInput);!'PlayerOptions' doesn't name a type and in PlayerOptions.h: public enum class PlayerOptions { !Expected unqualified-id before 'public' Quit, None };
  3. Rohrak

    Code won't compile

      Ah right, I see.  I didn't include it in my code anyway, so I'm still not sure where the problem lies.   Thanks anyway!
  4. Rohrak

    Code won't compile

    I'm currently following Bruce Sutherland's "Learn C++ for Game Development."  I'm using Xcode.   I've added the following code, but can't get it to compile:   main.cpp: #include "Player.h" #include "GameLoop.h" int main (int argc, char * const argv[]) { Player player; GameLoop::WelcomePlayer(player); bool isPlaying = true; while(isPlaying) { isPlaying = GameLoop::RunGame(); } return 0; } Player.h: #pragma once #include <string> struct Player { std::string m_Name; }; GameLoop.h: #pragma once #include "Player.h" #include "PlayerOptions.h" namespace GameLoop { void WelcomePlayer(Player& player); void GivePlayerOptions(); void GetPlayerInput(std::string& playerInput); PlayerOptions EvaluateInput(std::string& playerInput); bool RunGame(); } GameLoop.cpp: #include "GameLoop.h" #include <iostream> using namespace std; namespace GameLoop { void WelcomePlayer(Player& player) { cout << "Welcome to Text Adventure!" << endl << endl; cout << "What is your name?" << endl << endl; cin >> player.m_Name; cout << endl << "Hello, " << player.m_Name << "!" << endl; } void GivePlayerOptions() { cout << "What would you like to do?" << endl << endl; cout << "1: Quit" << endl << endl; } void GetPlayerInput(string& playerInput) { cin >> playerInput; } PlayerOptions EvaluateInput(string& playerInput) { PlayerOptions chosenOption = PlayerOptions::None; if(playerInput.compare("1") == 0) { cout << "You have chosen to quit!" << endl << endl; chosenOption = PlayerOptions::Quit; } else { cout << "I do not recognise that option. Try again!" << endl << endl; } return chosenOption; } bool RunGame() { bool shouldEnd = false; GivePlayerOptions(); string playerInput; GetPlayerInput(playerInput); shouldEnd = EvaluateInput(playerInput) == PlayerOptions::Quit; return !shouldEnd; } } PlayerOptions.h: #pragma once enum class PlayerOptions { Quit, None }; When I try to compile, I get quite a few errors on the PlayerOptions.h file: #pragma once enum class PlayerOptions { !Expected identifier before 'class' Quit, !ISO C++ forbids declaration of 'Quit' with no type None !ISO C++ forbids declaration of 'None' with no type }; !Expected ';' before '}' token   The code is exactly as it is in the book, except from an include in the main.cpp file.  The book has: #include "stdafx.h" When I try to add this, I get a message stating that the file can't be found.  I'm guessing it's supposed to be a local file, but I'm not sure what importance it has on the project.   If I make the enum class PlayerOptions public, it gets rid of most error messages, but it still complains about the same errors in the PlayerOptions.h file.   Does anyone have any ideas?   Many thanks.  
  5. Rohrak

    Coding on Mac OSX

    Hi, I've previously had experience with Java, C, C++ and C#. I had been using Visual Studio on Windows in the past, when messing about creating a very simple 2D game engine. I am now working exclusively on a Mac, and I'm going to have another bash at some coding (I've been out the game for many years now.) I was looking into using xCode. I tried to download it from the App store and I was notified that I don't have the required version of OSX. I'm very reluctant to upgrade, as I don't want any issues with other software that I currently need to use regularly. I'm planning on getting a refresher on C++ and possibly getting back into simple game development too. I'm a bit stumped on where to go from here, so was wondering if anyone can recommend an IDE? I've also been looking into some books on C++, which work with Visual Studio. Is there anything I should watch out for here? Should I be able to follow along with another IDE? Thanks
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!