It’s not particularly rewarding to play, but maybe you can improve on it – right now it does three things:

- draws a pig at a random distance
- asks for angle and “force”
- plots points until they go off the screen

//FIRST, THE SETUP

- Lbl B
- ClrDraw
- AxesOff
- Degree
- PlotsOff
- FnOff
- 10→Xmax:10→Ymax
- -2→Xmin:-2→Ymin

- rand*4+4→P
*(random number between 4 and 8 for the pig’s x-coordinate)* - Line(-2,-1,10,-1)
*(the ground)* - Line(0,-1,0,0)

(*the slingshot*) - Circle (P,0,1)

(*this represents the pig. I made a more detailed pig face since I had some extra time, which I’ve included at the bottom*).

- 0→X:0→Y

(*starting values for plotting the bird path*) - -0.07→G

(*acceleration due to gravity… units are arbitrary, so I just tweaked this until it looked good)* - Pause: ClrHome
- Disp “ANGLE?”: Prompt T
- cos(T)→D: sin(T)→E

(*D and E will tell us the x and y increments for the bird’s path)* - Disp “FORCE (1-10)?”: Prompt F
- F/10*D→D: F/10*E→E
*(D and E are scaled by 1/10 of the “force” …also arbitrary)*

- Lbl A
- Pt-On(X,Y)
- X+D→X: Y+E→Y

(*If D and E both remain constant, the bird will go in a line. The curve is produced by changing E, the increment for y.)* - E+G→E

(*You could think of E as velocity and G and acceleration)* - If Y>0 and X<10: Goto A

(*Keep plotting points until you go off-screen to the right or hit the ground*) - Pause
- Goto B

(*New pig!*)

- Line(P-1,0,P-0.5,1)
- Line(P-0.5,1,P+.5,1)
- Line(P+0.5,1,P+1,0)
- Line(P+1,0,P+0.5,-1)
- Line(P+.5,-1,P-0.5,-1)
- Line(P-0.5,-1,P-1,0)

(*This forms a hexagon for the pig’s head*) - Line (P+0.4,0.1,P+0.4,-0.7)
- Line(P+0.4,-0.7,P-0.4,-0.7)
- Line(P-0.4,-0.7,P-0.4,0.1)
- Line(P-.4,0.1,P+0.4,0.1)

(*This forms a rectangle nose)* - Pt-On(P+0.5,1.2,2): Pt-On(P-0.5,1.2,2)

(*Ears are points with “style 2” so they’re tiny squares)* - Pt-On(P+0.5,0.5,3): Pt-On(P+-0.4,0.5,3)

(*Eyes have “style 3” so they’re tiny crosses)* - Pt-On(P-0.15,-0.3): Pt-On(P+0.15,-0.3)

(*Nostrils!)*

## No comments:

## Post a Comment