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

Pages: [1] 2
1
General discussions / Re: SFML 3 - What is your vision?
« on: September 06, 2014, 03:26:25 am »
I Can't think of much, I've just started using SFML... But one of the reasons I didn't used VS2013... Was because sfTheora was incompatible with 2013....

WHAT I MEAN IS : Let the next SFML Version play video natively :)

2
General / Re: Threading problems.
« on: September 03, 2014, 12:26:08 am »
@zsbzsb I Do Use Visual Studio 2013, wether for C# or wether for C++, but as sfThera wasn't working in 2013 I used 2010 instead... but thanks about the RAII Thing as I had no idea about it, although I had heard its name before :)

Thanks

3
General / Re: Threading problems.
« on: September 02, 2014, 11:34:34 pm »
@Jesper Juhl , @Ixrec thank you for all of these usefull tips! (I always say this xD)

About the / instead of \\ I HAD NO IDEA!!

About the "ShellExecute" I plan my game just to be for Windows, sure my future games would be cool to Multi Platform but this one just for Windows, but thanks for that as well.

The Screenshot thing is ... far from being finished, It's just a "place holder" for now but your tips will help a lot when I "finish" it.

Thanks again for the if to else if tip

Thanks for the suggestion for that book :) I will read it when I have time

And I tried compiling the sfTheora source in Visual Studio... in CMAKE.... etc and it just gives me errors :\ I'm sure its compilable but I just can't do it, and Visual Studio 2010 is going to do just fine for now specially since this game is more of like of a "hello world" project.

4
General / Re: Threading problems.
« on: September 02, 2014, 11:07:37 pm »
@Ixrec thank you for that I will use most of those stuff from now on, specially the sf::Rect::contains() one :P

Please understand that this is my first game EVER and this is all to new to me.. I mean SFML is kind of user friendly (yay) but the way you "manage" your game is.... just new to me, C++ by it self is just not the language for a beginner :P but then all this things that you need to keep track from x.x.


Well again thanks for that, it might look like not but they're really helping me :)

Oh and btw "fullscreen.height * 0.45" is not a "magic" number or something like that... it's because that is the defined y (?) position of one of the buttons so I was telling the "mouse" to look in that way.... And I get exactly what you mean... I mean theres "nothing" pretty much "done" so far and I already feel SOOOOOO Scrambled :S sometimes I even wonder if I'm doing it right :P

Thanks! :)

5
General / Re: Threading problems.
« on: September 02, 2014, 10:49:49 pm »
@Jesper Juhl that was just the last bit of the loop :P
Here is the whole main.cpp code

#include <sfTheora.h>
#include <SFML/Audio.hpp>
#include <SFML/Config.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include "textCreator.h"
#include "mainScreen.h"
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
#include "variables.h"
#include "Funcs.h"

using namespace std;

