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

Pages: 1 ... 10 11 [12] 13 14
166
General / Re: Slow performance with A*
« on: June 26, 2015, 07:18:29 pm »

Thanks for taking the time to help me with this. I worry that I might just be trying something too complicated for my current skillset. I'll probably keep at this for a few more days, but if I can't get it working, I'll move onto something simpler.

You can try something easier to debug instead of something simpler.

Example, select an arbitrary position (X,Y) , and the apply path finding when X time had passed.

Example:

extern const int TILESIZE = 32 ;
extern const int MAPSIZE = 11;

#include <SFML/Graphics.hpp>
#include "Tile.h"
#include "Layer.h"
#include "CollisionLayer.h"
#include "Cursor.h"
#include "EventHandler.h"
#include "Unit.h"
#include "Units.h"
#include "Path.h"

#define NOT !
#define AND &&
// Auxiliary MACROS.

int main()
{  
    sf::RenderWindow window( sf::VideoMode( 640 , 480 ) , "Joyous Day!" ) ;
    sf::Clock myTimer ;

    Layer testLayer( MAPSIZE , MAPSIZE ) ;
    Cursor testCursor ;

    auto testObj = testLayer.getTileVector() ;
    Path testPath( testObj[9][9] , testObj[1][2] ) ; //This is the creation of the path object, it takes in an origin and a destination tile.  
    std::vector<Tile> path = testPath.findPath( testLayer ) ; //The findPath function does most of the work. It works for the example tiles
   
    bool timeCompleted = false ;
    int timeToReach = 3 ; // 3 seconds.
    float Xpos ; // = insert a number
    float Ypos ; // = insert a number
    double _TILESIZE = 1/TILESIZE ; // To use multiplication.
   
    // Main loop.
    while ( window.isOpen() )
    {  
        // Events section.

        sf::Event event ;

        while ( window.pollEvent( event ) )
        {
            if ( event.type == sf::Event::Closed )
                window.close() ;
        }
       
        // Path finding section.

            if ( NOT timeCompleted AND myTimer.getElapsedTime().asSeconds() >= timeToReach ) // Only will be executed ONCE (is easier to debug)
            {
                timeCompleted = true ; // Set false to ensure that this block won't be execute anymore.

                testCursor.shape.move( TILESIZE , 0 ) ; // I don't know what happens here...
               
                auto myTileVector = testLayer.getTileVector() ;
                 
                testPath.setPath( myTileVector[5][5] , myTileVector[ Xpos * _TILESIZE ][ Ypos * _TILESIZE ] ) ;

                path = testPath.findPath( testLayer ) ;
               
            }

        // Draw section.
         
        window.clear() ;

        for ( auto &pathTile : path )
        {  
                MyShape = pathTile.getShape() ;  
            MyShape.setFillColor( sf::Color( 255 , 0 , 0 , 128 ) ) ;
            window.draw( MyShape ) ;
        }
       
        testLayer.drawLayer( window ) ;
        testCursor.drawCursor( window ) ;

        window.display() ;

    } // end of MAIN LOOP


    return 0 ; // End of process.
}
 

167
General / Re: Slow performance with A*
« on: June 25, 2015, 07:27:13 pm »
Hi everyone,
I am having a problem with slowdown in a project of mine. I am trying to get a basic AStar implementation going, finding a path from a tile to another. At this point I have it working if I create the path outside of the 'while(window.isOpen())' loop, but if I put it inside, even under a keypress conditional, I get a lot of slowdown.
This makes me think there is some issue with something being done too many times, but I've gone over all the relevant code and a ton of websites and I can't find anything. Even stranger, when I uncomment the code in the keypress conditional, it does nothing, then on the second press finds a path to the cursor, then on any other presses does nothing again. All pretty slowly, of course.

Hoping you guys can help point me in the right direction.
Here is the main code, pared down as much as I can:

