Gengo Girls #59: Super-Niche Movies

Gengo Girls #59: Super-Niche Movies

You might think casual past tense isn’t that important for speaking formal Japanese, but it uses the same basic rules as another incredibly important piece of grammar that you absolutely can’t speak Japanese without. So memorize all these past tense rules; you’re going to need them again in just a few more strips.

Vocabulary

食べる = たべる = to eat

Transcript

言語ガールズ #59

Super-Niche Movies

Yellow: Teach me casual past tense so I can watch 日本の movies!

Blue: And pass your next 日本語 test?

Yellow: Sure, that too.

Blue: All casual past tense verbs end in or , so they’re easy to recognize.

Blue: But how you add to the verb depends on the verb’s dictionary form.

Blue: If the dictionary form ends in “iru” or “eru” you can just switch the final to .

Yellow: That means 見る to 見た and 食べる to 食べた.

Blue: Other verbs can be a little more complicated.

Yellow: Maybe I can find a movie that only uses “iru” and “eru” verbs…

Gengo Girls #58: Details, Details

Gengo Girls #58: Details, Details

You’ve already seen “dekiru” as a verb meaning “to be able to do”. But when used in the past tense it also means “to have completed”.

This might seem a little confusing, but it actually makes a lot of sense. To be able to do something means being able to complete whatever tasks are associated with that thing. From that perspective it makes a lot of sense to use the same verb for “to be able” and “to complete”.

Vocabulary

出来る = できる = to complete; to be able to do

書く = かく = to write

Transcript

言語ガールズ #58

Details, Details

Yellow: 私は宿題を出来ました!

Yellow: Turned it in right before the teacher walked into class.

Blue: That was really cutting it close.

Blue: What’s wrong?

Yellow: 私の名前を書きませんでした

Immortal Boredom Would Never Kick In

As you might have guessed, I find immortality to be a fun theme for fiction. After all, I did make a game called Immortals Should Try Harder.

Today I want to talk about the “bored immortal”, a classic fantasy and sci-fi trope. He or she has lived for hundreds or thousands of years and has already seen everything there is to see and done everything there is to do and now they are just plain bored with life.

But would that really happen?

The basic idea seems to be that doing the same thing again and again eventually gets boring. Since immortals live forever they would eventually do everything often enough to get bored with everything.

But this skips over an important point: Boring activities become fun again if you just wait long enough.

Have you even eaten so much of a favorite food that you’ve gotten sick of the taste, only to suddenly start craving it again a few months later?

Do you have a favorite holiday that you enjoy year after year?

Have you ever had a sudden urge to reread a book, rewatch a movie or replay a game that you haven’t touched in years?

Do you sometimes find yourself wishing you had the free time to restart a hobby you gave up in the past?

My personal non-immortal life experiences show that:

  • Doing an activity too often causes a sort of boredom fatigue, but that fatigue heals with time
  • The brain doesn’t remember the fine details of books and movies for more than a few years, making them fun to reread
  • Actively having a good experience is superior to mere memories of that experience

All of which suggests that an immortal could keep themselves amused for pretty much forever by just switching between a few dozen lifestyles and having a really big collection of favorite books, movies, games and hobbies.

Spend a few years doing research at a big library. Then spend some time touring Europe and practicing cooking all their regional specialties. Then hunker down and run a small farm in the Alaskan frontier. Then switch to being an auto mechanic and learning how machines really work.

And eventually the immortal starts to miss some of their earlier lifestyle. They head back to the library or the kitchen or the farm and find that after a hundred years the activity they were once bored with has become fresh and entertaining once again. They reread the book they have forgotten. They rediscover favorite recipes. They find that the “boring old farm life” is actually a nice change of pace every once and a while.

And they repeat this cycle, happily, forever.

Now of course an immortal would still probably have their ups and downs and slumps. But I think breaking out of a period of depressing boredom would be as easy as finding something they used to enjoy decades ago and forcing themselves to give it another try.

So if you plan to live forever you had better start collecting books and movies now. You’re going to need a few thousand.

Discussion Prompt:

  • How often can you rewatch a movie or reread a book? How many would you need to fight off immortal boredom?
  • How many years worth of different activities and lifestyles do you think an immortal would need to keep the non-boredom cycle going? Or do you think the cycle would eventually degrade no matter how many different lifestyles they switched between?
  • Would an immortal with perfect memory be harder to entertain than a more human immortal whose memories tend to fade after a few decades or centuries?
  • Are there any activities that you never seem to get bored of, like getting a good night’s rest? Could just a few of these always good activities sustain an immortals mental health forever, even if they had perfect memory?

Gengo Girls #57: I Didn’t Do It

Gengo Girls #57: I Didn't Do It

Look at all the different rules all coming together in that one example! We’ve got an implied subject, a possessive, an object and a past tense irregular verb (“suru” to “shimasen” to “shimasen deshita”). Sure, it may not seem like a big deal to be able to say “I didn’t do my homework” but the amount of grammar represented in that one idea is actually pretty impressive. Good job reader for keeping up so far!

