修复Demo的Main.cpp的问题,并修复int32-float的转换。
This commit is contained in:
parent
e150b153b9
commit
3f6e2bab2c
|
|
@ -1,15 +1,13 @@
|
||||||
#include <algorithm>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include <cstdlib>
|
|
||||||
#include "Timer.h"
|
|
||||||
#include "DrawContext.h"
|
#include "DrawContext.h"
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
#include "TimeSource.h"
|
#include "TimeSource.h"
|
||||||
|
|
@ -23,15 +21,10 @@
|
||||||
#include "SDLDisplay.h"
|
#include "SDLDisplay.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int32_t width = 1024;
|
namespace
|
||||||
const int32_t height = 600;
|
|
||||||
|
|
||||||
static void PrintUsage(const char *program_name)
|
|
||||||
{
|
{
|
||||||
std::cout
|
const int32_t DemoWidth = 1024;
|
||||||
<< "Usage: " << program_name << " [--fps 30|45|60]\n"
|
const int32_t DemoHeight = 600;
|
||||||
<< " " << program_name << " [--fps=30|45|60]\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ProgramOptions
|
struct ProgramOptions
|
||||||
{
|
{
|
||||||
|
|
@ -45,6 +38,13 @@ static void PrintUsage(const char *program_name)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void PrintUsage(const char* program_name)
|
||||||
|
{
|
||||||
|
std::cout
|
||||||
|
<< "Usage: " << program_name << " [--fps 30|45|60]\n"
|
||||||
|
<< " " << program_name << " [--fps=30|45|60]\n";
|
||||||
|
}
|
||||||
|
|
||||||
static Platform::IDisplay* CreateDisplay()
|
static Platform::IDisplay* CreateDisplay()
|
||||||
{
|
{
|
||||||
#ifdef USE_FRAMEBUFFER
|
#ifdef USE_FRAMEBUFFER
|
||||||
|
|
@ -54,13 +54,6 @@ static void PrintUsage(const char *program_name)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintUsage(const char* program_name)
|
|
||||||
{
|
|
||||||
std::cout
|
|
||||||
<< "Usage: " << program_name << " [--fps 30|45|60]\n"
|
|
||||||
<< " " << program_name << " [--fps=30|45|60]\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
static ProgramOptions ParseProgramOptions(int argc, char* argv[])
|
static ProgramOptions ParseProgramOptions(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
ProgramOptions options;
|
ProgramOptions options;
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,8 @@ namespace
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
std::cout << "[INFO] Start make tom game." << std::endl;
|
||||||
|
|
||||||
const ProgramOptions options = ParseProgramOptions(argc, argv);
|
const ProgramOptions options = ParseProgramOptions(argc, argv);
|
||||||
if (options.show_help)
|
if (options.show_help)
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +259,7 @@ int main(int argc, char* argv[])
|
||||||
Core::Timer timer(options.target_fps);
|
Core::Timer timer(options.target_fps);
|
||||||
Platform::SteadyTimeSource time_source;
|
Platform::SteadyTimeSource time_source;
|
||||||
|
|
||||||
std::cout << "Tom game started. Target FPS: " << timer.target_fps() << std::endl;
|
std::cout << "[INFO] Tom game started. Target FPS: " << timer.target_fps() << std::endl;
|
||||||
|
|
||||||
bool is_running = true;
|
bool is_running = true;
|
||||||
uint32_t animation_time_ms = 0;
|
uint32_t animation_time_ms = 0;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,11 @@ namespace Math
|
||||||
|
|
||||||
Vector2() : x(0), y(0) {}
|
Vector2() : x(0), y(0) {}
|
||||||
Vector2(float x, float y) : x(x), y(y) {}
|
Vector2(float x, float y) : x(x), y(y) {}
|
||||||
Vector2(const Vector2Int& other) :x(other.x), y(other.y) {}
|
Vector2(const Vector2Int& other)
|
||||||
|
: x(static_cast<float>(other.x)),
|
||||||
|
y(static_cast<float>(other.y))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 交换当前 Vector2 对象与另一个 Vector2 对象的 x 和 y 的值
|
/// 交换当前 Vector2 对象与另一个 Vector2 对象的 x 和 y 的值
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue