Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bit69tream committed Dec 26, 2023
1 parent 66e9ea8 commit 2a1c738
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 149 deletions.
11 changes: 5 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
PLATFORM ?= PLATFORM_DESKTOP

# Define project variables
PROJECT_NAME ?= raylib_game
PROJECT_NAME ?= sinister
PROJECT_VERSION ?= 1.0
PROJECT_BUILD_PATH ?= .

Expand Down Expand Up @@ -220,17 +220,17 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map
LDFLAGS += -s USE_GLFW=3 -s TOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -s FORCE_FILESYSTEM=1

# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -s ASYNCIFY
endif

# Add resources building if required
ifeq ($(BUILD_WEB_RESOURCES),TRUE)
LDFLAGS += --preload-file $(BUILD_WEB_RESOURCES_PATH)
endif

# Add debug mode flags if required
ifeq ($(BUILD_MODE),DEBUG)
LDFLAGS += -s ASSERTIONS=1 --profiling
Expand Down Expand Up @@ -298,7 +298,7 @@ endif

# Define source code files required
#------------------------------------------------------------------------------------------------
PROJECT_SOURCE_FILES ?= raylib_game.c
PROJECT_SOURCE_FILES ?= sinister.c

# Define all object files from source files
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
Expand Down Expand Up @@ -341,4 +341,3 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
del *.o *.html *.js
endif
@echo Cleaning done

143 changes: 0 additions & 143 deletions src/raylib_game.c

This file was deleted.

104 changes: 104 additions & 0 deletions src/sinister.c
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;
}

0 comments on commit 2a1c738

Please sign in to comment.