SFML community forums

General => SFML projects => Topic started by: eigenbom on August 04, 2012, 06:08:39 am

Title: moonman
Post by: eigenbom on August 04, 2012, 06:08:39 am
Hey guys, I just released a really early alpha of the sfml2 game I've been working on this year.

(http://moonman.io/wp-content/uploads/2012/08/newpalgrave.png)

It's called moonman, and is a 2d platformer minecraft-like. You can grab it from here (http://moonman.io/files/moonman0.1.zip), with more info available at this thread (http://forums.tigsource.com/index.php?topic=21997.msg775365#msg775365).
Title: Re: moonman (v0.1 windows alpha)
Post by: Zephilinox on August 04, 2012, 09:42:16 pm
I heard of this name before somewhere, best of luck to you
Title: Re: moonman (v0.1 windows alpha)
Post by: eXpl0it3r on August 04, 2012, 10:32:08 pm
I heard of this name before somewhere, best of luck to you
Maybe because of this (http://en.sfml-dev.org/forums/index.php?topic=6494.0), this (http://en.sfml-dev.org/forums/index.php?topic=5749.msg48092#msg48092) or this (http://moonman.io/)? ;)
I defently recognized the art style again back from the "Who Are You" thread and the website. :)

Although it maybe a bit annoying to maintain two diffrent threads I'd still suggest you put links to the most recent download in here to. ;)
So if anyone wants to download it, here you go: Moonman 0.1 (Windows) (http://moonman.io/files/moonman0.1.zip)

As you've stated over there with:
Quote
Jumping onto sloped ground may cause physics issues
I guess you mean rather a collision detection problem at higher speed, right?
Like this:
http://www.youtube.com/watch?v=9AWA-Ac6BCo (http://www.youtube.com/watch?v=9AWA-Ac6BCo)

Also it's kind of odd that you can mine any block within reach. I mean how do you manage to mine around the blocks in front of you?

Other than that it looks really good! :)
Title: Re: moonman (v0.1 windows alpha)
Post by: eigenbom on August 05, 2012, 02:52:33 am
Thx guys!

eXploit3r -- Yeh I wrote my own collision code, and the stuff for slopes is still a work in progress. Although I'm seriously considering switching to box2d at some stage.

And there was a link in the original post, but I'll make it bigger. :)
Title: Re: moonman (v0.1 windows alpha)
Post by: Zephilinox on August 07, 2012, 06:14:37 pm
How did you implement lua in your code? LuaBind? could you show me a simple example? I've been trying to run lua 5.2 but there are no tutorials for it even though it has been out for half a year.
Title: Re: moonman (v0.1 windows alpha)
Post by: eXpl0it3r on August 07, 2012, 06:21:16 pm
I'm not sure what he's using but Diluculum (http://www.stackedboxes.org/~lmb/en/diluculum/index?/) seems to be quite a nice "binding" and I've know a project that is using it. Although I give you any code the homepage and it's documentation should be quite enough. ;)
Title: Re: moonman (v0.1 windows alpha)
Post by: Nexus on August 07, 2012, 08:53:59 pm
Nice! I love exploration games like Knytt and some others from Nifflas, I can only encourage to add such elements to your game ;)

Some remarks:


How did you implement lua in your code? LuaBind? could you show me a simple example? I've been trying to run lua 5.2 but there are no tutorials for it even though it has been out for half a year.
A week ago, I wanted to do the same thing, with no success. After I tried Lua 5.1 with luabind, which works well so far.
Title: Re: moonman (v0.1 windows alpha)
Post by: StormWingDelta on August 10, 2012, 12:40:03 am
No clue why but for some reason my computer chokes on the game. The whole screen for the game goes blurry-lined and doesn't play for some reason. Any Ideas why since I'm at a loss on this one?
Title: Re: moonman (v0.1 windows alpha)
Post by: eXpl0it3r on August 10, 2012, 12:45:38 am
No clue why but for some reason my computer chokes on the game. The whole screen for the game goes blurry-lined and doesn't play for some reason. Any Ideas why since I'm at a loss on this one?
Stop posting this under all the game threads, it's obviously something with your computer and not with the games. -.-
Title: Re: moonman (v0.1 windows alpha)
Post by: Tank on August 10, 2012, 08:54:22 pm
Nexus & Zephilinox:
I *really* recommend Diluculum if you can live with Lua 5.1. I tried so many bind libraries and always hit the edge, got 5000% more compile time, missed features and whatnot. If you're looking for a really simple to use and rather low-level binding library without too much bloat, I highly suggest taking a look at Diluculum -- which is btw. maintained by a very nice person, had some e-mail conversation with him. ;)

I'm using it in my game and it's really straightforward and fast.
Title: Re: moonman (v0.1 windows alpha)
Post by: eigenbom on August 13, 2012, 01:55:32 am
Thx for checking out the demo guys. :)

