when you start a new world, pick a backgrou nd.. click on add objects to add objects to your world

25
When you start a new world, pick a backgr ound.

Upload: ethelbert-higgins

Post on 01-Jan-2016

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

When you start a new world, pick a background.

Page 2: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Click on add objects to add objects to your world.

Page 3: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Pick the type of objectand then you can drag and drop on the background. Click donewhen you finish withplacing objects.

Page 4: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

When the program runs, world.my first method will be executed, so I put the things I wanted to do in world.my first method. But first I had to make the bounce methods.

objects

Page 5: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I clicked on the toyball1object and I can see the bounce method that I created. I created it by clicking on create new method and then naming it bounce. Since it is associated with toyball1 it became toyball1.bounce.

Page 6: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

When you click on bounce for toyBall1.bounce, you see two move statements that I did to make a bouncing motion. I dragged toyBall1.move over twice and selected down or up and the number of meters to move.

Page 7: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

To show you, I dragged toyBall1.move over again and it shows how to pick down and the meters, other will get me access to other numbers.

Page 8: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

As you can see, I havea bounce method for each ball. This is volleyball.

Page 9: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

After I made the bounce method for each ball. I went back to world.my first method which will execute when I run and I dragged over the bounce method for each ball. Note that to do that I clicked on the ball, and then dragged its bounce method over to world.my first method.When I finish, I can click play and I will see the balls bounce.

Page 10: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I clicked play and now the tennisBall is doing its bounce method.

Page 11: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

my first method

startuphousekeeping

process

wrapup

Startup or housekeeping is doneonce at the beginning of theprogram.

Process is usually done multipletimes - it usually is controlled bya loop.It is possible to just do it once.

Wrapup is done once atthe end when you are closingdown. For example sayingthe program is ending ordisplaying totals.

Page 12: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Now I am creating three methods within world.my first method. They will be executed in sequence when I play. The three methods are all associated with world so they are named world.startup, world.process and world.wrapup.After I create them, I drag them over to world.my first method.

Page 13: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Here is the code in startup.world (to see it I clicked on edit next to startup). To make this I went to toyBall1 and dragged its move over and then I did the same with the other balls.

Page 14: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

As I said on the last slide, I clicked on toyBall1 and got its associated methods and dragged the move over to world.startup.What I am doing is moving all three balls into the air as my startup.

Page 15: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Note that world.wrapup brings all the balls down.But, before I do wrapup, I do world.process.

Page 16: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I drag up loop and tell it that I want it to be executed5 times. Then I drag up Do together so they are done all at once and then I click on each ball and drag itsbounce method over. The balls will bounce together 5 times.

Page 17: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world
Page 18: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Now I am using an if else.

Page 19: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I clicked on create new variable when I made whichBall and gave it the name whichBall and value 1 stayed.

Page 20: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I am now duplicating the whichBall set value lineI dragged whichBall right below the existing one andit let me pick set value and I set it to 1 temporarily, I am going to change that to a random number.

Page 21: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

Then I went over to functions and dragged the randomnumber function over where the temporary 1 was.Now I click on more to get the minimum and a newmore comes up to let me get the maximum.

Page 22: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I now have a random number that is decimal from 0 to 3 so I say if it is < or = 1 bounce the toyBall1, else < or = 2 bounce tennisBall, else bounce volleyBall. One ball will bounce in world.process.

Page 23: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

This programs combines the last two programs, the pick of the random number and the if are inside the loop sothere will be 5 bounces each dependent on the randomnumber that is chosen.

Page 24: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world

I set up the while loop and dragged howMany down and said do it while howMany is < 3. To get the increment, I again dragged howMany down and selected increment.

Page 25: When you start a new world, pick a backgrou nd.. Click on add objects to add objects to your world