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

Pages: [1] 2
1
Window / Re: Black dots in the window depending on window style
« on: January 09, 2015, 10:57:35 pm »
It's a HP Pavilion dv6-6000
Display res: 1366x768

2
Window / Re: Black dots in the window depending on window style
« on: January 09, 2015, 08:05:38 pm »
Err... LCD I'd guess?
It's a laptop.

3
Window / Black dots in the window depending on window style
« on: January 09, 2015, 07:47:08 pm »
I'm pretty sure that this is in the right section of the forums... I was a little unsure?
But anyway:

Today, out of the blue, a program which I've been working on starting doing this when I started it:
Window creation code:
sf::RenderWindow window(sf::VideoMode(600, 400), "Main", sf::Style::Close);


After playing around with the window for a bit, I found that removing the style code returned it to normal:
Window creation code:
sf::RenderWindow window(sf::VideoMode(600, 400), "Main");



There's been no changes made to the computer, (no new software, drivers etc) and the source was not modified between when it was working properly and when it starting showing the dots.

The GUI aspects of the program are drawn through SFGUI but even if I create a rectangle and draw it directly, it is still affected.
Anyone have any possible reasons for why it could be doing that? Because I'm a little confused?

OS: Windows 8.1
Graphics Card: Integrated (AMD 64Bit processor)
SFML Version: About 2 weeks old from the github

4
SFML projects / Re: Word puzzle game of sorts
« on: August 13, 2014, 10:54:46 am »
Looks a LOT better than my first little toy around with SFML XD ().

I wouldn't include the namespace sf though... It's down to personal preference, but I used to do that and soon got annoyed by the amount of variable names that I couldn't use, Like: "Window", "Text", "Font", "Thread" etc :3

5
Graphics / Re: Program Crashes On Close
« on: July 04, 2014, 03:43:51 pm »
Never mind... I fixed it. The animation class was bugged and was drawing things which shouldn't exist (not entirely sure why but I re-wrote a few things) and causing it to crash.

EDIT: It was trying to draw a pointer to a texture which no longer existed.

Thanks - Cl9.

6
Graphics / [SOLVED] Program Crashes On Close
« on: July 04, 2014, 12:52:48 am »
Hey, recently I've been writing a fairly small game. I wanted to start writing bits of the GUI and so I wrote a small class which just printed out some text, everything was fine and the program ran without errors (this was yesterday I wrote the class), but today however, when the program closes I keep getting a stopped responding message from Windows. I used the debugger and the errors looked like they were related to the sf::Font class and so I just removed two lines which were:
Code: [Select]
    sf::Font font;
    if(!font.loadFromFile("font.ttf"))
        cout << "\nFailed to load a font!" << endl;

Removing these two lines removed all of the errors and the program ran smoothly again. I obviously need text for a GUI and so I'd really like to know what's going on...?

Build Log:
Code: [Select]
-------------- Clean: Debug in Game (compiler: GNU GCC Compiler)---------------

Cleaned "Game - Debug"

-------------- Build: Debug in Game (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -g -Os -std=c++0x -IC:\Users\Name\Desktop\SFML-2.0\include -Iinclude -c C:\Users\Name\Desktop\Game\Game\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LC:\Users\Name\Desktop\SFML-2.0\lib -o bin\Debug\Game.exe obj\Debug\main.o   -lsfml-system -lsfml-window -lsfml-graphics -lsfml-network -lsfml-audio
Output file is bin\Debug\Game.exe with size 804.23 KB
Process terminated with status 0 (0 minute(s), 11 second(s))
0 error(s), 0 warning(s) (0 minute(s), 11 second(s))


Debugger Log:

Code: [Select]
#0 669A1D1B FT_Done_Library() (C:\WINDOWS\SysWOW64\sfml-graphics-2.dll:??)
#1 669AA61C FT_Done_FreeType() (C:\WINDOWS\SysWOW64\sfml-graphics-2.dll:??)
#2 66981CE4 sf::Font::cleanup() () (C:\WINDOWS\SysWOW64\sfml-graphics-2.dll:??)
#3 0000000B ?? () (??:??)
#4 8F0D76C3 ?? () (??:??)
#5 691C1CFD sf::GlResource::~GlResource() () (C:\WINDOWS\SysWOW64\sfml-window-2.dll:??)
#6 8F0B630A ?? () (??:??)
#7 0028FB58 ?? () (??:??)
#8 00401413 __mingw_CRTStartup() (../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:254)
#9 00401585 mainCRTStartup() (../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:272)


And I get a message from Code::Blocks:
Code: [Select]
Program received signal SIGSEGV, Segmentation fault.

Computer Specs:

OS: Windows 8.1 64Bit
Compiler: GCC MinGW
Graphics Card: AMD Radeon 6600M and 6700M Series, AMD Radeon HD 6520G


The code runs fine appart from the errors, and the text displays. I've tried two different font files,re-downloaded the SFML DLL's, re-downloaded SFML and rebuilt the whole project to no avail.The SFML version I am running is the dynamic pre-compiled MinGW 4.7 version... help...? :3

7
Graphics / Re: Weird texturing issue
« on: February 28, 2014, 07:54:45 pm »
I've fixed the problem thanks, I've fixed the problem by using the setRect() function in the CreateBlock() class... I'm still unsure as to why it happened though thanks :)

8
Graphics / Re: Weird texturing issue
« on: February 27, 2014, 09:12:30 pm »
Unfortunately for some reason... the debugger in the code::blocks IDE does not work with the program, it launches it but the program never starts the GUI. I shall try downloading another debugger and trying that...

9
Graphics / Re: Weird texturing issue
« on: February 27, 2014, 08:58:22 pm »
What can cause problems like this? Should I manually define the rect of the texture?

10
Graphics / Re: Weird texturing issue
« on: February 27, 2014, 08:34:55 pm »
Even whilst disabling the animation code it still does this though?

11
Graphics / Weird texturing issue
« on: February 27, 2014, 05:49:00 pm »
Hey, over the past few days I've been writing a small engine to render blocks to the screen along with lighting but I've encountered a weird bug which causes a block after several animated blocks to become glitched:





I really can't find what's causing the problem and it's annoying me quite a bit...

Here's the source (it's quite messy):

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <fstream>
#include <sstream>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
using namespace std;
int nolight = 0;
//String to int conversion function
int StringToInt(string Number)
{
    return atoi(Number.c_str());
}
//Int to string conversion function
template <typename T>
string IntToString ( T Number )
{
    ostringstream ss;
    ss << Number;
    return ss.str();
}

struct Position //A position struct for handling all variables to do with position
{
    int x = 0, y = 0;
};

struct WindowSettings //A structure for holding window settings such as its name and size
{
    const string windowName = "Test";
    const int Width = 1024; //32 across
    const int Height = 512; //16 up
};


class PlayerClass //The player class for handling the player
{
private:
    int Health = 0; //Player health variable
    int x = 0, y = 0; //Player position variables (x,y)
public:
    void setHealth(int Health); //Setting player health
    int getHealth(); //Getting player health
    void setPosition(Position NewPosition); //Set the players position using position struct.
    Position getPosition(); //Get the players position using position struct
};

void PlayerClass::setHealth(int NewHealth) //Setting player health
{
    Health = NewHealth;
}

int PlayerClass::getHealth() //Getting player health
{
    return Health;
}

Position PlayerClass::getPosition() //Get the players position
{
    Position ReturnValue;
    ReturnValue.x = x;
    ReturnValue.y = y;
    return ReturnValue;
}