extern const int TILESIZE = 32;

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && testCursor.shape.getPosition().x < testLayer.width * TILESIZE - TILESIZE)
                {
                        if (!rightPressed)
                        {
                                testCursor.shape.move(TILESIZE, 0);
                               
                                /*
                                This is where I'm having the issues, when uncommented, these lines cause a ton of slowdown.

                                testPath.setPath(testLayer.getTileVector()[5][5], testLayer.getTileVector()[(testCursor.shape.getPosition().x / TILESIZE)][(testCursor.shape.getPosition().y / TILESIZE)]);
                                path = testPath.findPath(testLayer);
                                */
)

                                rightPressed = true;
                        }
                }
                else
                {
                        rightPressed = false;
                }
               

 

I think i can help:

1) Diminish the calls
Use:
sf::Vector2f myPos = testCursor.shape.getPosition()
and pass myPos.x and myPos.y
Instead of calling twice for X and Y coordinates.
(Your code is bloated of twice-calls only for obtain X and Y axis )
2) Path finding (A*) is expensive, if for some reason your rightPressed turns false testPath.findPath(testLayer) will be called several times because sf::Keyboard::isKeyPressed() will return true several times even if you tap fast the Right key.
3)Use multiplication insted of division when possible, multiplication is faster.

168
Graphics / Re: using VertexArray, am i rigth??
« on: June 19, 2015, 01:35:42 am »
As Hapax said VertexArray is for reduce the calls to one for drawing a group of primitives.

The best method could be:


void Menu::draw (RenderTarget &target, RenderStates states) const
{
        states.texture = &sprite_sheet ;  
        target.draw ( vertexArray , states);
}

 

You can fuse multiple textures in a single sprite sheet , set the primitive type of the VertexArray sf::Quads.
The tutorial and the reference page explain how to apply the sprites and texture coordinates to the primitives.

If you don't understand well the tutorial , you can contact me for PM.

169
SFML projects / Re: Particle System!
« on: June 16, 2015, 08:27:30 pm »
If it provides no advantages over Thor Particles, then why reinvent the wheel instead of just using what is already available?

As same i said before, i can´t compare, i haven´t used/saw Thor´s particles.
As far as i know there is no images/videos of Thor. If someone show me examples... ::)

I don't want to discuss more about reinventing the wheel/ thor particles vs my particles etc...

I only want yo show this, and know the community's reviews ( is bad/good ,what need what left etc) about what I did.

170
SFML projects / Re: Un-named Engine (Updated: 6/9/2015)
« on: June 16, 2015, 12:51:37 am »
Great to see someone creating another game engine. (I so good for the community)
Indeed, yet another unfinished game engine is exactly what the world has waited for ;D
(Sorry, could not resist ;))
Nexus being Nexus...
Well, he's not exactly alone in thinking that you should write games, not engines... And I, for one, tend to agree.

I don't know others, i'm making my engine not for make a game when finished, i made to give options to the community. Is this bad?.

171
SFML projects / Re: Particle System!
« on: June 16, 2015, 12:48:35 am »
Images look nice enough, but why would I use this instead of Thor Particles? :
 http://www.bromeon.ch/libraries/thor/v2.0/doc/group___particles.html
 http://www.bromeon.ch/libraries/thor/v2.0/tutorial-particles.html
Honest question. I'm currently using Thor's particle module and it works well - why would I want to switch?

I made it not for replace thor´s particles engine.  Its just another option. And, i have no images/videos for thor´s particles so i actually can´t comparate it, but comming by Nexus (bromeon) i imagine that is a great quality particles engine.

The main purpose of its creations it´s only use it in my game engine. If other(s) wants to use it great.

172
SFML projects / Re: Un-named Engine (Updated: 6/9/2015)
« on: June 15, 2015, 12:02:36 am »
Great to see someone creating another game engine. (I so good for the community)
Indeed, yet another unfinished game engine is exactly what the world has waited for ;D
(Sorry, could not resist ;))

Nexus being Nexus...


Depending on what you plan to do, you could use existing SFML extension libraries such as FeatherKit, Thor, Let There Be Light, etc. instead of reinventing the wheel. You can still write your own abstractions on top.


