Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to convert this C++ code into C# code? What syntax am I forgetting?
    primarykey
    data
    text
    <p>Google is flooded with Unity3D &amp; XNA resources. It is quite difficult to search for anything dealing with C# without the results being overwhelmingly Unity or XNA based. To even find good tutorials, I had to find a book on amazon and then google the author with -XNA -Unity, lol.</p> <p>My C++ code is organized nicely with each separate major class being its own file, in an organized directory.</p> <pre><code>Game.cpp Init.cpp Render.cpp Update.cpp </code></pre> <p>Game.cpp, being main(), where my game runs and calls Init, Render, and Update.</p> <pre><code>class Game { public: Game(); private: void Init(); void Update(sf::Time deltaTime); void Render(); sf::RenderWindow mWindow; }; int main() { Init(); while (mWindow.isOpen()) { Update(TimePerFrame); Render(); } } </code></pre> <p>And of course, Init.cpp</p> <pre><code>#include "Game.hpp" void Game::Init() { mWindow.setVerticalSyncEnabled(true); } </code></pre> <p>Now, I have the C# bindings for SFML and switched from Code::Blocks to VS2012. I've been working with C++ for so long that I am having some trouble with C#. I went through some tutorials to refresh myself with the syntax, but there is something I'm still not remembering. Obviously, this is a dumb question. However, google is not very much help due to how overwhelmingly swarmed C# is with Unity &amp; XNA results, and I just can't remember how to do this right.</p> <p>I want to have the same separate files,</p> <pre><code> Game.cs Init.cs Update.cs Render.cs </code></pre> <p>However, I can't even get it to function in a single class.</p> <p>Game.cs</p> <pre><code>class Game { public void Main() { // Create the main window RenderWindow mWindow = new RenderWindow(new VideoMode(1200, 1200), "SevenBlack"); mWindow.Closed += new EventHandler(OnClose); Color windowColor = new Color(0, 0, 0); //Initialize Game Init(); while (mWindow.IsOpen()) { Update(TimePerFrame); } Render(); } } private void Init() { mWindow.setVerticalSyncEnabled(true); } private void Update(long dt) { } private void Render() { mWindow.Clear(windowColor); mWindow.Display(); } } </code></pre> <p>I get "The name 'mWindow' does not exist in the current context.</p> <pre><code> private void Game::Init() { mWindow.setVerticalSyncEnabled(true); } </code></pre> <p>Does not work either, since this is C#.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload