Tynker Soccer Game – Step-by-Step Coding Guide

 In this project, we create a two-player Soccer Game using Tynker.

Players control their characters using the mouse, hit the soccer ball, and try to score goals.
When the ball touches a goal area, the game announces the winner and stops.



This project introduces:

  • Mouse controls

  • Collision detection

  • Direction control

  • Simple win logic

  • Sports-based game design

Suitable for Grades 4–7 and beginner coders.



 Game Objective

  • Move players by dragging them with the mouse

  • Hit the soccer ball toward the opponent’s goal

  • First player to score wins the game



 Game Elements Used

 Actors

  • Red Player (actor1)

  • Blue Player (actor)

 Game Object

  • Soccer Ball (Basketball sprite used as ball)

 Goals

  • Red Goal (left side)

  • Blue Goal (right side)

 Step-by-Step Coding Guidelines

 Step 1: Set Player Direction on Start

Code (for both players):

on start
→ point towards left edge / right edge
→ set rotation style left-right

Explanation:

  • Ensures players face the correct direction

  • Prevents upside-down rotation

  • Makes movement look realistic

 Step 2: Move Player Using Mouse Control

Code:

when actor clicked
→ repeat while mouse down?
→ go to mouse-pointer

Explanation:

  • Allows players to drag their character

  • Movement happens only while mouse button is pressed

  • Introduces interactive control

 This makes the game very intuitive for kids.

 Step 3: Animate Player When Touching the Ball

Code:

when touching Basketball occurs
→ animate Side Basketball Run Dribble

Explanation:

  • Plays a dribbling animation

  • Adds realism to the soccer movement

  • Helps students understand event-triggered animation

 Step 4: Make the Ball Move When Hit

Code (Ball Sprite):

when touching actor occurs
→ point towards left edge
→ move 100 pixels
when touching actor1 occurs
→ point towards right edge
→ move 100 pixels

Explanation:

  • Ball moves based on which player hits it

  • Direction changes dynamically

  • Simulates kicking the ball

 This introduces directional logic + physics feel

 Step 5: Detect Goal and Declare Winner

Code (Goal Area):

when touching Basketball occurs
→ say "Red wins" for 2 seconds
→ set bubble to top message box
→ stop all

Explanation:

  • When the ball touches the goal:

    • Winner message appears

    • Game stops completely

  • Clear and satisfying game ending

 How to Play the Game

  1. Click and drag a player using the mouse

  2. Hit the soccer ball

  3. Push the ball into the opponent’s goal

  4. First goal wins the match














Comments