summaryrefslogtreecommitdiffhomepage
path: root/projects/VS2017.UWP/raylib.App.UWP/App.cpp
diff options
context:
space:
mode:
authorReece Mackie <[email protected]>2019-04-27 19:33:51 +0100
committerRay <[email protected]>2019-04-27 20:33:51 +0200
commit2de1f318212dbceb71db6be053be995208748f2a (patch)
treea357bfc6e8b825ebfd26098a32bc11efa2c8dc8e /projects/VS2017.UWP/raylib.App.UWP/App.cpp
parentf37e55a77bd6177dbaea4d7f484961c09104e104 (diff)
downloadraylib-2de1f318212dbceb71db6be053be995208748f2a.tar.gz
raylib-2de1f318212dbceb71db6be053be995208748f2a.zip
UWP Support Overhaul (#819)
* Working build * Fix build again, stop deleting files * Hotfix crash, needs investigating * Remove VS2015.UWP, I cannot update the project * Lots of UWP work, added keyboard and mouse press support. Still need to finish scroll wheel, mouse position and cursor hiding, plus other stuff that I haven't seen yet. * Implemented a ton more things, added BaseApp.h to provide common code to UWP apps. * Remove constant window dimensions * Enable and Disable cursor support. * Actually use mouse delta * Gamepad Support * Cleaning and small tweaks * Restore original example. * Update comment * Use 'Messages' to handle the cursor functions so code is more portable. * Comment * Comment unused message fields and use vector for mouse pos instead. * Move messages to utils.h and use messages for everything. No more plat-specific code in raylib.h * Working build * Fix build again, stop deleting files * Hotfix crash, needs investigating * Remove VS2015.UWP, I cannot update the project * Lots of UWP work, added keyboard and mouse press support. Still need to finish scroll wheel, mouse position and cursor hiding, plus other stuff that I haven't seen yet. * Implemented a ton more things, added BaseApp.h to provide common code to UWP apps. * Remove constant window dimensions * Enable and Disable cursor support. * Actually use mouse delta * Gamepad Support * Cleaning and small tweaks * Restore original example. * Update comment * Use 'Messages' to handle the cursor functions so code is more portable. * Comment * Comment unused message fields and use vector for mouse pos instead. * Move messages to utils.h and use messages for everything. No more plat-specific code in raylib.h * Tested some desktop stuff and added projection matrix updates for window resizing. * Fixed big bad mouse bug * Fix alt buttons and add hack to combat flickery key presses (far from perfect) * Remove debug code * Final commit * Well, so I thought * Wow, i am bad * Remove packages folder * Remove useless include * Apply requested changes and fix linux build * Try to stop packages folder * Have we fixed the formatting properly? * Third time's the charm? * Where did this come from? * Re-fix * Autoformat is gonna kill * Fixed XBOX ONE Support * Fix tabs
Diffstat (limited to 'projects/VS2017.UWP/raylib.App.UWP/App.cpp')
-rw-r--r--projects/VS2017.UWP/raylib.App.UWP/App.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/projects/VS2017.UWP/raylib.App.UWP/App.cpp b/projects/VS2017.UWP/raylib.App.UWP/App.cpp
new file mode 100644
index 00000000..ae137ed2
--- /dev/null
+++ b/projects/VS2017.UWP/raylib.App.UWP/App.cpp
@@ -0,0 +1,78 @@
+#include "pch.h"
+#include "app.h"
+
+#include "raylib.h"
+
+using namespace raylibUWP;
+
+// The main function creates an IFrameworkViewSource for our app, and runs the app.
+[Platform::MTAThread]
+int main(Platform::Array<Platform::String^>^)
+{
+ auto appSource = ref new ApplicationSource<App>();
+ CoreApplication::Run(appSource);
+
+ return 0;
+}
+
+App::App()
+{
+ //This does not work... need to fix this.
+ SetConfigFlags(0);
+
+ Setup(640, 480);
+}
+
+static int posX = 100;
+static int posY = 100;
+static int gTime = 0;
+
+// This method is called every frame
+void App::Update()
+{
+ //return;
+ // Draw
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ posX += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_X) * 5;
+ posY += GetGamepadAxisMovement(GAMEPAD_PLAYER1, GAMEPAD_XBOX_AXIS_LEFT_Y) * -5;
+
+ DrawRectangle(posX, posY, 400, 100, RED);
+
+ DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
+
+ auto mPos = GetMousePosition();
+
+ DrawCircle(mPos.x, mPos.y, 40, BLUE);
+
+ if (IsKeyDown(KEY_S)) DrawCircle(100, 100, 100, BLUE);
+
+ if (IsKeyPressed(KEY_A))
+ {
+ posX -= 50;
+ EnableCursor();
+ }
+
+ if (IsKeyPressed(KEY_D))
+ {
+ posX += 50;
+ DisableCursor();
+ }
+
+ if (IsKeyDown(KEY_LEFT_ALT))
+ DrawRectangle(250, 250, 20, 20, BLACK);
+ if (IsKeyDown(KEY_BACKSPACE))
+ DrawRectangle(280, 250, 20, 20, BLACK);
+ if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
+ DrawRectangle(280, 250, 20, 20, BLACK);
+
+ static int pos = 0;
+ pos -= GetMouseWheelMove();
+
+ DrawRectangle(280, pos + 50, 20, 20, BLACK);
+ DrawRectangle(250, 280 + (gTime++ % 60), 10, 10, PURPLE);
+
+ EndDrawing();
+} \ No newline at end of file