int main()
{
        sf::ContextSettings settings;
        settings.antialiasingLevel = 8;
        sf::RenderWindow window(sf::VideoMode(fullscreen.width, fullscreen.height), "SFML App", sf::Style::Fullscreen, settings);
        sf::Clock clock;

        window.setVerticalSyncEnabled(true);
       
        mainFont.loadFromFile("Fonts\\sansation.ttf");

        sf::Text pressENT;
        pressENT.setColor(sf::Color::White);
        pressENT.setFont(mainFont);
        pressENT.setString("Press [ENTER] to Skip this Video");
        pressENT.setPosition(fullscreen.width-(fullscreen.width*0.65), fullscreen.height-(fullscreen.height*0.10));

        sftheora::Video introVideo("intro.ogg");
        //introVideo.setPosition((fullscreen.width/2)+(1280/2),0);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

                        if (event.type == sf::Event::KeyPressed)
                        {
                                switch(event.key.code)
                                {
                                case sf::Keyboard::Escape:
                                        {
                                                window.close();
                                                break;
                                        }
                                case sf::Keyboard::F12:
                                        {
                                                sf::Image screen = window.capture();
                                                srand(time(0));
                                                long double randomNum = 0;
                                                for(int i = 0; i < 5; i++)
                                                {
                                                        randomNum = rand() % 125000000 + 1;
                                                }
                                                string fileName = "Screenshots\\" + std::to_string(randomNum) + ".png";
                                                screen.saveToFile(fileName);
                                                break;
                                        }
                                case sf::Keyboard::Return:
                                        {
                                                if(introVideo.isDone() == false)
                                                {
                                                        introVideo.seek(introVideo.getDuration());
                                                }
                                                break;
                                        }
                                }
                        }
                        if(event.type == sf::Event::MouseButtonPressed)
                        {
                                switch(event.mouseButton.button)
                                {
                                case sf::Mouse::Left:
                                        {
                                                if((introVideo.isDone()==true)&&(isMainScreenOn==true))
                                                {
                                                        //This here is the "PlayBTN" Button :)
                                                        if((sf::Mouse::getPosition().x >= ((funcs::findCenterOfScreenWidth(fullscreen.width)) - (fullscreen.width*0.35)/2))
                                                                && (sf::Mouse::getPosition().x <= ((funcs::findCenterOfScreenWidth(fullscreen.width)) - (fullscreen.width*0.35)/2) + (fullscreen.width*0.35))
                                                                && (sf::Mouse::getPosition().y >= (fullscreen.height*0.45))
                                                                && (sf::Mouse::getPosition().y <= (fullscreen.height*0.45) + (fullscreen.height*0.10)))
                                                        {
                                                                //MessageBox(NULL, "you're in the button!", "congrats nigger!", MB_OK || MB_ICONINFORMATION); - TEST PURPOSES -
                                                                /*1 - Set Menu as OFF so it stops being drawn.
                                                                  2 - Launch a whole new ton of shit that I'll think of later...*/

                                                                isMainScreenOn = false;
                                                        }

                                                        //The Bottom Message
                                                        if((sf::Mouse::getPosition().x >= 0)
                                                                && (sf::Mouse::getPosition().x <= fullscreen.width)
                                                                && (sf::Mouse::getPosition().y <= fullscreen.height)
                                                                && (sf::Mouse::getPosition().y >= (fullscreen.height-(fullscreen.height*0.05))))
                                                        {
                                                                ShellExecute(NULL, "open", "http://www.youtube.com/mw2toptenworldmodz", NULL, NULL, NULL);
                                                        }
                                                }
                                        }
                                }
                        }
                               
        }

                introVideo.update(clock.restart());

        window.clear();
                if(introVideo.isDone() == false)
                {
                        window.draw(introVideo);
                        window.draw(pressENT);
                }
                if(introVideo.isDone() == true)
                {
                        if(isMainScreenOn==true)
                        {
                                mainScreen::drawMainScreen(&window);
                        }
                }
        window.display();
    }
    return EXIT_SUCCESS;
}


Before you say so YES I know about rand() being evil and me not should be using the SFML Events for the button presses and stuff like that but its my first game its very simple I Don't need to be very cautious... but I am taking "notes" of all that in my head for a more future serious project :)

6
General / Re: Threading problems.
« on: September 02, 2014, 10:35:33 pm »
Also for however requested my main loop here is the Drawing part of it.

...
window.clear();
                if(introVideo.isDone() == false)
                {
                        window.draw(introVideo);
                        window.draw(pressENT);
                }
                if(introVideo.isDone() == true)
                {
                        if(isMainScreenOn==true)
                        {
                                mainScreen::drawMainScreen(&window);
                        }
                }
        window.display();
    }
    return EXIT_SUCCESS;
}

7
General / Re: Threading problems.
« on: September 02, 2014, 10:30:24 pm »
@Jesper Juhl thank you for those tips! Those are some kinds of stuff that don't come in books... (except the else if ones)

And for your new post about enums, sadly I can't use C++11 ;(.
I was using Visual Studio 2013 in the beginning (which I hope is C++11 capable) but now I had to go to 2010 because I am using sfTheora for my game intro video :(

8
General / Re: Help on Game Peformance
« on: September 02, 2014, 10:28:25 pm »
I get 60 fps with it so I would assume it's a problem with your friends PC or with his graphics card driver...
Notice that I had a super simple game and I was getting 2fps then I upddated my graphics card and if I'm doing something "heavy" it goes to 30fps, something simple about 50-60fps...

btw I'm Portuguese as well :) (from Portugal not from Brasil)

9
General / Re: Threading problems.
« on: September 02, 2014, 10:22:03 pm »
@Ixrec I will make program single threaded right now :) and btw I do know about Enums, I tried writing one before I used that "alternative" but I forgot how it worked, so I wrote the "alternative" and then went back to "Jumping Into C++" and had a refresh on my concept of enums but then I just decided I would leave that instead of an enum to save my time.

