Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - Document4 CREATE A SIMPLE PONG GAME WHILE USING THESE REQUIRMENTS, PLEASE WRITE A SHORT EXPLAINATION OF WHAT YOU WISH TO ACHIEVE PLEASE WRITE NOTES EXPLAING EVERY STEP OF THE CODE ALL...

1 answer below »
Microsoft Word - Document4
CREATE A SIMPLE PONG GAME WHILE USING THESE REQUIRMENTS,

PLEASE WRITE A SHORT EXPLAINATION OF WHAT YOU WISH TO ACHIEVE

PLEASE WRITE NOTES EXPLAING EVERY STEP OF THE CODE

ALL CODE MUST BE DONE IN PROCESSING SOFTWARE, FREE DOWNLOAD
AVAILABLE ON processing.org

SUBMIT the zipped file of the folder that has the usage sketch and the
Class file(s). DO NOT submit as individual files.


1. create    one    Class    -    define    a    Class    for    the    main    object    in    your    project.    
a. declare    the    attributes.    
. write    constructor(s)    -    there    should    be    a    minimum    of    one    
constructor.    
c. write    methods    that    should    be    provided    by    your    object        (display    and    
other    methods    your    project    may    need    for    the    usage    sketch    to    
interact    with    it).        
2. in    the    usage    sketch    :    
a. create    only    one    instance    of    the    Class    and    display    it    -    DONOT    
create    an    a
ay    of    instances    for    your    Class    (e.g.    if    you    had    multiple    
alls    in    your    project,    create    only    1    instance    of    Ball    ).
    
. depending    on    your    project,    the    usage    sketch    may    require    you    to    
write    code    inside    draw    or    mouse    functions    or    keyboard    functions    -    if    
so,    then    those    code    should    be    there.
    
c. the    instance    that    you    created    in    step    2    should    behave    as    
expected    .
Answered Same Day Nov 09, 2021

Solution

Amar Kumar answered on Nov 10 2021
137 Votes
Ball ball;
Define the ball as a global object
Paddle paddleLeft;
Paddle paddleRight;
int scoreLeft = 0;
int scoreRight = 0;
void setup(){
size(800,600);
ball = new Ball(width/2, height/2, 50);
create a new ball to the center of the window
ball.speedX = 5;
Giving the ball speed in x-axis
ball.speedY = random(-3,3);
Giving the ball speed in y-axis

paddleLeft = new Paddle(15, height/2, 30,200);
paddleRight = new Paddle(width-15, height/2, 30,200);
}
void draw(){
background(0);
clear canvas
ball.display();
Draw the ball to the window
ball.move();
calculate a new location for the ball
ball.display();
Draw the ball on the window

paddleLeft.move();
paddleLeft.display();
paddleRight.move();
paddleRight.display();

if (ball.right() > width) {
scoreLeft = scoreLeft + 1;
ball.x = width/2;
ball.y = height/2;
}
if (ball.left() < 0) {
scoreRight = scoreRight + 1;
ball.x = width/2;
ball.y = height/2;
}
if (ball.bottom() > height) {
ball.speedY = -ball.speedY;
}
if (ball.top() < 0) {
ball.speedY = -ball.speedY;
}

if (paddleLeft.bottom() > height) {
paddleLeft.y =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here