Tynker Tennis Game – Step-by-Step Coding Guide

In this project, we create a Tennis Game using Tynker where:

  • A tennis ball moves continuously and bounces inside the court

  • Two players stand on opposite sides of the court

  • When a player touches the ball, a tennis attack animation plays

  • One player is controlled by the mouse, and the other behaves like an automatic opponent


This project helps students understand:
  • Continuous motion

  • Ball bounce physics

  • Mouse-based control

  • Animation on collision

  • Simple opponent logic

 Game Objective

  • Keep the tennis ball in motion

  • Hit the ball using the player characters

  • Observe realistic movement and bounce inside the tennis court

 Game Elements Used

 Actors

  • Player (actor) – Controlled by mouse

  • Opponent (actor1) – Auto-moving player

 Game Object

  • Tennis Ball

 Background

  • Tennis court background with boundaries

 Step-by-Step Coding Guidelines

 Step 1: Tennis Ball Movement & Bounce

Code (Tennis Ball):

on start
→ turn 15 degrees
→ forever
→ move 50 pixels
→ wait 0.001 secs
→ wait 0.005 secs
→ if on edge, bounce

Explanation:

  • turn 15 degrees sets the starting direction

  • move 50 pixels gives speed to the ball

  • Small wait values make motion smooth

  • if on edge, bounce keeps the ball inside the court

 This creates realistic ball movement



 Step 2: Player Setup (Right-Side Player)

Code:

on start
→ animate Side Run
→ forever
→ go to mouse-pointer
→ go to right edge
→ point towards left edge
→ set rotation style left-right

Explanation:

  • Player follows the mouse vertically

  • Locked to the right side of the court

  • Always faces the opponent

  • Prevents unwanted rotation

 This gives smooth mouse-based paddle control

 Step 3: Player Attack Animation on Ball Contact

Code:

when touching Tennis Ball occurs
→ animate Side Bow Attack

Explanation:

  • Plays a hit animation when ball touches player

  • Makes the game visually engaging

  • Introduces event-triggered animation

 Step 4: Opponent (Left-Side Player) Movement

Code:

on start
→ forever
→ go to Tennis Ball
→ go to left edge
→ move 10 pixels
→ wait 0.005 secs
→ if on edge, bounce
→ set rotation style left-right

Explanation:

  • Opponent automatically follows the ball

  • Stays on the left side

  • Acts like a basic AI player

  • Adds challenge to the game

 Great intro to AI-style behavior

 Step 5: Opponent Attack Animation

Code:

when touching Tennis Ball occurs
→ animate Side Bow Attack

Explanation:

  • Same hit animation for fairness

  • Visual feedback when opponent hits the ball

 How to Play the Game

  1. Move your mouse up and down

  2. Player follows the mouse on the right side

  3. Hit the ball when it comes near

  4. Watch the opponent return the ball







 

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course