@zsbzsb Thanks! :)

10
General / Threading problems.
« on: September 02, 2014, 09:48:12 pm »
Ok, before you say it I am OK with C++ but when it comes to pointers, threads, multi-d arrays and other things I am noob... I know they're important but I haven't learned it as of now...

Well I am using sf::Thread not std::Thread

The problem is I am "pausing" the thread but it jut pauses the main thread!

I Will Post my code below please help :(.

This file is called mainScreen.cpp it represents my Main Menu.
The problem is with the thread that changes the bottom message color.
(If I call it without the sf::sleep or as not being a thread the colors just change instantaneously (obviously))

#include "mainScreen.h"
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include "variables.h"
#include "textCreator.h"
#include "Funcs.h"
#include <dos.h>
#include <SFML/System.hpp>

/*NOTE: sf::Vector2f = (width, height)*/

void changeBtmMessageTextColor(int x);
void scrollBtmMessage();

sf::RectangleShape playBTN;
sf::Text playBTNText;
sf::Texture mainMenuTexture;
sf::Sprite mainMenuImg;
sf::Text creator;
int bottomMsgColor = 1; //1 = green, 2 = yellow, 3 = red
sf::Thread scroller(&scrollBtmMessage);
sf::Thread colorScroller(&changeBtmMessageTextColor, bottomMsgColor);

void changeBtmMessageTextColor(int x) //this is the block of code with problems!
{
        if(x==1)
        {
                creator.setColor(sf::Color::Yellow);
                sf::sleep(sf::milliseconds(1500));
        }
        if(x==2)
        {
                creator.setColor(sf::Color::Red);
                sf::sleep(sf::milliseconds(1500));
        }
        if(x==3)
        {
                creator.setColor(sf::Color::Green);
                sf::sleep(sf::milliseconds(1500));
        }
        sf::sleep(sf::milliseconds(1500));
}

void scrollBtmMessage()
{
        if(creator.getPosition().x >= fullscreen.width){
                creator.setPosition(0-3500,creator.getPosition().y);
        }
        else{
                creator.setPosition(creator.getPosition().x+2,creator.getPosition().y);
        }
}

void mainScreen::drawMainScreen(sf::RenderWindow *window)
{
        isMainScreenOn=true;
        if(isMainScreenBuilt == false)
        {
                //playBTN
                playBTN.setSize(sf::Vector2f((fullscreen.width*0.35),(fullscreen.height*0.10)));  
                playBTN.setPosition((funcs::findCenterOfScreenWidth(fullscreen.width)) - ((fullscreen.width*0.35)/2),fullscreen.height*0.45);
                playBTN.setFillColor(sf::Color::White);

                //playBTNText
                //textCreator::createText(playBTNText, mainFont, sf::Color::Green, "New Game", ((fullscreen.width*0.35)/2), ((fullscreen.height*0.10)/2));
                playBTNText.setColor(sf::Color::Black);
                playBTNText.setFont(mainFont);
                playBTNText.setString("Play Game");
                playBTNText.setPosition(funcs::findCenterOfScreenWidth(fullscreen.width)-90,(fullscreen.height*0.45)+((fullscreen.height*0.10)/PI));

                //mainMenuImg
                mainMenuTexture.loadFromFile("Images\\main_menu_img.png");
                mainMenuImg.setTexture(mainMenuTexture);
                mainMenuImg.setPosition(funcs::findCenterOfScreenWidth(fullscreen.width)-(1000/2),fullscreen.height*0.05);

                //creator
                creator.setColor(sf::Color::Green);
                creator.setFont(mainFont);
                creator.setString("Made by : MW2TopTenWORLD a.k.a MW2T1999 || Subscribe me at http://www.youtube.com/mw2toptenworldmodz (Click this message to go there!) || Thank You For Purchasing my Game or whatever...");
                creator.setPosition(0, fullscreen.height-(fullscreen.height*0.05));
               

                isMainScreenBuilt = true;
        }
        window->draw(playBTN);
        window->draw(playBTNText);
        window->draw(mainMenuImg);
        window->draw(creator);
        colorScroller.launch();
        //changeBtmMessageTextColor(bottomMsgColor);
        scroller.launch();
        if(bottomMsgColor!=3){
                bottomMsgColor++;
        }else{
                bottomMsgColor=1;
        }
}
 

Please Help :(

11
General / Re: why am I getting an error on Void...?
« on: August 28, 2014, 02:13:45 pm »
First...
I can see other bracket after the void brackets, did you putted it into a class?


Also do not name the void with public... if it is inside a class just do this

class awesomeClass
{
public:
 //public voids go here

private:
 //private voids go here
}
 

And now a problem with the void itself...

You wrote

 public void Draw(RenderWindow window, float delta)
        {
            window.Draw(background);
            window.Draw(player);
            window.Draw(enemy);
            window.Draw(dead);

        }
 

YOU need to do
 ... Draw(RenderWindow *window, ...)
        {
           window->Draw(background);
           ...

        }
 

Notice the * and ->.

And when you are calling the funtion you cannot do Draw(window,....); You need to do Draw(&window,.....); ...

I used a pointer (*) maybe you can use a reference... but pointers work for me.

Hope I helped.

12
General / Re: installation by yum
« on: August 27, 2014, 12:48:30 am »
1. Don't assume people speak your native language (I certainly don't) in an english language forum. Translate relevant parts to english; please.
2. Your distribution (RedHat derived I guess based on yum/rpm) may not ship SFML at all or may not ship the latest version. You'll have to take that up with your distro people.
3. It's trivial to clone the SFML git repository and build (compile) it yourself.

It's Portuguese, I will translate (I'm Portuguese as well)

