October Challenge.. Again!

Last year I posted quite enthusiastly that I was going to participate in Ludum Dare’s october challenge, which is “Finish a game — Take it to market — Earn $1”.

Back when I posted that, I had just found was Unity3D was and was amazed of how quickly I could do game prototypes. As you may know, I’m developing Memtiles and although I would love to say that I’m really in this year, it might be complicated. Anyway, Ludum Dare’s October Challenge is up again, so go for it!

I’ve aimed the end of the month to release the game. If everything goes according to plan, I’m going to have all the artwork ready, music, and gameplay. Then I release it, and make a marketing plan to advertise it. So I might not be making my first $1 this month, but hey, at least I’ll be finishing my first game :)

PS: As soon as I have the final artwork, I’ll post some more screenshots. :) I can already say that the games looks nothing like the Beta version. :) Its much, much better :)

Memtiles is almost done

After nearly a month after the beta release of Memtiles, I’m nearly in the end of development. I’ve basically being updating and creating new assets, textures, checking for sound effects, hiring for music composition and graphics. So it has been pretty busy. Mainly because I’m working part-time on this project, only when I come home from work, and on weekends.

Today I lost all connections to my assets, prefabs, textures, everything.. I don’t know what happened to Unity3D, but that sure as hell cost me 3 hours rebuilding all prefabs. I guess I should back my things before opening a new branch.. or check what to ignore on bitbucket.. Anyway, I have my prefabs back.

Screen Shot 2013-09-21 at 1.35.38 AM

So now I can actually focus on progressing in the development. I still have game art and sound/music coming up.

Hopefully I will still release this by mid/end october.

Memtiles for Android in Beta Phase

header

So I’m making a casual memory game for mobile platforms. Its a simple educational puzzle, where you need to retrieve the tile pairs on the grid.

There is currently only one mode and one theme, but more will be added this month. There will be 3 more themes and a new game mode (maybe). There is also the educational part to do :)

You can play it online in your browser at MichaelAdaixo.com/MemtilesBeta and also download the latest apk version for Android, from 2.3.1 to 4.x.

Please report any bug you might find, as well as suggestions. :)

Thanks.

The Elements of Programming Style

The following rules of programming style are excerpted from the book “The Elements of Programming Style” by Kernighan and Plauger, published by McGraw Hill. Quote from the book:

“To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually fi nd in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules.”

  1. Write clearly – don’t be too clever.
  2. Say what you mean, simply and directly.
  3. Use library functions whenever feasible.
  4. Avoid too many temporary variables.
  5. Write clearly – don’t sacri ce clarity for “efficiency”.
  6. Let the machine do the dirty work.
  7. Replace repetitive expressions by calls to common functions.
  8. Parenthesize to avoid ambiguity.
  9. Choose variable names that won’t be confused.
  10. Avoid unnecessary branches.
  11. If a logical expression is hard to understand, try transforming it.
  12. Choose a data representation that makes the program simple.
  13. Write fi rst in easy-to-understand pseudo language; then translate into whatever language you have to use
  14. Modularize. Use procedures and functions.
  15. Avoid gotos completely if you can keep the program readable.
  16. Don’t patch bad code – rewrite it.
  17. Write and test a big program in small pieces.
  18. Use recursive procedures for recursively-de fined data structures.
  19. Test input for plausibility and validity.
  20. Make sure input doesn’t violate the limits of the program.
  21. Terminate input by end-of- line marker, not by count.
  22. Identify bad input; recover if possible.
  23. Make input easy to prepare and output self-explanatory.
  24. Use uniform input formats.
  25. Make input easy to proofread.
  26. Use self-identifying input. Allow defaults. Echo both on output.
  27. Make sure all variable are initialized before use.
  28. Don’t stop at one bug.
  29. Use debugging compilers.
  30. Watch out for off -by-one errors.
  31. Take care to branch the right way on equality.
  32. Be careful if a loop exits to the same place from the middle and the bottom.
  33. Make sure your code does “nothing” gracefully.
  34. Test programs at their boundary values.
  35. Check some answers by hand.
  36. 10.0 times 0.1 is hardly ever 1.0.
  37. 7/8 is zero while 7.0/8.0 is not zero.
  38. Don’t compare foating point numbers solely for equality.
  39. Make it right before you make it faster.
  40. Make it fail-safe before you make it faster.
  41. Make it clear before you make it faster.
  42. Don’t sacri ce clarity for small gains in “efficiency.”
  43. Let your compiler do the simple optimizations.
  44. Don’t strain to re-use code; reorganize instead.
  45. Make sure special cases are truly special.
  46. Keep it simple to make it faster.
  47. Don’t diddle code to make it faster. Fi nd a better algorithm.
  48. Instrument your programs. Measure before making “efficiency” changes.
  49. Make sure comments and code agree.
  50. Don’t just echo the code with comments . Make every comment count.
  51. Don’t comment bad code – rewrite it.
  52. Use variable names that mean something.
  53. Use statement labels that mean something.
  54. Format a program to help the reader understand it.
  55. Document your data layouts.
  56. Don’t over-comment.

