SFML community forums

General => SFML projects => Topic started by: lolz123 on April 13, 2011, 11:28:38 pm

Title: Gore Factor SFML
Post by: lolz123 on April 13, 2011, 11:28:38 pm
Hello everybody,

Here is a project I am currently working on that uses SFML for window handling, sound, and some rendering stuff.

It is a remake of the game "Thing Thing" by Diseased Productions (flash).

So far, all you can do is run around the map and shoot stuff with your trusty AR.

Features:
- 2D Dynamic Shadows
- Box2D physics
- Compound vector/sprite and frame independent animations
- Water
- Lua Scripting
- Quad Tree Scene Graph

(http://i1218.photobucket.com/albums/dd401/222464/LightSystem_9-24-11.png)

Download link: https://sourceforge.net/projects/gorefactorsfml/
VS2010 Redistributable Package REQUIRED: http://www.microsoft.com/downloads/en/details.aspx?familyid=A7B7A05E-6DE6-4D3A-A423-37BF0912DB84&displaylang=en

YouTube Video:

http://www.youtube.com/watch?v=bI2sRM_N8Xc

Controls:
- Mouse to aim, click to shoot.
- Move with WASD.
- Reload with R.
- Hold space for slow motion
- Shift + ~ to open the Lua command console
Title: Gore Factor SFML
Post by: Groogy on April 14, 2011, 12:32:20 am
For dynamic shadows, have a look in the old french SFML wiki. There's some example code for a lightmanager for SFML2. I've just done a remake of it to rbSFML and it seems pretty great. There is though some optimizations that has to be done.
Title: Gore Factor SFML
Post by: WitchD0ctor on April 14, 2011, 06:48:10 am
awesome, im also working on a sidescrolling platformer with box2d,

how did you make it so that he can tell when its ok to jump?
Title: Gore Factor SFML
Post by: lolz123 on April 15, 2011, 02:58:04 am
To see whether or not he can jump, I did 2 things:

First, I used the TestPoint function to see if a point directly below the player is touching anything (by parsing all the bodies and hit testing to them). If it is, the player can jump.

Secondly, in the case that the player is somehow stuck in a way where that point is not touching anything, I made it check to see if the vertical velocity is zero and the vertical velocity the last frame was negative (not at the top of a jump). Then you can jump as well.
Title: Gore Factor SFML
Post by: Richy19 on April 19, 2011, 06:03:50 pm
Pretty awesome :D
Is it in C++?

Also how are you doing all the physics? like is each body part a difrent entity?
I tryed something similar once but made the player one box, doing that just made him clip the floor at times
Title: Gore Factor SFML
Post by: lolz123 on April 19, 2011, 11:19:06 pm
It is written in C++ with VS2010 but also uses Lua for some stuff.

The player is a single body shaped sort of like a capsule except that the bottom is pointy and is always kept upright. The friction on the body was removed, since it would drag the crates with it when walking on them, and instead the deceleration is handled manually.
Title: Gore Factor SFML
Post by: lolz123 on April 24, 2011, 05:40:54 pm
I got around to trying the SFML light manager code Groogy suggested, I had to change some stuff in order to get it to work with the newer versions of SFML 2, but it gives me a memory access violation when closing (specifically, when destroying the OpenGL context). It runs fine until I try to close it. Is this possibly related to the ATI issue? I had that as well but the newer SFML 2 versions seem to have fixed this. Also, this system only supports hard shadows like mine, so right now I don't see why I would use it. Still, I would like to know what is going on.

The only line of code I had to change was:

Code: [Select]
BlurEffect.SetTexture("texture", sf::Shader::CurrentTexture);

To:

Code: [Select]
BlurEffect.SetCurrentTexture("texture");

Which I doubt could have caused this error.

Any ideas?
Title: Gore Factor SFML
Post by: lolz123 on May 19, 2011, 10:50:22 pm
Source code is now up.
Title: Gore Factor SFML
Post by: Richy19 on August 24, 2011, 03:10:01 am
Where can the code be found?
Title: Gore Factor SFML
Post by: lolz123 on August 27, 2011, 04:41:07 am
I took the code for the old version down, new version is going up soon.

EDIT: I forgot to add, the new version will come with a map editor. The map editor is not written using SFML though, I got lazy and use Java Swing.
Title: Gore Factor SFML
Post by: Richy19 on August 27, 2011, 09:48:12 am
Awesome :D, Any idea on what date to look out for this?
Title: Gore Factor SFML
Post by: lolz123 on August 27, 2011, 04:54:02 pm
Probably within the next 48 hours!
Title: Gore Factor SFML
Post by: keyforge on September 07, 2011, 08:34:02 pm
Cool game! How did you handle your maps? It's a tile system but how are you storing the collision data?
Title: Gore Factor SFML
Post by: lolz123 on September 08, 2011, 02:32:42 am
Source is up now, as well as the map editor (comes with instructions).

@ keyforge: I am using Box2D for they physics, so I just added box-shaped bodies. However, to keep the body count down, I made it stretch the boxes horizontally as long as there was a row of consecutive "solid" tiles. See the source file for Entity_TileMap for more information.
Title: Gore Factor SFML
Post by: lolz123 on September 21, 2011, 11:20:08 pm
An update: I am working on soft shadows which are physically accurate and not just blurred. Here is a screenshot of the shadow system so far:

(http://i1218.photobucket.com/albums/dd401/222464/SemiWorkingSoftShadowsScreenie2.png)

I also plan on speeding up the algorithm some more through region queries that take the light angle into account and shadow occlusion.
Title: Gore Factor SFML
Post by: easy on September 22, 2011, 01:07:41 pm
This is really cool :D

But here's a question: how's the game coming? ;)
Title: Gore Factor SFML
Post by: lolz123 on September 22, 2011, 11:56:35 pm
@ Easy: Indeed, I have spent more time teching it up rather than adding content :)
Now that I have the shadows, though, I need to get them to run fast enough so that a larger variety of computers can handle them.
However, after that, there really isn't much more I want to add to the game engine, so I should be getting to creating game content soon. I got my map editor, Flash for animations, and event-based lua scripting ready to go.
Title: Gore Factor SFML
Post by: keyforge on September 23, 2011, 06:03:50 am
That's not necessarily a bad thing though, now that you have all the tech out of the way you can focus on making great game content while having nice looking graphics and a good framework.
Title: Gore Factor SFML
Post by: easy on September 23, 2011, 01:54:00 pm
Check this out! (http://www.sfml-dev.org/forum/viewtopic.php?t=5932)
Title: Gore Factor SFML
Post by: lolz123 on September 24, 2011, 03:37:29 am
Cool, I am honored! :)
Title: Gore Factor SFML
Post by: easy on September 24, 2011, 12:14:15 pm
I've chosen the image on the previous page, if it's okay?
Title: Gore Factor SFML
Post by: lolz123 on September 24, 2011, 04:10:08 pm
Sure!
Title: Gore Factor SFML
Post by: easy on September 26, 2011, 02:07:03 pm
Unfortunately I only could add it as a thumbnail on the profile image yet. :?
But I keep up posting to the IndieDB staff about the problem! ;)
Title: Gore Factor SFML
Post by: lolz123 on October 02, 2011, 04:36:48 am
It is now time for Gore Factor to live up to its name!

