Saturday, December 20, 2014

2D ragdoll physics using Box2D

This video contains five scenes showing 2D ragdoll physics and some other fun stuff that can be made using Box2D and my editor. The engine is written in C++ and is based on SDL2 and OpenGL.

Here are some features that can be seen in this video:

- skeleton flipping/scaling, joint limits
- custom gravity for maps, mouse joint
- skeleton animation to ragdoll transition
- player controlled vehicles (event-action)
- removing bodies and joints in realtime - railgun
- adding joints in realtime - stakegun

Big thanks to thecplusplusguy and iforce2d for their tutorials. Without those I probably wouldn't even start working on this:

You can download and try it out. There are some rendering glitches that can appear, I don't know what is causing those.

Saturday, December 6, 2014

Map editor preview

I had to make a map for another video, so I decided to record it and upload a time-lapse. I thought it will go faster, but it took me over an hour. This is the first time I used the new editor to actually make a map. It's great that I managed to work on a map for that long without any crashes.

This video shows only the basic features:
- multiple layers
- adding sprites
- changing textures
- scaling and resizing (vertex and line based)
- rotating
- delete, copy, cut, paste single or multiple sprites using a selection box
- paste preview
- moving sprites in front or behind each other
- moving sprites to a different layer
- parallax scrolling
- basic Box2D bodies

I have uploaded it as Public Build 1 and updated the manual. You can download it here:

Tuesday, November 25, 2014

Quake 2D secrets, cheats and source code

I am releasing the source code of my 2012 Quake 2D demo to public. You can download the code on my GitHub page. For more details about this project you can check out the dedicated page on the left of this blog.

I have also uploaded a video that shows in game secrets, cheats and different player models. It was also recorder in 60 FPS in HD since now my PC can handle it. In short you'll be seein flying Luigi blowing up Quake 2 enemies using Serious Sam weapons in bullet time. GOTY 2012 right there.

Saturday, November 8, 2014

Random Thoughts #1

Few days ago I finally got my new PC up and running, now with a brand new Antec power supply and a new Dell P2414H monitor. I still have to get used to certain things:
- How quiet the PC is. Event though there are total of 7 fans inside the loudest thing is the hard drive. Sometimes I'm not sure I have turned it on/off or not.
- How nice the text looks on this new monitor and how nice the contrast is. I wasn't even aware how bad my old monitor really was. Some internet sites look completely different now.

Haven't spent much time playing video games with the new PC, but everything looks crisp on 1080p. Really a huge difference. I can't imagine how games would look like on a 27"/30" screen on 1440p or 4K. Maybe in few years I will get there...


With the new PC rebuilding the engine and game takes around 1 and a half minute, while on the old one it took around 4 minutes. Sometimes I would forget what I was doing while waiting.

While I was waiting for my power supply to be replaced I did a lot of cleaning up. I fixed many bugs and editors seem to be crash free now, so I can finally try to make something to show the engine engine updates.

Monday, October 6, 2014

Random Thoughts #0

99% of programers work is not visible to the end user. You can render a texture on screen or play an audio file and people can more-or-less tell how much work it was put into making it. But how can you tell how much work did it take to get that texture even appear on the screen ?

Bla, bla, bla... On the left of the blog in the Broken Mug Engine section is a link to the "Changelog" page, where I will be listing the changes and fixes made to the engine, so you can see what is going on behind the screen.


I had big problems with dynamic light, so I rage quit, and didn't touch the code for several weeks. Then I bought a new PC after 9 years. I spent a lot of money, just to be sure it will be a build that will last. And what happened ? The Corsair power supply doesn't work properly, so I had to send it back. Now I'm waiting for it to get either replaced or fixed.

So I'm back in 2005 with a PC that takes forever to build the engine. At least it never needed any fixing. To get back on topic, I fixed the dynamic light problem and since I have no idea what to do with it, or what to do in general with the engine, I just clean all the messy and crash-friendly code. Some of the GUI features now run automatically, so I don't have to write redundant code. Also connecting and disconnecting various in-game entities is also done in the background and hopefully it will prevent crashes, like when I was doing it manually.

Tuesday, September 2, 2014

Dynamic 2D light

Since I have no AI that could use line of sight, I revisited my old dynamic light code(which was used to make line of sight in the first place), and replaced it with the line of sight stuff. It inherits a sensor class which keeps track of objects inside it, and then calculates the shadows/final light shape for rendering. You may notice lights are rendered with additive blending.

If you look at the health packs you will see this methods flaw. It is vertex based, so if a texture has transparent areas, you can see obvious gaps.

It also currently only supports convex shapes, and I would like to make light outlines on the sprites that the light hits.

Thursday, August 28, 2014

Line of sight

Working on some kind of 2D line of sight.

It's cool that I can get the area of the enemy/player which is visible, so let's say if enemy can see only a small part of the player it doesn't have to attack right away, but come closer or something... Just like for the destructible terrain I am using Clipper for this.

Thursday, August 21, 2014

Worms like destructible terrain using Box2D and Clipper

I made a little demonstration of Worms like destructible terrain made using Box2D chain loops and polygon clipping library called Clipper.

You can download it or read how it's done here:

Friday, August 8, 2014

Event listeners - player controls

I've made a new type of event listener which triggers an action when player presses a keyboard key or mouse button. Still need to make it block/unblock player controls, so the player sprite doesn't move if it controls something else, but whatever...

As an example I made a vehicle which can go left, right and break, all via event listeners and actions that control a Box2D joint motor. It's all done in the map editor.

Tuesday, August 5, 2014

Poly2tri and Box2D

Using poly2tri to triangulate complex polygons, then using the triangles to form Box2D bodies with multiple fixtures (triangle=>fixture). Box2D only supports convex polygons, this way I can make concave ones too. This way I could simulate almost pixel perfect collision, but that is overkill in most cases.

Wednesday, July 30, 2014

Tuesday, July 15, 2014

Lines of code...

With my current PC (from 2005) it takes 3 minutes and 30 seconds to rebuild everything:
- 190 files
- 26852 lines of code

That would be 3500 lines more than two months ago, and this doesn't include all the GUI layouts written in XML. Coding editors is really time consuming...

Friday, July 11, 2014

In-game event listeners and actions

Adding some event-action magic to my engine and map editor.

This is how it looks in the editor. I am not sure if all this makes sense and how it's usually done. In this setup when players bullet hits the orange button the attached event listener starts one action which activates a particle emitter, and an action that activates motors of attached Box2D revolute joints. The yellow lines are clickable, so the connections can be deleted.

And this is in game:

Of course this is just the beginning. I need to add a lot more different event listeners and actions that can modify different types of entities in the map.

Saturday, June 7, 2014

Broken Mug Engine - SDL OpenGL GUI and font rendering

First video of my game engine showing some GUI features and font rendering. It is written in C++ and is based on SDL and OpenGL. Most of the GUI layout is defined in external XML files including the two themes.

To make the video more interesting I made a little preview of my map editor, Box2D physics and 2D model editor.

For more info you can visit these blog pages: GUI or Font

Monday, May 19, 2014

I think this blog's current design is OK and pages for all important released projects are up(actually left). Now I should focus more on current and future stuff.

Monday, May 5, 2014

I guess I should write something about this blog...

This will basically be my home page/portfolio where I will post about my past and current projects. It will mostly be about programming and game/engine development, but I may occasionally post something about my other hobbies.

To do:
- figure out the design
- make pages for every released project
- put links to good tutorials and tools
- post about new engine
- release something new already

Friday, May 2, 2014