mirror of
https://github.com/yoboujon/yoyo_card.git
synced 2025-06-08 11:50:50 +02:00
Added a little demo program. Refactored project.
This commit is contained in:
parent
cc21e12738
commit
88f5987dcf
6 changed files with 75 additions and 25 deletions
|
@ -13,4 +13,4 @@ set(RAYLIB_VERSION 5.5)
|
|||
include(dependencies.cmake)
|
||||
|
||||
# Game source file
|
||||
include(game.cmake)
|
||||
add_subdirectory(game)
|
|
@ -11,15 +11,18 @@ set(TARGET game)
|
|||
# Source files
|
||||
set(SOURCES "${PROJECT_SOURCE_DIR}/src")
|
||||
add_executable(${TARGET}
|
||||
${SOURCES}/debug.cpp
|
||||
${SOURCES}/main.cpp
|
||||
)
|
||||
|
||||
# Include folders
|
||||
target_include_directories(${TARGET} PRIVATE "${PROJECT_SOURCE_DIR}/include")
|
||||
target_include_directories(${TARGET} PRIVATE "${raylib_INCLUDE_DIRS}")
|
||||
target_include_directories(${TARGET} PRIVATE "${imgui_INCLUDE_DIRS}")
|
||||
target_include_directories(${TARGET} PRIVATE "${rlImGui_INCLUDE_DIRS}")
|
||||
|
||||
# Libraries
|
||||
target_link_libraries(${TARGET} raylib)
|
||||
target_link_libraries(${TARGET} raylib imgui rlimgui)
|
||||
|
||||
# Compilation depending on the platform
|
||||
if(MSVC)
|
7
game/include/debug.h
Normal file
7
game/include/debug.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef _YOYO_CARD_DEBUG
|
||||
#define _YOYO_CARD_DEBUG
|
||||
|
||||
void debug_window(void);
|
||||
void open_window(void);
|
||||
|
||||
#endif //_YOYO_CARD_DEBUG
|
23
game/src/debug.cpp
Normal file
23
game/src/debug.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <imgui.h>
|
||||
#include <cmath>
|
||||
|
||||
bool _running = false;
|
||||
|
||||
void debug_window(void)
|
||||
{
|
||||
if (!_running)
|
||||
return;
|
||||
|
||||
ImGui::Begin("Hello, World!", &_running, ImGuiWindowFlags_NoCollapse);
|
||||
ImGui::Text("Welcome to Dear ImGui!");
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void open_window(void)
|
||||
{
|
||||
_running = true;
|
||||
}
|
40
game/src/main.cpp
Normal file
40
game/src/main.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <raylib.h>
|
||||
#include <rlImGui.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_DEBUG)
|
||||
#define main WinMain
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
InitWindow(800, 450, "hello world");
|
||||
//SetTargetFPS(60);
|
||||
rlImGuiSetup(true);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
// Start Drawing
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
rlImGuiBegin();
|
||||
|
||||
// Logic
|
||||
if(IsKeyPressed(KEY_F3))
|
||||
open_window();
|
||||
|
||||
debug_window();
|
||||
DrawText("Hello world from raylib! (Press F3 for debug!)", 190, 200, 20, LIGHTGRAY);
|
||||
|
||||
// End Drawing
|
||||
rlImGuiEnd();
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
// Free memory
|
||||
rlImGuiShutdown();
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
23
src/main.cpp
23
src/main.cpp
|
@ -1,23 +0,0 @@
|
|||
#include <raylib.h>
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_DEBUG)
|
||||
#define main WinMain
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
InitWindow(screenWidth, screenHeight, "raylib hello world");
|
||||
|
||||
SetTargetFPS(60);
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Hello world from raylib.", 190, 200, 20, LIGHTGRAY);
|
||||
EndDrawing();
|
||||
}
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue