SlideShare a Scribd company logo
Apply physics laws to the circles . When a circle hits one of the sides of the screen, its progress
should be altered in some way. While the circles currently move at a constant speed and have
randomized movement once they bounce off one edge of the screen, there are ways you can alter
this to make the animation more engaging. Some options you may wish to use for your work are
as follows, but you do not need to complete all of these. You can also try an idea of your own
instead.
Alter the speed of the circle.
Change the angle of trajectory so it follows physics laws instead of taking a randomized pattern.
(This means it would continue in the direction it was heading rather than moving backward.)
Add friction to specific surfaces, which would affect the circle and slow its progress once it
collided with the surface.
PLEASE USE GIVEN CODE BELOW WITH NO ADDITIONAL LIBRARIES
#include <GLFWglfw3.h>
#include "linmath.h"
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <vector>
#include <windows.h>
#include <time.h>
using namespace std;
const float DEG2RAD = 3.14159 / 180;
void processInput(GLFWwindow* window);
enum BRICKTYPE { REFLECTIVE, DESTRUCTABLE };
enum ONOFF { ON, OFF };
class Brick
{
public:
float red, green, blue;
float x, y, width;
BRICKTYPE brick_type;
ONOFF onoff;
Brick(BRICKTYPE bt, float xx, float yy, float ww, float rr, float gg, float bb)
{
brick_type = bt; x = xx; y = yy, width = ww; red = rr, green = gg, blue = bb;
onoff = ON;
};
void drawBrick()
{
if (onoff == ON)
{
double halfside = width / 6;
glColor3d(red, green, blue);
glBegin(GL_POLYGON);
glVertex2d(x + halfside, y + halfside);
glVertex2d(x + halfside, y - halfside);
glVertex2d(x - halfside, y - halfside);
glVertex2d(x - halfside, y + halfside);
glEnd();
}
}
};
class Circle
{
public:
float red, green, blue;
float radius;
float x;
float y;
float speed = 0.01; //speed of circles
int direction; // 1=up 2=right 3=down 4=left 5 = up right 6 = up left 7 = down right 8= down
left
Circle(double xx, double yy, double rr, int dir, float rad, float r, float g, float b)
{
x = xx;
y = yy;
radius = rr;
red = r;
green = g;
blue = b;
radius = rad;
direction = dir;
}
void CheckCollision(Brick* brk)
{
if (brk->brick_type == REFLECTIVE)
{
if ((x > brk->x - brk->width && x <= brk->x + brk->width) && (y > brk->y - brk->width
&& y <= brk->y + brk->width))
{
direction = GetDirection();
x = x + 0.01;
y = y + 0.02;
}
}
else if (brk->brick_type == DESTRUCTABLE)
{
if ((x > brk->x - brk->width && x <= brk->x + brk->width) && (y > brk->y - brk->width
&& y <= brk->y + brk->width))
{
brk->onoff = OFF;
}
}
}
int GetDirection()
{
return (rand() % 8) + 1;
}
void MoveOneStep()
{
if (direction == 1 || direction == 5 || direction == 6) // up
{
if (y > -1 + radius)
{
y -= speed;
}
else
{
direction = GetDirection();
}
}
if (direction == 2 || direction == 5 || direction == 7) // right
{
if (x < 1 - radius)
{
x += speed;
}
else
{
direction = GetDirection();
}
}
if (direction == 3 || direction == 7 || direction == 8) // down
{
if (y < 1 - radius) {
y += speed;
}
else
{
direction = GetDirection();
}
}
if (direction == 4 || direction == 6 || direction == 8) // left
{
if (x > -1 + radius) {
x -= speed;
}
else
{
direction = GetDirection();
}
}
}
void DrawCircle()
{
glColor3f(red, green, blue);
glBegin(GL_POLYGON);
for (int i = 0; i < 360; i++) {
float degInRad = i * DEG2RAD;
glVertex2f((cos(degInRad) * radius) + x, (sin(degInRad) * radius) + y);
}
glEnd();
}
};
vector<Circle> world;
int main(void) {
srand(time(NULL));
if (!glfwInit()) {
exit(EXIT_FAILURE);
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
GLFWwindow* window = glfwCreateWindow(480, 480, "Shingy Chiremba Week 8
Assignment", NULL, NULL);
if (!window) {
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
Brick brick(REFLECTIVE, 0.5, -0.33, 0.2, 1, 1, 0);
Brick brick2(DESTRUCTABLE, -0.5, 0.33, 0.2, 0, 1, 0);
Brick brick3(DESTRUCTABLE, -0.5, -0.33, 0.2, 0, 1, 1);
Brick brick4(DESTRUCTABLE, 1, 1, 0.5, 0, 0.5, 0.5);
Brick brick5(REFLECTIVE, 0.3, 0.3, 0.2, 1, 0.5, 0.5);
Brick brick6(DESTRUCTABLE, 0.2, 0.2, 0.2, 0.8, 0.3, 0.3);
while (!glfwWindowShouldClose(window)) {
//Setup View
float ratio;
int width, height;
glfwGetFramebufferSize(window, &width, &height);
ratio = width / (float)height;
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT);
processInput(window);
//Movement
for (int i = 0; i < world.size(); i++)
{
world[i].CheckCollision(&brick);
world[i].CheckCollision(&brick2);
world[i].CheckCollision(&brick3);
world[i].CheckCollision(&brick4);
world[i].CheckCollision(&brick5);
world[i].CheckCollision(&brick6);
world[i].MoveOneStep();
world[i].DrawCircle();
}
brick.drawBrick();
brick2.drawBrick();
brick3.drawBrick();
brick4.drawBrick();
brick5.drawBrick();
brick6.drawBrick();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate;
exit(EXIT_SUCCESS);
}
void processInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
{
double r, g, b;
r = rand() / 10000;
g = rand() / 10000;
b = rand() / 10000;
Circle B(0, 0, 02, 2, 0.05, r, g, b);
world.push_back(B);
}
}
Apply physics laws to the circles- When a circle hits one of the sides.pdf

More Related Content

Similar to Apply physics laws to the circles- When a circle hits one of the sides.pdf

#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
ajoy21
 
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
aquacosmossystems
 
An object that moves in a circle A c++ program to check if the gi.pdf
An object that moves in a circle A c++ program to check if the gi.pdfAn object that moves in a circle A c++ program to check if the gi.pdf
An object that moves in a circle A c++ program to check if the gi.pdf
david16271
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentation
Bill Adams
 
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Jason Li
 
10CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 310CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 3
Vanishree Arun
 
Robot Motion Source code
Robot Motion Source codeRobot Motion Source code
Robot Motion Source code
Brian Goggins
 
computer graphics slides by Talha shah
computer graphics slides by Talha shahcomputer graphics slides by Talha shah
computer graphics slides by Talha shah
Syed Talha
 
tetris
tetristetris
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
Mahmoud Samir Fayed
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
fungfung Chen
 
Iyarkanitham
Iyarkanitham Iyarkanitham
Iyarkanitham
poongodisivakumar
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
Mahmoud Samir Fayed
 
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
iosrjce
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular
500Tech
 
OpenGL 3D Drawing
OpenGL 3D DrawingOpenGL 3D Drawing
OpenGL 3D Drawing
Budditha Hettige
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous Agents
Bryan Duggan
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
SwatiHans10
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
Syed Zaid Irshad
 
SVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for BeginnersSVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for Beginners
Oswald Campesato
 

Similar to Apply physics laws to the circles- When a circle hits one of the sides.pdf (20)

#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx
 
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
draw a sphere and use raytracing on the sphere in OpenGL glut. .pdf
 
An object that moves in a circle A c++ program to check if the gi.pdf
An object that moves in a circle A c++ program to check if the gi.pdfAn object that moves in a circle A c++ program to check if the gi.pdf
An object that moves in a circle A c++ program to check if the gi.pdf
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentation
 
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
 
10CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 310CSL67 CG LAB PROGRAM 3
10CSL67 CG LAB PROGRAM 3
 
Robot Motion Source code
Robot Motion Source codeRobot Motion Source code
Robot Motion Source code
 
computer graphics slides by Talha shah
computer graphics slides by Talha shahcomputer graphics slides by Talha shah
computer graphics slides by Talha shah
 
tetris
tetristetris
tetris
 
The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184The Ring programming language version 1.5.3 book - Part 65 of 184
The Ring programming language version 1.5.3 book - Part 65 of 184
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
 
Iyarkanitham
Iyarkanitham Iyarkanitham
Iyarkanitham
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
 
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
Run Or Walk In The Rain? (Orthogonal Projected Area of Ellipsoid)
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular
 
OpenGL 3D Drawing
OpenGL 3D DrawingOpenGL 3D Drawing
OpenGL 3D Drawing
 
Introduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous AgentsIntroduction to Steering behaviours for Autonomous Agents
Introduction to Steering behaviours for Autonomous Agents
 
3D Transformation
3D Transformation3D Transformation
3D Transformation
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
SVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for BeginnersSVG, CSS3, and D3 for Beginners
SVG, CSS3, and D3 for Beginners
 

More from EricG3KColemanf

As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdfAs of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
EricG3KColemanf
 
As for how to build the tree- you can follow the steps selow- 1- Creat.pdf
As for how to build the tree- you can follow the steps selow- 1- Creat.pdfAs for how to build the tree- you can follow the steps selow- 1- Creat.pdf
As for how to build the tree- you can follow the steps selow- 1- Creat.pdf
EricG3KColemanf
 
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdfAs the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
EricG3KColemanf
 
As a manager- you need to have a firm understanding of the revenue cyc.pdf
As a manager- you need to have a firm understanding of the revenue cyc.pdfAs a manager- you need to have a firm understanding of the revenue cyc.pdf
As a manager- you need to have a firm understanding of the revenue cyc.pdf
EricG3KColemanf
 
arise(s) from differences in customs- social norms- attitudes- assumpt.pdf
arise(s) from differences in customs- social norms- attitudes- assumpt.pdfarise(s) from differences in customs- social norms- attitudes- assumpt.pdf
arise(s) from differences in customs- social norms- attitudes- assumpt.pdf
EricG3KColemanf
 
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdfarrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
EricG3KColemanf
 
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdfAssign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
EricG3KColemanf
 
ART I - Data Transformations 1- Transform the following values into de.pdf
ART I - Data Transformations 1- Transform the following values into de.pdfART I - Data Transformations 1- Transform the following values into de.pdf
ART I - Data Transformations 1- Transform the following values into de.pdf
EricG3KColemanf
 
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdfAssets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
EricG3KColemanf
 
Arnold Corporation has the following information for the current year-.pdf
Arnold Corporation has the following information for the current year-.pdfArnold Corporation has the following information for the current year-.pdf
Arnold Corporation has the following information for the current year-.pdf
EricG3KColemanf
 
Artificial Intelligence Study the step-by-step codes for a one layer o.pdf
Artificial Intelligence Study the step-by-step codes for a one layer o.pdfArtificial Intelligence Study the step-by-step codes for a one layer o.pdf
Artificial Intelligence Study the step-by-step codes for a one layer o.pdf
EricG3KColemanf
 
Assembly Language question- The Boolean variables b1 - b2- and b3 ar.pdf
Assembly Language question-   The Boolean variables b1 - b2- and b3 ar.pdfAssembly Language question-   The Boolean variables b1 - b2- and b3 ar.pdf
Assembly Language question- The Boolean variables b1 - b2- and b3 ar.pdf
EricG3KColemanf
 
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdfAt December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
EricG3KColemanf
 
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdfat S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
EricG3KColemanf
 
At Eileen's death- Winthrop received the death benefit payable under E.pdf
At Eileen's death- Winthrop received the death benefit payable under E.pdfAt Eileen's death- Winthrop received the death benefit payable under E.pdf
At Eileen's death- Winthrop received the death benefit payable under E.pdf
EricG3KColemanf
 
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdfAt December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
EricG3KColemanf
 
Astronomy questions help 1) What planetary time association is conside.pdf
Astronomy questions help 1) What planetary time association is conside.pdfAstronomy questions help 1) What planetary time association is conside.pdf
Astronomy questions help 1) What planetary time association is conside.pdf
EricG3KColemanf
 
