parent
20e5edb82c
commit
f03e03101b
8 changed files with 50 additions and 4 deletions
@ -0,0 +1,23 @@ |
|||||||
|
#include "Logger.h" |
||||||
|
#include "FileManager.h" |
||||||
|
|
||||||
|
#define MAX_STRING 100 |
||||||
|
constexpr int eventStringMax = 6; |
||||||
|
|
||||||
|
void Logger::OnCoinCollected(CoinCollectEvent *event) { |
||||||
|
char buffer[MAX_STRING]; |
||||||
|
sprintf(buffer, "Game event: %*s | time: %6.2f | value: %d\n", eventStringMax, "Coin", event->time, event->value); |
||||||
|
FileManager::instance->writeFile("log.txt", buffer, true); |
||||||
|
} |
||||||
|
|
||||||
|
void Logger::OnWallJumped(WallJumpEvent *event) { |
||||||
|
char buffer[MAX_STRING]; |
||||||
|
sprintf(buffer, "Game event: %*s | time: %6.2f | wall_height: %6.2f\n", eventStringMax, "Jump", event->time, event->wallHeight); |
||||||
|
FileManager::instance->writeFile("log.txt", buffer, true); |
||||||
|
} |
||||||
|
|
||||||
|
void Logger::OnWallCrashed(WallCrashEvent *event) { |
||||||
|
char buffer[MAX_STRING]; |
||||||
|
sprintf(buffer, "Game event: %*s | time: %6.2f | wall_height: %6.2f\n", eventStringMax, "Crash", event->time, event->wallHeight); |
||||||
|
FileManager::instance->writeFile("log.txt", buffer, true); |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include "Listener.h" |
||||||
|
|
||||||
|
class Logger : public GameListener{ |
||||||
|
protected: |
||||||
|
void OnCoinCollected(CoinCollectEvent * event) override; |
||||||
|
void OnWallJumped(WallJumpEvent * event) override; |
||||||
|
void OnWallCrashed(WallCrashEvent * event) override; |
||||||
|
}; |
Loading…
Reference in new issue