[root@localhost snake]yum install sfml
Loaded Plugins: langpacks, refresh-packagekit
Resolving dependencies
--> Executing Transaction check
---> The Package sfml.x86_64 0:2.0.0-1.fc19 will be installed
--> Dependencies resolution finished

Dependencies resolved

================================================================================
 Package     Architecture.     Version                  Repo          Size
================================================================================
Installing:
 sfml           x86_64           2.0.0-1.fc19              sfml           202 k

Short-Version of the transaction
================================================================================
Install  1 Package

Total Size: 202 k
Size after installed: 548 k
Is this ok [y/d/N]: y
Downloading packages:


The Package sfml-2.0.0-1.fc19.x86_64.rpm is not signed
[root@localhost snake]#




btw I translated DIRECTLY to Portuguese, maybe somethings are different because this isn't normal talking... it's Computer stuff.

13
General / Re: setFrameRateLimit & setVirtualSyncEnabled
« on: August 27, 2014, 12:42:32 am »
From what I know vSync simply syncs the frame rate to the refresh rate of the screen (or something like that) so it's a good frame rate :)
But I am sure not all graphic cards or monitors do not support vSync, so in case it didn't work it would just be set to a default value like 30, 60 ...etc :) Get what I Mean?

Anyways thanks for your suggestion and yeah I dont think there is a way thats why I asked ;(

14
General / setFrameRateLimit & setVirtualSyncEnabled
« on: August 26, 2014, 08:21:12 pm »
Hey, I know this is going to be very very very noobish...
but is there a way that I can do like

if(virtualsync() does not work)
{
   setframeratelimit)
}
else
{
virtualsync()
}

please :)

15
General / Re: Very High CPU Usage.
« on: August 26, 2014, 08:07:50 pm »
SOLVED
SOLVED
SOLVED!

All I had to do was update my video driver!
I Don't know why but it was "fucking" with SFML :P... And I actually found out that the game is so fast that my scrolling message just flies through the screen hehe... gotta fix that.

Well this was my problem... graphics card driver.
Hopefully its the same for others (if they have this problem)

Pages: [1] 2
anything