void PlayerClass::setPosition(Position NewPosition) //Set the players position
{
    x = NewPosition.x;
    y = NewPosition.y;
}
class MapClass //Class for handling the map, blocks and textures etc.
{
private:
    WindowSettings WINDOW_SETTINGS;
    vector<bool> isVisible; //Decides if a block should be rendered or not
    vector<sf::RectangleShape> Blocks; //A vector to hold the block shapes
    vector<double> heightMap; //A heightmap to decide what height mobs/the player should be on it
    vector<sf::Texture> blockTextures; //A vector for holding block textures
    vector<string> loadedTextures; //A vector containing all loaded textures to prevent them from being loaded multiple times
    vector<int> BlockHeights; //Block heights for heightmap calculation
    vector<int> BlockWidths; //Block widths for heightmap calculation
    vector<int> TextureID; //A reference to the ID of the texture used on a block
    vector<string> TextureFP;
    vector<sf::Clock> AnimationClock;
    vector<sf::Time> AnimationSwitchTime;
    vector<int> animatedBID;
    vector<int> AnimationPhase;
    vector<int> MaxAnimationPhase;
    vector<int> MinAnimationPhase;
    vector<sf::Time> CurrentAnimationTime;
    vector<bool> Animated; //True/false depending on if the block is animated
public:
    sf::RectangleShape *BlockReference(int BlockID);
    int loadTexture(string FileName); //A function for loading textures into memory
    void setVisibility(int BlockID, bool Visible); //Setting a block to render/not render
    int setBlockTexture(string Texturename, int BlockID); //Texture a block
    int createBlock(bool Visibility, string FileName, int Height, int Width, bool Animated, sf::Time AnimationSwitchTime,int StartPhase, int MaxPhase); //Create a new block
    void setBlockPos(int BlockID, Position BlockPosition); //Set a blocks position
    Position getBlockPos(int BlockID); //Return a blocks position in a POSITION structure.
    bool isBlockVisible(int BlockID); //Returns true if a block is visible, false if the block is not
    bool loadMap(string FilePath); //Loads a map automatically, creates all of the blocks, entity's and lights.
    int BlockCount(); //Returns number of loaded blocks
    void updateAnimatedBlocks();
    void reTextureBlocks();
};
int MapClass::BlockCount()
{
    return isVisible.size();
}
sf::RectangleShape *MapClass::BlockReference(int BlockID)
{
    return &Blocks[BlockID];
}
void MapClass::reTextureBlocks()
{
    for(int a = 0; a < (int)Blocks.size(); a++)
    {
        Blocks[a].setTexture(&blockTextures[TextureID[a]]);
    }
}
int MapClass::loadTexture(string FileName) //Load a texture into memory
{
    for(int a = 0; a < (int)loadedTextures.size(); a++)
    {
        if(loadedTextures[a] == FileName)
        {
            return a; //If the texture is already loaded then return that textures ID
        }
    }


    blockTextures.push_back(sf::Texture());
    if (!blockTextures[blockTextures.size()-1].loadFromFile(FileName+".png"))
    {
        cout << "\nCould not load block texture!" << endl;
        blockTextures.pop_back();
        return -1;
    }
    loadedTextures.push_back(FileName);
    for(int a = 0; a < (int)Blocks.size(); a++)
    {
        Blocks[a].setTexture(&blockTextures[TextureID[a]]);
    }
    return blockTextures.size()-1;
}
void MapClass::setVisibility(int BlockID, bool Visible) //Set a blocks visibility to true/false
{
    if(!BlockID > isVisible.size())
    {
        if(Visible)
            isVisible[BlockID] = true;
        else
            isVisible[BlockID] = false;
    }
}

int MapClass::setBlockTexture(string Texture, int BlockID) //Set a blocks texture to something
{
    int TextureID2 = loadTexture(Texture);
    Blocks[BlockID].setTexture(&blockTextures[TextureID2]);
    return TextureID2;
}

Position MapClass::getBlockPos(int BlockID)
{
    Position BP;
    BP.x = Blocks[BlockID].getPosition().x;
    BP.y = Blocks[BlockID].getPosition().y;
    return BP;
}