Vocabulary

宿題 = しゅくだい = homework

Transcript

言語ガールズ #57

I Didn’t Do It

Blue: To make a polite negative past tense verb you start with the polite negative present tense.

Yellow: That’s just switching ます to ません.

Blue: Then you add でした to the end.

Yellow: Isn’t that the past tense of です?

Blue: Yes it is.

Yellow: So I could say 私の宿題をしませんでした

Blue: I knew you were going to come up with an example like that.

Yellow: That reminds me, can I borrow your math homework for a few minutes?

Blue: いいえ

Let’s Program A JavaScript Game 14: A Winner Is You

Anybody Remember The Point Of This Game?

Way back in our game design segment we decided that our game is about a program (the player) defragmenting a hard drive. In order to win the player just has to stay alive long enough to rack up 1000GB of defrag points. The player can earn bonus defrag points by grazing viruses, allowing skilled players to complete the game with faster times.

Today we’re going to build that.

Keeping Score

In order to have a game about building up points until you win we obviously need to keep track of both how many points the player currently has and how many total points they need. We also want to know how long it took them to win. This is easy enough with a handful of global variables added up near the top of our script. Maybe right after all of our collision variables:

var currentFrameCount; //Keep track of how long it takes the player to
var currentPoints;
var TOTAL_POINTS_TO_WIN = 100;

Eventually we will want TOTAL_POINTS_TO_WIN to be one thousand, but for testing purposes let’s keep it low for now.

Since currentPoints and currentFrameCount get set back to zero every time the player loses we should set their value inside of the initializeGame function. I put it right after the code that resets the player’s location:

//Reset player location
player.x = 100;
player.y = 100;
player.yVel = 0;
player.onGround = false;

//Reset points and time
currentFrameCount=0;
currentPoints=0;

And finally let’s show this all to the player by updating our drawScreen function. Instead of printing out debug information about loops and collisions we’ll now print out the player’s current time and points so far by replacing this:

//Draw black text
context.fillStyle = '#000000';
context.fillText("Loop Count: "+loopCount, 20, 20);

if(feetCollision){
   context.fillText("Feet Collision: True", 20, 40);
}
else{
   context.fillText("Feet Collision: False", 20, 40);
}

if(deathCollision){
   context.fillText("Death Collision: True", 20, 60);
}
else{
   context.fillText("Death Collision: False", 20, 60);
}

if(grazeCollision){
   context.fillText("Graze Collision: True", 20, 80);
}
else{
   context.fillText("Graze Collision: False", 20, 80);
}

With this:

//Draw black text
context.fillStyle = '#000000';

//One frame should take 1/20 of a second
//For scoring purposes assume this is true even if the player is lagging
var time = currentFrameCount/20;
context.fillText("Time: "+ time.toFixed() + " seconds", 20, 20);
context.fillText("Progress: "+currentPoints+" out of "+TOTAL_POINTS_TO_WIN+" GB Defragged", 20, 40);

How Much Is A Point Worth?

Now that we have time and score variables we just have to figure out a good way to fill them up.

Time is easy enough. We just increase our frame count variable once per loop and we’re done.