Ascientist inoculates mice- one at a time- with a disease germ until h.pdf
Ascientist inoculates mice- one at a time- with a disease germ until h.pdfAscientist inoculates mice- one at a time- with a disease germ until h.pdf
Ascientist inoculates mice- one at a time- with a disease germ until h.pdf
EricG3KColemanf
 
Astronomy questions help please 5) According to the Maya- Venus' cyc.pdf
Astronomy questions help please   5) According to the Maya- Venus' cyc.pdfAstronomy questions help please   5) According to the Maya- Venus' cyc.pdf
Astronomy questions help please 5) According to the Maya- Venus' cyc.pdf
EricG3KColemanf
 
asdoon- coum now many times 'a' and T appear in your sting.pdf
asdoon- coum now many times 'a' and T appear in your sting.pdfasdoon- coum now many times 'a' and T appear in your sting.pdf
asdoon- coum now many times 'a' and T appear in your sting.pdf
EricG3KColemanf
 

More from EricG3KColemanf (20)

As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdfAs of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
As of December 31-2022 - Oriole Company has assets of $41900 and stock.pdf
 
As for how to build the tree- you can follow the steps selow- 1- Creat.pdf
As for how to build the tree- you can follow the steps selow- 1- Creat.pdfAs for how to build the tree- you can follow the steps selow- 1- Creat.pdf
As for how to build the tree- you can follow the steps selow- 1- Creat.pdf
 
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdfAs the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
As the COVID-19 pandemic progresses- we are seeing dramatic increases.pdf
 
