Compare commits
12 Commits
f63b445e52
...
master
Author | SHA1 | Date | |
---|---|---|---|
9138103552 | |||
2a63b62832 | |||
93d0ff1406 | |||
664e33cb79 | |||
8931fe54d4 | |||
53c2fa722f | |||
19f8b51be9 | |||
0bef1edfb9 | |||
f0858189e2 | |||
fe421727d0 | |||
00b71cd0ae | |||
a7cb9a7383 |
@ -35,12 +35,12 @@ file(GLOB src
|
|||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${src})
|
add_executable(${PROJECT_NAME} ${src})
|
||||||
|
|
||||||
set (CMAKE_C_FLAGS "-O2 -Wall -Wextra -pedantic -Wno-unused-variable -Wno-unused-parameter -Wno-discarded-qualifiers")
|
set (CMAKE_C_FLAGS "-O2 -Wall -Wextra -pedantic -Wno-discarded-qualifiers -Wno-unused-variable -Wno-unused-parameter -Wno-parentheses")
|
||||||
|
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES2 -sFULL_ES3 -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS='['png']' -sUSE_SDL_MIXER=2 -sSDL2_MIXER_FORMATS='['ogg']' -sUSE_SDL_TTF=2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='['png']' -s USE_SDL_MIXER=2 -s SDL2_MIXER_FORMATS='['ogg']' -s USE_SDL_TTF=2 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -Wno-strict-prototypes -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-command-line-argument -Wno-ignored-qualifiers")
|
||||||
add_link_options(" --preload-file res --use-preload-plugins sNO_DYNAMIC_EXECUTION=1 -sALLOW_MEMORY_GROWTH=1 -sASSERTIONS=1 -sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0")
|
target_link_options(${PROJECT_NAME} PRIVATE --preload-file res -s USE_WEBGL2=1 )
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows")
|
||||||
target_link_libraries(${PROJECT_NAME} mingw32 m SDL2main SDL2 SDL2_image SDL2_mixer SDL2_ttf opengl32 glew32)
|
target_link_libraries(${PROJECT_NAME} mingw32 m SDL2main SDL2 SDL2_image SDL2_mixer SDL2_ttf opengl32 glew32)
|
||||||
|
@ -12,7 +12,7 @@ My entry for the 2024 WeightGaming Gain Jam. Action game where you collect stuff
|
|||||||
- SDL_ttf
|
- SDL_ttf
|
||||||
- GLEW
|
- GLEW
|
||||||
|
|
||||||
You'll also need the game [resources]((/files/games/frillrun/frillrun-resources-1.0.7z) in the same directory as the executable.
|
To play the game, you'll also need the game resources, get those [here](https://shweetz.net/files/games/frillrun/frillrun-resources-1.0.7z). and place the ``res`` folder in the same directory as the executable.
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ This repository uses CMake to compile, so:
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
I used MinGW for the Windows build, so basically the same as Linux but you'll need to use MSYS, MinGW, etc. to compile it.
|
I used MinGW for the Windows build, so basically the same as Linux but you'll need to use MSYS, MinGW, etc. to compile it. I would recommend using ninja with cmake, so ``cmake .. -G Ninja `` and then ``ninja`` in the build directory.
|
||||||
|
@ -24,6 +24,8 @@ void jsw_seed ( unsigned long s )
|
|||||||
* ( x[i - 1] ^ ( x[i - 1] >> 30 ) ) + i );
|
* ( x[i - 1] ^ ( x[i - 1] >> 30 ) ) + i );
|
||||||
x[i] &= 0xffffffffUL;
|
x[i] &= 0xffffffffUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mersenne Twister */
|
/* Mersenne Twister */
|
||||||
@ -37,12 +39,12 @@ unsigned long jsw_rand ( void )
|
|||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
for ( i = 0; i < N - 1; i++ ) {
|
for ( i = 0; i < N - 1; i++ ) {
|
||||||
y = ( x[i] & U ) | x[i + 1] & L;
|
y = ( x[i] & U ) | (x[i + 1] & L);
|
||||||
a = ( y & 0x1UL ) ? A : 0x0UL;
|
a = ( y & 0x1UL ) ? A : 0x0UL;
|
||||||
x[i] = x[( i + M ) % N] ^ ( y >> 1 ) ^ a;
|
x[i] = x[( i + M ) % N] ^ ( y >> 1 ) ^ a;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = ( x[N - 1] & U ) | x[0] & L;
|
y = ( x[N - 1] & U ) | (x[0] & L);
|
||||||
a = ( y & 0x1UL ) ? A : 0x0UL;
|
a = ( y & 0x1UL ) ? A : 0x0UL;
|
||||||
x[N - 1] = x[M - 1] ^ ( y >> 1 ) ^ a;
|
x[N - 1] = x[M - 1] ^ ( y >> 1 ) ^ a;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ random_seed_set(u64 seed)
|
|||||||
void
|
void
|
||||||
random_seed_time_set(void)
|
random_seed_time_set(void)
|
||||||
{
|
{
|
||||||
jsw_time_seed();
|
random_seed_set(jsw_time_seed());
|
||||||
}
|
}
|
||||||
|
|
||||||
f32
|
f32
|
||||||
@ -21,14 +21,13 @@ random_f32(void)
|
|||||||
f32
|
f32
|
||||||
random_f32_in_range(f32 min, f32 max)
|
random_f32_in_range(f32 min, f32 max)
|
||||||
{
|
{
|
||||||
return (f32)((random_f32() * (max - min + 1)) + min);
|
return (f32)((random_f32() * (max - min)) + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s32
|
s32
|
||||||
random_s32_in_range(s32 min, s32 max)
|
random_s32_in_range(s32 min, s32 max)
|
||||||
{
|
{
|
||||||
return (s32)((random_f32() * (max - min + 1)) + min);
|
return (s32)((random_f32() * (max - min)) + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../COMMON.h"
|
#include "../COMMON.h"
|
||||||
|
|
||||||
|
@ -57,9 +57,21 @@ renderer_init(Renderer* self, Window* window, CameraType type, const ivec2* buff
|
|||||||
|
|
||||||
self->window = window;
|
self->window = window;
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
|
||||||
|
self->glContext = SDL_GL_CreateContext(self->window->sdl);
|
||||||
|
#else
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||||
|
|
||||||
self->glContext = SDL_GL_CreateContext(self->window->sdl);
|
self->glContext = SDL_GL_CreateContext(self->window->sdl);
|
||||||
|
|
||||||
glew_init();
|
glew_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
vao_init(&self->vao);
|
vao_init(&self->vao);
|
||||||
vbo_init(&self->vbo, GL_ARRAY_BUFFER, true);
|
vbo_init(&self->vbo, GL_ARRAY_BUFFER, true);
|
||||||
@ -87,6 +99,8 @@ renderer_init(Renderer* self, Window* window, CameraType type, const ivec2* buff
|
|||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
//glDepthFunc(GL_LESS);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +134,9 @@ void
|
|||||||
renderer_clear(Renderer* self)
|
renderer_clear(Renderer* self)
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
||||||
|
renderer_buffer_clear(self, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -140,6 +157,14 @@ renderer_buffer_use(Renderer* self, RendererBuffer buffer)
|
|||||||
fbo_bind(&self->fbos[buffer]);
|
fbo_bind(&self->fbos[buffer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
renderer_buffer_clear(Renderer* self, RendererBuffer buffer)
|
||||||
|
{
|
||||||
|
fbo_bind(&self->fbos[buffer]);
|
||||||
|
glClearBufferfv(GL_COLOR, 0, TRANSPARENT);
|
||||||
|
fbo_unbind();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
renderer_buffer_unbind(void)
|
renderer_buffer_unbind(void)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "glew.h"
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "vao.h"
|
#include "vao.h"
|
||||||
@ -10,6 +9,10 @@
|
|||||||
#include "vbo.h"
|
#include "vbo.h"
|
||||||
#include "vertexattribute.h"
|
#include "vertexattribute.h"
|
||||||
|
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
|
#include "glew.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RENDERER_BUFFER_COUNT RENDERER_BUFFER_CURSOR + 1
|
#define RENDERER_BUFFER_COUNT RENDERER_BUFFER_CURSOR + 1
|
||||||
typedef enum RendererBuffer
|
typedef enum RendererBuffer
|
||||||
{
|
{
|
||||||
@ -47,6 +50,7 @@ void renderer_free(Renderer* self);
|
|||||||
void renderer_update(Renderer* self);
|
void renderer_update(Renderer* self);
|
||||||
void renderer_present(Renderer* self);
|
void renderer_present(Renderer* self);
|
||||||
void renderer_buffer_unbind(void);
|
void renderer_buffer_unbind(void);
|
||||||
|
void renderer_buffer_clear(Renderer* self, RendererBuffer buffer);
|
||||||
|
|
||||||
void renderer_buffer_position_from_window_position
|
void renderer_buffer_position_from_window_position
|
||||||
(
|
(
|
||||||
|
@ -44,14 +44,9 @@ sdl_init(void)
|
|||||||
else
|
else
|
||||||
printf(STRING_SDL_MIXER_INIT);
|
printf(STRING_SDL_MIXER_INIT);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Quits SDL. */
|
/* Quits SDL. */
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
void
|
void
|
||||||
surface_rgba_init(SDL_Surface** self, ivec2 size)
|
surface_rgba_init(SDL_Surface** self, ivec2 size)
|
||||||
{
|
{
|
||||||
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||||
*self = SDL_CreateRGBSurface
|
*self = SDL_CreateRGBSurface
|
||||||
(
|
(
|
||||||
0,
|
0,
|
||||||
@ -14,4 +15,17 @@ surface_rgba_init(SDL_Surface** self, ivec2 size)
|
|||||||
0x0000FF00,
|
0x0000FF00,
|
||||||
0x000000FF
|
0x000000FF
|
||||||
);
|
);
|
||||||
|
#else
|
||||||
|
*self = SDL_CreateRGBSurface
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
size[0],
|
||||||
|
size[1],
|
||||||
|
32,
|
||||||
|
0x000000FF,
|
||||||
|
0x0000FF00,
|
||||||
|
0x00FF0000,
|
||||||
|
0xFF000000
|
||||||
|
);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -82,3 +82,15 @@ texture_free(Texture* self)
|
|||||||
glDeleteTextures(1, &self->handle);
|
glDeleteTextures(1, &self->handle);
|
||||||
memset(self, '\0', sizeof(Texture));
|
memset(self, '\0', sizeof(Texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
texture_clear(Texture* self)
|
||||||
|
{
|
||||||
|
vec4 color = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
texture_bind(self);
|
||||||
|
|
||||||
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, self->size[0], self->size[1], GL_RGBA, GL_FLOAT, color);
|
||||||
|
|
||||||
|
texture_unbind();
|
||||||
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
|
|
||||||
@ -20,6 +26,7 @@ typedef struct Texture
|
|||||||
bool texture_from_path_init(Texture* self, const char* path);
|
bool texture_from_path_init(Texture* self, const char* path);
|
||||||
void texture_init(Texture* self, ivec2 size, void* data);
|
void texture_init(Texture* self, ivec2 size, void* data);
|
||||||
void texture_surface_init(Texture* self, SDL_Surface* surface);
|
void texture_surface_init(Texture* self, SDL_Surface* surface);
|
||||||
|
void texture_clear(Texture* self);
|
||||||
void texture_parameter_set(GLenum pname, GLint parameter);
|
void texture_parameter_set(GLenum pname, GLint parameter);
|
||||||
void texture_bind(Texture* self);
|
void texture_bind(Texture* self);
|
||||||
void texture_unbind(void);
|
void texture_unbind(void);
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../COMMON.h"
|
#include "../COMMON.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../COMMON.h"
|
#include "../COMMON.h"
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@ vertex_attribute_set(GLuint index, GLint size, GLenum type, GLsizei stride, size
|
|||||||
case GL_INT:
|
case GL_INT:
|
||||||
case GL_UNSIGNED_INT:
|
case GL_UNSIGNED_INT:
|
||||||
case GL_INT_2_10_10_10_REV:
|
case GL_INT_2_10_10_10_REV:
|
||||||
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
|
||||||
glVertexAttribIPointer(index, size, type, stride, (void*)offset);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
glVertexAttribPointer(index, size, type, GL_FALSE, stride, (void*)offset);
|
glVertexAttribPointer(index, size, type, GL_FALSE, stride, (void*)offset);
|
||||||
break;
|
break;
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
#include <GLES3/gl32.h>
|
||||||
|
#else
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../COMMON.h"
|
#include "../COMMON.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ entity_cursor_add(ECS* ecs)
|
|||||||
(f32*)ENTITY_CURSOR_POSITION
|
(f32*)ENTITY_CURSOR_POSITION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
component_pulsate_init
|
component_pulsate_init
|
||||||
(
|
(
|
||||||
ecs_component_get(ecs, COMPONENT_PULSATE, id),
|
ecs_component_get(ecs, COMPONENT_PULSATE, id),
|
||||||
@ -28,6 +29,7 @@ entity_cursor_add(ECS* ecs)
|
|||||||
(f32*)ENTITY_CURSOR_PULSATE_MAX_SCALE,
|
(f32*)ENTITY_CURSOR_PULSATE_MAX_SCALE,
|
||||||
ENTITY_CURSOR_PULSATE_FREQUENCY
|
ENTITY_CURSOR_PULSATE_FREQUENCY
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
EntityID entity_cursor_add(ECS* ecs);
|
EntityID entity_cursor_add(ECS* ecs);
|
||||||
|
|
||||||
#define ENTITY_CURSOR_DEPENDENCY_COUNT 3
|
#define ENTITY_CURSOR_DEPENDENCY_COUNT 2
|
||||||
static const ComponentType ENTITY_CURSOR_DEPENDENCIES[ENTITY_CURSOR_DEPENDENCY_COUNT] =
|
static const ComponentType ENTITY_CURSOR_DEPENDENCIES[ENTITY_CURSOR_DEPENDENCY_COUNT] =
|
||||||
{
|
{
|
||||||
COMPONENT_GAME_OBJECT,
|
COMPONENT_GAME_OBJECT,
|
||||||
COMPONENT_COPY_MOUSE_POSITION,
|
COMPONENT_COPY_MOUSE_POSITION,
|
||||||
COMPONENT_PULSATE,
|
//COMPONENT_PULSATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const RendererBuffer ENTITY_CURSOR_BUFFER = RENDERER_BUFFER_CURSOR;
|
static const RendererBuffer ENTITY_CURSOR_BUFFER = RENDERER_BUFFER_CURSOR;
|
||||||
|
@ -14,6 +14,11 @@ _game_quit(Game* self)
|
|||||||
|
|
||||||
ecs_free(&self->ecs);
|
ecs_free(&self->ecs);
|
||||||
|
|
||||||
|
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
||||||
|
renderer_buffer_free(&self->renderer, (RendererBuffer)i);
|
||||||
|
|
||||||
|
renderer_free(&self->renderer);
|
||||||
|
|
||||||
window_free(&self->window);
|
window_free(&self->window);
|
||||||
|
|
||||||
resources_free(&self->resources);
|
resources_free(&self->resources);
|
||||||
@ -55,20 +60,16 @@ _game_tick(Game* self)
|
|||||||
static void
|
static void
|
||||||
_game_update(Game* self)
|
_game_update(Game* self)
|
||||||
{
|
{
|
||||||
renderer_update(&self->renderer);
|
|
||||||
ecs_update(&self->ecs);
|
ecs_update(&self->ecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_game_draw(Game* self)
|
_game_draw(Game* self)
|
||||||
{
|
{
|
||||||
renderer_clear_color_set(&self->renderer, (f32*)RENDERER_CLEAR_COLOR);
|
renderer_clear_color_set(&self->renderer, (f32*)BLACK);
|
||||||
|
|
||||||
renderer_clear(&self->renderer);
|
renderer_clear(&self->renderer);
|
||||||
|
|
||||||
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
|
||||||
renderer_buffer_init(&self->renderer, (RendererBuffer)i);
|
|
||||||
|
|
||||||
ecs_draw(&self->ecs);
|
ecs_draw(&self->ecs);
|
||||||
|
|
||||||
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
||||||
@ -80,7 +81,6 @@ _game_draw(Game* self)
|
|||||||
(RendererBuffer)i,
|
(RendererBuffer)i,
|
||||||
&self->postprocessing[i]
|
&self->postprocessing[i]
|
||||||
);
|
);
|
||||||
renderer_buffer_free(&self->renderer, (RendererBuffer)i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer_present(&self->renderer);
|
renderer_present(&self->renderer);
|
||||||
@ -92,7 +92,7 @@ game_init(Game* self)
|
|||||||
|
|
||||||
memset(self, '\0', sizeof(Game));
|
memset(self, '\0', sizeof(Game));
|
||||||
|
|
||||||
random_seed_time_set();
|
random_seed_set(0);
|
||||||
|
|
||||||
resource_shader_read(&self->resources);
|
resource_shader_read(&self->resources);
|
||||||
|
|
||||||
@ -107,6 +107,9 @@ game_init(Game* self)
|
|||||||
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
||||||
postprocessing_init(&self->postprocessing[i], OPAQUE, TRANSPARENT);
|
postprocessing_init(&self->postprocessing[i], OPAQUE, TRANSPARENT);
|
||||||
|
|
||||||
|
for (s32 i = 0; i < RENDERER_BUFFER_COUNT; i++)
|
||||||
|
renderer_buffer_init(&self->renderer, (RendererBuffer)i);
|
||||||
|
|
||||||
if (!resources_init(&self->resources))
|
if (!resources_init(&self->resources))
|
||||||
{
|
{
|
||||||
printf("%s\n", STRING_RESOURCE_ERROR);
|
printf("%s\n", STRING_RESOURCE_ERROR);
|
||||||
|
@ -53,6 +53,11 @@ control_tick(Control* self, Input* input)
|
|||||||
|
|
||||||
if (input->keyboard.current[KEYBOARD_KEY_M])
|
if (input->keyboard.current[KEYBOARD_KEY_M])
|
||||||
self->current[CONTROL_MUTE] = true;
|
self->current[CONTROL_MUTE] = true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (input->keyboard.current[KEYBOARD_KEY_RCTRL] || input->keyboard.current[KEYBOARD_KEY_LCTRL])
|
||||||
|
self->current[CONTROL_CHEAT] = true;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -24,8 +24,6 @@ buffer_draw(Renderer* renderer, Shader* shader, RendererBuffer buffer, Postproce
|
|||||||
camera_projection_get(&renderer->camera[buffer], projection);
|
camera_projection_get(&renderer->camera[buffer], projection);
|
||||||
camera_view_get(&renderer->camera[buffer], view);
|
camera_view_get(&renderer->camera[buffer], view);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
texture_quad_draw
|
texture_quad_draw
|
||||||
(
|
(
|
||||||
&renderer->fboTextures[buffer],
|
&renderer->fboTextures[buffer],
|
||||||
|
@ -21,10 +21,19 @@ typedef struct ShaderPaths
|
|||||||
|
|
||||||
static const ShaderPaths SHADER_PATHS[SHADER_COUNT] =
|
static const ShaderPaths SHADER_PATHS[SHADER_COUNT] =
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
{
|
||||||
|
.vertex = "res/shader/texture_quad_es.vs",
|
||||||
|
.fragment = "res/shader/texture_quad_es.fs"
|
||||||
|
}
|
||||||
|
#else
|
||||||
{
|
{
|
||||||
.vertex = "res/shader/texture_quad.vs",
|
.vertex = "res/shader/texture_quad.vs",
|
||||||
.fragment = "res/shader/texture_quad.fs"
|
.fragment = "res/shader/texture_quad.fs"
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TEXTURE_COUNT TEXTURE_ENDING_THREE + 1
|
#define TEXTURE_COUNT TEXTURE_ENDING_THREE + 1
|
||||||
@ -91,7 +100,7 @@ typedef enum TextureType
|
|||||||
TEXTURE_CUTSCENE_FINAL_SCENE_THIRTEEN,
|
TEXTURE_CUTSCENE_FINAL_SCENE_THIRTEEN,
|
||||||
TEXTURE_ENDING,
|
TEXTURE_ENDING,
|
||||||
TEXTURE_ENDING_TWO,
|
TEXTURE_ENDING_TWO,
|
||||||
TEXTURE_ENDING_THREE,
|
TEXTURE_ENDING_THREE
|
||||||
} TextureType;
|
} TextureType;
|
||||||
|
|
||||||
static const char* TEXTURE_PATHS[TEXTURE_COUNT] =
|
static const char* TEXTURE_PATHS[TEXTURE_COUNT] =
|
||||||
@ -157,7 +166,7 @@ static const char* TEXTURE_PATHS[TEXTURE_COUNT] =
|
|||||||
"res/gfx/cutscene/c06s13.png",
|
"res/gfx/cutscene/c06s13.png",
|
||||||
"res/gfx/cutscene/ending.png",
|
"res/gfx/cutscene/ending.png",
|
||||||
"res/gfx/cutscene/ending2.png",
|
"res/gfx/cutscene/ending2.png",
|
||||||
"res/gfx/cutscene/ending3.png",
|
"res/gfx/cutscene/ending3.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FONT_COUNT FONT_BIG + 1
|
#define FONT_COUNT FONT_BIG + 1
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "../../ecs/entity/visual/entity_text_disappearing.h"
|
#include "../../ecs/entity/visual/entity_text_disappearing.h"
|
||||||
#include "../../ecs/entity/visual/entity_text_queue_entry.h"
|
#include "../../ecs/entity/visual/entity_text_queue_entry.h"
|
||||||
|
|
||||||
static const vec4 LEVEL_SUNSET_COLOR = {0.15f, 0.10f, 0.10f, 1.0f};
|
static const vec4 LEVEL_SUNSET_COLOR = {0.35f, 0.20f, 0.20f, 1.0f};
|
||||||
|
|
||||||
#define LEVEL_TUTORIAL_TEXT_COUNT 3
|
#define LEVEL_TUTORIAL_TEXT_COUNT 3
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ void _level_event_queue_init(Level* self);
|
|||||||
void
|
void
|
||||||
_level_event_queue_init(Level* self)
|
_level_event_queue_init(Level* self)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
random_seed_set(self->eventSeed);
|
||||||
|
|
||||||
for (s32 i = 0; i < LEVEL_EVENT_COUNT; i++)
|
for (s32 i = 0; i < LEVEL_EVENT_COUNT; i++)
|
||||||
{
|
{
|
||||||
LevelEvent event;
|
LevelEvent event;
|
||||||
@ -21,8 +24,7 @@ _level_event_queue_init(Level* self)
|
|||||||
|
|
||||||
vector_push(&self->eventQueue, &event);
|
vector_push(&self->eventQueue, &event);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
random_seed_set(self->eventSeed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -392,9 +394,12 @@ level_event_return(Level* self)
|
|||||||
void
|
void
|
||||||
level_event_choose(Level* self)
|
level_event_choose(Level* self)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
u32 index;
|
u32 index;
|
||||||
LevelEvent* event;
|
LevelEvent* event;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
index = (u32)random_s32_in_range(0, self->eventQueue.count);
|
index = (u32)random_s32_in_range(0, self->eventQueue.count);
|
||||||
|
|
||||||
event = (LevelEvent*)vector_get(&self->eventQueue, index);
|
event = (LevelEvent*)vector_get(&self->eventQueue, index);
|
||||||
@ -405,6 +410,9 @@ level_event_choose(Level* self)
|
|||||||
|
|
||||||
if (self->eventQueue.count <= 0)
|
if (self->eventQueue.count <= 0)
|
||||||
_level_event_queue_init(self);
|
_level_event_queue_init(self);
|
||||||
|
*/
|
||||||
|
|
||||||
|
self->nextEvent = (LevelEvent)random_s32_in_range(0, LEVEL_EVENT_COUNT);
|
||||||
|
|
||||||
self->eventSeed++;
|
self->eventSeed++;
|
||||||
|
|
||||||
@ -468,7 +476,7 @@ level_event_init(Level* self)
|
|||||||
|
|
||||||
self->eventSeed = self->settings.seedStart;
|
self->eventSeed = self->settings.seedStart;
|
||||||
|
|
||||||
_level_event_queue_init(self);
|
random_seed_set(self->eventSeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -227,6 +227,8 @@ level_init(Level* self, ECS* ecs, LevelSettings settings, u32 levelValue)
|
|||||||
level_pause_init(self);
|
level_pause_init(self);
|
||||||
level_unpause(self);
|
level_unpause(self);
|
||||||
|
|
||||||
|
random_seed_set(0);
|
||||||
|
|
||||||
self->settings = settings;
|
self->settings = settings;
|
||||||
self->medal = LEVEL_MEDAL_NONE;
|
self->medal = LEVEL_MEDAL_NONE;
|
||||||
self->nextMedal = LEVEL_MEDAL_BRONZE;
|
self->nextMedal = LEVEL_MEDAL_BRONZE;
|
||||||
|
@ -40,7 +40,7 @@ static const Scene CUTSCENE_TWO_SCENES[CUTSCENE_TWO_COUNT] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_TWO_SCENE_FOUR,
|
.texture = TEXTURE_CUTSCENE_TWO_SCENE_FOUR,
|
||||||
.string = "Although...one instinct did claw at the creature...hunger. Though the creature's body pleaded to consume the fruits of its labor..every morsel must be delivered to the matriarch at all costs, as she insisted!"
|
.string = "Although...one instinct did claw at the creature...hunger. Though the creature's body pleaded to consume the fruits of its labor...every morsel must be delivered to the matriarch at all costs, as she insisted!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_TWO_SCENE_FIVE,
|
.texture = TEXTURE_CUTSCENE_TWO_SCENE_FIVE,
|
||||||
@ -65,7 +65,7 @@ static const Scene CUTSCENE_THREE_SCENES[CUTSCENE_THREE_COUNT] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_THREE_SCENE_FOUR,
|
.texture = TEXTURE_CUTSCENE_THREE_SCENE_FOUR,
|
||||||
.string = "As the creature scampers off with its newfound prize, the frilled matriarch eyes glide over to her underling and its plunder in between one of her many gorging sessions."
|
.string = "As the creature scampers off with its newfound prize, the frilled matriarch's eyes glide over to her underling and its plunder in between one of her many gorging sessions."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_THREE_SCENE_FIVE,
|
.texture = TEXTURE_CUTSCENE_THREE_SCENE_FIVE,
|
||||||
@ -98,7 +98,7 @@ static const Scene CUTSCENE_FOUR_SCENES[CUTSCENE_FOUR_COUNT] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_FOUR_SCENE_FIVE,
|
.texture = TEXTURE_CUTSCENE_FOUR_SCENE_FIVE,
|
||||||
.string = "It seemed that the amulet's abilities were increasing, The frilled runt's power continued to grow. What other secrets might it hold?"
|
.string = "It seemed that the amulet's abilities were increasing, and the frilled runt's power was continuing to grow. What other secrets might it hold?"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.texture = TEXTURE_CUTSCENE_FOUR_SCENE_SIX,
|
.texture = TEXTURE_CUTSCENE_FOUR_SCENE_SIX,
|
||||||
@ -232,7 +232,7 @@ static const SceneCollection CUTSCENE_FINAL =
|
|||||||
static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
.medalThresholds = {200, 275, 325},
|
.medalThresholds = {200, 250, 300},
|
||||||
.time = 7200,
|
.time = 7200,
|
||||||
.colorCover = {-0.05f, -0.05f, -0.05f, 0.0f},
|
.colorCover = {-0.05f, -0.05f, -0.05f, 0.0f},
|
||||||
.collectibleMax = 30,
|
.collectibleMax = 30,
|
||||||
@ -260,7 +260,7 @@ static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
|||||||
.isTutorialFinal = false
|
.isTutorialFinal = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.medalThresholds = {300, 500, 600},
|
.medalThresholds = {300, 400, 500},
|
||||||
.time = 10800,
|
.time = 10800,
|
||||||
.colorCover = {-0.10f, -0.10f, -0.05f, 0.0f},
|
.colorCover = {-0.10f, -0.10f, -0.05f, 0.0f},
|
||||||
.collectibleMax = 35,
|
.collectibleMax = 35,
|
||||||
@ -288,7 +288,7 @@ static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
|||||||
.isTutorialFinal = false
|
.isTutorialFinal = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.medalThresholds = {400, 550, 625},
|
.medalThresholds = {350, 450, 550},
|
||||||
.time = 10800,
|
.time = 10800,
|
||||||
.colorCover = {0.15f, 0.05f, 0.00f, 0.0f},
|
.colorCover = {0.15f, 0.05f, 0.00f, 0.0f},
|
||||||
.collectibleMax = 40,
|
.collectibleMax = 40,
|
||||||
@ -316,7 +316,7 @@ static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
|||||||
.isTutorialFinal = false
|
.isTutorialFinal = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.medalThresholds = {500, 600, 700},
|
.medalThresholds = {400, 500, 600},
|
||||||
.time = 10800,
|
.time = 10800,
|
||||||
.colorCover = {0.3f, 0.15f, 0.0f, 0.0f},
|
.colorCover = {0.3f, 0.15f, 0.0f, 0.0f},
|
||||||
.collectibleMax = 45,
|
.collectibleMax = 45,
|
||||||
@ -344,7 +344,7 @@ static const LevelSettings LEVEL_SETTINGS[LEVEL_COUNT] =
|
|||||||
.isTutorialFinal = false
|
.isTutorialFinal = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.medalThresholds = {750, 900, 1150},
|
.medalThresholds = {750, 1000, 1250},
|
||||||
.time = 18000,
|
.time = 18000,
|
||||||
.colorCover = {-0.25f, -0.50f, -0.10f, 0.0f},
|
.colorCover = {-0.25f, -0.50f, -0.10f, 0.0f},
|
||||||
.collectibleMax = 50,
|
.collectibleMax = 50,
|
||||||
@ -396,7 +396,7 @@ static const LevelData LEVEL_DATA_DEFAULT[LEVEL_COUNT] =
|
|||||||
.time = -1
|
.time = -1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.status = LEVEL_STATUS_UNLOCKED,
|
.status = LEVEL_STATUS_LOCKED,
|
||||||
.score = -1,
|
.score = -1,
|
||||||
.time = -1
|
.time = -1
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,7 @@ main(s32 argc, char** argv)
|
|||||||
game_init(&game);
|
game_init(&game);
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
emscripten_set_main_loop(loop, 60, true);
|
emscripten_set_main_loop(loop, -1, true);
|
||||||
#else
|
#else
|
||||||
while (true)
|
while (true)
|
||||||
loop();
|
loop();
|
||||||
|
Reference in New Issue
Block a user