Categories
BLOG

win & in games

Win the game

On this Page

This is the 12th step out of 16 of the Gamedev Phaser tutorial. You can find the source code as it should look after completing this lesson at Gamedev-Phaser-Content-Kit/demos/lesson12.html.

Implementing winning in our game is quite easy: if you happen to destroy all the bricks, then you win.

How to win?

Add the following new code into your ballHitBrick() function:

We loop through the bricks in the group using bricks.children , checking for the aliveness of each with each brick’s .alive() method. If there are no more bricks left alive, then we show a winning message, restarting the game once the alert is dismissed.

Compare your code

You can check the finished code for this lesson in the live demo below, and play with it to understand better how it works:

Next steps

Both losing and winning are implemented, so the core gameplay of our game is finished. Now let’s add something extra — we’ll give the player three lives instead of one.

Implementing winning in our game is quite easy: if you happen to destroy all the bricks, then you win.

Can “win the game” and “win in the game” be used interchangeably?

Ok, see this sentence:

If your life is a game, then how to win the game of life?

How to win Flappy bird game?

If your life is a game, then how to win in the game of life?

How to win in Flappy bird game?

Can “win the game” and “win in the game” be used interchangeably?

2 Answers 2

The two are not the same.

One can speak of winning something (without the in) if this item refers to a tangible item such as a single match or sequence of games, e.g. winning a chess match, or the reward for winning, e.g. winning a cup. A good indication that this case pertains is that sentence still makes sense if the item is preceded by the indefinite article a/an (a match, a cup).

When one speaks of winning in (or at) something, he is referring to gaining some advantage for himself in a larger context of a more abstract nature. For example, winning in chess means achieving generally positive results over an indeterminate number of games or possible even an entire career.

Although it is reasonable to speak of winning in the game of life, nobody “wins” the game of life per se; as Woody Allen once said:

“I don’t want to achieve immortality through my work; I want to achieve immortality through not dying. I don’t want to live on in the hearts of my countrymen; I want to live on in my apartment.”

Can “win the game” and “win in the game” be used interchangeably? Ok, see this sentence: If your life is a game, then how to win the game of life? How to win Flappy bird game? If ]]>