As a manager- you need to have a firm understanding of the revenue cyc.pdf
As a manager- you need to have a firm understanding of the revenue cyc.pdfAs a manager- you need to have a firm understanding of the revenue cyc.pdf
As a manager- you need to have a firm understanding of the revenue cyc.pdf
 
arise(s) from differences in customs- social norms- attitudes- assumpt.pdf
arise(s) from differences in customs- social norms- attitudes- assumpt.pdfarise(s) from differences in customs- social norms- attitudes- assumpt.pdf
arise(s) from differences in customs- social norms- attitudes- assumpt.pdf
 
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdfarrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
arrange the leaf nodes is such a way so that there is i) minimum numbe.pdf
 
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdfAssign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
Assign the correct ICD-10-CM-PCS codes to the following exercises Iron.pdf
 
ART I - Data Transformations 1- Transform the following values into de.pdf
ART I - Data Transformations 1- Transform the following values into de.pdfART I - Data Transformations 1- Transform the following values into de.pdf
ART I - Data Transformations 1- Transform the following values into de.pdf
 
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdfAssets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
Assets Debit Credit Cash 214-320 Investments 491-000 Taxes receivable-.pdf
 
Arnold Corporation has the following information for the current year-.pdf
Arnold Corporation has the following information for the current year-.pdfArnold Corporation has the following information for the current year-.pdf
Arnold Corporation has the following information for the current year-.pdf
 