bool MapClass::isBlockVisible(int BlockID)
{
    if(!isVisible[BlockID])
    {
        return false;
    }
    Position BlockPosT;
    BlockPosT = getBlockPos(BlockID);
    if((BlockPosT.x > WINDOW_SETTINGS.Width && BlockPosT.x > WINDOW_SETTINGS.Width - BlockWidths[BlockID]) || (BlockPosT.x < 0 && BlockPosT.x < Blocks[BlockID].getPosition().x + BlockWidths[BlockID]))
    {
        if((BlockPosT.y > WINDOW_SETTINGS.Height && BlockPosT.y > WINDOW_SETTINGS.Height - BlockHeights[BlockID]) || (BlockPosT.y < 0 && BlockPosT.y < Blocks[BlockID].getPosition().y + BlockHeights[BlockID]))
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }

}

int MapClass::createBlock(bool Visible, string TextureName, int Height, int Width, bool AnimatedS, sf::Time SwapTime,int StartPhase, int MaxPhase) //Create a new block and set its texture
{
    TextureFP.push_back(TextureName);
    TextureID.push_back(0);
    isVisible.push_back(Visible);
    Blocks.push_back(sf::RectangleShape(sf::Vector2f(Height,Width)));
    BlockHeights.push_back(Height);
    BlockWidths.push_back(Width);
    int id = setBlockTexture(TextureName, Blocks.size()-1);
    TextureID[Blocks.size()-1] = id;
    setBlockTexture(TextureName, Blocks.size()-1);
    Animated.push_back(AnimatedS);
    if(AnimatedS == true)
    {
        AnimationClock.push_back(sf::Clock());
        AnimationSwitchTime.push_back(sf::Time(SwapTime));
        CurrentAnimationTime.push_back(sf::Time());
        animatedBID.push_back(Blocks.size()-1);
        AnimationPhase.push_back(0);
        MaxAnimationPhase.push_back(MaxPhase);
        MinAnimationPhase.push_back(StartPhase);
    }
    return Blocks.size()-1;

}

void MapClass::setBlockPos(int BlockID, Position NewPos) //Set a blocks position
{
    Blocks[BlockID].setPosition(NewPos.x, NewPos.y);
}

MapClass Map; //In charge of map management
class LightingClass //Manage block lighting
{
private:
    int lightLevel = 0;
    vector<Position> lightPos;
    vector<int> lightStrengh;
public:
    int getLightLevel();
    void setLightLevel(int Level);
    int calculateLighting(int BlockID);
    void addLight(Position LightPosition, int LightLevel);
};

