SFML community forums

General => SFML projects => Topic started by: Naufr4g0 on September 08, 2011, 02:15:42 pm

Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on September 08, 2011, 02:15:42 pm
(http://i53.tinypic.com/2m4ws39.png)

In the last year I have spent a lot of time in game development, using the SFML libraries that I find very well done.
I began to write this game in 2010 with another graphic library, but eventually I came to SFML, writing the code from scratch.
The game is a simple time-waster and your goal is to avoid the falling rocks, surviving as much as possible and making the highest score you can do.
You can also do combos avoiding more rocks in sequence.
The highest level of difficulty is selected on menu screen, the highest rate of falling rocks you obtain in the game.
Press 'Left-CTRL' key to activate Bullet-Time, so you can more easily avoid falling rocks.
The game is not complete. I want to put some other obstacles like arrows, shurikens and bombs. I want to make the ground deformable, too, so the game can be more varied.
Consider the game I linked below as a demo.
Let me know if you have some issues to start the game.
Every kind of comment is welcome.
I hope you enjoy it!

Controls:

Arrow keys to move
Left-CTRL to activate Bullet-Time
-------------------------------
F1 to take a screenshot
M to toggle music mute
space to restart game when ninja falls in the water

Download
Download Falling Rocks v0.5.3 (http://bit.ly/qaETfb) (for windows)

Download Falling Rocks v0.5.2 (http://bit.ly/nDceeA)
Download Falling Rocks v0.5.1d (http://bit.ly/pEuu0n)

Video

http://www.youtube.com/watch?v=yjfamlt2ZXg (http://www.youtube.com/watch?v=yjfamlt2ZXg)
Title: Falling Rocks! (demo inside)
Post by: Lo-X on September 08, 2011, 02:26:55 pm
Simple and addictive :D
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on September 08, 2011, 02:50:47 pm
Quote from: "Lo-X"
Simple and addictive :D


I'm happy you like it! =)
Title: Falling Rocks! (demo inside)
Post by: Lo-X on September 08, 2011, 03:13:14 pm
Quote from: "Naufr4g0"
I'm happy you like it! =)


Like ? No.. I Love It !
As if my best score in Impossible Mode is 426... That's so hard...
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on September 08, 2011, 03:36:12 pm
Quote from: "Lo-X"

Like ? No.. I Love It !
As if my best score in Impossible Mode is 426... That's so hard...


=) Post a screenshot if you do a better score! :D
Title: Falling Rocks! (demo inside)
Post by: keyforge on September 09, 2011, 05:09:57 am
Very good game! Nice graphics too. I've spent a good half an hour on it!
Title: Falling Rocks! (demo inside)
Post by: greeniekin on September 09, 2011, 06:10:08 am
You tube video looks very good.
Though on my pc it is unplayable. Your game does not scale motion with time.
Eg say it is meant to work at 30 fps but because my computer is more powerful and gets 90 fps all objects will go 3X faster.

Basically I hit start rocks flying past in a blur then I'm dead in 1 second.

It is weird though because the animated water and the menu select icon seem to animate at the correct speed.

If you need more help on how to implement this just ask. Though I suspect you already know and implemented it for animations anyway.
Title: Falling Rocks! (demo inside)
Post by: coolhome on September 09, 2011, 06:38:16 am
That game is fun and addicting. I got 800 some on my first try and now I can't even get close to that on hard! Only suggestion I have is to create a volume / mute option in the menu. :D I tent to ignore game music hehe!
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on September 09, 2011, 07:05:24 am
Quote from: "greeniekin"
You tube video looks very good.
Though on my pc it is unplayable. Your game does not scale motion with time.
Eg say it is meant to work at 30 fps but because my computer is more powerful and gets 90 fps all objects will go 3X faster.

Basically I hit start rocks flying past in a blur then I'm dead in 1 second.

It is weird though because the animated water and the menu select icon seem to animate at the correct speed.

If you need more help on how to implement this just ask. Though I suspect you already know and implemented it for animations anyway.


Try to select  Vert Sync. = OFF in the Options screen, it should fix the speed issue. :)
This option sets FPS to 60.
Have you set a value for screen vert refresh over 60?
Title: Falling Rocks! (demo inside)
Post by: greeniekin on September 09, 2011, 04:07:40 pm
Quote from: "Naufr4g0"

Try to select  Vert Sync. = OFF in the Options screen, it should fix the speed issue. :)
This option sets FPS to 60.
Have you set a value for screen vert refresh over 60?


I actually was using it on a pc at uni.

I tried again at home and with vert sync on and off. It worked perfectly.

Though what I was referring to it will not matter what the frame rate is.
It is discussed here.
http://www.sfml-dev.org/tutorials/1.3/window-time.php

You may have already implemented as I have no issue at home, and a uni computer could have been compromised some how. Though you should know with a glance at that page.
Title: Falling Rocks! (demo inside)
Post by: bzn on September 09, 2011, 05:41:56 pm
Love this game! Reached 2100 points in hard mode, after a "almost-hit" combo of 19 or so. :)
It's actually almost too easy to get many points by these combos.
Title: Falling Rocks! (demo inside)
Post by: eXpl0it3r on September 09, 2011, 07:13:07 pm
Very nice game! =)

