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

Pages: [1] 2
1
SFML projects / RPG prototype
« on: June 09, 2021, 08:20:49 pm »
Good afternoon, I have been working on the project since the last days of March approx. The project consists of doing a little RPG prototype, so the game is a 2D top-down RPG inspired by the old Final Fantasy games (from I to VI).

What could we do in the prototype?

The basic idea of the prototype is that the player controls a character who moves in a grid-based movement. The world in that the character lives has towns, castles, dungeons... and an overworld. Towns are where the character can buy items, weapons, can learn new spells, can talk to NPCs, can rest in an inn... In the overworld and dungeons, the hero fights with different enemies. The fights start when the character is moving (that's random) and a battle screen is displayed in order to perform it in a turn-based system (Well, the typical Final Fantasy games).

What have I achieved?

For the moment I have been building the basics of a game engine (game loop, resource management, game states management). Also I can display a "map" using a tileset and I can move the character in a smooth grid-based movement with animation.



Why are you doing this project?

I have different reasons that have motivated me to start this project:
  • I always wanted to do my own RPG after I have played the old Final Fantasy games, that I love them and I have replayed them a lot of times.
  • I want to improve my coding skills and be better at structuring software projects.
  • Having a project is always better in a portfolio than nothing.

I will keep this thread updated when I add new features to the prototype  :)

Finally, you can follow me on Twitter: https://twitter.com/alazaro92 to get new updates or in my blog (https://lazaro92.github.io), that I have to write more in it.

2
General / Re: Project Files Organization
« on: May 28, 2021, 06:57:59 pm »
Well, the question is more about how people organize the source code in their projects... If they follow any rules.

3
General / Project Files Organization
« on: May 27, 2021, 07:19:06 pm »
Good afternoon,

I am doing a game with SFML and now I'm doing some refactoring. I have a doubt about how to organize the files. Currently, I have the source files in the Source folder and the headers in the Header folder, but there will be more files in the future so I want to do some tidying.

For example, I have moved the source files for the GUI in Source/UI and the headers in Headers/UI, where I put files like Label, Button, Container...

I have navigated through some projects in Github and I see that people tend to put all files in Header/Source folder without subfolders.

My idea is to have an easy to uderstand project and try to make a clean project.

4
General / Re: Help with tile based movement
« on: May 25, 2021, 08:25:32 pm »
    At the end I solved it!



So from the Player class I send a command which contains the direction to go (left, right, upper, down) and then the Ncp changes his status from wait to move, performing one step in the received direction. Then it goes to the destination tile and changes the state to wait (state which accepts the input).

For the tile move from tile to tile I use the lerp function that I have programmed, where the params are:
  • The origin position
: The center of the origin tile.
  • The destination position
: The center of the destination tile.[/li]
[li]dt: the time it has passed (value in the range of (0,1])[/li]
[/list]

float Npc::lerp(float origin, float dest, float dt)
{
    return origin + dt * (dest - origin);
}

Now the idea is to animate the Npc sprite using a class Animation  that I have in progress, but first I have to do some refactor  :P

5
General / Help with tile based movement
« on: May 20, 2021, 07:54:08 pm »
Good afternoon,

First I have to say that I have been trying to implement the SMOOTH tile-based movement for five days (I'm trying to add it using clean code).

For the moment, I have implemented a "teleportation movement" where the sprite moves to the next (up, down, left or right) tile without walking, so it goes 16px automatically. When I say next, if I maintain pressed the button it can be more than one tile. Here goes the GIF:



This is done in the GameState, that represents the state where the game occurs. The most important classes are:
Source/World:  this contains the elements that you see on the screen: the NPCs (for the moment one).
Source/TileMap: this builds and renders the tilemap that you see in the gif.
Source/Npc: this is the guy you see on the image.
Source/Player: this sends the Player output to the Npc via a command Queue.

Github: https://github.com/lazaro92/fantasy-maker/tree/develop

My idea to implement the smooth movement is to move the npc via the Player class, in the Player NpcMover struct. While I move the player, in the World class I would like to check if the movement has been completed (so the npc has moved all the exact16px, not one less or more).

Do you have any ideas or examples of a smooth tile-based movement? It would help me a lot :)

----------------

After I implement the movement, I will start with collision detection, so the idea after movement will be that if I press a key, before the Npc starts to move the system will check if the destination tile is available to move in.

6
Graphics / Re: TileMap: array of sprites vs vertexArray
« on: May 04, 2021, 09:08:13 pm »
I want to render only what is viewed in the view, the first thing I need is to obtain the left top pixel of the current visualization, in order to get first tile that I want to draw. How can I obtain this pixel? I have been looking the View wiki and didn't found anything.

----- EDIT

I'm looking the tutorials and I see that you can define the Viewport, setting a FloatRect with left, top, witdh and height parameters.

So I have to get the viewport from the current view and get the x and y attributes. This would work if viewport is defined with pixels, not with relative position to the window.

I'm lost at this point.

7
Graphics / Re: Sprite Efficiency
« on: May 03, 2021, 07:44:10 pm »
Hi,

it must be strange that an old post receives a new comment. I'm designing the tilemap for the game and I wanted to know what did you implement at the end: Did you used a tileset based on an array of sprites or did you build it with a VertexArray?

8
Graphics / Re: TileMap: array of sprites vs vertexArray
« on: May 03, 2021, 07:37:49 pm »
Thanks a lot, Stauricus!

For the second point, I can use one texture that is the atlas and set the corresponding sprite to the tiles by an index in the int array that represents the map.

I will try to make or find an algorithm to draw only what is viewed in the viewport. I will try to do it with the VertexArray instead of with tiles.