@Zephi, yeh I'm using luabind. I used it for a prev project (fugu (http://www.csse.monash.edu.au/~cema/fugu/)), and it does the job.

@stormwingdelta I bet you have onboard Intel video? If so, I'm looking at a workaround atm to fix some issues people are having. (Related to this (https://github.com/SFML/SFML/issues/101).)

@Nexus Thanks for the notes, yeh I love Nifflas too, and plan to steal some ideas :)

I use render textures for large 256x256 block chunks which only update once the terrain changes, purely so I could zoom out and have it run fast (runs at 60fps on max zoom on my mid-entry vaio.) What are the specs of your machine/gfx, and did you have lighting enabled when you were zoomed out? And was the slowness caused everytime you mined/placed a block, or every single frame?

And I think I agree with you about having to mine three blocks underground, I'll look at speeding up the mining rate..

Title: Re: moonman (v0.1 windows alpha)
Post by: SoulBlade on August 28, 2012, 04:09:56 am
I love it!  Great work!

I'm wondering if you could explain some of your technique with rendering?  I'd love to learn more about what you do here; it runs so smoothly!

Overall, great job and I'm looking forward to see more from you.
Title: Re: moonman (v0.1 windows alpha)
Post by: eigenbom on August 29, 2012, 10:14:53 am
I love it!  Great work!

I'm wondering if you could explain some of your technique with rendering?  I'd love to learn more about what you do here; it runs so smoothly!

Thx, glad you like it!

I spent a little while on getting the rendering system running quickly, and I think it performs as well as it does because it a) caches chunks of blocks, lighting, etc., into render textures, and b) culls those chunks outside of the viewport. Technically I've got chunks of 256x256 blocks which each map to one render texture (of size 2048x2048). Then whenever a block is changed, its subchunk (16x16 block region) is redrawn into the render texture. There's some tricky business with notifying adjacent blocks when drawing a block whose visual depends on its neighbours, but that's the gist of it!

Also, here's a gif of a fluid system i'm building atm (amongst other things!)

(http://moonman.io/wp-content/uploads/2012/08/fluidfill.gif)
Title: Re: moonman (v0.1 windows alpha)
Post by: eigenbom on September 13, 2012, 12:02:57 am
Update: New build is available.

(http://moonman.io/wp-content/uploads/2012/09/newtreegrass3.png)

Changelog for v0.2
Added a program launcher
Added water simulation (press middle mouse to unleash water!)
Added porous blocks
Added foreground blocks (e.g., vines)
Reduce mining distance
Many bug fixes


Download: http://moonman.io/files/moonman 0.2.zip (http://moonman.io/files/moonman 0.2.zip)
(You may need to get vcredist_x86 (http://moonman.io/files/vcredist_x86.exe) too.)
Title: Re: moonman
Post by: eXpl0it3r on September 13, 2012, 12:29:32 am
Nice! :)

But now I can't fall through the surface that easily anymore. ;D

But it's still possible, for instance if you take image above and just walk to the left into the water and then as far left as possible. The moonman's head will then be stuck in the wall and if you jump it's sometimes possible to fall down.
Additionally the tools go through the wall and you can pickup stuff that you didn't even reach yet (maybe it's a feature who knows? :P ).

Keep the good work up! :)
Title: Re: moonman
Post by: eigenbom on September 13, 2012, 12:33:34 am
Thx, haha, no it's not a feature. My next milestone is to rewrite a lot of the physics stuff to make it nice and solid.
Title: Re: moonman
Post by: eigenbom on November 06, 2012, 04:56:41 am
But it's still possible, for instance if you take image above and just walk to the left into the water and then as far left as possible. The moonman's head will then be stuck in the wall and if you jump it's sometimes possible to fall down.

So I spent the last few weeks integrating Box2D into moonman, so now all tiles are completely impenetrable. ;)

Here's a pic!
(http://moonman.io/wp-content/uploads/2012/11/physics5thnov.png)

There's a test build here (http://moonman.io/files/moonman%200.21.zip) (windows) but nothing's really changed on the surface, and I've disabled animation. But if you're interested in seeing a SFML/Box2D/tile-based platformer in action then give it a go.

F1: profiler
F8: show physics bodies



CHANGELOG

0.21 06/11/2012
Refactored physics to use Box2D
added glm lib
added variable jump height and jump after fall delay
fixed ascent control
added platforms
Use a smaller fixed timestep with proper accumulator
Renderer interpolated for smoother results
Added basic ladder support in physics (not yet in-game)
Added physics debug drawing (f8)
Smoothed camera a bit
Sped up physics by ~400% with a simple 4x4 tile grouping optimisation
increased platform height, added contact normal check, and decreased foot height
Stackable blocks now act properly, can't have stackable slopes unless upside down
Upside down slopes behave properly now
moved physics sim() to execute phase, added fluid manager toprofiler
basic support in physics for multiple chunks
incremented version number, disabled animation
mm accelerates faster up slopes to give fluidity
extended platform length
platforms only collide if normal has a small x component, which fixes hitting the sides of the platforms
tuned some constants in physics
Made logging more verbose, but still needs to be verboser

Title: Re: moonman
Post by: The Terminator on November 06, 2012, 02:39:05 pm
Moon man looks cool! I'm on my iPhone at the moment so I can't try it but it looks pretty fun. I like the water update :)
Title: Re: moonman
Post by: FRex on November 06, 2012, 04:02:54 pm
Cool. :) Did you make own box2d debug drawer or..? ;)
Also, what did you use for tiles? Chain shapes? I ask cus the physics seem a bit jiterry. But since every tile is removeable it has to be own shape.. :|
Also may I ask why choose cegui instead of certain other gui dedicated for sfml? ;D
Title: Re: moonman
Post by: Nexus on November 06, 2012, 05:40:21 pm
Cool, looks already quite nice :)

The first time, the game crashed at starting with 1024x768, now it works.

The collision detection is not very fluent, one changes the height while walking. When you stand still, the character trembles for a short time. I don't know what you can do on Box2D side, but I'm sure you find a possibility ;)
Title: Re: moonman
Post by: eigenbom on November 06, 2012, 10:30:43 pm
thx guys, yeh the jittery-ness is because of both the camera movement and box2d, and to be honest i hadn't really noticed it, but i do now! :)

for the debug drawer i just hacked apart the box2d one, i basically just do an AABB query of the screen rectangle to get all the visible fixtures then use slightly hacked versions of the debug drawing routines in b2World, just copied and pasted into my own classes. ;)

the tiles are all just separate polygon shapes, grouped into bodies of 4x4 tiles to speed up the broadphase. i'm actually super-stoked to see it running at under 2ms/frame on my comp, but i'll have to address that jitteriness, most likely just in the renderer.

hmm cegui, yeh ... you know i think I tried tgui and sfgui a while back , as well as other gui libs like gwen etc., but i think i settled on cegui mainly because it has been used successfully in commercial projects, although it is quite a beast to use, considering my gui requirements are quite low! ;)

Title: Re: moonman
Post by: eigenbom on November 06, 2012, 10:32:01 pm
The first time, the game crashed at starting with 1024x768, now it works.

Hmm, could you try crashing it again and checking/posting the log.txt? Is your screen resolution less than 1024x768?
Title: Re: moonman
Post by: FRex on November 06, 2012, 11:44:59 pm
I think somewhere in the manual it's stated that you can have all static fixtures on one body. Also , the jitter can be caused by using 1 shape/ 1 tile, that's the reason edge chains exist(to fix problem with jitter movement over touching shapes).
Title: Re: moonman
Post by: eigenbom on November 06, 2012, 11:52:57 pm
I think somewhere in the manual it's stated that you can have all static fixtures on one body.

Oh really? I'll have to check that out.

Quote
Also , the jitter can be caused by using 1 shape/ 1 tile, that's the reason edge chains exist(to fix problem with jitter movement over touching shapes).

Yeh I considered chain shapes, and they are still an option, but they require a more complex algo to setup. I solved earlier inter-tile issues by using a circle for moonman's feet, so if I can fix the small amount of jittering in the renderer then I'll be happy.
Title: Re: moonman
Post by: FRex on November 07, 2012, 12:13:32 am
Quote
Note that every fixture must have a parent body, even fixtures that are static. However, you can attach all static fixtures to a single static body.
http://www.box2d.org/manual.html in 2.2
I don't know what impact on performance would that have but probably none since density, mass, velocities and dampings don't apply to static bodies.
Title: Re: moonman
Post by: eigenbom on November 07, 2012, 12:24:03 am
Quote
Note that every fixture must have a parent body, even fixtures that are static. However, you can attach all static fixtures to a single static body.
http://www.box2d.org/manual.html in 2.2
I don't know what impact on performance would that have but probably none since density, mass, velocities and dampings don't apply to static bodies.


