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.


Topics - MW2TopTenWORLD

Pages: [1]
1
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 :(

2
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 :)

3
General / Very High CPU Usage.
« on: August 19, 2014, 12:05:23 am »
Hello, I am currently working on a game with SFML (2.1), I am using Visual C++ 2010.
Just to start my computer is not the best, maybe not even close :P however this is way too exagerated as all I have done so far is a little bit of the main menu and it uses 56% of the CPU... And However I can play Call of Duty : Modern Warfare 2 (which I Suppose it's heavier then a little bit of the main menu of my game...) and it only uses about 36%...

So yeah, I Do not know where the problem is... I have tried many things, I have tried not loading an intro video (I Am Using SfTheora 1.4 to do so) by removing all of the SfTheora calls and everything associated to it, I had one multi-thread call which was just scrolling text around the screen , I tried removing it as well, I tried removing a function (void) which was cycling the colors of a text, I tried commenting out the WHOLE events  code block ... I tried removing vSync, I tried using framerate limit, I tried who knows what! I went from every part of my code, changing things... NOTHING, The CPU just keeps at that level pretty much :( With a thing THIS small (so far) I guess it shouldn't even be on 1% CPU... MAX I would say like 4%... So... Why does it stay like that?

Please Make Any Suggestions and tell me if you need anything to help me out :(



Thanks :)

Pages: [1]