Hope that helps :)

Generic Method

I’ve come up with a pretty neat solution to this:
If you don’t want to write the same method for different data types, you can use generics.

///
/// Math Class that helps
/// 
public static class MathHelper
{
    ///
    /// Clamps value within desired range
    /// 
    ///Value to be clamped
    ///Min range
    ///Max range
    /// Clamped value within range
    public static int Clamp(int value, int min, int max)
    {
        if (value > max)
            return max;
        if (value < min)
            return min;
        return value;
    }

    ///
    /// Clamps value within desired range
    /// 
    ///Value to be clamped
    ///Min range
    ///Max range
    /// Clamped value within range
    public static float Clamp(float value, float min, float max)
    {
        if (value > max)
            return max;
        if (value < min)
            return min;
        return value;
    }

    ///
    /// Clamps value within desired range
    /// 
    ///Value to be clamped
    ///Min range
    ///Max range
    /// Clamped value within range
    public static double Clamp(double value, double min, double max)
    {
        if (value > max)
            return max;
        if (value < min)
            return min;
        return value;
    }
}

It’s pretty easy once you know what to look for :) Just search Generics c# and you’ll find a bunch of questions and answers on StackOverflow, msdn and CodeProject :)
Here’s the solution:

///
/// Math Class that helps
/// 
public static class MathHelper
{
    ///
    /// Clamps value within desired range
    /// This is a generic. So use any type you want
    /// 
    ///Value to be clamped
    ///Min range
    ///Max range
    /// Clamped value within range
    public static T Clamp(T value, T min, T max) 
        where T : IComparable
    {
        T result = value;
        if (result.CompareTo(max) > 0)
            result = max;
        if (result.CompareTo(min) < 0)
            result = min;

        return result;
    }
}

Pretty Cool eh!? :)

Now instead of having multiple methods to make the same operation, you have one that works for many types.

int val = MathHelper.Clamp(-1, 0, 2);              // for ints
float val = MathHelper.Clamp(-1.0f, 0.0f, 2.0f);   // for floats
double val = MathHelper.Clamp(-1.0d, 0.0d, 2.0d);  // for doubles

Coursera Again

So I could not finish, Algorithms I and II and Cryptography I and II because of work and my masters degree. But I enlisted to two other courses, that will be happening on my “masters vacations”. I’m still working 8+ hours a day, but I don’t have to study for exams now. :)

So I’m taking two interesting courses at coursera. First one is “Malicious Software and its Underground Economy: Two Sides to Every Story” and the other, maybe the one I will pay more attention because I really think I need it, “Startup Engineering”.

So far so good. I’m keeping up! :D
Coursera

Coin Generation

The new hype right now is to install a small app that will make you earn some money. I don’t know if its safe yet, but I’m trying it with some friends and I already made $40 this june. Mostly through referrals. I’ve also setup a website, http://www.coingeneration.co.uk, where I explain a little of what’s this all about, and then I take you to the official website with my referral link.

Check it out if you have the time.

GitHub Activity

So I’ve decided to put some of my work on github. I’ve been updating ChocoboHeaven.com yesterday and I might put it on github. I have a bunch of other little code snippets and projects that I’ll put there, so anyone can look at that.

Going Open Source :)