void LightingClass::addLight(Position LightPos, int LL)
{
    lightPos.push_back(LightPos);
    lightStrengh.push_back(LL);
}
int LightingClass::calculateLighting(int Bid)
{
    int closestLightDistance = 99999999;
    int tempDistance = 0;
    Position blockpos = Map.getBlockPos(Bid);
    int ClosestLightID = 0;

    for(int b = 0; b < (int)lightPos.size(); b++)
    {
        tempDistance = (std::abs(blockpos.x - lightPos[b].x) + std::abs(blockpos.y - lightPos[b].y));
        if(tempDistance < closestLightDistance)
        {
            closestLightDistance = tempDistance;
            ClosestLightID = b;
        }
    }
    if(closestLightDistance <= 128)
    {
        int LightDensity = 0;
        if(closestLightDistance <= 32)
        {
            LightDensity = 120+(lightStrengh[ClosestLightID]*4);
        }
        else if(closestLightDistance <= 64)
        {
            LightDensity = 80+(lightStrengh[ClosestLightID]*4);
        }
        else if(closestLightDistance <= 96)
        {
            LightDensity = 60+(lightStrengh[ClosestLightID]*2);
        }
        else if(closestLightDistance <= 128)
        {
            LightDensity = 40+(lightStrengh[ClosestLightID]*2);
        }
        return LightDensity;
    }
    return 20; //Return a black value by default if the block is not within light range of an object
}
void LightingClass::setLightLevel(int ll)
{
    lightLevel = ll;
}
int LightingClass::getLightLevel()
{
    return lightLevel;
}
LightingClass Lighting; //Handles block lighting
bool MapClass::loadMap(string FilePath)
{
    cout << "\nLoading " << FilePath << "... " << endl;
    ///Load the map file into memory
    ifstream File;
    string Buffer;
    string Line = "";
    vector<string> MapL;
    File.open(FilePath);
    if(File.is_open())
    {
        while(!File.eof()) //While there's data to read. Using eof doesn't matter here
        {
            getline(File, Line); //Get the file line and store it in line
            for(int charPos = 0; charPos < (int)Line.size(); charPos++)
            {
                if(Line[charPos] == ',') //Remove commas and split each into a vector
                {
                    MapL.push_back(Buffer);
                    Buffer = "";
                }
                else
                {
                    Buffer += Line[charPos];
                }


            }
        }
        MapL.push_back(Buffer); //Ensure that last line of the map is processed
        Buffer.clear(); //Clear the buffer
    }
    else
    {
        cout << "\nCould not find map: " << FilePath << endl;
        return false;
    }
    File.close();
    ///Process the map and register any blocks, light-sources or entity's
    bool blocksProcessed = false, lightsProcessed = false, entitysProcessed = false;
    int blockX = 0, blockY = 0; //Current block to create
    string TexturePath = "";
    Position blockpos;
    int bid = 0; //Temporarily stores the block id of a created block for placing
    for(int a = 0; a < (int)MapL.size(); a++)
    {
        if(blocksProcessed == false && lightsProcessed == false) //Load lights onto the screen
        {
                if(MapL[a] == "Blocks:")
                {
                    a++;
                    lightsProcessed = true;
                }
                else if(StringToInt((string)MapL[a]) == 1)
                {
                        int lightx = 0, lighty = 0, intensity = 0;
                        lightx = StringToInt((string)MapL[a+1]);
                        lighty = StringToInt((string)MapL[a+2]);
                        intensity = StringToInt((string)MapL[a+3]);
                        Position lightpos;
                        lightpos.x = lightx;
                        lightpos.y = lighty;
                        Lighting.addLight(lightpos, intensity);
                        a+=3;
                        nolight++;
                }
            }
        if(lightsProcessed == true && blocksProcessed == false) //Loads blocks onto the screen
        {
            sf::Time SwitchTime;
            TexturePath = "";
            blockpos.x = blockX, blockpos.y = blockY;
                switch(StringToInt((string)MapL[a]))
                {
                    case 0: //Air
                        break;
                    case 1: //stone
                        TexturePath = "blocks\\stone";
                        bid = Map.createBlock(true, TexturePath, 32 , 32, false, sf::Time(), 0,0);
                        break;
                    case 2: //water
                        TexturePath = "blocks\\water_still";
                        SwitchTime = sf::milliseconds(100);
                        bid = Map.createBlock(true, TexturePath, 32 , 32, true, SwitchTime, 1,16);
                        break;

                    case 3: //lava
                        TexturePath = "blocks\\lava_still";
                        SwitchTime = sf::milliseconds(100);
                        bid = Map.createBlock(true, TexturePath, 32 , 32, true, SwitchTime, 1,10);
                        break;
                    case 4: //grass
                        TexturePath = "blocks\\grass_side";
                        bid = Map.createBlock(true, TexturePath, 32 , 32, false, sf::Time(), 0,0);
                        break;
                }
            }
            if(TexturePath != "")
            {
                Map.setBlockPos(bid, blockpos);
            }

            blockX += 32;
            if(blockX == 1024)
            {
                blockY += 32;
                blockX = 0;
            }
            if(blockY == 512)
            {
                blockY = 0;
            }
    }
    return true;
}

