Posts Tagged ‘Unity’

Silly programming challenge: Choose randomly -1 or 1

Thursday, July 7th, 2016

My friend Aviv, a fellow Unity developer, and me were trying to figure out how many different significant ways we can come up with to solve the simple problem of choosing a random value.
You can try this silly challenge yourself, or jump right to our solution.
Let me know if you found other solutions.

[spoiler name=”solutions”]
float ex1 = Mathf.Sign(Random.Range(-0.5f, 0.5f));

float ex2 = Mathf.Sign(Random.Range(-1,1));

int ex3 = (Random.Range(0,2) * 2) – 1;

int ex4 = Random.Range(0,2);
if (ex4 == 0) { ex4 = -1; }

int[] choices = new int[]{-1, 1};
int ex5 = choices[Random.Range(0, ex5.Length)];

int ex6 = (Random.value > 0.5f) ? 1 : -1;

int ex7 = Mathf.Sign (Random.rotation.x);

List<int> values = new List<int>(){1,-1};
int ex8 = Random.Range(-1,2);
while (!values.Contains(ex8)) { ex8 = Random.Range(-1,2); }

[/spoiler]

Of those, I would say ex1 is too similar to ex2 (also it was interesting to notice it would work with integers too).
So I would score us 7 solutions.

I would choose ex6 for real life usage, since I think it’s the most readable.
ex7 is the funniest but it should work (notice we are using the UnityEngine library, not the System library)

Ens艒 is out

Monday, May 30th, 2016


Remember my Planet of the Apps teaser-post?
My game is out!

Apple App Store – http://clk.im/Enso_YT_iOS
Google Play Store – http://clk.im/Enso_YT_A

The Harder They Fall

Wednesday, December 9th, 2015

This weekend we are having Ludum Dare 34!
Not sure if I will participate yet 馃榾
But it does remind me of my Ludum Dare 32 Project: The Harder They Fall.
52461-shot0-1429515768.png-eq-900-500
The subject was: “An unconventional weapon”.
So we decided to go for Bubble shooter in Space.

The game requires both mouse and arrow-keys, and it takes a while to load.
You can try it here.
Like a lot of my games, I sometimes wonder if I should make a better version of this…

Planet of the Apps

Wednesday, December 2nd, 2015

Hello Readers,
I’m excited to share I’ve joined the amazing team at Planet Of the Apps!

And I just started my first project.
Here is a first screenshot from inside the Unity editor:
12316561_10153381414749405_670012374930000027_n

Can you guess how it plays?
^_^

“Princessize” is getting noticed

Thursday, November 19th, 2015

I already posted about our game Princessize and how it got to be featured on Rock Paper Shotgun.

So, since than, other known and less known sources showed interest in this game.

The top of those – more than 100K viewers watched our game being played by CinnamonToastKen:

Thanks, Ken!

You can get it on Google.Play
Or try it on the web