Quote
Note that every fixture must have a parent body, even fixtures that are static. However, you can attach all static fixtures to a single static body.

Hmm .. yeh it says that you can do it, but doesn't say anything about whether its optimal to do so or anything. As far as I understand it, Box2D uses a body's AABB in its broadphase, so being smart about how you group your static fixtures into bodies should give a speed-up, which is basically what I've done.. but then again I have no idea what magic Box2D is doing underneath.. :D
Title: Re: moonman
Post by: FRex on November 07, 2012, 12:35:34 am
It's optimal. Trust me.  ;)
I know, you don't...well, suit yourself  :P :
Erin recommends it:
http://www.box2d.org/forum/viewtopic.php?f=3&t=7968

Quote
I recommend placing many fixtures on to a few static bodies. I would use one static body per 100 meters.

Box2D has some traversals of the body list that can be slow when the lists are huge.
Title: Re: moonman
Post by: eigenbom on November 07, 2012, 12:51:58 am
It's optimal. Trust me.  ;)
I know, you don't...well, suit yourself  :P :
Erin recommends it:
http://www.box2d.org/forum/viewtopic.php?f=3&t=7968

Quote
I recommend placing many fixtures on to a few static bodies. I would use one static body per 100 meters.

Box2D has some traversals of the body list that can be slow when the lists are huge.

Ah cool, thx heaps for the link. It's not that I don't trust you, its just that its a complex problem, and I have no idea what your experience with tile-based box2d programs are.. :)

I don't think Erin is talking about terrain that can undergo lots of local changes like mine, but rather probably a single static body that is created at start-up and not changed afterwards. But if I get a chance I'll do a quick hack and test it out, only when I implement it and see the actual speed-up would I be convinced. And its currently working so fast anyway, I've already reduced it from like 40ms to 2ms per frame, which is approaching 'fast enough' for me. :)
Title: Re: moonman
Post by: FRex on November 07, 2012, 01:00:54 am
None really, but googling "<library name> forum <problem>"(ie "box2d forum many fixtures on one static body" top 5th result) is extremely effective. ;D
Title: Re: moonman
Post by: eigenbom on November 07, 2012, 01:14:39 am
None really, but googling "<library name> forum <problem>"(ie "box2d forum many fixtures on one static body" top 5th result) is extremely effective. ;D

um, ok then, well thx ???
Title: Re: moonman
Post by: Nexus on November 07, 2012, 01:35:44 am
Hmm, could you try crashing it again and checking/posting the log.txt? Is your screen resolution less than 1024x768?
No, my screen resolution was above. I can't reproduce it anymore, even not after unpacking again. So maybe it was something else, don't waste too much time here...

Is it intended that the player can quarry stones behind other stones? If not, it would still be nice if he would automatically mine the ones in front first, and then the others, without moving the cursor. Therefore, one doesn't need to hover with the mouse over every tiny block again and again, because as mentioned in an earlier post, this quickly becomes annoying.
Title: Re: moonman
Post by: eigenbom on November 07, 2012, 02:02:07 am
Hmm, could you try crashing it again and checking/posting the log.txt? Is your screen resolution less than 1024x768?
No, my screen resolution was above. I can't reproduce it anymore, even not after unpacking again. So maybe it was something else, don't waste too much time here...

Hah, strange, oh well, thx for trying. :)

Quote
Is it intended that the player can quarry stones behind other stones? If not, it would still be nice if he would automatically mine the ones in front first, and then the others, without moving the cursor. Therefore, one doesn't need to hover with the mouse over every tiny block again and again, because as mentioned in an earlier post, this quickly becomes annoying.

Yeh I've actually just (this last hour) made it so you can't mine blocks that are occluded by other blocks. I really like the idea of automatically mining blocks in front of you if you hold down the mouse button, thx. I'll add it to my TODO list and hopefully get some time to play with that idea.
Title: Re: moonman
Post by: Nexus on November 07, 2012, 02:35:42 pm
To find out which tiles to quarry, you could look at the Bresenham algorithm. Maybe you can adapt it somehow to your game.
Title: Re: moonman
Post by: FRex on November 07, 2012, 04:57:52 pm
Box2D has effective quad-tree-magical ray casts and aabb queries but they're a bit weird.
But everything is explained here:
http://www.iforce2d.net/b2dtut/world-querying
Title: Re: moonman
Post by: eigenbom on November 07, 2012, 10:34:54 pm
Quote from: Nexus
To find out which tiles to quarry, you could look at the Bresenham algorithm. Maybe you can adapt it somehow to your game.