void MapClass::updateAnimatedBlocks()
{
    for(int a = 0; a < (int)animatedBID.size(); a++)
    {
        CurrentAnimationTime[a] = AnimationClock[a].getElapsedTime();
        if(CurrentAnimationTime[a] >= AnimationSwitchTime[a])
        {
            if(AnimationPhase[a] >= MaxAnimationPhase[a]-1)
            {
                AnimationPhase[a] = MinAnimationPhase[a]-1;
            }
            else
            {
                AnimationPhase[a]++;
            }
            int yloc = AnimationPhase[a] * 32;
            sf::IntRect tsize(0, yloc, 32, 32); //Set the portion of the texture to be visible
            Blocks[animatedBID[a]].setTextureRect(tsize);
            setBlockTexture(TextureFP[animatedBID[a]], animatedBID[a]);
            AnimationClock[a].restart();
        }
    }
}

int main()
{
    PlayerClass Player; //In charge of player functions
    WindowSettings Settings; //Declares a structure containing details about the window

    //Creating our enviroment
    Map.loadMap("map.txt");
    if(nolight != 0)
    {
        for(int a = 0; a < Map.BlockCount(); a++)
        {
            int LightLevel = Lighting.calculateLighting(a);
            sf::RectangleShape& TempBlock = *Map.BlockReference(a);
            sf::Color bc = TempBlock.getFillColor();
            TempBlock.setFillColor(sf::Color(bc.r,bc.g,bc.b, LightLevel));
        }
    }

    sf::RenderWindow window(sf::VideoMode(Settings.Width,Settings.Height), Settings.windowName); //Creating the window
    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event)) //The event loop
        {
            if(event.type == sf::Event::Closed) //if window close button is pressed then:
            {
                window.close();
            }
        }
        window.clear(sf::Color::Black); //Clear the window with a black colour to erase previous frame
        for(int a = 0; a < Map.BlockCount(); a++)
        {
            Map.updateAnimatedBlocks();
            sf::RectangleShape &blockToDraw = *Map.BlockReference(a);
            window.draw(blockToDraw);
        }
        window.display(); //Finally display the window
    }
    return 0;
}

[/code=cpp]

The map file looks like this:

[code]
Blocks:,
2,2,2,2,2,2,2,4,4,4,4,4,4,
END_OF_FILE,
 

What's causing this?
Any help is appreciated - Cl9.

12
Network / Re: Which is faster?
« on: January 02, 2014, 08:43:00 pm »
And what if you don't know how many things you'll have to send?
Such as a map, made up of tiles, which can be varying sizes?

Btw, great book on SFML :D

13
Network / Which is faster?
« on: January 02, 2014, 08:19:35 pm »
I've got a question, which would be faster if I wanted to send a client its inventory which is made up of an array of integer item id's server wise:

Convert the integers into strings, and put them all into the same string seperated by commas, and then send the whole string in one packet to the client to be seperated back into individual item id's like so:

Code: [Select]
int Inventory[10] = {0,1,2,3,4,5,6,2,1};
*send each integer seperately*

or:

Code: [Select]
int Inventory[10] = {0,1,2,3,4,5,6,2,1};
*convert into strings*
string Result = "0,1,2,3,4,5,6,2,1";
*send in one packet instead of 10*

Which of these has the best performance?
Or is there a faster way?

14
Graphics / Re: Weird lines in particle test
« on: December 01, 2013, 10:24:36 pm »
Thankyou for your help everyone :D

Do I have to add the +0.5f after every movement or is there a quicker way of doing it?

Here's what I have now which works great:
Code: [Select]
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
using namespace std;
sf::Vector2f Randomize(int Boundary1, int Boundary2)
{
    srand(time(NULL));
    return sf::Vector2f((0 +((rand() % Boundary1))), (0 +((rand() % Boundary2))));
}