You can now kill the zombies. So far, I only have the head shot "finisher", in which the zombie's head explodes.

I am posting it as a link, since it is kind of M rated now:

http://i1218.photobucket.com/albums/dd401/222464/GoreFactorGoreScreenie1.png

More to come! When the finishers for the zombies are all finished I will upload the next version.
Title: Gore Factor SFML
Post by: meissner61 on October 05, 2011, 03:04:02 am
Is this really using vectors as the assets? Thats kind of cool, can you talk me through why you chose that? The only bonus i see to using vectors is you can zoom in and out with no blur

EDIT: NVM i see it uses png's my bad
Title: Gore Factor SFML
Post by: lolz123 on October 05, 2011, 09:49:21 pm
@meissner61: To clarify, the animation system interpolates certain key frames to get coordinates for sprites and other things such as depth, scale, alpha, and rotation. The sprites are then transformed according to these values, but the sprite itself is just a .png, not a vector image. I called this "vector animation" since it is similar to the motion tween feature in Flash. With it you can create smooth animations that don't look choppy when slowed down (useful for the slow motion feature). In addition, they use way, way less memory than sprite animations. The downside is that they are harder to animate and may run slower depending on the complexity of the animation.
Title: Gore Factor SFML
Post by: lolz123 on November 02, 2011, 10:32:58 pm
Ah, I just couldn't resist adding more tech. This time, it has to do with AI.

