Oracle’s Java FAQ Displays in Chinese

17. January, 2014

I just looked at an article in the Oracle Java FAQ and I was a bit surprised to get this result:

         如何設定例外網站清單?


本文適用於:

  • Java 版本: 7.0

從 Java 7 Update 51 版本開始導入了例外網站清單功能。藉由將應用程式 URL 新增至「例外」清單,可讓使用者執行通常會被安全檢查封鎖的「豐富網際網路應用程式 (Rich Internet Applications, RIA)」。[...]

The solution was pretty simple: Append ?locale=en to the end of the URL: http://www.java.com/de/download/faq/exception_sitelist.xml?locale=en

That fixed it for me … sometimes.


Unhappy?

17. January, 2014

This might help:

The Holstee ManifestoCopyright information

The Holstee Manifesto
Copyright information


Upgrading from Xtext 2.3 to 2.4

16. January, 2014

This is a summary of the steps to upgrade from Xtext 2.3 to 2.4:

  • The plugin org.eclipse.xtext.xtend2.lib has been renamed to org.eclipse.xtend2.lib
  • In the *.mwe2 file of your DSL, replace EcoreGeneratorFragment with EMFGeneratorFragment
  • Run the *.mwe2 script to regenerate the whole project
  • Merge plugin.xml_gen and plugin.xml

import this

10. January, 2014

During the Flask presentation yesterday, I learned about an Easter egg in Python: “import this” which will print:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one– and preferably only one –obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea — let’s do more of those!


People Despair When They No Longer Experience Themselves as Efficacious

7. January, 2014

Simple fact: When you feel helpless, unable to change your circumstances, and when your input doesn’t spawn any reaction, you despair.


As I Began To Love Myself

26. December, 2013

This text/poem is attributed to Charlie Chaplin but there is some discussion whether this is true or not.

I’m not sure what is correct but I feel that the poem itself is too important to bother much about the details. There are two versions. Version 1 is from the Sahaja Yoga:

As I began to love myself
I found that anguish and emotional suffering
are only warning signs that I was living against my own truth.
Today, I know, this is “AUTHENTICITY“.

As I began to love myself
I understood how much it can offend somebody
as I try to force my desires on this person,
even though I knew the time was not right and the person was not ready for it,
and even though this person was me.
Today I call it “RESPECT“.

As I began to love myself
I stopped craving for a different life,
and I could see that everything that surrounded me was inviting me to grow.
Today I call it “MATURITY“.

As I began to love myself
I understood that at any circumstance,
I am in the right place at the right time, and
everything happens at the exactly right moment,
so I could be calm.
Today I call it “SELF-CONFIDENCE“.

As I began to love myself
I quit stealing my own time, and
I stopped designing huge projects for the future.
Today, I only do what brings me joy and happiness,
things I love to do and that make my heart cheer,
and I do them in my own way and in my own rhythm.
Today I call it “SIMPLICITY“.

As I began to love myself
I freed myself of anything that is no good for my health –
food, people, things, situations, and
everything the drew me down and away from myself.
At first I called this attitude a healthy egoism.
Today I know it is “LOVE OF ONESELF“.

As I began to love myself
I quit trying to always be right,
and ever since I was wrong less of the time.
Today I discovered that is “MODESTY“.

As I began to love myself
I refused to go on living in the past and
worry about the future.
Now, I only live for the moment,
where EVERYTHING is happening.
Today I live each day, day by day, and I call it “FULFILLMENT“.

As I began to love myself
I recognized that my mind can disturb me and
it can make me sick.
But As I connected it to my heart,
my mind became a valuable ally.
Today I call this connection “WISDOM OF THE HEART“.

We no longer need to fear arguments,
confrontations or any kind of problems with ourselves or others.
Even stars collide, and out of their crashing new worlds are born.
Today I know THAT IS “LIFE“!

There is also a YouTube version by Adrea Bezerra.

M.Peer Mohamed Sardhar posted a much longer and more complex version:

When I started loving myself” – A poem by Charlie Chaplin written on his 70th birthday on April 16, 1959:

When I started loving myself
I understood that I’m always and at any given opportunity
in the right place at the right time.
And I understood that all that happens is right –
from then on I could be calm.
Today I know: It’s called TRUST.

When I started to love myself I understood how much it can offend somebody
When I tried to force my desires on this person,
even though I knew the time is not right and the person was not ready for it,
and even though this person was me.
Today I know: It’s called LETTING GO

When I started loving myself
I could recognize that emotional pain and grief
are just warnings for me to not live against my own truth.
Today I know: It’s called AUTHENTICALLY BEING.

When I started loving myself
I stopped longing for another life
and could see that everything around me was a request to grow.
Today I know: It’s called MATURITY.