int RandomizeInt(int Boundary1, int Boundary2)
{
    return (Boundary1 +((rand() % Boundary2)));
}

struct PI
{
    sf::Color Colour = sf::Color::Yellow;
    int X = 0;
    int Y = 0;
    int LifeTime = 20000;
};

int main()
{
    int FPS = 0; //Setting up variables for measuring the FPS
    sf::Clock FPSClock;
    sf::Time FPSTime;

sf::Music music;
if (!music.openFromFile("sound.ogg"))
    return -1; // error
music.play();



    bool MousePressed = false;
    sf::Clock EffectClock;
    sf::Time EffectTime;

    int ActiveParticles = 0; //How many particles are active

    int ParticleCap = 0; //The limit of how many particles can be placed
    cout << "\nParticle Cap: ";
    cin >> ParticleCap;

    PI ParticleInfo[ParticleCap]; //Our particle information such as colour and lifetime.

    sf::VertexArray Pixel(sf::Points, ParticleCap);

    sf::RenderWindow window(sf::VideoMode(800, 600), "Partical System", sf::Style::Default);
    window.setVerticalSyncEnabled(true);

    while (window.isOpen())
    {
        sf::Vector2i MousePosition = sf::Mouse::getPosition(window); //Storing mouse coords for later use

        if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && MousePressed == false) //Checking if mouse is pressed
        {
            for(int a = 0; a < ParticleCap; a++) //Updating particle information
            {
                Pixel[a].position = sf::Vector2f(MousePosition.x+0.5f,MousePosition.y+0.5f);
                ParticleInfo[a].X = MousePosition.x+0.5f;
                ParticleInfo[a].Y = MousePosition.y+0.5f;
            }
            MousePressed = true;

            EffectClock.restart();
        }
        else if(!sf::Mouse::isButtonPressed(sf::Mouse::Left) && MousePressed == true)
        {
            MousePressed = false;
        }

        sf::Event event; //Polling window events to check for user input
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        EffectTime = EffectClock.getElapsedTime();
        for(int a = 0; a < ParticleCap; a++) //Updating particle information
        {

            ParticleInfo[a].LifeTime = RandomizeInt(0,40);
            ParticleInfo[a].X = ParticleInfo[a].X + RandomizeInt(0,6) - 3;
            ParticleInfo[a].Y = ParticleInfo[a].Y + RandomizeInt(0,6) - 3;
            Pixel[a].color = ParticleInfo[a].Colour;
            if(EffectTime.asMilliseconds() > ParticleInfo[a].LifeTime)
            {
                //Pixel[a].position = sf::Vector2f(-1,-1);
                ParticleInfo[a].X = MousePosition.x;
                ParticleInfo[a].Y = MousePosition.y;
                Pixel[a].position = sf::Vector2f(ParticleInfo[a].X+0.5f, ParticleInfo[a].Y+0.5f);
                EffectClock.restart();
            }
            else
            {
                Pixel[a].position = sf::Vector2f(ParticleInfo[a].X+0.5f, (ParticleInfo[a].Y - 6)+0.5f);
                ParticleInfo[a].Y = (ParticleInfo[a].Y - 6)+0.5f;
            }
        }


        window.clear(sf::Color::Black);
        window.draw(Pixel);
        window.display();


        FPS++; //Calculating FPS and displaying it
        FPSTime = FPSClock.getElapsedTime();
        if(FPSTime.asSeconds() >= 1)
        {
            cout << "\nFPS: " << FPS << endl;
            FPSClock.restart();
            FPS = 0;
        }
    }

    return 0;
}

Thanks, and sorry for the late replies... I've been filling in college application forms...

15
Graphics / Re: Weird lines in particle test
« on: December 01, 2013, 09:59:41 pm »
It is a completely white screen if I do that.

Pages: [1] 2
anything