Presentation is loading. Please wait.

Presentation is loading. Please wait.

DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.

Similar presentations


Presentation on theme: "DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot."— Presentation transcript:

1 DAY 4

2 MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot

3 MAKING SOMETHING ‘JUMP FORWARD’ Simple! Move it a certain amount ‘up’ Glide back down, and forward a little!

4 SOME FINAL THINGS BEFORE MARIO… Comments ! Comments in code help others understand what you did! To add a comment, right-click in the main coding area and select ‘add comment’ Then, drag the comment on TOP of the code you wish to explain You can add ANYTHING to comments Comments WILL BE WORTH POINTS IN PROJECTS

5 SOME FINAL THINGS BEFORE MARIO… Conditional Statements Conditional statements are anything where your program makes a decision To make a decision, your program must check a condition Examples of conditions that games check: Has the player won? How many lives do they have? Is the score more than, in which case I’ll give them another life? … what else?

6 SOME FINAL THINGS BEFORE MARIO… Conditional Statements In Snap! there’s a number of conditional statements. But the main one is… IF An ‘if’ statement only runs the code inside it, if the condition is met

7 SOME FINAL THINGS BEFORE MARIO… Conditional Statements You can check 2 conditions at once in an if If EITHER condition can be true for what you want in your application, use OR If BOTH conditions need to be true for what you want in your application, use AND Use mathematical operators to write your condition

8 SOME FINAL THINGS BEFORE MARIO… Getting to the screen edge If you’re moving a sprite to the right and it hits the edge of the screen, what should it do? For our Mario project, you will return it to the LEFT of the screen

9 SOME FINAL THINGS BEFORE MARIO… Getting to the screen edge Same goes for moving to the left!

10 SOME FINAL THINGS BEFORE MARIO… Let me ask a question Why do I have this wait here?

11 SOME FINAL THINGS BEFORE MARIO… Let me ask a question Well, let’s play a game If I have these 2 code blocks in the same sprite, what happens?

12 SOME FINAL THINGS BEFORE MARIO… Let me ask a question It’s a trick you can’t tell me what will happen The sprite will jump around a little probably staying roughly in the middle. But you just don’t know The 2 code blocks are fighting each-other to be first. This is called a race

13 SOME FINAL THINGS BEFORE MARIO… Let me ask a question The point of the wait here, is to ensure that other code blocks have a chance to react So there’s no race

14 SOME FINAL THINGS BEFORE MARIO… Debugging your code Use wait to see what happens if you change timing on your code ‘check’ an item to watch and see if it’s value changes as you expect

15 SOME FINAL THINGS BEFORE MARIO… Biggest TIP Save OFTEN Then, if you make a mistake, you can get your code back This means save your projects as different ‘versions’, with different names ‘Mario-Version1’ ‘Mario-Version2’

16 Time for Mario!

17 HOMEWORK! Read and take notes of ‘Blown to Bits’, Chapter 1 1 page of notes due, on 2/11 http://www.bitsbook.com/ Then, go to the ‘Download’ page to get a chapter


Download ppt "DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot."

Similar presentations


Ads by Google