generated from raysan5/raylib-gamejam-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66e9ea8
commit 2a1c738
Showing
3 changed files
with
109 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/******************************************************************************************* | ||
* | ||
* raylib gamejam template | ||
* | ||
* Template originally created with raylib 4.5-dev, last time updated with raylib 5.0 | ||
* | ||
* Template licensed under an unmodified zlib/libpng license, which is an OSI-certified, | ||
* BSD-like license that allows static linking with closed source software | ||
* | ||
* Copyright (c) 2022-2023 Ramon Santamaria (@raysan5) | ||
* | ||
********************************************************************************************/ | ||
|
||
#include "raylib.h" | ||
|
||
#if defined(PLATFORM_WEB) | ||
#define CUSTOM_MODAL_DIALOGS | ||
#include <emscripten/emscripten.h> | ||
#endif | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#define SUPPORT_LOG_INFO | ||
#if defined(SUPPORT_LOG_INFO) | ||
#define LOG(...) printf(__VA_ARGS__) | ||
#else | ||
#define LOG(...) | ||
#endif | ||
|
||
#define MAX(a, b) ((a) > (b) ? (a) : (b)) | ||
|
||
static const int screenWidth = 500; | ||
static const int screenHeight = 700; | ||
|
||
static RenderTexture2D target = { 0 }; | ||
|
||
void UpdateDrawFrame(void) { | ||
BeginTextureMode(target); { | ||
ClearBackground(BLACK); | ||
|
||
DrawRectangle(0, 0, screenWidth, screenHeight, SKYBLUE); | ||
} EndTextureMode(); | ||
|
||
|
||
BeginDrawing(); { | ||
ClearBackground(BLACK); | ||
|
||
float width = (float)target.texture.width; | ||
float height = (float)target.texture.height; | ||
|
||
float aspect = width / height; | ||
|
||
float finalHeight = MAX((float)GetScreenHeight(), height); | ||
|
||
float finalWidth = finalHeight * aspect; | ||
|
||
DrawTexturePro(target.texture, | ||
(Rectangle) { | ||
.x = 0, | ||
.y = 0, | ||
.width = width, | ||
.height = -height | ||
}, | ||
(Rectangle) { | ||
.x = (float)GetScreenWidth() / 2, | ||
.y = (float)GetScreenHeight() / 2, | ||
.width = finalWidth, | ||
.height = finalHeight, | ||
}, | ||
(Vector2) { finalWidth / 2, finalHeight / 2 }, | ||
0.0f, | ||
WHITE); | ||
} | ||
EndDrawing(); | ||
} | ||
|
||
|
||
int main(void) { | ||
#if !defined(_DEBUG) | ||
SetTraceLogLevel(LOG_NONE); | ||
#endif | ||
InitWindow(screenWidth, screenHeight, "sinister"); | ||
SetWindowState(FLAG_WINDOW_RESIZABLE); | ||
|
||
target = LoadRenderTexture(screenWidth, screenHeight); | ||
/* SetTextureFilter(target.texture, TEXTURE_FILTER_BILINEAR); */ | ||
|
||
#if defined(PLATFORM_WEB) | ||
emscripten_set_main_loop(UpdateDrawFrame, 60, 1); | ||
#else | ||
SetTargetFPS(60); | ||
|
||
while (!WindowShouldClose()) { | ||
UpdateDrawFrame(); | ||
} | ||
#endif | ||
|
||
UnloadRenderTexture(target); | ||
CloseWindow(); | ||
|
||
return 0; | ||
} |