Theres is others Lua Game engines projects abandoned here, for this reason i´m making one i. And cover all the needs posible. I will provide a good-execellent API, well docs and examples, maintian the projects, if someone want to colaborate with the project is wellcome.

And looking around how Thor can help in the project cause i will use LTBL to the shaders , i´m thinking include the module of Input (for joystick) , Math and Shapes.

173
General / Re: Opening and closing fraps causes program to crash.
« on: June 14, 2015, 03:51:42 am »
When you gonna close FRAPS it will advice you if you are sure to unload the program...
But you even can turn off the fps benchmark. (The program has several options as you know)

174
SFML projects / Re: Un-named Engine (Updated: 6/9/2015)
« on: June 13, 2015, 09:29:30 pm »
Great to see someone creating another game engine. (I so good for the community)
I like RPG's too.

I'm too creating a game engine with SFML/C++/Lua.

And yes, SFML made simple almost all the things that it have?

What about the physics? You didn't mention that, but is better build part by part and no few of this few of that.

Keep going  ;).

175
SFML projects / Particle System!
« on: June 13, 2015, 08:50:26 pm »
This is a particle system written in pure c++/sfml by me.
It'll be used on my lua game engine. (Will have 2 particle system, the two have "physics" but the first won't interact will Box2D/LiquidFun objects, and the second will).

Particles can have a lot of behaviors by setting severals params.
About the perfomace can move 4000 particles with a framerate at 2,250+ fps ; 

If someone are interested on the source code can contact me, you can use my particle system in yours games too.

I'll append some images link. Jope you like it.

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391062effect01.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391064effect02.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391072effect3.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391065effect4.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391067effect5.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391068effect6.png

http://www.subirimagenes.com/imagedata.php?url=http://s2.subirimagenes.com/imagen/9391073effect7.png

176
Graphics / Re: C++ SFML 2.2 vectors
« on: June 08, 2015, 06:08:04 pm »

[/code]


This is the testObject.h class

#pragma once

#include "entity.h"

class testObject : public Entity
{
public:
    testObject();
    void Initialize();
    void Render(sf::RenderWindow window, std::vector<sf::Sprite> sprites);
    void Update();
private:
    sf::RenderWindow window;
};



You can't copy a renderWindow class in function Render, try giving a pointer instead copying an object.
I Believe...

Try this.

    void Render(sf::RenderWindow *window, std::vector<sf::Sprite> sprites);
 

177
when you do this

sf::RenderTexture myTexture ;
myTexture.loadFromFile( "image.png" )

// you can do that:

if ( !myTexture.loadFromFile( "image.png" ) )
   //error or whatever you want.
  // loadFromFile can fail for several reasons, one of this reasons can be there is no more vram.
 

178
Graphics / Re: sfml background lagging
« on: June 01, 2015, 07:24:34 pm »
If you dont post details of what you call "lagging" few we can do bro,

179
Graphics / Re: q: how to use the sf:view correctly?
« on: June 01, 2015, 07:06:50 pm »
you need to consider "view" as a diferent window.

First , in the window localize the point: middle_x , middle_y , then draw a rectangle with the size WINDOW_X_LENGTH, WINDOW_Y_LENGTH - 50 and put the center of this rectagle in middle_x , middle_y and that its your new window.

suposse this example:

window size( 800 , 650 ) ( 800 , 650 - 50 = 800 , 600 view size ) 
image size ( 1440 , 660 )
center of the image (  720 , 330 ) ( center of the view )
And mi profile avatar rendered with the view. ( positionated in 0,0 )

See attachment.

180
Well if fraps tells you that you got low fps, it's certainly that there is a problem with your gpu-side work. In particular when you're doing nothing else than display.
Which means it have nothing to do with C++ or lua....

This are not low fps because there are displaying 1000 crates (512x512) each one.

My pc have i7 4th generation and a max CPU frequency of 3 ghz.

With a regular game i get (with no frame limit)  1400-1700.

Pages: 1 ... 10 11 [12] 13 14
anything