Skip to main content
step3

Creating circular worlds like Democracy

Last Ludum Dare I implemented a circular world for my game. I wanted to do that for some time, but before this LD I had no idea how to implement such a thing. Now I see that is pretty easy to do so. In this post I will explain how to create a circular world like the one I used in Democracy.

The beauty of a circular world is that we can work only with the radius of the planet, ignoring its position at the screen. So, first thing to do is defining our planet to a radius “r” (lets say 150px) and to screen position (0, 0). To center the planet in the window, you move the camera to (-w/2, -h/2) where w is the window width and h is the window height. You should see something like this:

step1

Now that we have an empty world, lets add some objects on it. All objects must have a position in this world, but this position isn’t the same of in screen, it is simpler. Suppose that at the point (0, r), what could be the north of our planet, is the angle 0°, then the east (r, 0) is 90° and so on, until the north point again. See the image below for reference:

step1-2

Now our object can be at positions like 47° or 270°, but we still must draw it into the screen. That’s pretty simple. Let’s say we have a sprite with (s_w, s_h), width and height, respectively. Then we set its screen position to (0, 0) and its anchor to (0, r+s_h). With this we have an sprite at the north point 0°, to relocate it to 306° we simply set its rotation as “sprite.rotation = 306” and done!

step2
White box is at north (0°) and the red box is at 306°.

Additionally you can also set the height of the object in that world (the distance of that object to the ground). To put a cloud at 30px high, you simply add the height to the sprites anchor, such that anchor is (0, r + s_w + height):

step3

Sometimes you may find useful to convert the world position, now (position, height), to the screen position. For example, to add some particles. So, to find the screen coordinates (x, y) of an object at (position, height) you do:

Contrarily, when you want to convert the screen position to world coordinates, for example to find where the mouse is pointing. You can do:

Simple right?

Let me know if you found this article useful, or if you have an alternative way to do that, or yet, if you created some circular world based on this. Cheers!

sample1

LD32 Progress Report #1

So, I finally decided what to do for this ludum dare, which has the theme “unconventional weapon“. My weapon of choice is “Democracy“, a humble tribute to Heinlein’s novel – and, of course, the Verhoeven’s movie – Starship Troopers.

Player controls an invasion operation at a distant planet, inhabited by big insects , in order to spread “democracy” through the galaxy. The player must exterminate the insects and collect the planet resources to win.

This is what looks like for now:

sample1

ss2

My Entry for Ludum Dare 31: Baa-Ram-Ewe

banner

Finally I finished my entry for this Ludum Dare (LD31, the theme is The Entire Game on One Screen). This time, I am so exhausted that I couldn’t do any progress report during the weekend, but, on the other hand, I could finish the game, including the mechanics, graphics and sounds.

My idea was creating something with artificial intelligence (again) and for some reason, after the theme announcement, I remembered that I never touched at a flocking algorithm and this would be a good opportunity for it. The game idea is to take some sheeps from one point and bring them to another, without letting them to leave the map or to be killed. The player uses the mouse to herd the sheeps, which will behave accordingly to their neighbor mates and some tiles in the environment.

As tradition, I writing here a summary of the competition:

What was good:

  • Could finish the game!
  • Cute sheeps with nice behavior;
  • I could follow the schedule without any change;
  • I could do some music and sound effects;
  • I drawn my first tileset!

What wasn’t good:

  • Lot of problems with collisions ;/
  • Spend a lot of time with rotation math (shame on me);
  • The sound effects are pretty limited and the music is too simple;
  • The graphics are cool but some things I’m hating, such as the windmill;
  • I had to redraw the tileset 2 times!

Which technologies and techniques I used:

  • The sheeps are controlled by a flocking algorithm, (or boid algorithm) as described here and here;
  • The graphics were made in Inkscape;
  • The map were built in Tiled, using a 32×32 tileset;
  • I recorded the audio for the sound effects in Audacity;
  • The music were made in Guitar Pro and converted in audacity;
  • CreateJS and Creatine were used as programming base;

anim1

(VIEW LUDUM DARE ENTRY | PLAY BAA-RAM-EWE)

chibi_plan

Planning for my game on Ludum Dare 30

I’ve just finished the planning for my game (still untitled)!

chibi_plan

Well, even before the theme, I was planning to base the game on AI in order to use some behavior trees. Thus, I was hoping to include some autonomous agents to the game. So, when the theme was revealed, I had this idea:

Everybody wants a person to share a life, to found a family, to fall in love, to marry, etc; and when this happen, one person connects its own world to the other.

My game aims to connect worlds metaphorically: chibis walking in the park looking for their unknown loves while you protect them from obstacles (such as bad matching and meddler chibis).

It seems that this is an ambitious game and I hope I can finish it in this weekend.