Posts: 2304
-
Karma: 17,798
#Running on Python 2.7.6
#Running Python Visual 2.7-6.10
# -*- coding: utf-8 -*-
from graphics import *
from visual import *
import math
velocity=input("Velocity= ")
angle1=input("Angle1= ")
scene.width=1200
scene.height=700
scene.autoscale=0
scene.range=(100,100,100)
scene.center=(120,40,75)
ball= sphere(pos=(-25,-1,0),radius=2, color=color.blue)
ground=box(pos=(0,-2,0), size=(10,2,10), color=color.white)
ground2=box(pos=(150,-2,0),size=(210,2,10),color=color.white)
canon=box(pos=(0,2,-5), size=(2,10,2),color=color.white)
canon.rotate(angle=0.6, axis=(0,0,-1))
target3 = sphere(pos=(250,0,0), radius=5, color=color.yellow)
target2 = sphere(pos=(160,0,0), radius=7, color=color.orange)
target1= sphere(pos=(85,0,0), radius=10,color=color.red)
gravity=9.8
angle2=angle1*(pi/180)
velocityY=velocity*sin(angle2)
velocityX=velocity*cos(angle2)
seconds=0
dt=0.1
AngleDisplay=text(text="Angle Thrown Degrees: "+str(round(angle1,2)),
pos=(215,110,0), depth=0.1, height=3, color=color.green)
VelocityDisplay=text(text="Velocity Shot: "+str(velocity)+" m/s",
pos=(225,100,0), depth=0.1, height=3, color=color.green)
Title=text(text="Skeeball Final Project",
pos=(90,110,0), depth=0.1, height=5, color=color.green)
tenp=text(text="10 Points",
pos=(78,-15,0), depth=0.1, height=3, color=color.green)
Fiftp=text(text="50 Points",
pos=(153,-15,0), depth=0.1, height=3, color=color.green)
Hundp=text(text="100 Points",
pos=(240,-15,0), depth=0.1, height=3, color=color.green)
finished = False
while not finished:
rate(25)
seconds+=dt
ballY=2+velocityY*seconds - .5 * gravity * seconds**2
ballX=velocityX*seconds
ball.pos=vector(ballX,ballY,0)
if ballY