But as mentioned above there seems to be a speed problem.
With VSync=ON the game is really unplayable, turing it off does fix the issue.
But I don't think it has much to do with FPS, then turnin off VSync would mean the FPS go up and the game gets even faster. Or the setting is just reversed...  :lol:
Title: Falling Rocks! (demo inside)
Post by: Haikarainen on September 09, 2011, 09:45:32 pm
Bug!

Do you use Window::GetFrametime() to get hardwareindependent speed? Currently the game is running in uberfastforward for me, unplayable. Looks really cool and fun on the video tho!

How to use getframetime?

Code: [Select]
sf::Uint32 Frametime = Window.GetFrametime();
float Playerspeed = 0.2f;
Player.Move(Playerspeed*Frametime, 0)
Title: Falling Rocks! (demo inside)
Post by: Haikarainen on September 09, 2011, 09:54:27 pm
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?
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on September 09, 2011, 10:55:21 pm
Quote from: "greeniekin"

I actually was using it on a pc at uni.

I tried again at home and with vert sync on and off. It worked perfectly.

Though what I was referring to it will not matter what the frame rate is.
It is discussed here.
http://www.sfml-dev.org/tutorials/1.3/window-time.php

You may have already implemented as I have no issue at home, and a uni computer could have been compromised some how. Though you should know with a glance at that page.


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! :(

Quote from: "eXpl0it3r"
Very nice game! =)

But as mentioned above there seems to be a speed problem.
With VSync=ON the game is really unplayable, turing it off does fix the issue.
But I don't think it has much to do with FPS, then turnin off VSync would mean the FPS go up and the game gets even faster. Or the setting is just reversed...  :lol:


I know that the option could be misinterpreted, but in the game VSYNC ON means VSYNC ON if graphic card driver vsync option is set to "let the application decide". In other cases fps could be > 60 or virtually infinite if vsync driver option is set to "always off".
VSYNC OFF means framerate limited to 60 without vsync! :)
VSYNC ON, when it works, return smooth movements even if you don't notice it.

Quote from: "bzn"
Love this game! Reached 2100 points in hard mode, after a "almost-hit" combo of 19 or so. :)
It's actually almost too easy to get many points by these combos.


What's a "almost-hit" combo? Anyway a combo give score only when you don't die within a second. :)
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 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. :)
Title: Falling Rocks! (demo inside)
Post by: greeniekin 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;
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 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..
Title: Falling Rocks! (demo inside)
Post by: easy 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!
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 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.
Title: Falling Rocks! (demo inside)
Post by: Haikarainen 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]
Title: Falling Rocks v0.5.2 released
Post by: Naufr4g0 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 (http://bit.ly/nDceeA)

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. :)
Title: Falling Rocks! (demo inside)
Post by: keyforge 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
Title: Falling Rocks! (demo inside)
Post by: Haikarainen 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
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 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. :)
Title: FALLING ROCKS v0.5.3 released!
Post by: Naufr4g0 on September 13, 2011, 09:50:28 pm
UPDATE: Version 0.5.3 released!

Changes I made in this version:

Download link:

Download Falling Rocks v0.5.3 (http://bit.ly/qaETfb)
Title: Falling Rocks! (demo inside)
Post by: Haze 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)
Title: Falling Rocks! (demo inside)
Post by: meissner61 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!
Title: Falling Rocks! (demo inside)
Post by: Nexus 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 (http://www.gamesetwatch.com/knytts.jpg).
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 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 (http://www.gamesetwatch.com/knytts.jpg).


I love that game! :D
I'm proud to know that my game have remembered you Knytt Stories.
Title: :o
Post by: David on October 13, 2011, 04:16:57 pm
Ooooh, I love it! I'm just a huge fan of 8bit graphics and music :D . The combo system is also really cool
Title: Great game
Post by: justcolorado on November 26, 2011, 01:18:40 am
And great concept.  Played it 20x already
Title: Re: Great game
Post by: Naufr4g0 on November 26, 2011, 01:23:30 am
Quote from: "justcolorado"
And great concept.  Played it 20x already


I'm happy you like it! :)
I will soon release a new version of the game with online hi-score. :)
Title: Falling Rocks! (demo inside)
Post by: Stupebrett on December 05, 2011, 07:55:37 pm
Really awesome game! I'm addicted to it already.
Title: Falling Rocks! (demo inside)
Post by: aBallofWin on January 09, 2012, 04:38:05 pm
Really fun game, you should develop it for the iphone or ipad :P
Title: Falling Rocks! (demo inside)
Post by: player931402 on February 02, 2012, 04:20:24 pm
Great game! gj!

Quote from: "aBallofWin"
Really fun game, you should develop it for the iphone or ipad :P



yeah you should export your project on android and ipod/iphone..!
at  cost<1€ you become richest!
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on February 02, 2012, 07:29:52 pm
Quote from: "aBallofWin"
Really fun game, you should develop it for the iphone or ipad :P


Quote from: "player931402"
Great game! gj!

yeah you should export your project on android and ipod/iphone..!
at  cost<1€ you become richest!


I think it's a good idea!
I'm running to download Android and iOS SDKs! ;)
Title: Falling Rocks! (demo inside)
Post by: texus on February 02, 2012, 08:11:18 pm
Very nice game.
I just got a score of 1585 in impossible.

Apparently it's not for windows only: it runs perfectly on my linux with wine.
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on February 02, 2012, 09:02:55 pm
Quote from: "texus"
Very nice game.
I just got a score of 1585 in impossible.

Apparently it's not for windows only: it runs perfectly on my linux with wine.


Good!! Anyway I'm working to release a linux native version. :)
Potentially I can release a MacOS X version, too! But I haven't a Mac. :'D
Title: Falling Rocks! (demo inside)
Post by: iHope on February 03, 2012, 09:47:27 am
Quote
Good!! Anyway I'm working to release a linux native version.  
Potentially I can release a MacOS X version, too! But I haven't a Mac. :'D

You could try to find a person who has a Mac? There are lots of people in this forum who have Mac, I personally believe that you can find someone who wants to help you.

Sorry about my english :)
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on February 03, 2012, 05:57:14 pm
Quote from: "iHope"

You could try to find a person who has a Mac? There are lots of people in this forum who have Mac, I personally believe that you can find someone who wants to help you.

Sorry about my english :)


I know a lot of people owning a Mac, but...
most of them doesn't know how to compile a source code, for the rest I'm a bit jealous of my code. :'D
Anyway I planned to release the game for linux and mac OS X when it's finished.

Not even my English is perfect, I'm italian! ;)
Title: Falling Rocks! (demo inside)
Post by: TheEnigmist on February 03, 2012, 11:19:29 pm
Quote from: "Naufr4g0"
Quote from: "iHope"

You could try to find a person who has a Mac? There are lots of people in this forum who have Mac, I personally believe that you can find someone who wants to help you.

Sorry about my english :)


I know a lot of people owning a Mac, but...
most of them doesn't know how to compile a source code, for the rest I'm a bit jealous of my code. :'D
Anyway I planned to release the game for linux and mac OS X when it's finished.

Not even my English is perfect, I'm italian! ;)


Delfino geloso  :lol:  :lol:
Comunque bel gioco... vedi di diventare ricco!
Google Translate:
Nice game bro!
Title: Falling Rocks! (demo inside)
Post by: Naufr4g0 on February 04, 2012, 03:13:50 pm
Quote from: "TheEnigmist"

Delfino geloso  :lol:  :lol:
Comunque bel gioco... vedi di diventare ricco!
Google Translate:
Nice game bro!


Get rich?
If I wanted to get rich I would have already begun to code for the iPhone!
I need an iOS SFML port! ;)
Title: Falling Rocks! (demo inside)
Post by: TheEnigmist on February 04, 2012, 07:59:57 pm
Quote from: "Naufr4g0"
Quote from: "TheEnigmist"

Delfino geloso  :lol:  :lol:
Comunque bel gioco... vedi di diventare ricco!
Google Translate:
Nice game bro!


Get rich?
If I wanted to get rich I would have already begun to code for the iPhone!
I need an iOS SFML port! ;)


Ok :(