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

Pages: [1]
1
Graphics / Laggs when drawing.
« on: December 17, 2012, 09:26:23 pm »
So I'm working on a 2D game and right now I have a problem with drawing out my tiles. It laggs terribly and I don't really know what to do about it.

I got a set of tiles:  Tile * tiles[32][32];

   
for(int i = 0; i < 32; i++)
        {
                for(int j = 0; j < 32; j++)
                {
                        if(tile[j][i]->getPosition().x > (cameraCenter.x-cx-tss) &&
                                tile[j][i]->getPosition().x < (cameraCenter.x+cx+tss) &&
                                tile[j][i]->getPosition().y > (cameraCenter.y-cy-tss) &&
                                tile[j][i]->getPosition().y < (cameraCenter.y+cy+tss)){
                                        renderWindow.draw(tile[j][i]->sprite);
                        }
                }
        }

This is my code when I draw it.

Now I tried drawing when my Tiles wasn't pointer and I had no lagg.

Is there a reason why this is ?

And is there someone who can give some pointers to one that is new in both c++ and SFML.

If you need more of anything, just ask.
Thanks

2
General / Stuttery Movement - Need help making it smooth.
« on: November 04, 2012, 04:36:16 pm »
Hi,
I'm currently working on SFML 2.0 project where you control a rectangle that is moving around on a playing field.
The problem I'm having right now is that the movement is very stuttery and inconsistent.

I'll try to copy in some code so you can see what I've done.

This is from my game class, I've taken away the non essential parts.
void Game::GameLoop()
{      
        sf::Event currentEvent;
        while(_mainWindow.pollEvent(currentEvent))
        {
                switch(_gameState)
                {

                case Game::Playing:
                        {
                                player.Update(_mainWindow, currentEvent);
                                break;
                        }
                }
        }
}

This is in my player class:

void Player::Update(sf::RenderWindow& mW, sf::Event Event)
{
        _Event = Event;
        Move(mW);
}
void Player::Move(sf::RenderWindow& mW)
{
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
                _sprite.move(-5, 0);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
                _sprite.move(5,0);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
                _sprite.move(0, -5);
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
                _sprite.move(0, 5);
}

So I've figured out what some of the problems are, when using isKeyPressed there is a natural short"pause" right after I press the key and then it goes smooth. Is there anyway I can get rid of this ?
And also while holding down 2 keys, up and left for example, it seems like it going alot faster, like it's calling the Update twice and therefor calling the Move twice and therefor updating the position twice as fast.

This is my first time using SFML and I havn't been using C++ for that long either, I started coding in C# and XNA.

Anyways, any help and/or input is appreciated!

BR,
Fredrik

3
General / Re: Project can't find main function after changing computer.
« on: October 26, 2012, 10:05:44 am »
Thanks for answering. Will change to SFML 2.0!

4
General / Re: Project can't find main function after changing computer.
« on: October 26, 2012, 09:59:41 am »
At home it's a GTX 470.
At school it's something in the Radeon 7800 series.

5
General / Re: Project can't find main function after changing computer.
« on: October 26, 2012, 09:54:04 am »
The resolution of the program is 1024x768 and the resolution on both my computers are 1920x1080.

This is my main function.

#include "stdafx.h"
#include "Game.h"

int main()
{
        HWND hwnd = GetConsoleWindow();
    ShowWindow(hwnd, 0);

        Game::Start();
 
        return 0;

}

6
General / Project can't find main function after changing computer.
« on: October 26, 2012, 09:46:06 am »
So I currently work on a project in school using sfml. So I use two different computers to do this, but my project is in a dropbox folder on both computers so I ain't altering any of the files when I switch computers.

Anyways, to the problem. When I worked from home this morning it worked perfectly fine and when I was finished I updated the project in my db folder. Now when I got to school and try to start the exact same program all I get is a console window instead of the sfml game.

I'm using Visual Studios Ultimate 2010 C++.
With sfml 1.6 (this is due to a tutorial I choose to follow to get me started).

Any help is appreciated.
BR, Fredrik

Pages: [1]
anything