Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**** PONG ****/
- // Ported from 1.2.2 (C)
- // To 1.0 (C++, using Object Orientation)
- // For: Research Project HIT2080
- // Joel Rozen-Oxley 7536372
- // Includes
- // #include <stdlib.h>
- // #include "SwinGame.h"
- #include <iostream>
- using namespace std;
- class ball {
- public:
- ball(int vals[]);
- int radius;
- int delta_x;
- int delta_y;
- int max_speed;
- int old_x_centre;
- int new_x_centre;
- int old_y_centre;
- int new_y_centre;
- };
- ball::ball(int vals[]){
- radius = vals[0];
- delta_x = vals[1];
- delta_y = vals[2];
- max_speed = vals[4];
- old_x_centre = vals[5];
- new_x_centre = vals[6];
- old_y_centre = vals[7];
- new_y_centre = vals[8];
- }
- int main() {
- int create_vals[] = {1, 2, 3, 4, 5, 6, 7, 8 ,9};
- //initialize while creating object
- ball b = ball(create_vals);
- //print default values
- cout << "Radius = " << b.radius << "\n";
- cout << "Max Speed = " << b.max_speed << "\n";
- //Change values
- cout << "\n" << "Changing the values" << "\n\n";
- b.radius = 20;
- b.max_speed = 50;
- //print again
- cout << "Radius = " << b.radius << "\n";
- cout << "Max Speed = " << b.max_speed << "\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment