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 - Kulade

Pages: [1]
1
General / Re: Trouble switching states...
« on: February 03, 2014, 09:13:11 pm »
Wow, that is absolutely embarrassing... Sure enough, the problem is solved. Thanks for pointing that out, panithadrum!

2
General / Re: Trouble switching states...
« on: February 03, 2014, 04:43:20 am »
I've read the tutorials; it's just been a fairly long time since I last used SFML, so I forgot how I was supposed to do a few things. Given the feedback on my code, I changed the order of the polling and added a clear() after the display() method, but it didn't do anything to solve the actual problem. The game still freezes when I attempt to switch states, and it fails to clear the screen as well. I still think the problem lies in GameLoop(), as I've gotten the state switching to work just fine with TitleLoop() (as it was) before.

3
General / Re: Trouble switching states...
« on: February 02, 2014, 11:07:43 pm »
I clear it in a different loop. (Thanks for reminding me about that, though..)

void Game::TitleLoop ()
{
        //this is not a while loop. it runs only once. That said, I can create a texture object here as long as I take care to destroy it
        sf::Texture TitleScreen;
        sf::Sprite TScreen;
       
        TitleScreen.loadFromFile("Cacturne.png");

        TScreen.setTexture(TitleScreen);

        //A title screen. Wooohooo!
        while (GameState == Title)
        {
                TScreen.setPosition(0,0);
                Window.draw(TScreen);
                Window.display();

                //Polling afterwards because I want to be able to destroy anything I've loaded at this point
                while(Window.pollEvent(Event))
                {
                        if (Event.type == sf::Event::Closed)
                        {
                                //allows the program to exit this loop, and then, the program
                                GameState = Exiting;
                               
                        }
                        if ((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Space))
                        {
                                //Whenever I switch states, I must clear the window.
                                Window.clear();
                                GameState = TestRoom;
                        }
                }


               
               
        }

}

4
General / Trouble switching states...
« on: February 02, 2014, 10:01:14 pm »
Ok, so I think my problem here has a little less to do with SFML and a bit more to do with C++, but no matter.

I'm trying to draw a character sprite from a class, but this code seems to freeze the program.

I wrote a game class that essentially is the state pattern, but it also runs a window. And for the actual level [ being run in GameLoop() ], I've created a character that should appear and fall. However, it seems to freeze before it even gets there, not even succeeding at clearing the window before it switches states.

However, I've tested that code and it doesn't seem to be the problem. The problem only occurs in GameLoop, and I presume it's because of how I'm using the draw() function here:

void Game::GameLoop ()
{
// We already set up the window. Everything that occurs will be inside the window.
//I'm gonna write some code for this and link it to the title loop.
        Character Character;

        while (GameState == TestRoom);
        {

                Character.UpdatePosition();
                Window.draw(Character.Shantae);
                Window.display();

        }


}

I knew it was bad coding practice, but I didn't think it would be a big deal to make "Shantae" (the sprite, of course) temporarily public. Anyway, I'm not sure what's the best way to access this sprite so that I can use window.draw() without errors. Here's a bit of the Character class, by the way:
class Character
{
public:
        //UpdatePosition is going to check for all movement starting with falling. We can call it from within the game loop.
        void UpdatePosition();
        Character();
        sf::Sprite Shantae;

};

Thanks for any help, you guys.

5
General / Re: Gravity, jump, physics : any advices?
« on: February 01, 2014, 10:22:10 pm »
Well, I'm not sure if you want to build the physics up by yourself, but if you don't, you should check out the Box2D library. A lot of people use it with SFML. Give the documentation a thorough look, make sure you understand the necessary concepts, and you should have a somewhat simple way to handle all the physics.

6
General / Adding a Title screen / organizing code
« on: June 21, 2011, 08:50:42 pm »
Ok, I'm not sure how I should implement a title screen into my game. Making one is incredibly easy, of course, but... I don't know how to make the Title screen lead to the actual game. A better way of putting it is that I have no clue how to make both of them part of the same program. It's pretty embarrassing... :oops:

I'm fairly sure that there are a few ways to do this, so could you guys give me some suggestions? Thank you for any help.


EDIT: Actually, the Title Screen isn't a big problem. It's just that I'm trying to find a way to organize my code. The best question I should ask is: In what way do you write organized code? Also, is that something that a beginner should be worried about?

7
General / Visual C++ 2008- Can't compile for release
« on: April 02, 2011, 03:16:52 pm »
Quote from: "Contadotempo"
Is the second screenshot correct? You're trying to compile in Release but in the screenshot, the active configuration you're changing is Debug (Top-Left corner).


Thank you so much; I never would've spotted that. I had to use the Configuration Manager to change it, but now it's Active(Release) and it works fine! Thanks again!

8
General / Visual C++ 2008- Can't compile for release
« on: April 02, 2011, 04:40:55 am »
Hey, everyone.

My programs won't work outside of debug mode. Here's what happens:

I manage to compile the program, then I go to its folder to test it. I've gotten what I think are Buffer Overruns before, but now I just get this:



and it crashes. It shouldn't have those wierd I's.


This is what I did:

1. I used the code from the "graphics-window" project.
2.I change the Additional Dependencies so that I can compile the program for release. I make sure to check these, since everywhere I've looked, someone said that was the problem, but I'm not mixing the debug and release libraries.

3.I go to [Build]->Build (project name) and wait for everything to compile. It compiles fine, with a warning.
Code: [Select]
1>------ Rebuild All started: Project: Rainfall3, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Rainfall3', configuration 'Debug|Win32'
1>Compiling...
1>Main.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Embedding manifest...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Build log was saved at "file://c:\Users\Mike\Documents\Visual Studio 2008\Projects\Rainfall3\Rainfall3\Debug\BuildLog.htm"
1>Rainfall3 - 0 error(s), 1 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

4. I run the program and it goes wonky.

Any help is appreciated!

Pages: [1]
anything