Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
xorz57 committed Jun 25, 2024
1 parent aade747 commit 4377f6e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
22 changes: 11 additions & 11 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Application::Application() {
mView = mWindow.getDefaultView();
}

void Application::Run() {
void Application::run() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<float> dis(1.0, 20.0);
Expand All @@ -49,12 +49,12 @@ void Application::Run() {
sf::Clock spawnClock;

while (mWindow.isOpen()) {
ProcessEvents();
processEvents();

const sf::Time deltaTime = deltaClock.restart();
accumulator += deltaTime;
while (accumulator > fixedDeltaTime) {
FixedUpdate(fixedDeltaTime);
fixedUpdate(fixedDeltaTime);
totalTime += fixedDeltaTime;
accumulator -= fixedDeltaTime;
}
Expand Down Expand Up @@ -104,21 +104,21 @@ void Application::Run() {
ImGui::SFML::Shutdown();
}

void Application::ProcessEvents() {
void Application::processEvents() {
sf::Event event{};
while (mWindow.pollEvent(event)) {
ImGui::SFML::ProcessEvent(mWindow, event);
switch (event.type) {
case sf::Event::Closed:
HandleEventClosed(event);
handleEventClosed(event);
break;

case sf::Event::Resized:
HandleEventResized(event);
handleEventResized(event);
break;

case sf::Event::MouseWheelScrolled:
HandleEventMouseWheelScrolled(event);
handleEventMouseWheelScrolled(event);
break;

default:
Expand All @@ -127,16 +127,16 @@ void Application::ProcessEvents() {
}
}

void Application::HandleEventClosed(const sf::Event &) {
void Application::handleEventClosed(const sf::Event &) {
mWindow.close();
}

void Application::HandleEventResized(const sf::Event &event) {
void Application::handleEventResized(const sf::Event &event) {
mView.setSize(static_cast<float>(event.size.width), static_cast<float>(event.size.height));
mWindow.setView(mView);
}

void Application::HandleEventMouseWheelScrolled(const sf::Event &event) {
void Application::handleEventMouseWheelScrolled(const sf::Event &event) {
if (event.mouseWheelScroll.delta > 0.0f) {
mView.zoom(1.0f / 1.05f);
}
Expand All @@ -146,7 +146,7 @@ void Application::HandleEventMouseWheelScrolled(const sf::Event &event) {
mWindow.setView(mView);
}

void Application::FixedUpdate(const sf::Time &fixedDeltaTime) {
void Application::fixedUpdate(const sf::Time &fixedDeltaTime) {
const float dt = fixedDeltaTime.asSeconds();
for (size_t i = 0; i < mObjects.size(); ++i) {
Object &object1 = mObjects[i];
Expand Down
17 changes: 9 additions & 8 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
class Application {
public:
Application();
void Run();

void run();

private:
void ProcessEvents();
void HandleEventClosed(const sf::Event &event);
void HandleEventResized(const sf::Event &event);
void HandleEventMouseWheelScrolled(const sf::Event &event);
void HandleEventMouseButtonPressed(const sf::Event &event);
void HandleEventMouseButtonReleased(const sf::Event &event);
void FixedUpdate(const sf::Time &fixedDeltaTime);
void processEvents();
void handleEventClosed(const sf::Event &event);
void handleEventResized(const sf::Event &event);
void handleEventMouseWheelScrolled(const sf::Event &event);
void handleEventMouseButtonPressed(const sf::Event &event);
void handleEventMouseButtonReleased(const sf::Event &event);
void fixedUpdate(const sf::Time &fixedDeltaTime);

sf::VideoMode mMode{900u, 900u};
sf::String mTitle{"VerletSFML"};
Expand Down
2 changes: 1 addition & 1 deletion src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

int main() {
Application application;
application.Run();
application.run();
return 0;
}

0 comments on commit 4377f6e

Please sign in to comment.