function updateGame(){
   loopCount++;
   currentFrameCount++;
   // The rest of the function stays the same

Deciding how to update points is a little bit harder.

There are 20 frames per second in our game, so giving the player one point per frame would let them win the entire game in a mere 50 seconds. I think that’s a bit shorter than what we were hoping for.

So how long should the game last?

For a silly little web toy like this you can’t really expect players to concentrate for more than about three minutes.

Now if we give the player one point every 4 frames it will take them 4000 frames to collect the 1000 points they need to win. At twenty frames per second this is three and one third minutes and is a little bit longer than we want.

Or is it? Remember that players can graze to earn bonus points, which should shave half a minute or more off of the average player’s time. That cuts our three and one third minutes back down under the three minute limit.

So let’s try one point every four frames and see how that feels:

//Update the game by one step
function updateGame(){
   loopCount++;
   currentFrameCount++;
   if(currentFrameCount % 4 == 0){
      currentPoints++;
   }
   //Rest of the function doesn't change

Here we use the % “modulus” operator to find out whether or not the current frame count is evenly divisible by 4. If you’ve never used %, it just tells us what the remainder is from a piece of division. Example: 5 % 4 = 1, 7 % 4 = 3, 8 % 4 = 0, 122 % 4 = 2

Anyways, after giving the code a whirl I think that one point every four frames feels about right. The number goes up fast enough to feel satisfying but not so fast that the lowest digit is a mere blur.

Living Life On The Edge

Next goal is to implement bonus points from grazing. Exactly how many points grazing should be worth will take some experimentation but I’m going to start by having grazing be worth one point every four frames. That’s the same as our normal point rate and means that grazing will basically double your points per second.

Since we already keep track of grazing using the handy grazeCollision variable all we have to do to get graze points is copy our point code into a quick if statement somewhere near the end of updateGame. I put mine right before the code that checks if you’ve fallen off screen.

//Award bonus points if the player is grazing a virus
if(grazeCollision){
   if(currentFrameCount % 4 == 0){
      currentPoints++;
   }
}

Hmmm… this technically works but I don’t like how the score feels. It’s hard to tell at a glance that grazing makes you earn two points every four frames instead of the normal one. After all, the score is still being updated at the same old rate.

It would be much better if grazing made the player earn one point every two frames instead of two points every four frames. It’s mathematically the same but splitting the points up will make the score counter roll over faster and make it obvious the player is earning a bonus.

Making this happen is as simple as changing our bonus point code to kick in only when currentFrameCount is two frames past an even division by four. This way our normal points will kick in every fourth frame and our graze points will kick in two frames later.

//Award bonus points if the player is grazing a virus
if(grazeCollision){
   if(currentFrameCount % 4 == 2){
      currentPoints++;
   }
}

Victory

We’ve got points. We’ve got bonus points. All that’s left is popping up a victory screen when the player wins, which isn’t really all that different than the game over screen we’ve already designed.

First, we add some code to end of updateGame to check whether or not the player has enough points to win. If he does, we switch game state.

if(deathCollision){
   gameState = STATE_GAMEOVER;
}

if(currentPoints >= TOTAL_POINTS_TO_WIN){
   gameState = STATE_WIN;
}

And then we just write some quick code to handle the winning state.

//Check to see if the user is ready to restart the game
function updateWinScreen(){
   if(playerInput.up){
      gameState = STATE_START_SCREEN;
   }
}

//Show the player how long it took them to win the game
function drawWinScreen(){
   var canvas = document.getElementById('gameCanvas');
   var context = canvas.getContext('2d');

   //Draw background
   context.fillStyle = '#000000';
   context.fillRect(0,0,600,400);

   //Draw green text
   context.fillStyle = '#00CC00';
   context.font = 'bold 80px impact';
   context.fillText("YOU WIN!", 60, 100);
   
   context.font = 'bold 20px impact';
   var time = currentFrameCount/20;
   context.fillText("You defragmented the hard drive in "+ time.toFixed(1) + " seconds", 20, 200);
   context.fillText("Graze more viruses to improve your time", 20, 250);

   context.font = '30px impact';
   context.fillText("Press UP arrow to retry", 120, 350);
}

It’s up to you whether you want to keep these two functions next to each other in the code or split them up so all the “update” functions are next to each other and all the “draw” functions are next to each.

Anyways, with those two functions all that’s left is updating the main gameLoop function to properly call them when we’re in the winning state:

//The main game loop
function gameLoop(){
   var startTime = Date.now();
   
   if(gameState == STATE_START_SCREEN){
      updateStartScreen();
      drawStartScreen();
   }
   else if(gameState == STATE_RUNNING){
      updateGame();
      drawScreen();
   }
   else if(gameState == STATE_GAMEOVER){
      updateGameover();
      drawGameoverScreen();
   }
   else if(gameState == STATE_WIN){ //This is the new one!
      updateWinScreen();
      drawWinScreen();
   }
   else{ //Fix the game if we somehow end up with an invalid state
      gameState = STATE_START_SCREEN;
   }

   var elapsedTime = Date.now()-startTime;
   if(elapsedTime>=50){ //Code took too long, run again immediately
      gameLoop();
   }
   else{ //Code didn't take long enough. Wait before running it again
      setTimeout("gameLoop()",50-elapsedTime);
   }
}

And that’s that. You can test play the game and actually win now.

Kicking Things Up A Notch

It’s nice that everything works now, but the game is a little on the easy side with predictable enemies and small gaps. So next time I’ll be adding challenge by randomizing the platforms and enemies and even improving the game so that it gets more difficult the closer the player is to winning.

Gengo Girls #56: What Was THAT?

Gengo Girls #56: What Was THAT?

Those of you that speak Portuguese or it’s close relative Spanish might recognize “pan” as the word for “bread”. From what I’ve heard the Japanese’s first exposure to western style bread came from Portuguese traders so they adopted the Portuguese word for the food.

Vocabulary

朝ご飯 = あさごはん = breakfast

パン = bread

Transcript

言語ガールズ #56

What Was THAT?

Blue: です has an irregular past tense.

Blue: The polite past tense is でした. The casual past tense is だった.

Blue: But you only use these verbs when comparing nouns to other nouns.

Blue: Talking about adjectives in the past tense has different rules.

Yellow: So I could say “breakfast was bread”?

Blue: 朝ご飯はパンでした

Yellow: But I can’t say “breakfast was tasty”?

Blue: I’m trying to build suspense by leaving that lesson for later.

Yellow: It’s not working.