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

Pages: [1]
1
General / Re: How do i make enemy move by found shortest path?
« on: December 22, 2014, 02:25:38 pm »
Yeah, my english isn't that good to communicate so it's hard for me to ask good questions.
My main problem is/was that, i needed to have a position of each tile from bfs algorithm. In vertex array tutorials there is TileMap example it has "width" and "height" of array. When i have my path i need to get position of each tile, but i didn't have an idea how.
I am thinking about doing something like:

actuallTileNumber/width * tileSize.x = position.x and
actuallTileNumber/height * tileSize.y = position.y
then i just move sprite to the certain position, and get next tile.

I'm not really sure if it is correct and not sure if it would work, i can't test it now.

2
General / Re: How do i make enemy move by found shortest path?
« on: December 22, 2014, 01:09:54 pm »
You didn't understand m. I'm not asking for code, BFS searches through the map and finds shortest path. I know how to make circles/sprites move, but i don't know how to make a sprite move from tile 285->284->283.. and so on to some point. I'm asking for tips, not for code.

3
General / How do i make enemy move by found shortest path?
« on: December 22, 2014, 11:53:02 am »
Hello, i made a BFS algorithm, it finds shortest path. My map is represented as TileMap from Vertex tutorial.
So when i have path, how do i make someone move by it? My tilemap is 1d array.
My BFS code is (don't know if u actually need this):
void GraphFinder::shortestPath(int s, int e)
{
    std::queue<int> q;
        int v;
        bool found = false;
        bool *visited = new bool[414]; //414 is amount of tiles
        int *path = new int[414]; //414 is amount of tiles

        for(int i = 0; i < 414; ++i) //414 is amount of tiles
                visited[i] = false;

        path[s] = -1;

        q.push(s);
        visited[s] = true;

        while(!q.empty())
        {
                v = q.front();
                q.pop();
                if(v == e)
                {
                        found = true;
                        break;
                }
                for(auto i = adjList[v].begin(); i != adjList[v].end(); ++i)
                {
                        int u = *i;
                        if(!visited[u])
                        {
                                path[u] = v;
                                q.push(u);
                                visited[u] = true;
                        }
                }
        }
        if(!found) std::cout << "Way not found" << std::endl;
                else
        while(v > -1)
        {
                std::cout << v << std::endl;
                v = path[v];
        }
        while(!q.empty()) q.pop();
        delete [] path;
        delete [] visited;
}
 
I'm using SFML 2.1

4
Graphics / Why it doesn't draw?
« on: November 09, 2014, 11:23:24 pm »
My draw function doesn't work but i've got no compiler errors, i used debugger but it didn't help me(everythink seems fine), so i'm here to ask u why it doesn't actually draw
I've set the position of sprite, and texture. My draw function is:
void Player::render(sf::RenderWindow &window)
{
        window.draw(player);
}
 
but it actually doesn't show anything (yes, i have it in my game loop).
May be this because of textures are .bmp files? I've used .bmp files and everything was okay but now i don't know why it just doesn't draw.
It just seems like anything that i do with sprite isn't working, dunno why.
I know that because i made an circle and set this position to player position but i couldn't even move the sprite position (sprite is a player).
My render function in gameLoop is:
void Game::render()
{
        mWindow.clear();
        player.render(mWindow);
        mWindow.display();
}
 

Sorry for my bad english.

5
General / Looking for tips to improve my code
« on: September 22, 2014, 04:55:25 pm »
Hello. I am programming in SFML 2.0 for some time and i'd like you to give me some tips on improving my code overall. I made an Arkanoid clone.

Menu_State.h - main menu: http://pastebin.com/YVCrkiYg
Menu_State.cpp -  http://pastebin.com/x5rUZJU8

PlayGame_State.h - while playing: http://pastebin.com/ka7FGQ5y
PlayGame_State.cpp -  http://pastebin.com/vvRJ7Jpx

GameState.h - enum with game states: http://pastebin.com/bFEe8JXf

6
General / isKeyHold for some time
« on: September 14, 2014, 08:22:04 pm »
Hello. First of all i wanna say that, my english is not my native language so i may make many mistakes.

Ok, i have no idea how should i check if key was hold for some time, i mean i press space and i wanna to know if it was hold for some time or released, how am i supposed do that?

Pages: [1]
anything