Most side scrollers have either very simple AI or some scripted stuff. However, I am trying to use neural nets instead. I already wrote a training program, but discovered that back propagation is too slow, and will therefore switch to genetic algorithms. I should have a demo soon. I am using simple feed forward neural networks, whose input is the direction it must travel as well as a sort of picture of the tile map around it. I hope they will learn to jump over platforms and other obstacles, something you cannot do with just path finding.
Title: Gore Factor SFML
Post by: lolz123 on December 04, 2011, 09:37:49 pm
Update: Add new items. Swap weapons with the scroll wheel. The game now has HE grenades which show off the physics and particles, and a Glock-19, my favorite weapon in the game now (the animations worked out better for me this time!).
Right now, I am using some A* pathfinding instead of neural nets. My training method has only had limited success. Unless I get the neural nets to work, I will stick to A*.

(http://i1218.photobucket.com/albums/dd401/222464/explosionScreenie1.png)

(http://i1218.photobucket.com/albums/dd401/222464/gfpistolscreenie1.png)
Title: Gore Factor SFML
Post by: keyforge on December 05, 2011, 05:40:15 pm
I tried out your new version and it's very good! Your scroll wheel switching is really buggy on my mouse. I have to screw around with the wheel a lot to get it to switch to a weapon which seems to choose a random weapon. Great work!
Title: Gore Factor SFML
Post by: lolz123 on December 06, 2011, 12:19:47 am
Thanks for the feedback. I think I allow players to choose weapons with the number keys as well. In addition, the weapons list will be shown at the top of the screen in a fashion similar to Half-Life 2. This should make weapon selection a lot easier.
Title: Gore Factor SFML
Post by: lolz123 on December 21, 2011, 10:20:50 pm
I haven't posted an update in a while. Well, here it is:

The largest feature added to the game were soldiers with some pretty good AI if I do say so myself. I used A* and modified it so it would only add nodes if they were withing a certain distance from the ground. Also, I made the movement costs a sort of gradient where higher locations on the map have higher costs so that the paths would stick to the ground rather than float in the air. Finally, I coded the soldiers to recognize gaps in the floor, adjust the power of their jumps, and shoot at the player (with a reaction time delay) when he is in sight.

Furthermore, when the soldiers die, they turn into ragdolls that topple over. It looks pretty cool when you blow them up with grenades- in slow motion. Which brings me to another new feature.

I already had totally frame independent movement, but the sounds wouldn't play in slow motion when time was slowed down. So I created a system that creates copies of sound buffers at different sample rates, and creates and destroys these as needed in order to conserve memory. You can now slow and speed up time with the P and L keys, and use space to revert it to the normal speed. You can actually completely freeze time now. This will certainly become some sort of game mechanic.

Here are some screenshots:

(http://i1218.photobucket.com/albums/dd401/222464/AIScreenie.png)

(http://i1218.photobucket.com/albums/dd401/222464/gfragdollscreenie.png)

(http://i1218.photobucket.com/albums/dd401/222464/Ragdolls.png)
Title: Gore Factor SFML
Post by: easy on December 21, 2011, 11:59:15 pm
This is supercool! I can see the tons of work you've put into it: the animations an the movements are smooth, the lights and shadows are excellent, the water effect really adds to it, and the AI is really good! Also, you have a very clean code, and I like how it was structured, though I just had a short glance at it.

What I did not like, however, is the jumping. I guess I'd just have to play more with it to get accustomed to jumping, but I really dislike that the character jumps only if I release the button. I'd rather make the character jump when the player presses the key. You can still measure how long he's pressing it (hence how large to jump), for a limited time (not to jump out the world).

The movement and the aiming also feel like it's lagging behind. Not too much, but it's noticable.

The AI had a problem jumping up to a platform at some place, so it couldn't follow me anymore.

The whole source is in the root directory, it's confusing.

Overall, I really like it! Keep it coming! :P
Title: Gore Factor SFML
Post by: lolz123 on December 22, 2011, 02:14:11 pm
Thanks for the feedback!

You are right about the jumping, it does feel a bit awkward. Others complained about it too, so I will change so that he instantly jumps and jump height is determined by how long you leave the jump key pressed. The original idea behind that charge-jumping was to make it more realistic, since the other, more common method that I will change it to forces a constant velocity on the player until the jump button is released.

The aiming lag is on purpose. The idea was to simulate the time it would take for someone to actually move the gun to a different angle. This is important when doing the slow-motion thing, since otherwise you could aim just as fast as in real time.

The AI sometimes doesn't get paths, that is why it sometimes just goes back and forth on the same spot. I am not yet sure as to what causes this. Also, you may have noticed how the AI sometimes falls into the pits on the second floor, and sometimes doesn't. This is because of the low update time for the paths. I will probably multi-thread the path finding eventually (and maybe the light system too) to get rid of this delay which currently makes it update only every third of a second.