diff --git a/project/Easy2D.sln b/project/Easy2D.sln index 8d9ecab1..b7badeee 100644 --- a/project/Easy2D.sln +++ b/project/Easy2D.sln @@ -1,12 +1,13 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.271 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{3561A359-F9FD-48AB-A977-34E7E568BC8E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D", "Easy2D\Easy2D.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Samples", "Samples\Samples.vcxproj", "{45F5738D-CDF2-4024-974D-25B64F9043DE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -15,6 +16,14 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.Build.0 = Debug|Win32 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|x64.ActiveCfg = Debug|x64 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|x64.Build.0 = Debug|x64 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.ActiveCfg = Release|Win32 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.Build.0 = Release|Win32 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|x64.ActiveCfg = Release|x64 + {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|x64.Build.0 = Release|x64 {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.ActiveCfg = Debug|Win32 {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Build.0 = Debug|Win32 {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|Win32.Deploy.0 = Debug|Win32 @@ -25,14 +34,14 @@ Global {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|Win32.Build.0 = Release|Win32 {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x64.ActiveCfg = Release|x64 {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x64.Build.0 = Release|x64 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.ActiveCfg = Debug|Win32 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|Win32.Build.0 = Debug|Win32 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|x64.ActiveCfg = Debug|x64 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Debug|x64.Build.0 = Debug|x64 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.ActiveCfg = Release|Win32 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|Win32.Build.0 = Release|Win32 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|x64.ActiveCfg = Release|x64 - {3561A359-F9FD-48AB-A977-34E7E568BC8E}.Release|x64.Build.0 = Release|x64 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.ActiveCfg = Debug|Win32 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|Win32.Build.0 = Debug|Win32 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|x64.ActiveCfg = Debug|x64 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Debug|x64.Build.0 = Debug|x64 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.ActiveCfg = Release|Win32 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|Win32.Build.0 = Release|Win32 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|x64.ActiveCfg = Release|x64 + {45F5738D-CDF2-4024-974D-25B64F9043DE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/project/Samples/Demo1.h b/project/Samples/Demo1.h new file mode 100644 index 00000000..4c24c549 --- /dev/null +++ b/project/Samples/Demo1.h @@ -0,0 +1,36 @@ +// Copyright (C) 2019 Nomango + +#pragma once +#include "common.h" + +class Demo1 + : public Scene +{ +public: + static ScenePtr Create() + { + return new Demo1; + } + + Demo1() + { + // ´´½¨Îı¾ + auto text = E_NEW Text(L"Hello Easy2D!"); + // ÈÃÎı¾ÏÔʾÔÚÆÁÄ»ÖÐÑë + text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); + text->SetAnchor(0.5, 0.5); + // Ìí¼Óµ½³¡¾° + this->AddChild(text); + + // Ö´Ðж¯»­ + text->AddAction( + Tween::Spawn({ // Action5: ͬʱִÐÐ Action1 ºÍ Action4, ²¢ÎÞÏÞÑ­»· + Tween::RotateBy(60).SetDuration(1000), // Action1: 1ÃëÐýת 60 ¶È + Tween::Sequence({ // Action4: ˳ÐòÖ´ÐÐ Action2 ºÍ Action3 + Tween::FadeOut(500), // Action2: 500ºÁÃëµ­³ö¶¯»­ + Tween::FadeIn(500) // Action3: 500ºÁÃëµ­È붯»­ + }) + }).SetLoopCount(-1) + ); + } +}; diff --git a/project/Samples/Demo2.h b/project/Samples/Demo2.h new file mode 100644 index 00000000..508b86a3 --- /dev/null +++ b/project/Samples/Demo2.h @@ -0,0 +1,91 @@ +// Copyright (C) 2019 Nomango + +#pragma once +#include "common.h" + +class Man + : public Sprite +{ +public: + Man() + { + // ¼ÓÔØÍ¼Æ¬ + Load(L"res/man.png"); + // ËõСͼƬ + SetScale(0.5f); + } + + // ÿ֡¸üÐÂʱ + void OnUpdate(Duration dt) override + { + // »ñÈ¡ÊäÈëÉ豸 + auto input = Input::Instance(); + // °´ÏÂ×óÓÒ¼ü + if (input->IsDown(KeyCode::Left)) + { + this->Move(-2, 0); + } + else if (input->IsDown(KeyCode::Right)) + { + this->Move(2, 0); + } + + // °´ÏÂÉÏϼü + if (input->IsDown(KeyCode::Up)) + { + this->Move(0, -2); + } + else if (input->IsDown(KeyCode::Down)) + { + this->Move(0, 2); + } + + // °´ÏÂÊó±ê×ó¼ü£¬Ë³Ê±ÕëÐýתСÈË + if (input->IsDown(MouseButton::Left)) + { + // »ñÈ¡µ±Ç°Ðýת½Ç¶È + float rotation = this->GetRotation(); + // ÉèÖýǶÈÖµ+2 + this->SetRotation(rotation + 2); + } + + // µã»÷Êó±êÓÒ¼ü£¬Òþ²Ø»òÏÔʾСÈË + if (input->WasPressed(MouseButton::Right)) + { + // »ñÈ¡µ±Ç°ÏÔʾ״̬ + bool visible = this->IsVisible(); + // ÉèÖÃÏà·´µÄÏÔʾ״̬ + this->SetVisible(!visible); + } + } +}; + +class Demo2 + : public Scene +{ +public: + static ScenePtr Create() + { + return new Demo2; + } + + Demo2() + { + // ´´½¨ÈËÎï + auto man = E_NEW Man; + // ÔÚÆÁÄ»ÉϾÓÖÐÏÔʾ + man->SetAnchor(0.5f, 0.5f); + man->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); + + // ´´½¨ËµÃ÷ÎÄ×Ö + auto text = E_NEW Text(L"°´ÉÏÏÂ×óÓÒ¼üÒÆ¶¯\n°´Êó±ê×ó¼üÐýת\nµã»÷Êó±êÓÒ¼üÒþ²Ø"); + // ÉèÖÃÎÄ×ÖλÖà + text->SetAnchor(0.5f, 0.5f); + text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT - 50); + text->SetAlignment(TextAlign::Center); + + // Ìí¼Óµ½³¡¾° + this->AddChild(man); + this->AddChild(text); + } +}; diff --git a/project/Samples/Demo3.h b/project/Samples/Demo3.h new file mode 100644 index 00000000..fa74602a --- /dev/null +++ b/project/Samples/Demo3.h @@ -0,0 +1,87 @@ +// Copyright (C) 2019 Nomango + +#pragma once +#include "common.h" + +class Demo3 + : public Scene +{ + MusicPtr music; // ÒôÀÖ¶ÔÏó + TextPtr volume_text; // ÒôÁ¿ÎÄ×Ö + TextPtr state_text; // ²¥·Å״̬ÎÄ×Ö + +public: + static ScenePtr Create() + { + return new Demo3; + } + + Demo3() + { + // ¼ÓÔØÒôÀÖ + music = E_NEW Music; + if (!music->Load(L"res/music.wav")) + { + music = nullptr; + + auto err = E_NEW Text(L"ÒôƵÎļþ¼ÓÔØÊ§°Ü"); + this->AddChild(err); + } + + // ²¥·ÅÒôÀÖ£¨²ÎÊýÓÃÀ´ÉèÖò¥·ÅÑ­»·´ÎÊý£¬-1 ±íʾѭ»·²¥·Å£© + music->Play(-1); + + // ´´½¨ËµÃ÷ÎÄ×Ö + auto intro_text = E_NEW Text(L"°´ÉÏϼüµ÷ÕûÒôÁ¿\n°´¿Õ¸ñ¼üÔÝÍ£»ò¼ÌÐø"); + intro_text->SetAnchor(0.5f, 0.5f); + intro_text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 50); + + // ´´½¨ÒôÁ¿ÎÄ×Ö + volume_text = E_NEW Text(L"µ±Ç°ÒôÁ¿£º"); + volume_text->SetAnchor(0.5f, 0.5f); + volume_text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 30); + + // ´´½¨×´Ì¬ÎÄ×Ö + state_text = E_NEW Text(L"µ±Ç°×´Ì¬£º"); + state_text->SetAnchor(0.5f, 0.5f); + state_text->SetPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 + 60); + + // Ìí¼Óµ½³¡¾° + this->AddChild(intro_text); + this->AddChild(volume_text); + this->AddChild(state_text); + } + + void OnUpdate(Duration dt) override + { + if (music == nullptr) + return; + + // »ñÈ¡ÒôÁ¿ºÍ²¥·Å״̬ + float volume = music->GetVolume(); + bool playing = music->IsPlaying(); + + // ÐÞ¸ÄÎı¾ + volume_text->SetText(L"µ±Ç°ÒôÁ¿£º" + std::to_wstring(volume)); + state_text->SetText(playing ? L"µ±Ç°×´Ì¬£ºÕýÔÚ²¥·Å" : L"µ±Ç°×´Ì¬£ºÍ£Ö¹²¥·Å"); + + // »ñÈ¡ÊäÈëÉ豸 + auto input = Input::Instance(); + + // °´¿Õ¸ñ¼üÔÝÍ£»ò¼ÌÐø + if (input->WasPressed(KeyCode::Space)) + { + music->IsPlaying() ? music->Pause() : music->Resume(); + } + + // °´ÉÏϼüµ÷ÕûÒôÁ¿ + if (input->WasPressed(KeyCode::Up)) + { + music->SetVolume(volume + 0.1f); + } + else if (input->WasPressed(KeyCode::Down)) + { + music->SetVolume(volume - 0.1f); + } + } +}; diff --git a/project/Samples/Samples.vcxproj b/project/Samples/Samples.vcxproj new file mode 100644 index 00000000..9479c9e6 --- /dev/null +++ b/project/Samples/Samples.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {45F5738D-CDF2-4024-974D-25B64F9043DE} + Samples + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Level3 + Disabled + true + ../../src + + + true + Console + + + + + Level3 + Disabled + true + ../../src + + + true + Console + + + + + Level3 + MaxSpeed + true + true + true + ../../src + + + true + true + true + Console + + + + + Level3 + MaxSpeed + true + true + true + ../../src + + + true + true + true + Console + + + + + + + + + + + + + + + {ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf} + + + + + + \ No newline at end of file diff --git a/project/Samples/Samples.vcxproj.filters b/project/Samples/Samples.vcxproj.filters new file mode 100644 index 00000000..4683312d --- /dev/null +++ b/project/Samples/Samples.vcxproj.filters @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/Samples/common.h b/project/Samples/common.h new file mode 100644 index 00000000..b3e36e18 --- /dev/null +++ b/project/Samples/common.h @@ -0,0 +1,9 @@ +// Copyright (C) 2019 Nomango + +#pragma once +#include "easy2d.h" + +using namespace easy2d; + +const int WINDOW_WIDTH = 640; +const int WINDOW_HEIGHT = 480; diff --git a/project/Samples/include-forwards.h b/project/Samples/include-forwards.h new file mode 100644 index 00000000..9c7bae91 --- /dev/null +++ b/project/Samples/include-forwards.h @@ -0,0 +1,7 @@ +// Copyright (C) 2019 Nomango + +#pragma once +#include "common.h" +#include "Demo1.h" +#include "Demo2.h" +#include "Demo3.h" diff --git a/project/Samples/main.cpp b/project/Samples/main.cpp new file mode 100644 index 00000000..d0f1e9ee --- /dev/null +++ b/project/Samples/main.cpp @@ -0,0 +1,82 @@ +// Copyright (C) 2019 Nomango + +#include "include-forwards.h" + +namespace +{ + struct Demo + { + String title; + ScenePtr(*Create)(); + }; + + Demo s_Demos[] = { + { L"¶¯»­Ê¾Àý", Demo1::Create }, + { L"ÊäÈëʾÀý", Demo2::Create }, + { L"ÒôƵ²¥·ÅʾÀý", Demo3::Create }, + }; + int s_DemoIndex = 0; + int s_DemoNum = sizeof(s_Demos) / sizeof(Demo); +} + +class DemoApp + : public Application +{ +public: + DemoApp() + { + Options options; + options.title = L"Easy2DʾÀý³ÌÐò"; + options.width = WINDOW_WIDTH; + options.height = WINDOW_HEIGHT; + + Init(options); + } + + void OnStart() override + { + ChangeDemoScene(); + } + + void ChangeDemoScene() + { + Window::Instance()->SetTitle(s_Demos[s_DemoIndex].title); + + ScenePtr scene = s_Demos[s_DemoIndex].Create(); + EnterScene(scene); + + // Ìí¼Ó°´¼ü¼àÌý + scene->AddListener(KeyboardEvent::Up, Closure(this, &DemoApp::KeyPressed)); + + // ÏÔʾÌáʾÎÄ×Ö + TextPtr intro = new Text(L"Key 1~3 to select demo"); + intro->SetFontSize(16.f); + scene->AddChild(intro); + } + + void KeyPressed(Event const& evt) + { + E2D_ASSERT(evt.type == KeyboardEvent::Up); + + if (evt.key.code > KeyCode::Num0 && + evt.key.code <= (KeyCode::Num0 + s_DemoNum)) + { + s_DemoIndex = evt.key.code - KeyCode::Num1; + ChangeDemoScene(); + } + } +}; + +int main() +{ + try + { + DemoApp app; + app.Run(); + } + catch (std::exception& e) + { + ::MessageBoxA(nullptr, e.what(), "An exception has occurred!", MB_ICONERROR | MB_TASKMODAL); + } + return 0; +} diff --git a/project/Samples/res/man.png b/project/Samples/res/man.png new file mode 100644 index 00000000..4f89e869 Binary files /dev/null and b/project/Samples/res/man.png differ diff --git a/project/Samples/res/music.wav b/project/Samples/res/music.wav new file mode 100644 index 00000000..b54e0547 Binary files /dev/null and b/project/Samples/res/music.wav differ diff --git a/src/core/Application.cpp b/src/core/Application.cpp index 270e5eea..fd01c85a 100644 --- a/src/core/Application.cpp +++ b/src/core/Application.cpp @@ -154,6 +154,13 @@ namespace easy2d Window::Instance()->Destroy(); } + void Application::Destroy() + { + transition_ = nullptr; + next_scene_ = nullptr; + curr_scene_ = nullptr; + } + void Application::EnterScene(ScenePtr const & scene) { E2D_ASSERT(scene && "Application::EnterScene failed, NULL pointer exception"); @@ -218,6 +225,8 @@ namespace easy2d next_scene_ = nullptr; } + OnUpdate(dt); + if (curr_scene_) curr_scene_->Update(dt); @@ -284,7 +293,7 @@ namespace easy2d if (!app->transition_ && app->curr_scene_) { Event evt((msg == WM_KEYDOWN) ? KeyboardEvent::Down : KeyboardEvent::Up); - evt.key.code = KeyCode(wparam); + evt.key.code = static_cast(wparam); evt.key.count = static_cast(lparam & 0xFF); app->curr_scene_->Dispatch(evt); diff --git a/src/core/Application.h b/src/core/Application.h index 8a8f1512..8c84ba28 100644 --- a/src/core/Application.h +++ b/src/core/Application.h @@ -74,12 +74,18 @@ namespace easy2d // Ïú»Ùʱ virtual void OnDestroy() {} + // ¸üÐÂʱ + virtual void OnUpdate(Duration dt) { E2D_NOT_USED(dt); } + // ÔËÐÐ void Run(); // ½áÊø void Quit(); + // Ïú»Ù + void Destroy(); + // Çл»³¡¾° void EnterScene( ScenePtr const& scene /* ³¡¾° */ diff --git a/src/core/Event.hpp b/src/core/Event.hpp index 461f89f8..b57f4e74 100644 --- a/src/core/Event.hpp +++ b/src/core/Event.hpp @@ -52,7 +52,7 @@ namespace easy2d struct { - MouseButton button; // ½öµ±ÏûÏ¢ÀàÐÍΪ Down | Up | Click ʱÓÐЧ + int button; // ½öµ±ÏûÏ¢ÀàÐÍΪ Down | Up | Click ʱÓÐЧ }; struct @@ -79,7 +79,7 @@ namespace easy2d Last }; - KeyCode code; + int code; // enum KeyCode int count; static inline bool Check(UINT type) diff --git a/src/core/Font.hpp b/src/core/Font.hpp index d27b7f4f..1a673ec2 100644 --- a/src/core/Font.hpp +++ b/src/core/Font.hpp @@ -49,7 +49,7 @@ namespace easy2d public: Font( const String& family = L"", - float size = 22, + float size = 18, unsigned int weight = FontWeight::Normal, bool italic = false ) diff --git a/src/core/Input.cpp b/src/core/Input.cpp index bf6aa753..2ba5ccb7 100644 --- a/src/core/Input.cpp +++ b/src/core/Input.cpp @@ -72,34 +72,22 @@ namespace easy2d want_update_ = true; } - bool Input::IsDown(KeyCode code) + bool Input::IsDown(int code_or_btn) { - return keys_[static_cast(code)]; + E2D_ASSERT(code_or_btn >= 0 && code_or_btn < 256); + return keys_[code_or_btn]; } - bool Input::IsDown(MouseButton btn) + bool Input::WasPressed(int code_or_btn) { - return keys_[static_cast(btn)]; + E2D_ASSERT(code_or_btn >= 0 && code_or_btn < 256); + return keys_pressed_[code_or_btn]; } - bool Input::WasPressed(KeyCode code) + bool Input::WasReleased(int code_or_btn) { - return keys_pressed_[static_cast(code)]; - } - - bool Input::WasPressed(MouseButton btn) - { - return keys_pressed_[static_cast(btn)]; - } - - bool Input::WasReleased(KeyCode code) - { - return keys_released_[static_cast(code)]; - } - - bool Input::WasReleased(MouseButton btn) - { - return keys_released_[static_cast(btn)]; + E2D_ASSERT(code_or_btn >= 0 && code_or_btn < 256); + return keys_released_[code_or_btn]; } float Input::GetMouseX() diff --git a/src/core/Input.h b/src/core/Input.h index 67df496a..7a91e101 100644 --- a/src/core/Input.h +++ b/src/core/Input.h @@ -31,34 +31,19 @@ namespace easy2d E2D_DECLARE_SINGLETON(Input); public: - // ¼ì²â¼üÅ̰´¼üÊÇ·ñÕý±»°´Ï + // ¼ì²â¼üÅÌ»òÊó±ê°´¼üÊÇ·ñÕý±»°´Ï bool IsDown( - KeyCode code + int code_or_btn ); - // ¼ì²âÊó±ê°´¼üÊÇ·ñÕý±»°´Ï - bool IsDown( - MouseButton btn - ); - - // ¼ì²â¼üÅ̰´¼üÊÇ·ñ¸Õ±»µã»÷ + // ¼ì²â¼üÅÌ»òÊó±ê°´¼üÊÇ·ñ¸Õ±»µã»÷ bool WasPressed( - KeyCode code + int code_or_btn ); - // ¼ì²âÊó±ê°´¼üÊÇ·ñ¸Õ±»µã»÷ - bool WasPressed( - MouseButton btn - ); - - // ¼ì²â¼üÅ̰´¼üÊÇ·ñ¸Õ̧Æð + // ¼ì²â¼üÅÌ»òÊó±ê°´¼üÊÇ·ñ¸Õ̧Æð bool WasReleased( - KeyCode code - ); - - // ¼ì²âÊó±ê°´¼üÊÇ·ñ¸Õ̧Æð - bool WasReleased( - MouseButton btn + int code_or_btn ); // »ñµÃÊó±ê x ×ø±ê diff --git a/src/core/Text.h b/src/core/Text.h index 4e532111..e09798f7 100644 --- a/src/core/Text.h +++ b/src/core/Text.h @@ -119,7 +119,7 @@ namespace easy2d String const& family ); - // ÉèÖÃ×ֺţ¨Ä¬ÈÏֵΪ 22£© + // ÉèÖÃ×ֺţ¨Ä¬ÈÏֵΪ 18£© void SetFontSize( float size ); diff --git a/src/core/keys.hpp b/src/core/keys.hpp index 92081bcc..2dd31a1b 100644 --- a/src/core/keys.hpp +++ b/src/core/keys.hpp @@ -24,88 +24,98 @@ namespace easy2d { // Êó±ê°´¼ü - enum class MouseButton : int + struct MouseButton { - Left = VK_LBUTTON, // Êó±ê×ó¼ü - Right = VK_RBUTTON, // Êó±êÓÒ¼ü - Middle = VK_MBUTTON // Êó±êÖмü + typedef int Value; + + enum : int + { + Left = VK_LBUTTON, // Êó±ê×ó¼ü + Right = VK_RBUTTON, // Êó±êÓÒ¼ü + Middle = VK_MBUTTON // Êó±êÖмü + }; }; // °´¼ü¼üÖµ - enum class KeyCode : int + struct KeyCode { - Unknown = 0, - Up = VK_UP, - Left = VK_LEFT, - Right = VK_RIGHT, - Down = VK_DOWN, - Enter = VK_RETURN, - Space = VK_SPACE, - Esc = VK_ESCAPE, - Ctrl = VK_CONTROL, - Shift = VK_SHIFT, + typedef int Value; - A = 0x41, - B, - C, - D, - E, - F, - G, - H, - I, - J, - K, - L, - M, - N, - O, - P, - Q, - R, - S, - T, - U, - V, - W, - X, - Y, - Z, + enum : int + { + Unknown = 0, + Up = VK_UP, + Left = VK_LEFT, + Right = VK_RIGHT, + Down = VK_DOWN, + Enter = VK_RETURN, + Space = VK_SPACE, + Esc = VK_ESCAPE, + Ctrl = VK_CONTROL, + Shift = VK_SHIFT, - Num0 = 0x30, - Num1, - Num2, - Num3, - Num4, - Num5, - Num6, - Num7, - Num8, - Num9, + A = 0x41, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, - Numpad0 = VK_NUMPAD0, - Numpad1, - Numpad2, - Numpad3, - Numpad4, - Numpad5, - Numpad6, - Numpad7, - Numpad8, - Numpad9, + Num0 = 0x30, + Num1, + Num2, + Num3, + Num4, + Num5, + Num6, + Num7, + Num8, + Num9, - F1 = VK_F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, + Numpad0 = VK_NUMPAD0, + Numpad1, + Numpad2, + Numpad3, + Numpad4, + Numpad5, + Numpad6, + Numpad7, + Numpad8, + Numpad9, + + F1 = VK_F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + }; }; }