Download presentation
Presentation is loading. Please wait.
1
Under the direction of Susan Rodger
Solar System Model This is an modification of the July 2012 solar system tutorial by Michael Marion By Natalie Huffman Under the direction of Susan Rodger Duke University June 2017
2
Pictures to download This tutorial comes with three images that will allow you to make blank spheres look like planets They are called “Sun”, “Earth”, and “Jupiter” Download them now and store them in an accessible location on your computer
3
Create a new Alice world
Select “moon” as your environment Go to setup scene Click on the “shapes/text” tab at the bottom
4
Add objects Click on new Sphere() Set the name as “sun”
Do not drag into the scene! Set the name as “sun”
5
Get rid of the ground There’s no ground in space!
Select this.ground from the menu on the far left Set the “opacity” property to 0.0
6
Your scene should look like this
Add a camera marker from the Camera Marker tab on the bottom right Name the camera “sunCam”
7
Camera Markers in Alice 3
Camera markers let you save a viewpoint Above the scene buttons are two positioning buttons The black camera represents your current point of view The first button moves your point of view to the red camera (scene1) In order to move to scene2, you would click on the scene2 button and then on the left top button Note: this picture is from a different tutorial
8
Camera markers, cont. The second button, if clicked, would reset the scene1 view to the current view Do not click this button! Once we set a camera view, we will likely not want to change it Change scene1 camera Change current view
9
This doesn’t look much like a sun
We can change the “paint” property to make it look more like a sun Click the “Import Image” button and select the sun picture you downloaded at the beginning of this tutorial
10
Now it looks more like a sun
Repeat this process twice more Note that there is no need to add additional camera markers Call the spheres “earth” and “jupiter” respectively Use the “Earth” and “Jupiter” pictures to make the spheres look more like those planets
11
Our planets are all on top of each other
Alice creates objects in the same place, so all of our planets are on top of each other You can fix this by moving them Right click on this.earth in the left-hand menuproceduresthis.earth moveLEFTCustom DecimalNumber Enter “4” for the custom number
12
Repeat this for Jupiter, but move it 10 spaces instead of 4
13
Your planets probably look a little weird
Almost like there’s a line down the front of them This is because you’re seeing the line where Alice joins together the top and bottom of the picture We don’t want to see that seam, so we’ll turn our planets so it’s facing away from the camera
14
Right click on the sunproceduresthis.sun turnBACKWARDS.25
Repeat this for the Earth and for Jupiter The planets and the sun should look more normal now
15
Size We want our spheres to be different sizes, to reflect the way the sun, the Earth, and Jupiter are all different sizes Click on the sun in the left menu and change the radius to 2.0 We want the Earth’s radius to stay the same (0.5) Change Jupiter’s radius to 0.8
16
Reposition your window using the arrows until you can see all three spheres
Try to get the sun in the middle of the screen, since the two planets will eventually orbit it You can add a camera marker here as well so you don’t lose your place
17
Time for the code! Click on the “edit code” button
Create a new Scene procedure by clicking on the dropdown menuSceneAdd Scene Procedure Name it “rotate”
18
Add a parameter A parameter is an input to our procedure
For example, when we use the “move” procedure, we have to provide a parameter—how far we want to move The parameter value is set in the method that uses the procedure, so it can be changed easily
19
Parameters Set the value type to DecimalNumber Set the name to “year”
This parameter will control how long our planet’s orbits are
20
Drag a while loop into the method and select “true”
Drag a do together block into the while loop
21
Now select this.earth from the lower left-hand menu
Drag in a turn statement, and select LEFT and 1.0 This statement will make the earth turn in a circle, but we want it to turn around the sun Click on the dropdown arrow and select asSeenBythis.sun
22
Click on the dropdown arrow again and select durationyear (the parameter we created)
This will make one full turn last for a year Finally, click on the dropdown arrow and select animationStyleBegin_And_End_Abruptly This will stop there from being a pause between one orbit and the next
23
Jupiter Right click on the turn statement and select “copy to clipboard” Click and drag from the clipboard into the do together block Click on this.earth and change it to this.jupiter Click on 1.0 and change it to 0.25 This means that jupiter’s orbit will complete .25 of an orbit in one year
24
Go back to myFirstMethod
Drag in rotate and select 1.0 This means that a year (one rotation of Earth) lasts one second Feel free to play with this value to make the planets spin slower and faster
25
Run your code! If all three planets are not in your view, you can go back to scene setup and edit the camera view However, there is an easier way What if we let the arrow keys control the camera?
26
Click on the initializeEventListener tab
Click on Add Event ListenerKeyboard addArrowKeyPressListener Click on this.camera in the lower left menu and drag in a move statement Select any direction and amount
27
Click on getMoveDirection (in the header) and drag it onto LEFT
Select FORWARD_BACKWARD_LEFT_RIGHT Change the number to 2.0
28
Run your code! You should now be able to use the arrow keys to move the camera for a better view
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.