kojack, I don't want to use a shader for this. I think there are other options before that.

9
Graphics / TileMap: array of sprites vs vertexArray
« on: May 02, 2021, 09:15:21 pm »
Hi,
I'm doing a videogame (or I'm trying to do  :P) that renders a top-down map based on tiles. I had followed the guides and I saw that there is an example that used a vertex array for displaying a map and I had implemented it, but now, before I proceed further, I want to make the correct decisions for the design of the game.

I have been reading some posts related to this topic and I have extracted the next points:

  • So first, Sprites are lightweight objects, so it does not represent a noticeable difference.
  • With VertexArray, the tiles are in a single entity and it does only a draw call, but with the sprite array it makes a draw call per tile. Performance depends on the number of calls to the draw function.
  • With vertexArray, the tiles are static, so they can't change and with sprite array, you can animate them (for example the typical tiles of sea that simulates waves.)
  • With vertexArray, I can draw a map larger than the view, and it does not affect performance. With the tiles, I should only render the tiles that are visible in the view.

Are the points correct? I'm missing something?

For the moment I'm using VertexArray for displaying a 64x128 tiled map, where tiles are 16x16 pixels and the view is 256*224 pixels (SNES resolution).

10
I knew it would be a stupid question. The problem is that I'm passing width for the width param and also for the height param, so ii's adding extra data to the vertex array. I didn't see it.

mTileMap.load(texture, TILE_SIZE, mLevel, tileMapWidth, tileMapWidth);
                                                                                 this is height param ----^

This thread can be deleted. Or it can help other people. I don't know.

11
I have updated the code and I will check what mLucas is saying...

12
Good afternoon,

I have found an strange behaviour (sure it's a stupid question) but I was doing a tileMap for my game following the SFML example https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-tile-map and the result is:



(This is the good image - the tilemap is smaller than the screen, so it displays the black space)

The int array is created in the buildScene function of class world and passed to the tilemap in the same function.

The problem is that if I create the array in the header file it shows more sprites than normal.



Also, I had changed the c style array to a std::vector that is created in the header and filled in the constructor and it gives the same problem.

Do you know what is happening?

PD printing the array in World::buildScene and TileMap::load gives the same array.

buildScene
1 1 1 1 1 1 1 1 1 1 1 1 1 33 33 291 1 1 1 1 1 1 1 1 1 65 101 99 1 1 32 1 289 1 1 1 1 65 67 1 1 1 1 1 1 1 1 1 0 65 67 1 1 32 32 32 32 1 1 1 1 65 67 1 1 32 1 1 10 11 1 1 1 97 99 1 1 32 32 1 42 43 1 1 1 1 1 1 1 230 231 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 
TileMap::load
1 1 1 1 1 1 1 1 1 1 1 1 1 33 33 291 1 1 1 1 1 1 1 1 1 65 101 99 1 1 32 1 289 1 1 1 1 65 67 1 1 1 1 1 1 1 1 1 0 65 67 1 1 32 32 32 32 1 1 1 1 65 67 1 1 32 1 1 10 11 1 1 1 97 99 1 1 32 32 1 42 43 1 1 1 1 1 1 1 230 231 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1


------------------------

header file: https://github.com/lazaro92/fantasy-maker/blob/feature/1/Include/Book/World.hpp
src file: https://github.com/lazaro92/fantasy-maker/blob/feature/1/Source/World.cpp

13
General discussions / Re: Setting Frame Limit of the project
« on: December 21, 2019, 08:32:23 pm »
I have seen the code of setFrameRateLimit:

void Window::setFramerateLimit(unsigned int limit)
{
    if (limit > 0)
        m_frameTimeLimit = seconds(1.f / limit);
    else
        m_frameTimeLimit = Time::Zero;
}
 

Can I combine it with my game loop? so before the loop starts I set the frame rate to 60 and then the loop is executed.

I don't know if, after the display is executed and the process goes to sleep, the time of clock is counting.

14
General discussions / Re: Setting Frame Limit of the project
« on: December 04, 2019, 07:28:38 pm »
Hi I skipped the loop problem to focus on the book, and now that I had advanced more I want to solve the loop problem because I don't want to burn my computer every time I'm executing my code for testing.

I want to use standard sleep, so in the main loop I have to write the sleep at the end of the outer loop? How many time it has to be sleeping?

void Game::run()
{
    sf::Clock clock;
    sf::Time timeSinceLastUpdate = sf::Time::Zero;

    while(mWindow.isOpen())
    {
        processEvents();

        timeSinceLastUpdate += clock.restart();
       
        // collects the user input and computes the game logic.
        while (timeSinceLastUpdate > TimePerFrame)
        {
            timeSinceLastUpdate -= TimePerFrame;
            processEvents();
            update(TimePerFrame);    
        }        
        render();
        <- here goes sleep ?
    }
}
 

If you see the video of above in this thread, you will see what type of game I want to do, so for this game I don't think it is necessary that the computer is working at 100% of cpu

15
General / SFML, how to learn it
« on: October 06, 2019, 06:51:20 pm »
Hi, I'm beginner with SFML, I have done the Angry bird Udemy tutorial (https://www.udemy.com/course/flappy-bird-sfml/) and now I'm reading the book "SFML Game Development".

MY problem is that I'm learning in my free time, and I doing my don't have a lot of free time. Before buying the book I was doing an RPG project, but after I get the book I'm doing the book project and my progress is slow.

What do you recommend: to read the book and continue with my main project or read the book, make the projects book and after work in my main project?

Pages: [1] 2
anything