Build a Game Project: Feed-A-Star-Mole

Smoothing the Transitions

Build a Game Project: Feed-A-Star-Mole

Check out a free preview of the full Build a Game Project: Feed-A-Star-Mole course

The "Smoothing the Transitions" Lesson is part of the full, Build a Game Project: Feed-A-Star-Mole course featured in this preview video. Here's what you'd learn in this lesson:

Brian adds extra code to the working project to smooth out the transitions for the worm score meter.

Preview
Close

Transcript from the "Smoothing the Transitions" Lesson

[00:00:00]
>> Brian Holt: Just to go a little bit further with CSS animations, just to add a nice little touch to it. Here, we're in container, there's a property called transition, which says, hey, if I change the width from 5% to 10%, do just a nice animation between those two states.

[00:00:16]
And usually the browser is pretty good about doing stuff like that, animating heights and widths, and paddings, and margins, and colors, and some other things like that. So what we can say is, we can say, transition: width, and let me make sure I just get that right.
>> Brian Holt: We want this to take about.

[00:00:39]
You can decide how long you want it to take. I'm gonna put it at 0.5 seconds, and I want it to ease in and out. You can have it be linear so it moves steadily, but I'm gonna have it so it goes out and then it slows down.

[00:00:55]
Almost like a ball bouncing. It's fast when it hits the bottom, and then when it hits the top it slows down, and then it goes back down, that's what ease in and out looks like. So now if I say that, and I refresh the page here.
>> Brian Holt: Now, if I can click on it, you can see that the worm will move a little bit slower, it will actually have a nice little animation to it.

[00:01:20]
>> Brian Holt: Which is pretty cool, right?
>> Brian Holt: Man, I'm striking out, this game's hard.
>> Brian Holt: Until I win.
>> Brian Holt: And that, my friends, is it, that's the whole game.
>> Brian Holt: So, how do you feel about this? Hopefully that questions is like, this is really hard, but the concepts hopefully make sense that, given enough time and caffeine you could write this, or wine, depending how you feel about it.

[00:01:59]
>> Brian Holt: But yeah, we just coded a game from start to finish together.
>> Brian Holt: Took us about 70 lines of CSS, and about 175 lines of code, it's not too bad.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now