When I started loving myself
I stopped depriving myself of my free time
and stopped sketching further magnificent projects for the future.
Today I only do what’s fun and joy for me,
what I love and what makes my heart laugh,
in my own way and in my tempo.
Today I know: it’s called HONESTY.

When I started loving myself
I escaped from all what wasn’t healthy for me,
from dishes, people, things, situations
and from everything pulling me down and away from myself.
In the beginning I called it the “healthy egoism”,
but today I know: it’s called SELF-LOVE.

When I started loving myself
I stopped wanting to be always right
thus I’ve been less wrong.
Today I’ve recognized: it’s called HUMBLENESS.

When I started loving myself
I refused to live further in the past
and worry about my future.
Now I live only at this moment where EVERYTHING takes place,
like this I live every day and I call it CONSCIOUSNESS.

When I started loving myself
I recognized, that my thinking
can make me miserable and sick.
When I requested for my heart forces,
my mind got an important partner.
Today I call this connection HEART WISDOM.

We do not need to fear further discussions,
conflicts and problems with ourselves and others
since even stars sometimes bang on each other
and create new worlds.
Today I know: THIS IS LIFE!


Writing Games with Processing: Intro Screen

24. December, 2013

Merry Christmas, everyone :-)

In the last post, we cleaned up the code. This makes it now very simple to add an intro to the game:

class IntroState extends State {
  
  Player p;
  Enemy e;
  Step playerStep;
  Step enemyStep;
  
  void setup() {
    
    playerStep = new Step();
    playerStep.x += + 3*tileSize;
    
    p = new Player();
    
    e = new Enemy("Kenny");

    enemyStep = new Step();
    
    frameRate(10);
  }

The class Step adds a very simple movement algorithm to the player and enemy we created in setup():

class Step {
  int minX = tileSize * 3;
  int minY = tileSize * 3;
  int maxX = width - (tileSize * 3);
  int maxY = height - (tileSize * 3);

  int x = minX;
  int y = minY;
  int dx = tileSize;
  int dy = 0;
  
  void next() {
    int newX = x + dx;
    int newY = y + dy;
    
    if(newX > maxX) {
      newX = maxX;
      dx = 0;
      dy = tileSize;
      newY += dy;
    } else if(newY > maxY) {
      newY = maxY;
      dx = -tileSize;
      dy = 0;
      newX += dx; 
    } else if(newX < minX) {
      newX = minX;
      dx = 0;
      dy = -tileSize;
      newY += dy;
    } else if(newY < minY) {
      newY = minY;
      dx = tileSize;
      dy = 0;
      newX += dx; 
    }
    
    x = newX;
    y = newY;
  }
}

The code simply moves a coordinate along the outline of a rectangle. Using this code, we can move the player and enemy and then render the screen:

  void draw() {
    movePlayer();
    moveEnemy();
    
    drawBackground();
    p.draw();
    e.draw();
  }
  
  void movePlayer() {
    playerStep.next();
    p.x = playerStep.x;
    p.y = playerStep.y;
  }
  
  void moveEnemy() {
    enemyStep.next();   
    e.x = enemyStep.x;
    e.y = enemyStep.y;
  }

drawBackground() is similar to the code in the main game code. Only this time, we display the game title and a short explanation what the game is about.

We could also use this to display a high score list, etc.

  void drawBackground() {
    fill(174, 204, 27);
    rect(0, 0, width, height);
    
    textAlign(CENTER, TOP);
    textSize(40);
    color outline = color(255,255,255);
    color fill = color(0,0,0);
    int y = height/2 - 60;
    textWithOutline("Run, Platty, Run!", width/2, y, outline, fill);
    y += 50;
    
    textSize(20);
    textWithOutline("Use cursor keys to evade the hungry crocodiles", width/2, y, outline, fill);
    y += 40;
    
    outline = color(0,0,255);
    fill = color(255,255,255);
    textWithOutline("Press any key to start", width/2, y, outline, fill);
    y += 20;
  }

The last element we need is a key handler which starts the game itself:

  void keyPressed() {
    changeState(new MainGame());
  }

Easy, isn’t it? Just imagine how complex this might have been without the refactoring. We might have ended up with a draw() method with several if(), checking for the current state of the game, trying to avoid messing with the wrong variables, …

By splitting the game into steps, each step can do it’s own thing. This is the major goal of refactoring: Cutting down dependencies.

The whole project can be cloned from here. The version of this blog post is tagged with v9.

Cool, our game is almost complete. One last thing is missing: Displaying the high score table.

Previous: Cleaning Up
First post: Getting Started


Follow

Get every new post delivered to your Inbox.

Join 339 other followers