IAT 265 Study Guide - Final Guide: Pong, Ellipse

169 views9 pages

Document Summary

A ball that moves about the screen. If the ball goes off the end of the sketch, the opposite player gets a point. Allow paddle to inflence the x velocity int leftplayerscore, rightplayerscore; // player scores. // draw all the objects in the scene for (movingobject o: objects) { o. update(); o. render(); if (rightplayer. doescollide(ball) || leftplayer. doescollide(ball)) { ball. velx(ball. velx() *-1); // check if the ball goes off the right edge. // give point to player 1 if (ball. x() > width + ball. size/2) { leftplayerscore++; // move ball in front of leftplayer"s paddle ball. x(leftplayer. frontedge() + ball. size/2); // set flag to indicate if ball should be released serveready = true; // check if the ball goes off the left edge. // give point to player 2 if (ball. x() < ball. size/2) { rightplayerscore++; rightplayer. y(height/2); // move ball in front of rightplayer"s paddle ball. x(rightplayer. frontedge() - ball. size/2); // set the velocity equal to zero ball. vel. x = 0;

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents