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

Author Topic: Falling Rocks! (demo inside)  (Read 31221 times)

0 Members and 1 Guest are viewing this topic.

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks! (demo inside)
« Reply #15 on: September 09, 2011, 11:14:21 pm »
Quote from: "Haikarainen"
Turned on VSync in ATi CCC, now the game runs fine but everything else lags :S

Edit; Turned off vsync in game(found it lol) and turned off vsync in ATi, now it also runs fine

Edit2: Really fun game, GJ! :D Did you make the graphics/music as well?


I did the all the graphics (except for background in the in-game screen), menu music is a free song downloaded on modarchive.org. In-game music was created by Giuseppe Navarria. :)

greeniekin

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Falling Rocks! (demo inside)
« Reply #16 on: September 10, 2011, 04:54:36 am »
Quote from: "Naufr4g0"


I'm aware about the fps issue. As you can see in your own link, it's not so difficult to implement an engine that adapts to any type of refresh.
The only thing I don't like of this solution is that GetFrametime() method doesn't return the same value for each frame when I switch on "sync vert refresh". So sprite movement appears less smooth! :(


I would have thought the animation would be more consistent.

Anyway if you are going to have it based off frames rather than time. Cap the frames to an appropriate speed so the experience is consistent for everyone. You can do this just by timing the time it takes to do calculations and draw and then either enter a loop until the timer is greater than 1/60th of a second or sleep for remaining time after doing everything. Not sure which method is better.

Or possibly have
float speed;
if(vsync)
    speed=1/60;
else
    speed=App.GetFrameTime();

charX+=10*speed;

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks! (demo inside)
« Reply #17 on: September 10, 2011, 02:17:13 pm »
Quote from: greeniekin
Quote from: "Naufr4g0"

Or possibly have
float speed;
if(vsync)
    speed=1/60;
else
    speed=App.GetFrameTime();

charX+=10*speed;


Unfortunately the problem is more complex.
There is no SFML::RenderWindow method that can read if Vsync was really enabled or not, and there's no other method that can read refresh rate (60hz, 75hz, ecc.) so I can't exactly know the real conditions in which the game runs.
Therefore I think the only way is to use GetFrameTime() method, with the problems that this entails ..
Anyway I could find an opengl function that give me the data I need or build a tester when the game starts..

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
Falling Rocks! (demo inside)
« Reply #18 on: September 10, 2011, 03:08:52 pm »
I couldn't play your game beacuse of it's so fast! I know I should just set it to use VSync, but come on, this not how it's intended to be!

What problems do you experience when using framerate independent movement and animation? I do the same, for all the thing that should change over time. I don't use clocks - at least not for important stuff - because then the game would not be synchronized well.

Here's some pseudo code for movement:

Code: [Select]
sf::Vector2Df position(sprite.GetPosition());
sf::Vector2Df shift;

float playerSpeed = 20;
float deltaTime = float(Window.GetFrameTime()) / 1000.f;

if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Left)) shift.x = -deltaTime * playerSpeed;
if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Right))shift.x =  deltaTime * playerSpeed;
if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Up))   shift.y = -deltaTime * playerSpeed;
if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Down)) shift.y =  deltaTime * playerSpeed;

position += shift;

/* ... Do some collision and response which modifies position vector too ... */

sprite.SetPosition(position);



Here's some for animation:

Code: [Select]
[animationTimer, animationFrame, maxAnimationFrames are integers declared in your class outside this function]

int animationSpeed = 200; // 1/5 second

animationTimer += int(Window.GetFrameTime());
if (animationTimer > animationSpeed)
{
  animationTimer -= animationSpeed;
  ++animationFrame;
  /* With the two lines above actually you can go out of sync
     with your animation, but only if the FrameTime is too large.
     If it is, the game must be unplayable anyway, so I tend to
     ignore this possibility. */
  if (animationFrame > maxAnimationFrames) animationFrame = 0;
}

sprite.setAnimationFrame(animationFrame); // This is really pseudo!

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks! (demo inside)
« Reply #19 on: September 10, 2011, 03:51:03 pm »
Ok Ok You've convinced me!! =)
I will release soon a framerate independent version of the game.
For me it's not so hard to implement that.

Haikarainen

  • Guest
Falling Rocks! (demo inside)
« Reply #20 on: September 10, 2011, 05:12:31 pm »
Easy has it ;) hehe

But for animations you should probably use time instead, thor::Timer is awesome for animations and is what i decided to use after playing around with frametimes.

Why ? The outofsync-because-of-large-frametimes can be a bigger error than you might expect! i.e move your window and the frametime wont update until you release it = very large frametimes.
How to try this with frametime-dependent speeds? hold right-button while moving your window; Voila your player is way gone and might also be stuck/been moving past walls. For collision detection i trace every pixel every frame.

Also, it makes everything way more easier.

For this just have a thor::Timer for your animationclass;
Code: [Select]

float msperframe = 200;

if(timer.IsExpired()){
  NextFrame();
  timer.Reset(msperframe, true);
}
[/code]

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks v0.5.2 released
« Reply #21 on: September 11, 2011, 01:40:20 am »
Changes I made:

- The game is finally framerate independent!
- Changed ninja images in menu screen
- Fixed a bug that froze the game for about a tenth of a second when the ninja was hit.

Download Falling Rocks 0.5.2

Thanks you all! I never decided to change the time-handling without your suggestions.
I think the game now runs smoothly both Vsync is enabled or not. :)

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Falling Rocks! (demo inside)
« Reply #22 on: September 11, 2011, 04:19:27 am »
It worked for me both times, vsync or without, on both versions.

Also, you should add some like challenges randomly throughout the game, such as like rock storm where a lot more rocks fall or something. Just a suggestion :D
Need a place to upload your code, files or screenshots? Use SFML Uploads!

Haikarainen

  • Guest
Falling Rocks! (demo inside)
« Reply #23 on: September 11, 2011, 06:05:17 am »
Quote from: "keyforge"
It worked for me both times, vsync or without, on both versions.


Might be your driver settings ;) check CCC if you go with ATI

OnT: You should add a sf::Event::Closed in your event handling, its irritating to not be able to kill the game with the upper right x :P

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks! (demo inside)
« Reply #24 on: September 11, 2011, 11:22:57 am »
Quote from: "Haikarainen"

OnT: You should add a sf::Event::Closed in your event handling, its irritating to not be able to kill the game with the upper right x :P


Ok, I will add this "feature" in next version. :)

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
FALLING ROCKS v0.5.3 released!
« Reply #25 on: September 13, 2011, 09:50:28 pm »
UPDATE: Version 0.5.3 released!

Changes I made in this version:
  • Fixed a bug in acceleration and deceleration of time in bullet-time mode when VSync was disabled (it was too fast).
  • You can now quit the game using the X button on the window.
  • You can mute music by pressing "M" key.
  • You can save more than 1 screenshot. They are named with a sequential number (shot_1.png, shot_2.png, ...)
  • Change title name image in the menu screen.

Download link:

Download Falling Rocks v0.5.3

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Falling Rocks! (demo inside)
« Reply #26 on: October 12, 2011, 10:55:01 pm »
I love this game!
The old-school graphics look very good and coherent.
I got 900 points and something.

Feature suggestion: you should store the high score and display it somewhere.

EDIT: got 2029  8)

meissner61

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Falling Rocks! (demo inside)
« Reply #27 on: October 12, 2011, 11:27:43 pm »
I swear to jesus if this game had progression and other silly things to keep our mind thinking we are getting somewhere... You would have an angry birds right here and be making bank right now!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Falling Rocks! (demo inside)
« Reply #28 on: October 13, 2011, 12:38:32 am »
Funny, even if quite difficult game! :)

I also like the graphics, they somehow remind me of Knytt Stories.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Falling Rocks! (demo inside)
« Reply #29 on: October 13, 2011, 12:45:33 pm »
Thank you all, I'm glad you enjoyed my work! :)

Quote from: "Haze"
I love this game!
The old-school graphics look very good and coherent.
I got 900 points and something.

Feature suggestion: you should store the high score and display it somewhere.


This is the next feature I want to add. :)

Quote from: "meissner61"
I swear to jesus if this game had progression and other silly things to keep our mind thinking we are getting somewhere... You would have an angry birds right here and be making bank right now!


I'm working just to add a goal to the game. :)
I want to add a story mode with gradually increasing difficulty levels.
I would also like to create different stages, with different backgrounds and other kinds of falling objects.

Quote from: "Nexus"
Funny, even if quite difficult game! :)

I also like the graphics, they somehow remind me of Knytt Stories.


I love that game! :D
I'm proud to know that my game have remembered you Knytt Stories.

 

anything