Python Forum
bouncing ball with variable collision points (in time)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bouncing ball with variable collision points (in time)
#1
Hi everybody.
I have a piece of code, generating a bouncing ball with equal time intervals (collision points occur in equal time durations). What I need to do is making this ball to occur in rhythmic intervals and I want to determine this time myself. So to conclude, I want a ball that hit the floor for example 6 times and time duration between collisions are determined by myself.

here is the code I have. what should I do to change is to what I want?
import turtle
wn=turtle.Screen()
wn.bgcolor('black')
wn.title('bouncing ball simulator')

ball=turtle.Turtle()
ball.shape('circle')
ball.color('green')
ball.penup()
ball.speed(0)
ball.goto(0,200)
ball.dy=0

gravity=0.1

while True:
ball.dy-=gravity
ball.sety(ball.ycor()+ball.dy)
if ball.ycor()<-300:
ball.dy*=-1
Reply


Messages In This Thread
bouncing ball with variable collision points (in time) - by Zhaleh - Jul-24-2020, 02:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read rainfall time series and insert missing data points MadsM 4 2,192 Jan-06-2022, 10:39 AM
Last Post: amdi40
Star I was making code for collision for my character izmamonke 2 2,095 Aug-06-2021, 04:30 PM
Last Post: izmamonke
  How to define a variable in Python that points to or is a reference to a list member JeffDelmas 4 2,661 Feb-28-2021, 10:38 PM
Last Post: JeffDelmas
  SOLVED - Collision detection - TURTLE OuateDePhoque 9 11,400 Nov-18-2020, 06:29 PM
Last Post: OuateDePhoque
  The count variable is giving me a hard time in this code D4isyy 2 1,981 Aug-09-2020, 10:32 PM
Last Post: bowlofred
  How can i change the direction of the ball based on player's xcor and ycor collisions MohammedSohail 0 1,773 May-25-2020, 08:39 AM
Last Post: MohammedSohail
  Player object wont recognize collision with other objects. Jan_97 3 2,725 Dec-22-2019, 04:08 PM
Last Post: joe_momma
  AttributeError: 'Ball' object has no attribute 'hit_paddle' meza1123 1 3,507 Jan-30-2019, 07:25 PM
Last Post: buran
  Would like to input a date variable and determine whether it is within the time range harold 3 2,586 Jan-05-2019, 09:04 AM
Last Post: Gribouillis
  Could not build the ssl module while installing python3.7 from tar ball badfish 1 7,842 Dec-11-2018, 04:33 AM
Last Post: badfish

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020