Yeh I've implemented Amanatides algorithm (http://www.cse.yorku.ca/~amana/research/grid.pdf) for voxel tracing that I used in my old physics collision code,  but instead of using that I actually just implemented a really simple method for detecting if a block is occluded .. which is simplified because the mining radius is only 3 blocks which reduces the number of paths to a block.

Quote from: FRex
Box2D has effective quad-tree-magical ray casts and aabb queries but they're a bit weird.
But everything is explained here:
http://www.iforce2d.net/b2dtut/world-querying

Cheers, yeh I had hoped to use b2d's ray-casting for the bullet/laser trajectories. Failing that I'll fall back on the voxel traversal.

thx guys!
Title: Re: moonman
Post by: eigenbom on November 14, 2012, 05:29:34 am
A few updates, just putting a few things back in, like animation, and fixing various bugs. I also spent a few hours getting moonman running on OSX, and after a few hiccups its finally working. thx sfml!

(http://moonman.io/wp-content/uploads/2012/11/macman.png)

In the next update the game will be more "gamey", with health bars, enemies, etc. :)
Title: Re: moonman
Post by: eigenbom on February 01, 2013, 07:13:13 am
Cross-post from here (http://forums.tigsource.com/index.php?topic=21997.msg844631#msg844631)

Update: I've uploaded version 0.3! This is the last of the tech demo builds. From the next build onwards, moonman will be an actual game. :)

Download moonman 0.3 windows (http://moonman.io/files/moonman%200.3.zip)
Download moonman 0.3a osx (http://moonman.io/files/moonman-osx-0.3a.zip)

I appreciate any and all bug reports or funny behaviours. Please refer to the readme.txt for instructions and keymappings. There are keys to spawn spiders, give yourself lots of loot, etc.

The bad news is that I'm taking a month long hiatus on moonman, in order to get my ios game finished and published. The good news is that once that's finished I'll be spending much more time on moonman, sprinting towards releasing the first commerical version in June/July. Exciting and busy times!

As always, thanks for reading.


Changelog for 0.3
-----------------
heaps of refactoring!
stalactite block
ctrl+click is right-click on mac, so removed water click function
Replaced cegui logging window with manual SFML-based window
show rectangle around selected block for mining
ladders!
block flashes on hit
leaves slope block
inpenetrable blocks on border
disabled block tinting
draw black rects for border chunks
fix: light shouldnt come through border chunks
disabled start-up image
vines are now climbable
added in-game menu
f2 - edit mode
added ‘save&quit’ to menu
dark outline render mode (fancy mode) now optional and disabled by default
tab hides all UI stuff
full cleanup of background renderer
fix: renderer was slow
spiderweb slight colour variant/tint
dont repeat jump with space, wait until it is repressed
fix: colours, minimal palette
items are picked up via collision with mm using physics system
inventory - can drag items into world
fix: background renderer was slow, not I cull occluded stars and use
vertexbuffers
MAJOR: removed cegui
refactored function calls into game events, e.g., EV_SWAP_ITEMS
refactored: Messages are now called Events
renderer: Snap all objects to nearest pixel to prevent jittering
MAJOR: Particles!
blocks register a “particle_colour” (default is just dirt colour)
fix: made world saving safer, by saving the world to a tmp file and then do a filecopy when its done   
MAJOR: can mine + place background blocks (called "walls") The hammer is used
to mine walls.
Added minimum damage threshold to blocks (so we cant mine diamond with our hands!)
Added spawn_block_on_destroy, so some blocks don't create block items when
destroyed (e.g., glass)
Added block attachment logic. E.g., grass is destroyed if the dirt below it is
destroyed. Also vines, stalactites, etc.
fix: can place non-collidable objects under self
pick axe is now good at picking stone and rock both
added life/death/respawn
Can kill all things with ‘k’
added health bar
all entities receive falling damage
added 'u' and 'y' keys to spawn mobs
mm damaged when spider collides with him
changed background (temporarily)
made a new game launcher


(http://moonman.io/wp-content/uploads/2013/01/pt3a.png)

(http://moonman.io/wp-content/uploads/2013/01/pt3b.png)

(http://moonman.io/wp-content/uploads/2013/01/pt3c.png)

(http://moonman.io/wp-content/uploads/2013/01/pt3d.png)