Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: My current project using SFML  (Read 5914 times)

0 Members and 1 Guest are viewing this topic.

pogrady

  • Newbie
  • *
  • Posts: 21
    • View Profile
My current project using SFML
« on: January 25, 2013, 09:27:25 am »
Hello!

Wanted to share the current project I am working on entitled The Dungeon 2: The Key of Antioch.  Its a sequel to the first Dungeon, and the demo is really just a playable mini game of an aspect of the whole project.  Since I hit a milestone I thought it might be cool to whip up a little game and demonstrate what I have been working on.

So...

Take a gander at my web page, and download!


Harsay

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: My current project using SFML
« Reply #1 on: January 27, 2013, 04:41:58 pm »
Looks nice but I cant play it because game works too fast.

Did you add FPS limit?

io

  • Jr. Member
  • **
  • Posts: 52
  • z/OS by day, SFML by night
    • View Profile
Re: My current project using SFML
« Reply #2 on: January 28, 2013, 06:56:35 am »
Running too fast on my end as well.

Also, a suggestion -- after zooming out and then zooming it it may be beneficial to center your player again on the screen otherwise you are going to zoom in and your character will be off screen :).

pogrady

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: My current project using SFML
« Reply #3 on: January 28, 2013, 06:18:50 pm »
I added a check at the end of the loop to see if the time elapsed was less then 32, if it was then pause for 32 milliseconds. Is this the correct way of doing it?  I didn't use system("PAUSE"), but rather a home brew function that loops until a specified time has been reached.  Come to think of it the function uses GetTickCount, part of the win32 library... i might have to change that.

Also, is there another way to slow the game down without limiting the FPS?

The zoom centers on the player, i don't know why it was not coming back centered.  If you click on a different spot the camera will change locations, causing the zoom to no longer be centered on the player.

In all honesty though, zoom and "pan" were not intended to be release with this build :).  I uploaded a newer version.

Thanks for trying it...  I am still working on it.  Your comments are appreciated. 

AFS

  • Full Member
  • ***
  • Posts: 115
    • View Profile
Re: My current project using SFML
« Reply #4 on: January 29, 2013, 04:01:33 am »
For speed, what I do is having a clock (sf::Clock) to count the time of each frame. At the end of each frame the clock starts again.

So, I pass the elapsed time to the fuctions responsible of the movement, and multiply the movement speed by the time elapsed, as seconds. The result is the true movement value.

For example, let's say that the movement speed of your character is 100 (this is constant for your character). Let's say that the time of the frame is always 0.01 seconds, that is, 100 frames per second. So, your character's speed mutiplied by the time: 100 * 0.01 = 1, so each frame you move 1 pixel.

Now let's say that the frame rate is 50 FPS, that is, each frame last 0.02 seconds. 100 * 0.02 = 2, so your character moves 2 pixels per frame at 50 FPS.

So basically, at low FPS, your character moves faster each frame to compensate. At high FPS, your character moves slower. In real time, your character will need *almost* the same time to reach its destination, regardless if you are running the game at 10 FPS or 1000. Just make sure you do the multiplication each frame, because the time of the frames is never constant.

To test it, use Window.setFramerateLimit, and try with different FPS.

At least that's how I do it, and it works fine as far as I can tell. I don't know if there is better ways to do it, though.
« Last Edit: January 29, 2013, 04:16:12 am by AFS »

pogrady

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: My current project using SFML
« Reply #5 on: January 29, 2013, 06:03:01 am »
Thanks for your help. 

I read somewhere that its generally a bad idea to slow the system or have the system pausing.  This makes sense i think as you want as much performance as possible from the computer, and having it pause is a waste.

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: My current project using SFML
« Reply #6 on: January 29, 2013, 08:12:38 pm »
Your monitor can't show past 60 fps (unless you have a very unusual monitor). Anything past that is wasted processing time. But, if you want to run the logic of the game past 60 fps or be able to automatically adjust to rare monitors that have different refresh rates, you will need frame independent movement.

Also, try enabling vsync. It limits the frame rate to the refresh rate of the monitor and prevents screen tearing.
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.

kaB00M

  • Full Member
  • ***
  • Posts: 101
    • View Profile
    • Caffeware
    • Email
Re: My current project using SFML
« Reply #7 on: January 30, 2013, 06:45:28 pm »
Game is really fast on my comp too.
 
Some suggestions:
    -Give a physical cue of for receiving damage. Flashing the character white of red would be nice.
    -Enable the character to shoot while standing still.

Also, once a skeleton started running down the blocks, so you should check out the collision detection.

Other than that is great. I like even the graphics!



pogrady

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: My current project using SFML
« Reply #8 on: February 01, 2013, 07:03:21 am »
This speed thing is really getting the best of me.

Ive implemented a system of blood that flies out of the player when they get hit.  After a short animation it lands on the ground and stays there.  Its kinda cool actually because you walk around and see the damage that the skeletons did to you.  I'm working on a death animation for the enemies, the fact that they just disappear bothers me.  Since i have the decal class that does the blood its simple now to have the enemies respond in kind.

The shooting while moving was a design choice.  I felt that by allowing the player to shoot while standing still turned the game into a shooting range, and not a "go get em" type feel i wanted.  I didn't want them to sit back and camp.  I wanted them to get into it and charge the skeletons.

Thanks for the compliment on the artwork, but its not mine.  I got the tile set from here: http://pousse.rapiere.free.fr/tome/.  I tried contacting the artist, but the email link is dead.  :-\

kaB00M

  • Full Member
  • ***
  • Posts: 101
    • View Profile
    • Caffeware
    • Email
Re: My current project using SFML
« Reply #9 on: February 01, 2013, 11:23:20 am »
This speed thing is really getting the best of me.

What do you mean? Just do:

window.setFramerateLimit(60)

After that you an use the this code to check if it's working.


Ive implemented a system of blood that flies out of the player when they get hit.  After a short animation it lands on the ground and stays there.  Its kinda cool actually because you walk around and see the damage that the skeletons did to you.  I'm working on a death animation for the enemies, the fact that they just disappear bothers me.  Since i have the decal class that does the blood its simple now to have the enemies respond in kind.

Looking forward to that.

The shooting while moving was a design choice.  I felt that by allowing the player to shoot while standing still turned the game into a shooting range, and not a "go get em" type feel i wanted.  I didn't want them to sit back and camp.  I wanted them to get into it and charge the skeletons.

I see. It makes sense.
In the future you could have multiple characters. On could be the "sit back and camp" kind of guy with its damage being very small. On the other hand, you could have a character with very little range that does much damage.

Thanks for the compliment on the artwork, but its not mine.  I got the tile set from here: http://pousse.rapiere.free.fr/tome/.  I tried contacting the artist, but the email link is dead.  :-\

Well you got good taste. :)



pogrady

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: My current project using SFML
« Reply #10 on: February 05, 2013, 05:22:30 am »
Quote
In the future you could have multiple characters. On could be the "sit back and camp" kind of guy with its damage being very small. On the other hand, you could have a character with very little range that does much damage.

I need an archer.  That would be cool..  Then the campers would be happy. :)

 

anything