Artificial Intelligence Study the step-by-step codes for a one layer o.pdf
Artificial Intelligence Study the step-by-step codes for a one layer o.pdfArtificial Intelligence Study the step-by-step codes for a one layer o.pdf
Artificial Intelligence Study the step-by-step codes for a one layer o.pdf
 
Assembly Language question- The Boolean variables b1 - b2- and b3 ar.pdf
Assembly Language question-   The Boolean variables b1 - b2- and b3 ar.pdfAssembly Language question-   The Boolean variables b1 - b2- and b3 ar.pdf
Assembly Language question- The Boolean variables b1 - b2- and b3 ar.pdf
 
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdfAt December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
At December 31-2020 - Ivanhoe Company has $570-000 of $100 par value-.pdf
 
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdfat S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
at S40-000- A total of 15-750 poundt were used in producing the boudde.pdf
 
At Eileen's death- Winthrop received the death benefit payable under E.pdf
At Eileen's death- Winthrop received the death benefit payable under E.pdfAt Eileen's death- Winthrop received the death benefit payable under E.pdf
At Eileen's death- Winthrop received the death benefit payable under E.pdf
 
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdfAt December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
At December 31- balances in Manufacturing Overhead are Ivanhoe Company.pdf
 
Astronomy questions help 1) What planetary time association is conside.pdf
Astronomy questions help 1) What planetary time association is conside.pdfAstronomy questions help 1) What planetary time association is conside.pdf
Astronomy questions help 1) What planetary time association is conside.pdf
 
Ascientist inoculates mice- one at a time- with a disease germ until h.pdf
Ascientist inoculates mice- one at a time- with a disease germ until h.pdfAscientist inoculates mice- one at a time- with a disease germ until h.pdf
Ascientist inoculates mice- one at a time- with a disease germ until h.pdf
 
Astronomy questions help please 5) According to the Maya- Venus' cyc.pdf
Astronomy questions help please   5) According to the Maya- Venus' cyc.pdfAstronomy questions help please   5) According to the Maya- Venus' cyc.pdf
Astronomy questions help please 5) According to the Maya- Venus' cyc.pdf
 
asdoon- coum now many times 'a' and T appear in your sting.pdf
asdoon- coum now many times 'a' and T appear in your sting.pdfasdoon- coum now many times 'a' and T appear in your sting.pdf
asdoon- coum now many times 'a' and T appear in your sting.pdf
 

Recently uploaded

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 

Recently uploaded (20)

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 

Apply physics laws to the circles- When a circle hits one of the sides.pdf

  • 1. Apply physics laws to the circles . When a circle hits one of the sides of the screen, its progress should be altered in some way. While the circles currently move at a constant speed and have randomized movement once they bounce off one edge of the screen, there are ways you can alter this to make the animation more engaging. Some options you may wish to use for your work are as follows, but you do not need to complete all of these. You can also try an idea of your own instead. Alter the speed of the circle. Change the angle of trajectory so it follows physics laws instead of taking a randomized pattern. (This means it would continue in the direction it was heading rather than moving backward.) Add friction to specific surfaces, which would affect the circle and slow its progress once it collided with the surface. PLEASE USE GIVEN CODE BELOW WITH NO ADDITIONAL LIBRARIES #include <GLFWglfw3.h> #include "linmath.h" #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <iostream> #include <vector> #include <windows.h> #include <time.h> using namespace std; const float DEG2RAD = 3.14159 / 180; void processInput(GLFWwindow* window); enum BRICKTYPE { REFLECTIVE, DESTRUCTABLE }; enum ONOFF { ON, OFF }; class Brick { public: float red, green, blue; float x, y, width; BRICKTYPE brick_type; ONOFF onoff; Brick(BRICKTYPE bt, float xx, float yy, float ww, float rr, float gg, float bb) {
  • 2. brick_type = bt; x = xx; y = yy, width = ww; red = rr, green = gg, blue = bb; onoff = ON; }; void drawBrick() { if (onoff == ON) { double halfside = width / 6; glColor3d(red, green, blue); glBegin(GL_POLYGON); glVertex2d(x + halfside, y + halfside); glVertex2d(x + halfside, y - halfside); glVertex2d(x - halfside, y - halfside); glVertex2d(x - halfside, y + halfside); glEnd(); } } }; class Circle { public: float red, green, blue; float radius; float x; float y; float speed = 0.01; //speed of circles int direction; // 1=up 2=right 3=down 4=left 5 = up right 6 = up left 7 = down right 8= down left Circle(double xx, double yy, double rr, int dir, float rad, float r, float g, float b) { x = xx; y = yy; radius = rr; red = r; green = g; blue = b; radius = rad; direction = dir; }
  • 3. void CheckCollision(Brick* brk) { if (brk->brick_type == REFLECTIVE) { if ((x > brk->x - brk->width && x <= brk->x + brk->width) && (y > brk->y - brk->width && y <= brk->y + brk->width)) { direction = GetDirection(); x = x + 0.01; y = y + 0.02; } } else if (brk->brick_type == DESTRUCTABLE) { if ((x > brk->x - brk->width && x <= brk->x + brk->width) && (y > brk->y - brk->width && y <= brk->y + brk->width)) { brk->onoff = OFF; } } } int GetDirection() { return (rand() % 8) + 1; } void MoveOneStep() { if (direction == 1 || direction == 5 || direction == 6) // up { if (y > -1 + radius) { y -= speed; } else { direction = GetDirection(); } } if (direction == 2 || direction == 5 || direction == 7) // right { if (x < 1 - radius) { x += speed;
  • 4. } else { direction = GetDirection(); } } if (direction == 3 || direction == 7 || direction == 8) // down { if (y < 1 - radius) { y += speed; } else { direction = GetDirection(); } } if (direction == 4 || direction == 6 || direction == 8) // left { if (x > -1 + radius) { x -= speed; } else { direction = GetDirection(); } } } void DrawCircle() { glColor3f(red, green, blue); glBegin(GL_POLYGON); for (int i = 0; i < 360; i++) { float degInRad = i * DEG2RAD; glVertex2f((cos(degInRad) * radius) + x, (sin(degInRad) * radius) + y); } glEnd(); } }; vector<Circle> world;
  • 5. int main(void) { srand(time(NULL)); if (!glfwInit()) { exit(EXIT_FAILURE); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); GLFWwindow* window = glfwCreateWindow(480, 480, "Shingy Chiremba Week 8 Assignment", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSwapInterval(1); Brick brick(REFLECTIVE, 0.5, -0.33, 0.2, 1, 1, 0); Brick brick2(DESTRUCTABLE, -0.5, 0.33, 0.2, 0, 1, 0); Brick brick3(DESTRUCTABLE, -0.5, -0.33, 0.2, 0, 1, 1); Brick brick4(DESTRUCTABLE, 1, 1, 0.5, 0, 0.5, 0.5); Brick brick5(REFLECTIVE, 0.3, 0.3, 0.2, 1, 0.5, 0.5); Brick brick6(DESTRUCTABLE, 0.2, 0.2, 0.2, 0.8, 0.3, 0.3); while (!glfwWindowShouldClose(window)) { //Setup View float ratio; int width, height; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float)height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); processInput(window); //Movement for (int i = 0; i < world.size(); i++) { world[i].CheckCollision(&brick); world[i].CheckCollision(&brick2); world[i].CheckCollision(&brick3); world[i].CheckCollision(&brick4); world[i].CheckCollision(&brick5); world[i].CheckCollision(&brick6);
  • 6. world[i].MoveOneStep(); world[i].DrawCircle(); } brick.drawBrick(); brick2.drawBrick(); brick3.drawBrick(); brick4.drawBrick(); brick5.drawBrick(); brick6.drawBrick(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate; exit(EXIT_SUCCESS); } void processInput(GLFWwindow* window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) { double r, g, b; r = rand() / 10000; g = rand() / 10000; b = rand() / 10000; Circle B(0, 0, 02, 2, 0.05, r, g, b); world.push_back(B); } }