Question: * The project is done in Microsoft Visual Studio 2 0 2 2 ( x 8 6 and SDL 2 used ) . The photo

* The project is done in Microsoft Visual Studio 2022(x86 and SDL2 used). The photo is Main.cpp to show the desired structure. The requirements for the project are that a maximized window with a title must be created for both video simulations.
**Problem:
You run into Galileo outside, and he's going to climb the Leaning Tower of Pisa with two balls.
One ball is heavy, and the other is light, and he says he wants to prove that both balls would reach the
ground at the same time. You tell him, in fact, he doesn't need to work hard in this way, and you will
show him some simulations. You then take him to a cafe for a drink, and then you open your laptop and
run your program.
Two balls of different colors appear on your screen, and their initial positions are at the same height. For
example, one ball's initial position is at (-5,25) and the other is at (5,25). Their weights differ by a
hundred times. For example, the heavy ball is 10 kg, while the light ball is only 0.1 kg. They're of the
same size, because you're going to assume they experience the same drag force later.
You make two simulations for Galileo. The first simulation ignores the resistance of the air, and it
demonstrates that the two balls of different masses reach the ground at the same time. The second
simulation considers the resistance of the air. For the sake of simplicity, you assume they experience the
same drag, since they are of the same size, shape and smoothness, the only difference is the mass. In the
second simulation, you apply a small drag force to both balls. The Simulation shows that the heavier ball
reaches the ground first. Its better to set the bouncing ratio to zero so when a ball hits the ground it
stops. The drag force for the two balls is set the same, and you decide how strong it is.
**Application.h
#ifndef APPLICATION_H
#define APPLICATION_H
#include "./Graphics.h"
#include "./Physics/Particle.h"
#include
class Application {
private:
bool running = false;
std::vector particles;
Vec2 pushForce = Vec2(0,0);
Vec2 mouseCursor = Vec2(0,0);
bool leftMouseButtonDown = false;
public:
Application()= default;
~Application()= default;
bool isRunning();
void setup();
void input();
void update();
void render();
void destroy();
};
#endif
***Code present in completed applications:
#include "Application.h"
#include "./Physics/Constants.h"
#include "./Physics/Force.h"
#include
bool Application::isRunning(){
return running;
}
void Application::setup(){
running = Graphics::openWindow("A single particle moving within a rectangle");//openWindow();
//------ set up the position of the coordinate system origin in the window ------
Graphics::setOrigin(Graphics::windowWidth /2, Graphics::windowHeight /2);
Particle* aDot = new Particle(0,0,10,0.5);
particles.push_back(aDot);
}
void Application::input(){
SDL_Event event;
while (SDL_PollEvent(&event)){
switch (event.type){
case SDL_QUIT:
running = false;
break;
void Application::update(){
static int timePreviousFrame;
int timeToWait = MILLISECS_PER_FRAME -(SDL_GetTicks()- timePreviousFrame);
if (timeToWait >0)
SDL_Delay(timeToWait);
float deltaTime =(SDL_GetTicks()- timePreviousFrame)/1000.0f;
if (deltaTime >0.016)
deltaTime =0.016;
timePreviousFrame = SDL_GetTicks();
for (auto particle : particles){
particle->addForce(pushForce);
Vec2 friction = Force::generateFrictionForce(*particle,40);
if(particle->velocity.magnitude()>0.001)
particle->addForce(friction);
}
for (auto particle : particles){
particle->integrate(deltaTime); // Integrate the acceleration and velocity to estimate the new position
}
for (auto particle : particles){
if (Graphics::xPosInWindow(particle->position.x - particle->radius)=0){
particle->position.x = Graphics::xPosInCoordinate(0)+ particle->radius;
particle->velocity.x *=-ratio;
particle->velocity.y *= ratio;
}
else if (Graphics::xPosInWindow(particle->position.x + particle->radius)>= Graphics::getWindowWidth()){
particle->position.x = Graphics::xPosInCoordinate(Graphics::getWindowWidth())- particle->radius;
particle->velocity.x *=-ratio;
particle->velocity.y *= ratio;
}
if (Graphics::yPosInWindow(particle->position.y - particle->radius)>= Graphics::getWindowHeight()){
particle->position.y = Graphics::yPosInCoordinate(Graphics::getWindowHeight())+ particle->radius;
particle->velocity.x *= ratio;
particle->velocity.y *=-ratio;
}
else if (Graphics::yPosInWindow(particle->position.y + particle->radius)=0){
particle->position.y = Graphics::yPosInCoordinate(0)- particle->radius;
particle->velocity.x *= ratio;
particle->velocity.y *=-ratio;
}
}
}
void Application::render(){
x
x
Graphics::renderFrame();
}
void Application::destroy(){
for (auto particle: particles){
delete particle;
}
Graphics::CloseWindow();
}
* The project is done in Microsoft Visual Studio

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!