Saturday 11 May 2013

Mechanics

I've just finished rewriting the mechanics code, which I had been putting off because it's so bloody complicated. But it's done now, which is great news because now the game engine itself is feature-complete.

Fun

Blackshift's mechanics system is what I call the code that handles pushing blocks, deciding what is pushed by what, what gets to move, what doesn't, and what is crushed. It's not a full physics simulation, it's much simpler and more abstract, which ironically makes it more difficult to code. Why? Because fake, abstract physics is specific to your game, whereas more realistic physics can be achieved using off-the-shelf libraries with little or no modification. Neither is better, but each suits a different type of game. Of course, you're free to use the wrong sort of physics for your game on purpose...

Not Tetris 2, Stabyourself.net

Blackshift's mechanics are, in a nutshell:

  1. The player, enemies, arrow blocks, and anything on a force floor generates a force.
  2. Forces propagate through blocks.
  3. Clusters of sticky blocks always move together.
  4. Once all the forces are propagated, anything that can move does.
  5. Anything that can move in more than one direction moves in the direction of the strongest force.
There are some other rules as well, to deal with annoying questions like "What happens if a cluster of sticky blocks has two different force floors under it?" and "Can arrow blocks push each other?"

In the end, I'm happy with how the mechanics work and I think we'll be able to get a lot of puzzle mileage out of them, especially when combined with the four sorts of blocks:
  1. Normal block; can be pushed and can push other blocks along in long columns.
  2. Heavy block; can only be pushed by the player, not by other blocks.
  3. Arrow block; pushes itself in one of four directions.
  4. Sticky block; always moves together with adjoining sticky blocks.
That should be enough for now, but if I think of any awesome new blocks (that won't mess the code up) I won't hesitate to add them. Any ideas?

(I'll post a video of the new mechanics in action once I'm free of all these embarrassing placeholder graphics.)

7 comments:

  1. Ideas? Well, let's see:

    -extra-light blocks that can be moved by shooting at them
    -blocks with chassis which only can be moved when turned on
    -explosive or fragile blocks (OK, that might be just an additional feature)
    -railway-blocks only pushable in certain paths/directions
    -'ice' blocks which slide until they hit a wall
    -blocks with handle that can be pulled as well
    -magnetic blocks attracting/repelling each other when close enough
    -combinations of the above (or rather not)

    Not saying that any of this would be necessary or even a good idea, I just listed everything that came to mind.
    Nice example for game with wrong sort of physics btw ^^
    Wunk

    ReplyDelete
    Replies
    1. Thanks for the input! Some good ideas there; I'm really not too fussed about adding too much stuff to Blackshift. I'll just make sure I don't foist it all on the player at once.

      Actually I already have explosive blocks; I forgot to mention them in the post. Magnets are a neat idea.

      Delete
    2. If you really need to add more blocks, I dunno. If you make the game too complicated, it will diminish the attraction to an already brilliant game. Magnets are interesting. However, they would have to be activated and deactivated.

      Delete
  2. 1.jump block:blocks that has a number on it which shows how far it jumps if the destination has enough space(think about sticky jump blocks, they need more than 1 space)
    2.friend block: only if there is another friend block nearby, it can be moved
    3.rotator: several sticky blocks which has an axis on one of the blocks, can be rotated if the goal has enough space.
    I have more ideas but they on my personal computer, I'll check type it.

    HZF

    ReplyDelete
    Replies
    1. Thanks! By the way, are there any other Chinese characters that make sense on their own which would work well on floor tiles? Things like 'safety', 'danger', 'this way', 'enemies' etc?

      Delete
  3. Yes, there are(the complicate one is traditional Chinese character):
    'safety':安;
    'danger':危;
    'this way':此;
    'that way':彼;
    'enemies':敌;
    'friend':友;
    'true':真;
    'false':假;
    'single':单,單;
    'double':双,雙;
    'triple':仨;
    'strong':强;
    'weak':弱;
    'magnet':磁;
    'jump':跳;
    'light':轻,輕(Antonym of heavy);
    'heavy':重;
    'explosive':爆;
    'railway':轨,軌;
    'ice':冰;
    'rotator':转,轉。
    Actually, a Chinese character usually have several meanings, so in daily use(modern use), we use word which made of two Chinese characters more. Take 'safety' for example, we use "安全",but our ancestor(hundreds of years ago) use "安" in Classical Chinese.
    Many people in China mainland can't write traditional Chinese characters,but most of them can recognize most of traditional characters.

    ReplyDelete
    Replies
    1. Dude I just noticed your post – this is great stuff, thanks a lot!

      Delete

Note: only a member of this blog may post a comment.