3 Commits

Author SHA1 Message Date
doylet 95a8714513 fp: Redo the attack boxes 2023-10-08 16:44:48 +11:00
doylet da41e986c5 fp: Reset game on game completion 2023-10-08 16:17:40 +11:00
doylet 1ae76db2f6 fp: Wire up game reset 2023-10-08 16:14:31 +11:00
88 changed files with 835 additions and 3665 deletions
-2
View File
@@ -1,2 +0,0 @@
CompileFlags:
Add: [-D_CLANGD=1]
-1
View File
@@ -1,3 +1,2 @@
Build/
Nocheckin/
feely_pona_build.exe
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-649
View File
@@ -1,649 +0,0 @@
/*
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
SPDX-License-Identifier: MIT
QOI - The "Quite OK Image" format for fast, lossless image compression
-- About
QOI encodes and decodes images in a lossless format. Compared to stb_image and
stb_image_write QOI offers 20x-50x faster encoding, 3x-4x faster decoding and
20% better compression.
-- Synopsis
// Define `QOI_IMPLEMENTATION` in *one* C/C++ file before including this
// library to create the implementation.
#define QOI_IMPLEMENTATION
#include "qoi.h"
// Encode and store an RGBA buffer to the file system. The qoi_desc describes
// the input pixel data.
qoi_write("image_new.qoi", rgba_pixels, &(qoi_desc){
.width = 1920,
.height = 1080,
.channels = 4,
.colorspace = QOI_SRGB
});
// Load and decode a QOI image from the file system into a 32bbp RGBA buffer.
// The qoi_desc struct will be filled with the width, height, number of channels
// and colorspace read from the file header.
qoi_desc desc;
void *rgba_pixels = qoi_read("image.qoi", &desc, 4);
-- Documentation
This library provides the following functions;
- qoi_read -- read and decode a QOI file
- qoi_decode -- decode the raw bytes of a QOI image from memory
- qoi_write -- encode and write a QOI file
- qoi_encode -- encode an rgba buffer into a QOI image in memory
See the function declaration below for the signature and more information.
If you don't want/need the qoi_read and qoi_write functions, you can define
QOI_NO_STDIO before including this library.
This library uses malloc() and free(). To supply your own malloc implementation
you can define QOI_MALLOC and QOI_FREE before including this library.
This library uses memset() to zero-initialize the index. To supply your own
implementation you can define QOI_ZEROARR before including this library.
-- Data Format
A QOI file has a 14 byte header, followed by any number of data "chunks" and an
8-byte end marker.
struct qoi_header_t {
char magic[4]; // magic bytes "qoif"
uint32_t width; // image width in pixels (BE)
uint32_t height; // image height in pixels (BE)
uint8_t channels; // 3 = RGB, 4 = RGBA
uint8_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels linear
};
Images are encoded row by row, left to right, top to bottom. The decoder and
encoder start with {r: 0, g: 0, b: 0, a: 255} as the previous pixel value. An
image is complete when all pixels specified by width * height have been covered.
Pixels are encoded as
- a run of the previous pixel
- an index into an array of previously seen pixels
- a difference to the previous pixel value in r,g,b
- full r,g,b or r,g,b,a values
The color channels are assumed to not be premultiplied with the alpha channel
("un-premultiplied alpha").
A running array[64] (zero-initialized) of previously seen pixel values is
maintained by the encoder and decoder. Each pixel that is seen by the encoder
and decoder is put into this array at the position formed by a hash function of
the color value. In the encoder, if the pixel value at the index matches the
current pixel, this index position is written to the stream as QOI_OP_INDEX.
The hash function for the index is:
index_position = (r * 3 + g * 5 + b * 7 + a * 11) % 64
Each chunk starts with a 2- or 8-bit tag, followed by a number of data bits. The
bit length of chunks is divisible by 8 - i.e. all chunks are byte aligned. All
values encoded in these data bits have the most significant bit on the left.
The 8-bit tags have precedence over the 2-bit tags. A decoder must check for the
presence of an 8-bit tag first.
The byte stream's end is marked with 7 0x00 bytes followed a single 0x01 byte.
The possible chunks are:
.- QOI_OP_INDEX ----------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----------------|
| 0 0 | index |
`-------------------------`
2-bit tag b00
6-bit index into the color index array: 0..63
A valid encoder must not issue 2 or more consecutive QOI_OP_INDEX chunks to the
same index. QOI_OP_RUN should be used instead.
.- QOI_OP_DIFF -----------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----+-----+-----|
| 0 1 | dr | dg | db |
`-------------------------`
2-bit tag b01
2-bit red channel difference from the previous pixel between -2..1
2-bit green channel difference from the previous pixel between -2..1
2-bit blue channel difference from the previous pixel between -2..1
The difference to the current channel values are using a wraparound operation,
so "1 - 2" will result in 255, while "255 + 1" will result in 0.
Values are stored as unsigned integers with a bias of 2. E.g. -2 is stored as
0 (b00). 1 is stored as 3 (b11).
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_LUMA -------------------------------------.
| Byte[0] | Byte[1] |
| 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |
|-------+-----------------+-------------+-----------|
| 1 0 | green diff | dr - dg | db - dg |
`---------------------------------------------------`
2-bit tag b10
6-bit green channel difference from the previous pixel -32..31
4-bit red channel difference minus green channel difference -8..7
4-bit blue channel difference minus green channel difference -8..7
The green channel is used to indicate the general direction of change and is
encoded in 6 bits. The red and blue channels (dr and db) base their diffs off
of the green channel difference and are encoded in 4 bits. I.e.:
dr_dg = (cur_px.r - prev_px.r) - (cur_px.g - prev_px.g)
db_dg = (cur_px.b - prev_px.b) - (cur_px.g - prev_px.g)
The difference to the current channel values are using a wraparound operation,
so "10 - 13" will result in 253, while "250 + 7" will result in 1.
Values are stored as unsigned integers with a bias of 32 for the green channel
and a bias of 8 for the red and blue channel.
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_RUN ------------.
| Byte[0] |
| 7 6 5 4 3 2 1 0 |
|-------+-----------------|
| 1 1 | run |
`-------------------------`
2-bit tag b11
6-bit run-length repeating the previous pixel: 1..62
The run-length is stored with a bias of -1. Note that the run-lengths 63 and 64
(b111110 and b111111) are illegal as they are occupied by the QOI_OP_RGB and
QOI_OP_RGBA tags.
.- QOI_OP_RGB ------------------------------------------.
| Byte[0] | Byte[1] | Byte[2] | Byte[3] |
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|-------------------------+---------+---------+---------|
| 1 1 1 1 1 1 1 0 | red | green | blue |
`-------------------------------------------------------`
8-bit tag b11111110
8-bit red channel value
8-bit green channel value
8-bit blue channel value
The alpha value remains unchanged from the previous pixel.
.- QOI_OP_RGBA ---------------------------------------------------.
| Byte[0] | Byte[1] | Byte[2] | Byte[3] | Byte[4] |
| 7 6 5 4 3 2 1 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 | 7 .. 0 |
|-------------------------+---------+---------+---------+---------|
| 1 1 1 1 1 1 1 1 | red | green | blue | alpha |
`-----------------------------------------------------------------`
8-bit tag b11111111
8-bit red channel value
8-bit green channel value
8-bit blue channel value
8-bit alpha channel value
*/
/* -----------------------------------------------------------------------------
Header - Public functions */
#ifndef QOI_H
#define QOI_H
#ifdef __cplusplus
extern "C" {
#endif
/* A pointer to a qoi_desc struct has to be supplied to all of qoi's functions.
It describes either the input format (for qoi_write and qoi_encode), or is
filled with the description read from the file header (for qoi_read and
qoi_decode).
The colorspace in this qoi_desc is an enum where
0 = sRGB, i.e. gamma scaled RGB channels and a linear alpha channel
1 = all channels are linear
You may use the constants QOI_SRGB or QOI_LINEAR. The colorspace is purely
informative. It will be saved to the file header, but does not affect
how chunks are en-/decoded. */
#define QOI_SRGB 0
#define QOI_LINEAR 1
typedef struct {
unsigned int width;
unsigned int height;
unsigned char channels;
unsigned char colorspace;
} qoi_desc;
#ifndef QOI_NO_STDIO
/* Encode raw RGB or RGBA pixels into a QOI image and write it to the file
system. The qoi_desc struct must be filled with the image width, height,
number of channels (3 = RGB, 4 = RGBA) and the colorspace.
The function returns 0 on failure (invalid parameters, or fopen or malloc
failed) or the number of bytes written on success. */
int qoi_write(const char *filename, const void *data, const qoi_desc *desc);
/* Read and decode a QOI image from the file system. If channels is 0, the
number of channels from the file header is used. If channels is 3 or 4 the
output format will be forced into this number of channels.
The function either returns NULL on failure (invalid data, or malloc or fopen
failed) or a pointer to the decoded pixels. On success, the qoi_desc struct
will be filled with the description from the file header.
The returned pixel data should be free()d after use. */
void *qoi_read(const char *filename, qoi_desc *desc, int channels);
#endif /* QOI_NO_STDIO */
/* Encode raw RGB or RGBA pixels into a QOI image in memory.
The function either returns NULL on failure (invalid parameters or malloc
failed) or a pointer to the encoded data on success. On success the out_len
is set to the size in bytes of the encoded data.
The returned qoi data should be free()d after use. */
void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len);
/* Decode a QOI image from memory.
The function either returns NULL on failure (invalid parameters or malloc
failed) or a pointer to the decoded pixels. On success, the qoi_desc struct
is filled with the description from the file header.
The returned pixel data should be free()d after use. */
void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels);
#ifdef __cplusplus
}
#endif
#endif /* QOI_H */
/* -----------------------------------------------------------------------------
Implementation */
#ifdef QOI_IMPLEMENTATION
#include <stdlib.h>
#include <string.h>
#ifndef QOI_MALLOC
#define QOI_MALLOC(sz) malloc(sz)
#define QOI_FREE(p) free(p)
#endif
#ifndef QOI_ZEROARR
#define QOI_ZEROARR(a) memset((a),0,sizeof(a))
#endif
#define QOI_OP_INDEX 0x00 /* 00xxxxxx */
#define QOI_OP_DIFF 0x40 /* 01xxxxxx */
#define QOI_OP_LUMA 0x80 /* 10xxxxxx */
#define QOI_OP_RUN 0xc0 /* 11xxxxxx */
#define QOI_OP_RGB 0xfe /* 11111110 */
#define QOI_OP_RGBA 0xff /* 11111111 */
#define QOI_MASK_2 0xc0 /* 11000000 */
#define QOI_COLOR_HASH(C) (C.rgba.r*3 + C.rgba.g*5 + C.rgba.b*7 + C.rgba.a*11)
#define QOI_MAGIC \
(((unsigned int)'q') << 24 | ((unsigned int)'o') << 16 | \
((unsigned int)'i') << 8 | ((unsigned int)'f'))
#define QOI_HEADER_SIZE 14
/* 2GB is the max file size that this implementation can safely handle. We guard
against anything larger than that, assuming the worst case with 5 bytes per
pixel, rounded down to a nice clean value. 400 million pixels ought to be
enough for anybody. */
#define QOI_PIXELS_MAX ((unsigned int)400000000)
typedef union {
struct { unsigned char r, g, b, a; } rgba;
unsigned int v;
} qoi_rgba_t;
static const unsigned char qoi_padding[8] = {0,0,0,0,0,0,0,1};
static void qoi_write_32(unsigned char *bytes, int *p, unsigned int v) {
bytes[(*p)++] = (0xff000000 & v) >> 24;
bytes[(*p)++] = (0x00ff0000 & v) >> 16;
bytes[(*p)++] = (0x0000ff00 & v) >> 8;
bytes[(*p)++] = (0x000000ff & v);
}
static unsigned int qoi_read_32(const unsigned char *bytes, int *p) {
unsigned int a = bytes[(*p)++];
unsigned int b = bytes[(*p)++];
unsigned int c = bytes[(*p)++];
unsigned int d = bytes[(*p)++];
return a << 24 | b << 16 | c << 8 | d;
}
void *qoi_encode(const void *data, const qoi_desc *desc, int *out_len) {
int i, max_size, p, run;
int px_len, px_end, px_pos, channels;
unsigned char *bytes;
const unsigned char *pixels;
qoi_rgba_t index[64];
qoi_rgba_t px, px_prev;
if (
data == NULL || out_len == NULL || desc == NULL ||
desc->width == 0 || desc->height == 0 ||
desc->channels < 3 || desc->channels > 4 ||
desc->colorspace > 1 ||
desc->height >= QOI_PIXELS_MAX / desc->width
) {
return NULL;
}
max_size =
desc->width * desc->height * (desc->channels + 1) +
QOI_HEADER_SIZE + sizeof(qoi_padding);
p = 0;
bytes = (unsigned char *) QOI_MALLOC(max_size);
if (!bytes) {
return NULL;
}
qoi_write_32(bytes, &p, QOI_MAGIC);
qoi_write_32(bytes, &p, desc->width);
qoi_write_32(bytes, &p, desc->height);
bytes[p++] = desc->channels;
bytes[p++] = desc->colorspace;
pixels = (const unsigned char *)data;
QOI_ZEROARR(index);
run = 0;
px_prev.rgba.r = 0;
px_prev.rgba.g = 0;
px_prev.rgba.b = 0;
px_prev.rgba.a = 255;
px = px_prev;
px_len = desc->width * desc->height * desc->channels;
px_end = px_len - desc->channels;
channels = desc->channels;
for (px_pos = 0; px_pos < px_len; px_pos += channels) {
px.rgba.r = pixels[px_pos + 0];
px.rgba.g = pixels[px_pos + 1];
px.rgba.b = pixels[px_pos + 2];
if (channels == 4) {
px.rgba.a = pixels[px_pos + 3];
}
if (px.v == px_prev.v) {
run++;
if (run == 62 || px_pos == px_end) {
bytes[p++] = QOI_OP_RUN | (run - 1);
run = 0;
}
}
else {
int index_pos;
if (run > 0) {
bytes[p++] = QOI_OP_RUN | (run - 1);
run = 0;
}
index_pos = QOI_COLOR_HASH(px) % 64;
if (index[index_pos].v == px.v) {
bytes[p++] = QOI_OP_INDEX | index_pos;
}
else {
index[index_pos] = px;
if (px.rgba.a == px_prev.rgba.a) {
signed char vr = px.rgba.r - px_prev.rgba.r;
signed char vg = px.rgba.g - px_prev.rgba.g;
signed char vb = px.rgba.b - px_prev.rgba.b;
signed char vg_r = vr - vg;
signed char vg_b = vb - vg;
if (
vr > -3 && vr < 2 &&
vg > -3 && vg < 2 &&
vb > -3 && vb < 2
) {
bytes[p++] = QOI_OP_DIFF | (vr + 2) << 4 | (vg + 2) << 2 | (vb + 2);
}
else if (
vg_r > -9 && vg_r < 8 &&
vg > -33 && vg < 32 &&
vg_b > -9 && vg_b < 8
) {
bytes[p++] = QOI_OP_LUMA | (vg + 32);
bytes[p++] = (vg_r + 8) << 4 | (vg_b + 8);
}
else {
bytes[p++] = QOI_OP_RGB;
bytes[p++] = px.rgba.r;
bytes[p++] = px.rgba.g;
bytes[p++] = px.rgba.b;
}
}
else {
bytes[p++] = QOI_OP_RGBA;
bytes[p++] = px.rgba.r;
bytes[p++] = px.rgba.g;
bytes[p++] = px.rgba.b;
bytes[p++] = px.rgba.a;
}
}
}
px_prev = px;
}
for (i = 0; i < (int)sizeof(qoi_padding); i++) {
bytes[p++] = qoi_padding[i];
}
*out_len = p;
return bytes;
}
void *qoi_decode(const void *data, int size, qoi_desc *desc, int channels) {
const unsigned char *bytes;
unsigned int header_magic;
unsigned char *pixels;
qoi_rgba_t index[64];
qoi_rgba_t px;
int px_len, chunks_len, px_pos;
int p = 0, run = 0;
if (
data == NULL || desc == NULL ||
(channels != 0 && channels != 3 && channels != 4) ||
size < QOI_HEADER_SIZE + (int)sizeof(qoi_padding)
) {
return NULL;
}
bytes = (const unsigned char *)data;
header_magic = qoi_read_32(bytes, &p);
desc->width = qoi_read_32(bytes, &p);
desc->height = qoi_read_32(bytes, &p);
desc->channels = bytes[p++];
desc->colorspace = bytes[p++];
if (
desc->width == 0 || desc->height == 0 ||
desc->channels < 3 || desc->channels > 4 ||
desc->colorspace > 1 ||
header_magic != QOI_MAGIC ||
desc->height >= QOI_PIXELS_MAX / desc->width
) {
return NULL;
}
if (channels == 0) {
channels = desc->channels;
}
px_len = desc->width * desc->height * channels;
pixels = (unsigned char *) QOI_MALLOC(px_len);
if (!pixels) {
return NULL;
}
QOI_ZEROARR(index);
px.rgba.r = 0;
px.rgba.g = 0;
px.rgba.b = 0;
px.rgba.a = 255;
chunks_len = size - (int)sizeof(qoi_padding);
for (px_pos = 0; px_pos < px_len; px_pos += channels) {
if (run > 0) {
run--;
}
else if (p < chunks_len) {
int b1 = bytes[p++];
if (b1 == QOI_OP_RGB) {
px.rgba.r = bytes[p++];
px.rgba.g = bytes[p++];
px.rgba.b = bytes[p++];
}
else if (b1 == QOI_OP_RGBA) {
px.rgba.r = bytes[p++];
px.rgba.g = bytes[p++];
px.rgba.b = bytes[p++];
px.rgba.a = bytes[p++];
}
else if ((b1 & QOI_MASK_2) == QOI_OP_INDEX) {
px = index[b1];
}
else if ((b1 & QOI_MASK_2) == QOI_OP_DIFF) {
px.rgba.r += ((b1 >> 4) & 0x03) - 2;
px.rgba.g += ((b1 >> 2) & 0x03) - 2;
px.rgba.b += ( b1 & 0x03) - 2;
}
else if ((b1 & QOI_MASK_2) == QOI_OP_LUMA) {
int b2 = bytes[p++];
int vg = (b1 & 0x3f) - 32;
px.rgba.r += vg - 8 + ((b2 >> 4) & 0x0f);
px.rgba.g += vg;
px.rgba.b += vg - 8 + (b2 & 0x0f);
}
else if ((b1 & QOI_MASK_2) == QOI_OP_RUN) {
run = (b1 & 0x3f);
}
index[QOI_COLOR_HASH(px) % 64] = px;
}
pixels[px_pos + 0] = px.rgba.r;
pixels[px_pos + 1] = px.rgba.g;
pixels[px_pos + 2] = px.rgba.b;
if (channels == 4) {
pixels[px_pos + 3] = px.rgba.a;
}
}
return pixels;
}
#ifndef QOI_NO_STDIO
#include <stdio.h>
int qoi_write(const char *filename, const void *data, const qoi_desc *desc) {
FILE *f = fopen(filename, "wb");
int size, err;
void *encoded;
if (!f) {
return 0;
}
encoded = qoi_encode(data, desc, &size);
if (!encoded) {
fclose(f);
return 0;
}
fwrite(encoded, 1, size, f);
fflush(f);
err = ferror(f);
fclose(f);
QOI_FREE(encoded);
return err ? 0 : size;
}
void *qoi_read(const char *filename, qoi_desc *desc, int channels) {
FILE *f = fopen(filename, "rb");
int size, bytes_read;
void *pixels, *data;
if (!f) {
return NULL;
}
fseek(f, 0, SEEK_END);
size = ftell(f);
if (size <= 0 || fseek(f, 0, SEEK_SET) != 0) {
fclose(f);
return NULL;
}
data = QOI_MALLOC(size);
if (!data) {
fclose(f);
return NULL;
}
bytes_read = fread(data, 1, size, f);
fclose(f);
pixels = (bytes_read != size) ? NULL : qoi_decode(data, bytes_read, desc, channels);
QOI_FREE(data);
return pixels;
}
#endif /* QOI_NO_STDIO */
#endif /* QOI_IMPLEMENTATION */
-91
View File
@@ -1,91 +0,0 @@
/*
Copyright (c) 2021, Dominic Szablewski - https://phoboslab.org
SPDX-License-Identifier: MIT
Command line tool to convert between png <> qoi format
Requires:
-"stb_image.h" (https://github.com/nothings/stb/blob/master/stb_image.h)
-"stb_image_write.h" (https://github.com/nothings/stb/blob/master/stb_image_write.h)
-"qoi.h" (https://github.com/phoboslab/qoi/blob/master/qoi.h)
Compile with:
gcc qoiconv.c -std=c99 -O3 -o qoiconv
*/
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#define STBI_NO_LINEAR
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#define QOI_IMPLEMENTATION
#include "qoi.h"
#define STR_ENDS_WITH(S, E) (strcmp(S + strlen(S) - (sizeof(E)-1), E) == 0)
int main(int argc, char **argv) {
if (argc < 3) {
puts("Usage: qoiconv <infile> <outfile>");
puts("Examples:");
puts(" qoiconv input.png output.qoi");
puts(" qoiconv input.qoi output.png");
exit(1);
}
void *pixels = NULL;
int w, h, channels;
if (STR_ENDS_WITH(argv[1], ".png")) {
if(!stbi_info(argv[1], &w, &h, &channels)) {
printf("Couldn't read header %s\n", argv[1]);
exit(1);
}
// Force all odd encodings to be RGBA
if(channels != 3) {
channels = 4;
}
pixels = (void *)stbi_load(argv[1], &w, &h, NULL, channels);
}
else if (STR_ENDS_WITH(argv[1], ".qoi")) {
qoi_desc desc;
pixels = qoi_read(argv[1], &desc, 0);
channels = desc.channels;
w = desc.width;
h = desc.height;
}
if (pixels == NULL) {
printf("Couldn't load/decode %s\n", argv[1]);
exit(1);
}
int encoded = 0;
if (STR_ENDS_WITH(argv[2], ".png")) {
encoded = stbi_write_png(argv[2], w, h, channels, pixels, 0);
}
else if (STR_ENDS_WITH(argv[2], ".qoi")) {
encoded = qoi_write(argv[2], pixels, &(qoi_desc){
.width = w,
.height = h,
.channels = channels,
.colorspace = QOI_SRGB
});
}
if (!encoded) {
printf("Couldn't write/encode %s\n", argv[2]);
exit(1);
}
free(pixels);
return 0;
}
+1 -1
-458
View File
@@ -1,458 +0,0 @@
Language: Cpp
IndentWidth: 4
TabWidth: 4
# Align parameters on the open bracket, e.g.:
# someLongFunction(argument1,
# argument2);
AlignAfterOpenBracket: Align
# Align array column and left justify the columns e.g.:
# struct test demo[] =
# {
# {56, 23, "hello"},
# {-1, 93463, "world"},
# {7, 5, "!!" }
# };
AlignArrayOfStructures: Left
# Align assignments on consecutive lines. This will result in formattings like:
#
# int a = 1;
# int somelongname = 2;
# double c = 3;
#
# int d = 3;
# /* A comment. */
# double e = 4;
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveMacros: Consecutive
# Align escaped newlines as far left as possible.
# #define A \
# int aaaa; \
# int b; \
# int dddddddddd;
AlignEscapedNewlines: Left
# Horizontally align operands of binary and ternary expressions.
# Specifically, this aligns operands of a single expression that needs to be
# split over multiple lines, e.g.:
#
# int aaa = bbbbbbbbbbbbbbb +
# ccccccccccccccc;
AlignOperands: Align
# true: false:
# int a; // My comment a vs. int a; // My comment a
# int b = 2; // comment b int b = 2; // comment about b
AlignTrailingComments: true
# If the function declaration doesnt fit on a line, allow putting all
# parameters of a function declaration onto the next line even if
# BinPackParameters is false.
#
# true:
# void myFunction(
# int a, int b, int c, int d, int e);
#
# false:
# void myFunction(int a,
# int b,
# int c,
# int d,
# int e);
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never # "while (true) { continue; }" can be put on a single line.
# If true, short case labels will be contracted to a single line.
#
# true: false:
# switch (a) { vs. switch (a) {
# case 1: x = 1; break; case 1:
# case 2: return; x = 1;
# } break;
# case 2:
# return;
# }
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true # enum { A, B } myEnum;
# Only merge functions defined inside a class. Implies “empty”.
#
# class Foo {
# void f() { foo(); }
# };
# void f() {
# foo();
# }
# void f() {}
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
# Only merge empty lambdas.
#
# auto lambda = [](int a) {}
# auto lambda2 = [](int a) {
# return a;
# };
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
# true: false:
# aaaa = vs. aaaa = "bbbb"
# "bbbb" "cccc";
# "cccc";
AlwaysBreakBeforeMultilineStrings: true
# Force break after template declaration only when the following declaration
# spans multiple lines.
#
# template <typename T> T foo() {
# }
# template <typename T>
# T foo(int aaaaaaaaaaaaaaaaaaaaa,
# int bbbbbbbbbbbbbbbbbbbbb) {
# }
AlwaysBreakTemplateDeclarations: MultiLine
# If false, a function calls arguments will either be all on the same line or
# will have one line each.
#
# true:
# void f() {
# f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
# }
#
# false:
# void f() {
# f(aaaaaaaaaaaaaaaaaaaa,
# aaaaaaaaaaaaaaaaaaaa,
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
# }
BinPackArguments: false
BinPackParameters: false # As BinPackArguments but for function definition parameters
# Add space after the : only (space may be added before if needed for
# AlignConsecutiveBitFields).
#
# unsigned bf: 2;
BitFieldColonSpacing: After
# LooooooooooongType loooooooooooooooooooooongVariable =
# someLooooooooooooooooongFunction();
#
# bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
# ccccccccccccccccccccccccccccccccccccccccc;
BreakBeforeBinaryOperators: None
# Always attach braces to surrounding context, but break before braces on
# function, namespace and class definitions.
BreakBeforeBraces: Linux
# true:
# template<typename T>
# concept ...
#
# false:
# template<typename T> concept ...
BreakBeforeConceptDeclarations: false
# true:
# veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
# ? firstValue
# : SecondValueVeryVeryVeryVeryLong;
#
# false:
# veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
# firstValue :
# SecondValueVeryVeryVeryVeryLong;
BreakBeforeTernaryOperators: true
# Break constructor initializers before the colon and commas, and align the
# commas with the colon.
#
# Constructor()
# : initializer1()
# , initializer2()
BreakConstructorInitializers: BeforeComma
# Break inheritance list only after the commas.
#
# class Foo : Base1,
# Base2
# {};
BreakInheritanceList: AfterComma
# true:
# const char* x = "veryVeryVeryVeryVeryVe"
# "ryVeryVeryVeryVeryVery"
# "VeryLongString";
BreakStringLiterals: true
ColumnLimit: 0
# false:
# namespace Foo {
# namespace Bar {
# }
# }
CompactNamespaces: false
# true: false:
# vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
# vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
# f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
# new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
Cpp11BracedListStyle: true
# Analyze the formatted file for the most used line ending (\r\n or \n). UseCRLF
# is only used as a fallback if none can be derived.
DeriveLineEnding: true
DerivePointerAlignment: true # As per DeriveLineEnding except for pointers and references
# Add empty line only when access modifier starts a new logical block. Logical
# block is a group of one or more member fields or functions.
#
# struct foo {
# private:
# int i;
#
# protected:
# int j;
# /* comment */
# public:
# foo() {}
#
# private:
# protected:
# };
EmptyLineBeforeAccessModifier: LogicalBlock
# true: false:
# namespace a { vs. namespace a {
# foo(); foo();
# bar(); bar();
# } // namespace a }
FixNamespaceComments: true
# false: true:
# class C { vs. class C {
# class D { class D {
# void bar(); void bar();
# protected: protected:
# D(); D();
# }; };
# public: public:
# C(); C();
# }; };
# void foo() { void foo() {
# return 1; return 1;
# } }
IndentAccessModifiers: false
# false: true:
# switch (fool) { vs. switch (fool) {
# case 1: { case 1:
# bar(); {
# } break; bar();
# default: { }
# plop(); break;
# } default:
# } {
# plop();
# }
# }
IndentCaseBlocks: false
# false: true:
# switch (fool) { vs. switch (fool) {
# case 1: case 1:
# bar(); bar();
# break; break;
# default: default:
# plop(); plop();
# } }
IndentCaseLabels: true
# extern "C" {
# void foo();
# }
IndentExternBlock: NoIndent
# Indents directives before the hash.
#
# #if FOO
# #if BAR
# #include <foo>
# #endif
# #endif
IndentPPDirectives: BeforeHash
# true: false:
# if (foo) { vs. if (foo) {
# bar();
# bar(); }
# }
KeepEmptyLinesAtTheStartOfBlocks: false
# The maximum number of consecutive empty lines to keep.
#
# MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
# int f() { int f() {
# int = 1; int i = 1;
# i = foo();
# i = foo(); return i;
# }
# return i;
# }
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
# Put all constructor initializers on the current line if they fit. Otherwise,
# put each one on its own line.
#
# Constructor() : a(), b()
#
# Constructor()
# : aaaaaaaaaaaaaaaaaaaa(),
# bbbbbbbbbbbbbbbbbbbb(),
# ddddddddddddd()
PackConstructorInitializers: CurrentLine
PointerAlignment: Right
# false:
# // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
# /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
#
# true:
# // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
# // information
# /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
# * information */
ReflowComments: true
# false: true:
#
# if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
# handleFunctionDecl(D); handleFunctionDecl(D);
# } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
# handleVarDecl(D); handleVarDecl(D);
# }
#
# if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
# for (auto *A : D.attrs()) { for (auto *A : D.attrs())
# if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
# handleAttr(A); handleAttr(A);
# } }
# }
# }
#
# if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
# for (auto *A : D.attrs()) { for (auto *A : D.attrs())
# handleAttr(A); handleAttr(A);
# }
# }
#
# if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
# if (shouldProcess(D)) { if (shouldProcess(D))
# handleVarDecl(D); handleVarDecl(D);
# } else { else
# markAsIgnored(D); markAsIgnored(D);
# } }
# }
#
# if (a) { vs. if (a)
# b(); b();
# } else { else if (c)
# if (c) { d();
# d(); else
# } else { e();
# e();
# }
# }
RemoveBracesLLVM: true
# Never v.s. Always
# #include <cstring> #include <cstring>
# struct Foo {
# int a, b, c; struct Foo {
# }; int a, b, c;
# namespace Ns { };
# class Bar {
# public: namespace Ns {
# struct Foobar { class Bar {
# int a; public:
# int b; struct Foobar {
# }; int a;
# private: int b;
# int t; };
# int method1() {
# // ... private:
# } int t;
# enum List {
# ITEM1, int method1() {
# ITEM2 // ...
# }; }
# template<typename T>
# int method2(T x) { enum List {
# // ... ITEM1,
# } ITEM2
# int i, j, k; };
# int method3(int par) {
# // ... template<typename T>
# } int method2(T x) {
# }; // ...
# class C {}; }
# }
# int i, j, k;
#
# int method3(int par) {
# // ...
# }
# };
#
# class C {};
# }
SeparateDefinitionBlocks: Always
# true: false:
# int a = 5; vs. int a= 5;
# a += 42; a+= 42;
SpaceBeforeAssignmentOperators: true
# Put a space before opening parentheses only after control statement keywords
# (for/if/while...).
#
# void f() {
# if (true) {
# f();
# }
# }
SpaceBeforeParens: ControlStatements
SpacesBeforeTrailingComments: 1
# static_cast<int>(arg);
# std::function<void(int)> fct;
SpacesInAngles: Never
Standard: Auto
# Macros which are ignored in front of a statement, as if they were an
# attribute. So that they are not parsed as identifier, for example for Qts
# emit.
# unsigned char data = 'x';
# emit signal(data); // This is parsed as variable declaration.
#
# vs.
#
# unsigned char data = 'x';
# emit signal(data); // Now it's fine again.
StatementAttributeLikeMacros: [emit]
---
+97 -6
View File
@@ -5,15 +5,106 @@ set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set build_dir=%script_dir%\Build
set code_dir=%script_dir%
set tely_dir=%code_dir%\External\tely
REM Bootstrap the build program
REM ================================================================================================
mkdir %build_dir% 2>nul
pushd %build_dir%
cl /nologo /Z7 /W4 %code_dir%\feely_pona_build.cpp || exit /B 1
copy feely_pona_build.exe %code_dir% 1>nul
popd
mkdir %build_dir%\Data 2>nul
REM Run the build program
%code_dir%\feely_pona_build.exe %* || exit /B 1
REM ================================================================================================
set robocopy_cmd=robocopy /MIR /NJH /NJS /NDL /NP %code_dir%\Data %build_dir%\Data
call powershell -Command "$duration = Measure-Command {%robocopy_cmd% | Out-Default}; Write-Host 'robocopy:' $duration.TotalSeconds 'seconds'"
REM ================================================================================================
REM TODO: Raylib seems to have problems shutting down fsanitize=address?
set common_compile_flags=/W4 /Z7 /MT /EHsc /nologo
set common_link_flags=/link /incremental:no
REM raylib =========================================================================================
set raylib_dir=%tely_dir%\external\raylib
if not exist %build_dir%\rcore.obj (
cl %common_compile_flags% ^
/w ^
/c ^
/D _DEFAULT_SOURCE ^
/D PLATFORM_DESKTOP ^
/I %raylib_dir% ^
/I %raylib_dir%\external\glfw\include ^
/I %raylib_dir%\glfw\deps\mingw ^
%raylib_dir%\rcore.c ^
%raylib_dir%\utils.c ^
%raylib_dir%\raudio.c ^
%raylib_dir%\rmodels.c ^
%raylib_dir%\rtext.c ^
%raylib_dir%\rtextures.c ^
%raylib_dir%\rshapes.c ^
%raylib_dir%\rglfw.c
)
REM raylib flags =========================================================================================
set raylib_compile_flags=%common_compile_flags% ^
/Tp %tely_dir%\tely_platform_raylib_unity.h ^
/I "%raylib_dir%"
set raylib_link_flags=%common_link_flags% ^
%build_dir%\rcore.obj ^
%build_dir%\utils.obj ^
%build_dir%\raudio.obj ^
%build_dir%\rmodels.obj ^
%build_dir%\rtext.obj ^
%build_dir%\rtextures.obj ^
%build_dir%\rshapes.obj ^
%build_dir%\rglfw.obj ^
gdi32.lib opengl32.lib winmm.lib user32.lib shell32.lib
REM DLL flags ======================================================================================
set dll_compile_flags=%common_compile_flags% /LD /Tp %code_dir%\feely_pona_unity.h
set dll_link_flags=%common_link_flags%
REM MSVC commands ==================================================================================
set msvc_exe_name=feely_pona_msvc
set msvc_cmd=cl %raylib_compile_flags% /Fo%msvc_exe_name% /Fe%msvc_exe_name% %raylib_link_flags%
set msvc_dll_cmd=cl %dll_compile_flags% /Fotely_dll_msvc /Fetely_dll_msvc %dll_link_flags%
REM CLANG commands =================================================================================
set clang_exe_name_sdl=feely_pona_clang
set clang_cmd_sdl=clang-cl %compile_flags% /Fo%clang_exe_name_sdl% /Fe%clang_exe_name_sdl% %link_flags%
set clang_dll_cmd=clang-cl %dll_compile_flags% /Fotely_dll_clang /Fetely_dll_clang %dll_link_flags%
REM MSVC build =====================================================================================
set msvc_sprite_packer_cmd=cl %common_compile_flags% %code_dir%\feely_pona_sprite_packer.cpp /Fofeely_pona_sprite_packer /Fefeely_pona_sprite_packer %common_link_flags%
powershell -Command "$duration = Measure-Command {%msvc_sprite_packer_cmd% | Out-Default}; Write-Host 'msvc (sprite packer):' $duration.TotalSeconds 'seconds'"
set msvc_build_platform=$platform_time = Measure-Command {%msvc_cmd% ^| Out-Default};
set msvc_build_dll=$dll_time = Measure-Command {%msvc_dll_cmd% ^| Out-Default};
set msvc_print_dll_time=Write-Host 'msvc dll:'$dll_time.TotalSeconds's'
set msvc_print_platform_and_dll_time=Write-Host 'msvc (platform+dll):'($platform_time.TotalSeconds + $dll_time.TotalSeconds)'s ('$platform_time.TotalSeconds + $dll_time.TotalSeconds')'
set msvc_check_if_exe_locked=$File = [System.IO.File]::Open('%build_dir%\%msvc_exe_name%.exe', 'Open', 'Write'); $File.Close(); $File.Dispose()
set msvc_exe_is_locked=0
if exist %build_dir%\%msvc_exe_name%.exe (
powershell -Command "%msvc_check_if_exe_locked%" 2>nul && set msvc_exe_is_locked=0 || set msvc_exe_is_locked=1
)
echo foo> %msvc_exe_name%.lock
if %msvc_exe_is_locked% == 1 (
powershell -Command "%msvc_build_dll% %msvc_print_dll_time%"
) else (
powershell -Command "%msvc_build_platform% %msvc_build_dll% %msvc_print_platform_and_dll_time%"
)
del %msvc_exe_name%.lock
REM CLANG build ====================================================================================
popd
exit /B 1
+9 -1
View File
@@ -10,4 +10,12 @@ if not exist "%sprite_packer%" (
exit /B 1
)
%sprite_packer% 5100x5100 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
REM %sprite_packer% 4096x4096 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\terry_resized_25%% || exit /b 1
REM %sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\terry_merchant_resized_25%% || exit /b 1
REM %sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\smoochie_resized_25%% || exit /b 1
REM %sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\clinger_resized_25%% || exit /b 1
REM %sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\club_terry_resized_25%% || exit /b 1
REM %sprite_packer% 4096x2048 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\map_resized_25%% || exit /b 1
REM %sprite_packer% 8192x8192 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\heart_resized_25%% || exit /b 1
%sprite_packer% 4096x4096 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
-11
View File
@@ -1,11 +0,0 @@
@echo off
setlocal
set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set build_dir=%script_dir%\Build
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.html doylet@doylet.dev:/selfhost/TerryCherry/index.html
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.data doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.data
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.js doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.js
scp -P 8110 %build_dir%\Terry_Cherry_Emscripten\Terry_Cherry.wasm doylet@doylet.dev:/selfhost/TerryCherry/Terry_Cherry.wasm
+351 -885
View File
File diff suppressed because it is too large Load Diff
+3 -16
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
enum FP_ProfileZone
@@ -47,8 +47,6 @@ struct FP_GlobalAnimations
Dqn_String8 club_terry_alive = DQN_STRING8("club_terry_alive");
Dqn_String8 club_terry_dark = DQN_STRING8("club_terry_dark");
Dqn_String8 end_screen = DQN_STRING8("end_screen");
Dqn_String8 heart = DQN_STRING8("heart");
Dqn_String8 heart_bleed = DQN_STRING8("heart_bleed");
@@ -57,20 +55,9 @@ struct FP_GlobalAnimations
Dqn_String8 icon_phone = DQN_STRING8("icon_phone");
Dqn_String8 icon_stamina = DQN_STRING8("icon_stamina");
Dqn_String8 intro_screen_arrows = DQN_STRING8("intro_screen_arrows");
Dqn_String8 intro_screen_subtitle = DQN_STRING8("intro_screen_subtitle");
Dqn_String8 intro_screen_terry = DQN_STRING8("intro_screen_terry");
Dqn_String8 intro_screen_title = DQN_STRING8("intro_screen_title");
Dqn_String8 kennel_terry = DQN_STRING8("kennel_terry");
Dqn_String8 map = DQN_STRING8("map");
Dqn_String8 map_billboard_attack = DQN_STRING8("map_billboard_attack");
Dqn_String8 map_billboard_dash = DQN_STRING8("map_billboard_dash");
Dqn_String8 map_billboard_monkey = DQN_STRING8("map_billboard_monkey");
Dqn_String8 map_billboard_range_attack = DQN_STRING8("map_billboard_range_attack");
Dqn_String8 map_billboard_strafe = DQN_STRING8("map_billboard_strafe");
Dqn_String8 map_police = DQN_STRING8("map_police");
Dqn_String8 merchant_button_a = DQN_STRING8("merchant_button_a");
Dqn_String8 merchant_button_b = DQN_STRING8("merchant_button_b");
-536
View File
@@ -1,536 +0,0 @@
// #include <Windows.h>
#include <stdlib.h>
#define DQN_IMPLEMENTATION
#include "External/tely/External/dqn/dqn.h"
#define DQN_CPP_BUILD_IMPLEMENTATION
#include "External/tely/External/dqn/dqn_cppbuild.h"
#if 0
void RebuildProgramIfRequired(int argc, char const **argv)
{
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
Dqn_String8 const exe_dir = Dqn_OS_EXEDir(scratch.arena);
Dqn_String8 build_program_path = Dqn_OS_EXEPath(scratch.arena);
Dqn_FsInfo build_program_info = Dqn_Fs_GetInfo(build_program_path);
Dqn_FsInfo source_path = Dqn_Fs_GetInfo(Dqn_String8_InitCString8(__FILE__));
if (!build_program_info.exists) {
Dqn_WinError error = Dqn_Win_LastError(scratch.arena);
Dqn_Log_WarningF("Failed to get the last write time of the build program '%.*s', skipping rebuild (%d): %.*s",
DQN_STRING_FMT(build_program_path), error.code, DQN_STRING_FMT(error.msg));
return;
}
if (!source_path.exists) {
Dqn_WinError error = Dqn_Win_LastError(scratch.arena);
Dqn_Log_WarningF(
"Failed to get the last write time of the build program's source code '%s', skipping rebuild (%d): %.*s",
__FILE__, error.code, DQN_STRING_FMT(error.msg));
return;
}
// NOTE: The build program is newer than the source path, no rebuild required
if (source_path.last_write_time_in_s < build_program_info.last_write_time_in_s) {
return;
}
Dqn_Log_InfoF("Build program source code has changed, rebuilding the program (timestamps changed source was %I64u, build program was %I64u)",
source_path.last_write_time_in_s,
build_program_info.last_write_time_in_s);
Dqn_String8 temp_build_program_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s.old", DQN_STRING_FMT(build_program_path));
if (!Dqn_Fs_Move(build_program_path, temp_build_program_path, true)) {
Dqn_WinError error = Dqn_Win_LastError(scratch.arena);
Dqn_Log_WarningF("Failed to backup the build program for rebuilding, skipping rebuild (%d): %.*s", error.code, DQN_STRING_FMT(error.msg));
return;
}
// NOTE: Rebuild the build program because a change was detected ===============
Dqn_String8 rebuild_cmd = Dqn_String8_InitF(scratch.allocator, "cl /Z7 /W4 /nologo %s /incremental:no /link", __FILE__);
Dqn_OSExecResult rebuild_result = Dqn_OS_Exec(rebuild_cmd, exe_dir /*working_dir*/);
if (rebuild_result.os_error_code) {
Dqn_WinError error = Dqn_Win_LastError(scratch.arena);
Dqn_Log_ErrorF("Detected change in the build program's source code '%s' but the OS failed to rebuild the program, skipping rebuild (%d): %.*s", __FILE__, error.code, DQN_STRING_FMT(error.msg));
return;
}
if (rebuild_result.exit_code) {
Dqn_Fs_Move(temp_build_program_path, build_program_path, true);
exit(rebuild_result.exit_code);
}
Dqn_String8Builder builder = {};
builder.allocator = scratch.allocator;
DQN_FOR_UINDEX (arg_index, argc)
Dqn_String8Builder_AppendF(&builder, "%s%s", arg_index ? " " : "", argv[arg_index]);
Dqn_String8 rebootstrap_cmd = Dqn_String8Builder_Build(&builder, scratch.allocator);
Dqn_OSExecResult exec_result = Dqn_OS_Exec(rebootstrap_cmd, exe_dir /*working_dir*/);
if (exec_result.os_error_code) {
Dqn_WinError error = Dqn_Win_LastError(scratch.arena);
Dqn_Log_ErrorF("Detected change in the build program's source code '%s' but the OS failed to rebuild the program, skipping rebuild (%d): %.*s", __FILE__, error.code, DQN_STRING_FMT(error.msg));
Dqn_Fs_Move(temp_build_program_path, build_program_path, true);
return;
}
exit(exec_result.exit_code);
}
#endif
#define PRINT_HELP Dqn_Print_StdLnF(Dqn_PrintStd_Out, "USAGE: feely_pona_build [--help|--dry-run|--web]")
int main(int argc, char const **argv)
{
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
bool dry_run = false;
bool target_web = false;
for (Dqn_usize arg_index = 1; arg_index < argc; arg_index++) {
Dqn_String8 arg = Dqn_String8_InitCString8(argv[arg_index]);
if (arg == DQN_STRING8("--help")) {
PRINT_HELP;
return 0;
} else if (arg == DQN_STRING8("--dry-run")) {
dry_run = true;
} else if (arg == DQN_STRING8("--web")) {
target_web = true;
} else {
PRINT_HELP;
return 0;
}
}
#if 0
RebuildProgramIfRequired(argc, argv);
#else
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "-- Dqn_CPPBuild v0");
#endif
uint64_t build_timings[2] = {};
build_timings[0] = Dqn_OS_PerfCounterNow();
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
Dqn_String8 const exe_dir = Dqn_OS_EXEDir(scratch.arena);
Dqn_String8 const code_dir = exe_dir;
Dqn_String8 const build_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/Build", DQN_STRING_FMT(exe_dir));
Dqn_String8 const tely_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely", DQN_STRING_FMT(exe_dir));
Dqn_Slice<Dqn_String8> common_compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("cl"),
DQN_STRING8("/W4"),
DQN_STRING8("/Z7"),
DQN_STRING8("/MT"),
DQN_STRING8("/EHsc"),
DQN_STRING8("/nologo"),
});
Dqn_Slice<Dqn_String8> common_link_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("/link"),
DQN_STRING8("/incremental:no"),
});
// NOTE: Assets ================================================================================
uint64_t robocopy_timings[2] = {};
{
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_String8 robocopy_cmd[] = {
Dqn_String8_InitF(scratch.allocator, "robocopy /NJH /NJS /NDL /NP %.*s\\Data\\Textures %.*s\\Data\\Textures atlas.*", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data\\Fonts %.*s\\Data\\Fonts", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data\\Audio %.*s\\Data\\Audio", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir)),
};
for (Dqn_String8 cmd : robocopy_cmd) {
if (dry_run)
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
else
Dqn_OS_Exec(cmd, /*working_dir*/ {});
}
}
// NOTE: Raylib ================================================================================
Dqn_String8 const raylib_dir = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/tely/external/raylib", DQN_STRING_FMT(exe_dir));
Dqn_Slice<Dqn_String8> const raylib_base_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rcore.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/utils.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/raudio.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rmodels.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtext.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rtextures.c", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rshapes.c", DQN_STRING_FMT(raylib_dir)),
});
Dqn_List<Dqn_String8> raylib_pc_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
uint64_t raylib_pc_timings[2] = {};
{
raylib_pc_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { raylib_pc_timings[1] = Dqn_OS_PerfCounterNow(); };
// NOTE: Setup raylib build context ========================================================
Dqn_CPPBuildContext build_context = {};
{
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {
Dqn_FsPath_ConvertF(scratch.arena, "%.*s", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/external/glfw/include", DQN_STRING_FMT(raylib_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/glfw/deps/mingw", DQN_STRING_FMT(raylib_dir)),
});
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("cl"),
DQN_STRING8("/w"),
DQN_STRING8("/c"),
DQN_STRING8("/D _DEFAULT_SOURCE"),
DQN_STRING8("/D PLATFORM_DESKTOP"),
DQN_STRING8("/Z7"),
DQN_STRING8("/MT"),
DQN_STRING8("/EHsc"),
DQN_STRING8("/nologo"),
});
build_context.build_dir = build_dir;
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
}
// NOTE: Compile each file separately with a custom output name ============================
for (Dqn_String8 base_file : raylib_base_files) {
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = base_file;
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s.obj", DQN_STRING_FMT(file_stem));
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
// NOTE: Build rlgfw =======================================================================
{
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/rglfw.c", DQN_STRING_FMT(raylib_dir));
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_rglfw.obj");
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
Dqn_List_Add(&raylib_pc_output_files, build_file.output_file_path);
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
}
// NOTE: QOI Converter =========================================================================
uint64_t qoi_converter_timings[2] = {};
{
qoi_converter_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { qoi_converter_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildContext build_context = {};
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/qoiconv.c", DQN_STRING_FMT(code_dir)) },
});
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("cl"), DQN_STRING8("-O2"), DQN_STRING8("-MT"), DQN_STRING8("/nologo")});
build_context.link_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/link"), DQN_STRING8("/incremental:no")});
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {Dqn_FsPath_ConvertF(scratch.arena, "%.*s/External/stb", DQN_STRING_FMT(tely_dir))});
build_context.build_dir = build_dir;
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
// NOTE: Feely Pona Sprite Packer ==============================================================
uint64_t feely_pona_sprite_packer_timings[2] = {};
{
feely_pona_sprite_packer_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_sprite_packer_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildContext build_context = {};
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.cpp", DQN_STRING_FMT(code_dir)) },
});
build_context.compile_flags = common_compile_flags;
build_context.link_flags = common_link_flags;
build_context.build_dir = build_dir;
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
// NOTE: Feely Pona No DLL =====================================================================
uint64_t feely_pona_no_dll_timings[2] = {};
Dqn_CPPBuildContext feely_pona_no_dll_build_context = {};
{
feely_pona_no_dll_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_no_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.h", DQN_STRING_FMT(code_dir));
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
feely_pona_no_dll_build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
feely_pona_no_dll_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
feely_pona_no_dll_build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
feely_pona_no_dll_build_context.compile_flags = common_compile_flags;
feely_pona_no_dll_build_context.build_dir = build_dir;
// NOTE: Link to raylib object files and windows libs ======================================
Dqn_List<Dqn_String8> link_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_link_flags);
{
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_pc_output_files, &it, 0); )
Dqn_List_Add(&link_flags, *it.data);
Dqn_List_Add(&link_flags, DQN_STRING8("gdi32.lib"));
Dqn_List_Add(&link_flags, DQN_STRING8("opengl32.lib"));
Dqn_List_Add(&link_flags, DQN_STRING8("winmm.lib"));
Dqn_List_Add(&link_flags, DQN_STRING8("user32.lib"));
Dqn_List_Add(&link_flags, DQN_STRING8("shell32.lib"));
}
feely_pona_no_dll_build_context.link_flags = Dqn_List_ToSliceCopy(&link_flags, scratch.arena);
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(feely_pona_no_dll_build_context, Dqn_CPPBuildMode_AlwaysRebuild);
}
}
// NOTE: Feely Pona DLL ========================================================================
uint64_t feely_pona_dll_timings[2] = {};
{
feely_pona_dll_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_dll_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity.h", DQN_STRING_FMT(code_dir));
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "tely_dll_msvc", DQN_STRING_FMT(code_dir));
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
Dqn_List_Add(&compile_flags, DQN_STRING8("/LD"));
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fetely_dll_msvc"));
Dqn_CPPBuildContext build_context = {};
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
build_context.build_dir = build_dir;
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_AlwaysRebuild);
}
}
// NOTE: Feely Pona platform ===================================================================
uint64_t feely_pona_platform_timings[2] = {};
{
feely_pona_platform_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_platform_timings[1] = Dqn_OS_PerfCounterNow(); };
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/tely_platform_raylib_unity.h", DQN_STRING_FMT(tely_dir));
build_file.output_file_path = Dqn_FsPath_ConvertF(scratch.arena, "feely_pona_msvc", DQN_STRING_FMT(code_dir));
build_file.flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {DQN_STRING8("/Tp")});
Dqn_List<Dqn_String8> compile_flags = Dqn_List_InitSliceCopy(scratch.arena, 128, common_compile_flags);
Dqn_List_Add(&compile_flags, DQN_STRING8("/Fefeely_pona_msvc"));
Dqn_CPPBuildContext build_context = {};
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
build_context.compile_flags = Dqn_List_ToSliceCopy(&compile_flags, scratch.arena);
build_context.link_flags = feely_pona_no_dll_build_context.link_flags;
build_context.build_dir = build_dir;
build_context.include_dirs = Dqn_Slice_InitCArrayCopy(scratch.arena, {raylib_dir});
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_String8 exe_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_msvc.exe", DQN_STRING_FMT(build_dir));
bool exe_is_locked = false;
if (Dqn_Fs_Exists(exe_path)) {
Dqn_FsFile exe_file = Dqn_Fs_OpenFile(exe_path, Dqn_FsFileOpen_OpenIfExist, Dqn_FsFileAccess_Read | Dqn_FsFileAccess_Write);
exe_is_locked = exe_file.error_size;
Dqn_Fs_CloseFile(&exe_file);
}
if (!exe_is_locked) {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_AlwaysRebuild);
}
}
}
// NOTE: raylib emscripten =====================================================================
uint64_t raylib_emscripten_timings[2] = {};
uint64_t feely_pona_emscripten_timings[2] = {};
if (target_web) {
Dqn_String8 const raylib_emscripten_lib_name = DQN_STRING8("raylib_emscripten.a");
// NOTE: Compile each raylib file separately with emcc =====================================
{
raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
// NOTE: Setup build context ===========================================================
Dqn_List<Dqn_String8> raylib_emscripten_output_files = Dqn_List_Init<Dqn_String8>(scratch.arena, 16);
Dqn_CPPBuildContext raylib_emscripten_build_context = {};
raylib_emscripten_build_context.compiler = Dqn_CPPBuildCompiler_GCC;
for (Dqn_String8 base_file : raylib_base_files) {
Dqn_String8 file_stem = Dqn_String8_FileNameNoExtension(base_file);
// NOTE: Append "emscripten" suffix to the object files
Dqn_CPPBuildCompileFile build_file = {};
build_file.input_file_path = base_file;
build_file.output_file_path = Dqn_String8_InitF(scratch.allocator, "raylib_%.*s_emscripten.o", DQN_STRING_FMT(file_stem));
raylib_emscripten_build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {build_file});
raylib_emscripten_build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("cmd"),
DQN_STRING8("/C"),
DQN_STRING8("emcc.bat"),
DQN_STRING8("-c"), // Compile and assemble, but do not link
DQN_STRING8("-Wall"),
DQN_STRING8("-Os"), // Optimize for size
DQN_STRING8("-D PLATFORM_WEB"),
DQN_STRING8("-D GRAPHICS_API_OPENGL_ES2"),
});
raylib_emscripten_build_context.build_dir = build_dir;
Dqn_List_Add(&raylib_emscripten_output_files, build_file.output_file_path);
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(raylib_emscripten_build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(raylib_emscripten_build_context, Dqn_CPPBuildMode_CacheBuild);
}
}
// NOTE: Build the wasm raylib library =================================================
{
Dqn_String8Builder builder = {};
builder.allocator = scratch.allocator;
Dqn_String8Builder_AppendF(&builder, "cmd /C emar.bat rcs %.*s", DQN_STRING_FMT(raylib_emscripten_lib_name));
for (Dqn_ListIterator<Dqn_String8> it = {}; Dqn_List_Iterate(&raylib_emscripten_output_files, &it, 0); )
Dqn_String8Builder_AppendF(&builder, " %.*s", DQN_STRING_FMT(*it.data));
Dqn_String8 cmd = Dqn_String8Builder_Build(&builder, scratch.allocator);
if (dry_run) {
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_OS_ExecOrAbort(cmd, build_dir);
}
}
}
// NOTE: feely pona emscripten =================================================================
{
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
// NOTE: Compile with emcc =============================================================
Dqn_CPPBuildContext build_context = {};
build_context.compile_file_obj_suffix = DQN_CPP_BUILD_OBJ_SUFFIX_O;
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STRING_FMT(code_dir)) },
});
Dqn_String8 prefix = DQN_STRING8("Terry_Cherry");
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
DQN_STRING8("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(prefix)),
DQN_STRING8("-Os"), // Optimize for size
DQN_STRING8("-Wall"),
DQN_STRING8("--shell-file"), Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_emscripten_shell.html", DQN_STRING_FMT(code_dir)),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(raylib_emscripten_lib_name)),
DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
// DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=2"),
// DQN_STRING8("-s"), DQN_STRING8("SAFE_HEAP=0"),
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
DQN_STRING8("-s"), DQN_STRING8("TOTAL_STACK=32MB"),
DQN_STRING8("-s"), DQN_STRING8("ALLOW_MEMORY_GROWTH"),
// DQN_STRING8("-s"), DQN_STRING8("STACK_OVERFLOW_CHECK=2"),
// DQN_STRING8("--profiling-funcs"), // Expose function names in stack trace
// DQN_STRING8("-g"), // Debug symbols
// NOTE: Must be relative path such that fopen("Data/...") works
// otherwise the VFS will encode the full absolute path to the
// assets
DQN_STRING8("--preload-file"), DQN_STRING8("Data"),
DQN_STRING8("-msimd128"),
DQN_STRING8("-msse2"),
});
build_context.build_dir = build_dir;
if (dry_run) {
Dqn_String8 cmd = Dqn_CPPBuild_ToCommandLine(build_context, Dqn_CPPBuildMode_AlwaysRebuild, scratch.allocator);
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
}
// NOTE: Move the files to a directory
Dqn_String8 folder_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s_Emscripten", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(prefix));
if (!Dqn_Fs_DirExists(folder_path)) {
Dqn_String8 mkdir_cmd = Dqn_String8_InitF(scratch.allocator, "mkdir %.*s", DQN_STRING_FMT(folder_path));
Dqn_OS_ExecOrAbort(mkdir_cmd, {});
}
Dqn_String8 const generated_file_extension[] = {
DQN_STRING8("data"),
DQN_STRING8("html"),
DQN_STRING8("js"),
DQN_STRING8("wasm"),
};
for (Dqn_String8 file_ext : generated_file_extension) {
Dqn_String8 src_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.%.*s", DQN_STRING_FMT(build_dir), DQN_STRING_FMT(prefix), DQN_STRING_FMT(file_ext));
Dqn_String8 dest_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/%.*s.%.*s", DQN_STRING_FMT(folder_path), DQN_STRING_FMT(prefix), DQN_STRING_FMT(file_ext));
Dqn_String8 cmd = Dqn_String8_InitF(scratch.allocator, "cmd /C move /Y %.*s %.*s", DQN_STRING_FMT(src_path), DQN_STRING_FMT(dest_path));
if (dry_run) {
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(cmd));
} else {
Dqn_OS_ExecOrAbort(cmd, build_dir);
}
}
}
}
build_timings[1] = Dqn_OS_PerfCounterNow();
Dqn_Print_StdLnF(Dqn_PrintStd_Out, "\n-- Dqn_CPPBuild Timings (%.2fms)", Dqn_OS_PerfCounterMs(build_timings[0], build_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " robocopy: %.2fms", Dqn_OS_PerfCounterMs(robocopy_timings[0], robocopy_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib: %.2fms", Dqn_OS_PerfCounterMs(raylib_pc_timings[0], raylib_pc_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " qoi_converter: %.2fms", Dqn_OS_PerfCounterMs(qoi_converter_timings[0], qoi_converter_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona sprite packer: %.2fms", Dqn_OS_PerfCounterMs(feely_pona_sprite_packer_timings[0], feely_pona_sprite_packer_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (no dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_no_dll_timings[0], feely_pona_no_dll_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (platform-raylib): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_platform_timings[0], feely_pona_platform_timings[1]));
if (target_web) {
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " raylib (emscripten): %.2fms", Dqn_OS_PerfCounterMs(raylib_emscripten_timings[0], raylib_emscripten_timings[1]));
Dqn_Print_StdLnF(Dqn_PrintStd_Out, " feely pona (emscripten): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_emscripten_timings[0], feely_pona_emscripten_timings[1]));
}
return 0;
}
-328
View File
@@ -1,328 +0,0 @@
<!doctype html>
<html lang="EN-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>raylib web game</title>
<meta name="title" content="raylib web game">
<meta name="description" content="New raylib web videogame, developed using raylib videogames library">
<meta name="keywords" content="raylib, games, html5, programming, C, C++, library, learn, videogames">
<meta name="viewport" content="width=device-width">
<!-- Open Graph metatags for sharing -->
<meta property="og:title" content="raylib web game">
<meta property="og:image:type" content="image/png">
<meta property="og:image" content="https://www.raylib.com/common/img/raylib_logo.png">
<meta property="og:site_name" content="raylib.com">
<meta property="og:url" content="https://www.raylib.com/games.html">
<meta property="og:description" content="New raylib web videogame, developed using raylib videogames library">
<!-- Twitter metatags for sharing -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@raysan5">
<meta name="twitter:title" content="raylib web game">
<meta name="twitter:image" content="https://www.raylib.com/common/raylib_logo.png">
<meta name="twitter:url" content="https://www.raylib.com/games.html">
<meta name="twitter:description" content="New raylib web game, developed using raylib videogames library">
<!-- Favicon -->
<link rel="shortcut icon" href="https://www.raylib.com/favicon.ico">
<style>
body {
font-family: arial;
margin: 0;
padding: none;
}
#header {
width: 100%;
height: 80px;
background-color: #888888;
}
/* NOTE: raylib logo is embedded in the page as base64 png image */
#logo {
width:64px;
height:64px;
float:left;
position:relative;
margin:10px;
background-image:url('data:image/png;base64,\
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADs\
MAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAA7JJREFUaEPtk0FyWzEMQ+37X7fZhxX4\
YY3AD1OKF1nkzTRlSBCCLeVBnvl/AUdaELOunPno1kts1kixdtEZKVs+xIxebBkZsVknn/L5nFGDLR8T4zVC9fX19S/+tTFijr\
YK4jUjbPUtqBHpnEE6PkZD7jQZV8n5Recw1XQKciZuPaEtR6UjNs5ENVGMsBVqpPtER0ZMOhpyp8m4YL4OjD9yxsyZxnQycfMJ\
ETNSzsRE1+dihK3YMiJmpHTW3xpmXPC6BXlCHfqnBlsjY5hxf/6EVEOM2BTEi0fYCX4ONSI6Kq3Blg/prIOMq2CsRur4KQ0x64\
SdjOufEDEdHZGOhmz5RDHCVqhRuQ86YsVskbc+GXchLiHnFyYH+UigQDVGnImbT8hwFkgLg2qiM8JO6Ylx1FNLa3DmYwqCTsZd\
4BPqGJG7MwKzpeiWKTKxXkLMVE3MSOmsdwxLH6Rd/wCCLSNDx6djeKfJuArGeoYamRHpaEjnCBYZVy8hZqo2GI36qPjsiOiMsB\
XGcev4Mx9TLGTchbgEjN/uz6jGrBvDjg+LTNx8Qp2CbG2xMKgmOiPslJ4Yxx+eSnSkzlosZNwFPiHl7FRTkLNRJm4+IeVM0ymI\
H42wE/wcKalQI4MRl4EW3p6VcRWMua8F6WjIlqZDxvVPiHQ6CjVbYkV9ohhhp/Rk1wiYgpyJ78i4CsZbjkb8Qx+ihvzu3RPaKo\
gZkY6GlEeMsKdPSOFIC8VoOusg44L5c+T8ouOoGhWbdWJ8tMi4egkxo4hoh2yNTGf3iIyr5Lyic4bRENXo+lvDjAt4C1Hk/OKt\
UaAj0+n4dMSZ2D+hrYJsaYh2SClG2jV9kJKKzhlGQ1SsW299Mq6C8dYZHTExo8fzieI5ivipYnYy7nwJqGKmOYyRwfiUBXITfh\
5qSHRGWEkfqJqURgvsdHyWYv7Ko8DnYYegk3EB00cxprdrJRzFd7YQzawu8L1GMTYS/KpPaAFTkIn1EmJmspJSs5xBzSyGhlkB\
mlxfNFiP5mw4wlbMh4F5Ddxp5jNINBdCEz9zPOC1zD7Q0HBdmXndwv0TMtydEdzlWJT4VZ8Qt9Qn4/onxMIwa5ZYGJU5yufBiC\
jwE50AGjLCVuS8Yt4H7OgZLKK5EKOsLviEWJSL/+0uMi7gLUSBseYwqEbXvSHCec1CJvZPyHCmYQffaBBfOTCGHM2aEbZi1+gO\
1XTWVXMnzrhAn5DSOZVsiQlHnSITKzGj6DeTcZWc/3oy7h9//PF4PL4BlvsWrb6RE+oAAAAASUVORK5CYII=');
}
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; }
/* NOTE: Canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten {
border: 0px none;
background: black;
width: 100%;
}
.spinner {
height: 30px;
width: 30px;
margin: 0;
margin-top: 20px;
margin-left: 20px;
display: inline-block;
vertical-align: top;
-webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite;
border-left: 5px solid black;
border-right: 5px solid black;
border-bottom: 5px solid black;
border-top: 5px solid red;
border-radius: 100%;
background-color: rgb(245, 245, 245);
}
@-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation {
from {-moz-transform: rotate(0deg);}
to {-moz-transform: rotate(360deg);}
}
@-o-keyframes rotation {
from {-o-transform: rotate(0deg);}
to {-o-transform: rotate(360deg);}
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
#status {
display: inline-block;
vertical-align: top;
margin-top: 30px;
margin-left: 20px;
font-weight: bold;
color: rgb(40, 40, 40);
}
#progress {
height: 0px;
width: 0px;
}
#controls {
display: inline-block;
float: right;
vertical-align: top;
margin-top: 15px;
margin-right: 20px;
}
#output {
width: 100%;
height: 140px;
margin: 0 auto;
margin-top: 10px;
display: block;
background-color: black;
color: rgb(37, 174, 38);
font-family: 'Lucida Console', Monaco, monospace;
outline: none;
}
input[type=button] {
background-color: lightgray;
border: 4px solid darkgray;
color: black;
text-decoration: none;
cursor: pointer;
width: 140px;
height: 50px;
}
input[type=button]:hover {
background-color: #f5f5f5ff;
border-color: black;
}
</style>
</head>
<body>
<div id="header">
<a id="logo" href="https://www.raylib.com"></a>
<div class="spinner" id='spinner'></div>
<div class="emscripten" id="status">Downloading...</div>
<span id='controls'>
<span><input type="button" value="🖵 FULLSCREEN" onclick="Module.requestFullscreen(false, false)"></span>
<span><input type="button" id="btn-audio" value="🔇 SUSPEND" onclick="toggleAudio()"></span>
</span>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
</div>
<div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</div>
<textarea id="output" rows="8"></textarea>
<script type='text/javascript' src="https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js/dist/FileSaver.min.js"> </script>
<script type='text/javascript'>
function saveFileFromMEMFSToDisk(memoryFSname, localFSname) // This can be called by C/C++ code
{
var isSafari = false; // Not supported, navigator.userAgent access is being restricted
//var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
var data = FS.readFile(memoryFSname);
var blob;
if (isSafari) blob = new Blob([data.buffer], { type: "application/octet-stream" });
else blob = new Blob([data.buffer], { type: "application/octet-binary" });
// NOTE: SaveAsDialog is a browser setting. For example, in Google Chrome,
// in Settings/Advanced/Downloads section you have a setting:
// 'Ask where to save each file before downloading' - which you can set true/false.
// If you enable this setting it would always ask you and bring the SaveAsDialog
saveAs(blob, localFSname);
}
</script>
<script type='text/javascript'>
var statusElement = document.querySelector('#status');
var progressElement = document.querySelector('#progress');
var spinnerElement = document.querySelector('#spinner');
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.querySelector('#output');
if (element) element.value = ''; // Clear browser cache
return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
},
canvas: (function() {
var canvas = document.querySelector('#canvas');
// As a default initial behavior, pop up an alert when webgl context is lost.
// To make your application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Module.setStatus.last.time < 30) return; // If this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = true;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.style.display = 'none';
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
},
//noInitialRun: true
};
Module.setStatus('Downloading...');
window.onerror = function() {
Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = function(text) { if (text) Module.printErr('[post-exception status] ' + text); };
};
</script>
<!-- REF: https://developers.google.com/web/updates/2018/11/web-audio-autoplay -->
<script type='text/javascript'>
var audioBtn = document.querySelector('#btn-audio');
// An array of all contexts to resume on the page
const audioContexList = [];
(function() {
// A proxy object to intercept AudioContexts and
// add them to the array for tracking and resuming later
self.AudioContext = new Proxy(self.AudioContext, {
construct(target, args) {
const result = new target(...args);
audioContexList.push(result);
if (result.state == "suspended") audioBtn.value = "🔈 RESUME";
return result;
}
});
})();
function toggleAudio() {
var resumed = false;
audioContexList.forEach(ctx => {
if (ctx.state == "suspended") { ctx.resume(); resumed = true; }
else if (ctx.state == "running") ctx.suspend();
});
if (resumed) audioBtn.value = "🔇 SUSPEND";
else audioBtn.value = "🔈 RESUME";
}
</script>
{{{ SCRIPT }}}
</body>
</html>
+3 -14
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
enum FP_EntityType
@@ -24,7 +24,6 @@ enum FP_EntityType
FP_EntityType_Smoochie,
FP_EntityType_Terry,
FP_EntityType_PhoneMessageProjectile,
FP_EntityType_Billboard,
FP_EntityType_Count,
};
@@ -35,7 +34,6 @@ enum FP_EntityTerryState
FP_EntityTerryState_RangeAttack,
FP_EntityTerryState_Run,
FP_EntityTerryState_Dash,
FP_EntityTerryState_DeadGhost,
};
enum FP_EntityMobSpawnerState
@@ -128,15 +126,6 @@ enum FP_EntityHeartState
FP_EntityHeartState_Idle,
};
enum FP_EntityBillboardState
{
FP_EntityBillboardState_Attack,
FP_EntityBillboardState_Dash,
FP_EntityBillboardState_Monkey,
FP_EntityBillboardState_RangeAttack,
FP_EntityBillboardState_Strafe,
};
struct FP_EntityRenderData
{
FP_Meters height;
+15 -61
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
static bool FP_Entity_IsBuildingForMobs(FP_GameEntity *entity)
@@ -39,20 +39,20 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
case FP_EntityTerryState_Attack: {
switch (direction) {
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_up; result.height.meters *= 1.5f; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_down; result.height.meters *= 1.6f; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_side; result.height.meters *= 1.5f; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_side; result.height.meters *= 1.5f; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_up; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_down; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_side; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_side; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
}
} break;
case FP_EntityTerryState_RangeAttack: {
switch (direction) {
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_phone_up; result.height.meters *= 1.25f; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_phone_down; result.height.meters *= 1.25f; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_phone_side; result.height.meters *= 1.25f; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_phone_side; result.height.meters *= 1.25f; break;
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_phone_up; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_attack_phone_down; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_attack_phone_side; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_phone_side; break;
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
}
} break;
@@ -76,10 +76,6 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
}
} break;
case FP_EntityTerryState_DeadGhost: {
result.anim_name = g_anim_names.terry_death; break;
} break;
}
} break;
@@ -129,7 +125,7 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
} break;
case FP_EntityType_MerchantPhoneCompany: {
result.height.meters = 5.f;
result.height.meters = 3.66f;
FP_EntityMerchantPhoneCompanyState state = DQN_CAST(FP_EntityMerchantPhoneCompanyState)raw_state;
switch (state) {
case FP_EntityMerchantPhoneCompanyState_Idle: result.anim_name = g_anim_names.merchant_phone_company; break;
@@ -201,8 +197,8 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
switch (direction) {
case FP_GameDirection_Up: result.anim_name = g_anim_names.catfish_attack_up; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.catfish_attack_down; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_attack_side; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_attack_side; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.catfish_attack_side; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.catfish_attack_side; break;
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
}
} break;
@@ -263,18 +259,6 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
result.anim_name = g_anim_names.portal_monk; break;
} break;
case FP_EntityType_Billboard: {
result.height.meters = 7.5f;
FP_EntityBillboardState state = DQN_CAST(FP_EntityBillboardState)raw_state;
switch (state) {
case FP_EntityBillboardState_Attack: result.anim_name = g_anim_names.map_billboard_attack; break;
case FP_EntityBillboardState_Dash: result.anim_name = g_anim_names.map_billboard_dash; break;
case FP_EntityBillboardState_Monkey: result.anim_name = g_anim_names.map_billboard_monkey; break;
case FP_EntityBillboardState_RangeAttack: result.anim_name = g_anim_names.map_billboard_range_attack; break;
case FP_EntityBillboardState_Strafe: result.anim_name = g_anim_names.map_billboard_strafe; break;
}
} break;
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
}
@@ -475,11 +459,11 @@ static FP_GameEntityHandle FP_Entity_CreateTerry(FP_Game *game, Dqn_V2 pos, DQN_
entity->local_hit_box_size = FP_Game_MetersToPixelsNx2(game->play, 0.5f, entity->sprite_height.meters * .6f);
entity->hp_cap = FP_DEFAULT_DAMAGE * 3;
entity->hp = entity->hp_cap;
entity->coins = 0;//1'000'000;
FP_Entity_AddDebugEditorFlags(game, result);
entity->flags |= FP_GameEntityFlag_NonTraversable;
entity->flags |= FP_GameEntityFlag_Attackable;
entity->flags |= FP_GameEntityFlag_CameraTracking;
entity->flags |= FP_GameEntityFlag_RecoversHP;
entity->terry_mobile_data_plan_cap = DQN_KILOBYTES(6);
entity->terry_mobile_data_plan = entity->terry_mobile_data_plan_cap;
entity->faction = FP_GameEntityFaction_Friendly;
@@ -649,12 +633,6 @@ static FP_GameEntityHandle FP_Entity_CreateHeart(FP_Game *game, Dqn_V2 pos, DQN_
FP_Entity_AddDebugEditorFlags(game, result);
entity->flags |= FP_GameEntityFlag_NonTraversable;
entity->flags |= FP_GameEntityFlag_Attackable;
entity->flags |= FP_GameEntityFlag_RecoversHP;
entity->hp_cap = FP_DEFAULT_DAMAGE * 16;
entity->hp = entity->hp_cap;
entity->faction = FP_GameEntityFaction_Friendly;
entity->hp_recover_every_n_ticks *= 4;
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.heart);
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index];
@@ -831,27 +809,3 @@ static FP_GameEntityHandle FP_Entity_CreateAirportTerryPlane(FP_Game *game, Dqn_
entity->base_acceleration_per_s.meters = 32.f;
return result;
}
static FP_GameEntityHandle FP_Entity_CreateBillboard(FP_Game *game, Dqn_V2 pos, FP_EntityBillboardState state, DQN_FMT_STRING_ANNOTATE char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
FP_GameEntity *entity = FP_Game_MakeEntityPointerFV(game, fmt, args);
FP_GameEntityHandle result = entity->handle;
va_end(args);
entity->action.state = state;
entity->action.next_state = state;
entity->type = FP_EntityType_Billboard;
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, entity->type, state, FP_GameDirection_Down);
entity->sprite_height = render_data.height;
uint64_t duration_ms = FP_GAME_ENTITY_ACTION_INFINITE_TIMER;
FP_Game_EntityActionReset(game, result, duration_ms, render_data.sprite);
entity->local_pos = pos;
FP_Entity_AddDebugEditorFlags(game, result);
entity->local_hit_box_offset = Dqn_V2_InitNx2(0, render_data.render_size.h * .1f);
entity->local_hit_box_size = Dqn_V2_InitNx2(render_data.render_size.w, render_data.render_size.h - (render_data.render_size.h * .4f));
return result;
}
+63 -69
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
#define FP_Game_MetersToPixelsNx1(game, val) ((val) * (game).meters_to_pixels)
@@ -30,29 +30,17 @@ struct FP_GameCameraM2x3
Dqn_M2x3 view_model;
};
static FP_GameCameraM2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera)
static Dqn_M2x3 FP_Game_CameraModelViewM2x3(FP_GameCamera camera, TELY_Platform *platform)
{
FP_GameCameraM2x3 result = {};
result.model_view = Dqn_M2x3_Identity();
result.view_model = Dqn_M2x3_Identity();
Dqn_V2 center_offset = camera.size * .5f;
Dqn_V2 rotate_origin = -camera.world_pos;
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Translate(rotate_origin));
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Rotate(camera.rotate_rads));
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Scale(camera.scale));
result.model_view = Dqn_M2x3_Mul(result.model_view, Dqn_M2x3_Translate(center_offset));
Dqn_V2 inverse_scale = Dqn_V2_InitNx1(1) / camera.scale;
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Translate(-center_offset));
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Scale(inverse_scale));
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Rotate(-camera.rotate_rads));
result.view_model = Dqn_M2x3_Mul(result.view_model, Dqn_M2x3_Translate(-rotate_origin));
#if 0
Dqn_M2x3 identity = Dqn_M2x3_Mul(result.model_view, result.view_model);
DQN_ASSERT(identity == Dqn_M2x3_Identity());
#endif
Dqn_M2x3 result = Dqn_M2x3_Identity();
if (platform) {
Dqn_V2 center_offset = Dqn_V2_InitV2I(platform->core.window_size) * .5f;
Dqn_V2 rotate_origin = -camera.world_pos - center_offset;
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(rotate_origin));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Rotate(camera.rotate_rads));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Scale(camera.scale));
result = Dqn_M2x3_Mul(result, Dqn_M2x3_Translate(center_offset));
}
return result;
}
@@ -222,7 +210,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
game->play.entity_free_list = game->play.entity_free_list->next;
result->next = nullptr;
} else {
if (game->play.entities.size > FP_GAME_ENTITY_HANDLE_INDEX_MAX)
if (game->play.entities.size >= (FP_GAME_ENTITY_HANDLE_INDEX_MAX + 1))
return result;
result = Dqn_VArray_Make(&game->play.entities, Dqn_ZeroMem_Yes);
@@ -238,15 +226,13 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
result->action.sprite_alpha = 1.f;
result->stamina_cap = 93;
result->hp_cap = DQN_CAST(uint32_t)(FP_DEFAULT_DAMAGE * .8f);
result->hp_cap = FP_DEFAULT_DAMAGE;
result->hp = result->hp_cap;
result->inventory.airports_base_price = 100;
result->inventory.churchs_base_price = 100;
result->inventory.kennels_base_price = 100;
result->inventory.clubs_base_price = 40;
result->base_attack = FP_DEFAULT_DAMAGE;
result->hp_recover_every_n_ticks = 12;
result->inventory.churchs_base_price = 50;
result->inventory.kennels_base_price = 50;
result->inventory.clubs_base_price = 50;
result->inventory.stamina_base_price = 10;
result->inventory.health_base_price = 10;
@@ -595,7 +581,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
Dqn_DSMap_MakeKeyU64(&astar_info, src_tile_u64).value->tile = src_tile;
// NOTE: Do the A* process =====================================================================
Dqn_usize last_successful_manhattan_dist = DQN_USIZE_MAX;
Dqn_usize last_successful_manhattan_dist = UINT64_MAX;
Dqn_V2I last_successful_tile = src_tile;
auto zone_astar_expand = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: A* expand"), FP_ProfileZone_FPUpdate_AStarExpand);
@@ -713,7 +699,7 @@ static Dqn_Slice<Dqn_V2I> FP_Game_AStarPathFind(FP_Game *game,
return result;
}
static Dqn_V2 FP_Game_CalcWaypointWorldPos(FP_Game *game, FP_GameEntityHandle entity_handle, FP_GameWaypoint const *waypoint)
static Dqn_V2 FP_Game_CalcWaypointWorldPos(FP_Game *game, FP_GameEntityHandle src_entity, FP_GameWaypoint const *waypoint)
{
Dqn_V2 result = {};
if (!game || !waypoint)
@@ -732,49 +718,43 @@ static Dqn_V2 FP_Game_CalcWaypointWorldPos(FP_Game *game, FP_GameEntityHandle en
case FP_GameWaypointType_ClosestSide: /*FALLTHRU*/
case FP_GameWaypointType_Side: {
// NOTE: Sweep entity with half the radius of the source entity
Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity_handle);
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
waypoint_hit_box.pos -= (entity_hit_box.size * .5f);
waypoint_hit_box.size += entity_hit_box.size;
Dqn_Rect src_rect = FP_Game_CalcEntityWorldHitBox(game, src_entity);
Dqn_Rect entity_rect = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
entity_rect.pos -= (src_rect.size * .5f);
entity_rect.size += src_rect.size;
Dqn_V2 side_pos_list[FP_GameDirection_Count] = {};
side_pos_list[FP_GameDirection_Up] = Dqn_V2_InitNx2(waypoint_hit_box.pos.x + waypoint_hit_box.size.w * .5f, waypoint_hit_box.pos.y - waypoint_hit_box.size.h * .1f);
side_pos_list[FP_GameDirection_Down] = Dqn_V2_InitNx2(waypoint_hit_box.pos.x + waypoint_hit_box.size.w * .5f, waypoint_hit_box.pos.y + waypoint_hit_box.size.h + waypoint_hit_box.size.h * .1f);
side_pos_list[FP_GameDirection_Left] = Dqn_V2_InitNx2(waypoint_hit_box.pos.x - waypoint_hit_box.size.w * .1f, waypoint_hit_box.pos.y + waypoint_hit_box.size.h * .5f);
side_pos_list[FP_GameDirection_Right] = Dqn_V2_InitNx2(waypoint_hit_box.pos.x + waypoint_hit_box.size.w + waypoint_hit_box.size.w * .1f, waypoint_hit_box.pos.y + waypoint_hit_box.size.h * .5f);
side_pos_list[FP_GameDirection_Up] = Dqn_V2_InitNx2(entity_rect.pos.x + entity_rect.size.w * .5f, entity_rect.pos.y - entity_rect.size.h * .1f);
side_pos_list[FP_GameDirection_Down] = Dqn_V2_InitNx2(entity_rect.pos.x + entity_rect.size.w * .5f, entity_rect.pos.y + entity_rect.size.h + entity_rect.size.h * .1f);
side_pos_list[FP_GameDirection_Left] = Dqn_V2_InitNx2(entity_rect.pos.x - entity_rect.size.w * .1f, entity_rect.pos.y + entity_rect.size.h * .5f);
side_pos_list[FP_GameDirection_Right] = Dqn_V2_InitNx2(entity_rect.pos.x + entity_rect.size.w + entity_rect.size.w * .1f, entity_rect.pos.y + entity_rect.size.h * .5f);
if (waypoint->type == FP_GameWaypointType_Side) {
result = side_pos_list[waypoint->type_direction];
} else {
Dqn_f32 best_dist = DQN_F32_MAX;
for (Dqn_V2 target_pos : side_pos_list) {
Dqn_f32 dist_squared = Dqn_V2_LengthSq_V2x2(entity_hit_box.pos, target_pos);
Dqn_f32 dist_squared = Dqn_V2_LengthSq_V2x2(src_rect.pos, target_pos);
if (dist_squared < best_dist) {
best_dist = dist_squared;
result = target_pos;
}
}
Dqn_f32 curr_dist_to_entity = Dqn_V2_LengthSq_V2x2(entity_rect.pos, src_rect.pos);
if (curr_dist_to_entity < best_dist) {
// NOTE: We are already closer to the entity than the closest calculated side,
// we assume we're at the entity already.
result = FP_Game_CalcEntityWorldPos(game, src_entity);
}
}
} break;
case FP_GameWaypointType_Queue: {
Dqn_ArrayFindResult<FP_GameEntityHandle> find_result = Dqn_FArray_Find<FP_GameEntityHandle>(&waypoint_entity->building_queue, entity_handle);
Dqn_usize index_in_queue = find_result.index;
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
Dqn_V2 queue_starting_p = {};
if (waypoint_entity->type == FP_EntityType_ClubTerry || waypoint_entity->type == FP_EntityType_ChurchTerry) {
queue_starting_p = Dqn_Rect_InterpolatedPoint(waypoint_hit_box, Dqn_V2_InitNx2(0.5f, 1.1f));
} else {
queue_starting_p = Dqn_Rect_InterpolatedPoint(waypoint_hit_box, Dqn_V2_InitNx2(1.f, 1.1f));
}
Dqn_f32 queue_spacing = FP_Game_MetersToPixelsNx1(game->play, 1.f);
result = Dqn_V2_InitNx2(queue_starting_p.x - (queue_spacing * index_in_queue), queue_starting_p.y);
case FP_GameWaypointType_Offset: {
result = FP_Game_CalcEntityWorldPos(game, waypoint_entity->handle) + waypoint->offset;
} break;
}
result += waypoint->offset;
return result;
}
@@ -909,26 +889,40 @@ static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity,
case FP_EntityType_MerchantTerry:
case FP_EntityType_PhoneMessageProjectile:
case FP_EntityType_Count: break;
case FP_EntityType_AirportTerryPlane:
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
case FP_EntityType_Billboard: break;
}
// NOTE: If no returns are hit above we proceed with the state change
entity->action.next_state = desired_state;
}
static void FP_GameRenderScanlines(TELY_Renderer *renderer,
Dqn_f32 scanline_gap,
Dqn_f32 scanline_thickness,
Dqn_V2 screen_size)
static void FP_GameRenderScanlines(TELY_Renderer *renderer, Dqn_f32 scanline_gap, Dqn_f32 scanline_thickness,
Dqn_V2 screen_size, Dqn_V2 camera_offset)
{
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); };
Dqn_f32 scanline_interval = scanline_gap + scanline_thickness;
for (Dqn_f32 y = 0; y < screen_size.h; y += scanline_interval) {
Dqn_f32 y_offset = fmodf(camera_offset.y, scanline_interval);
for (Dqn_f32 y = -y_offset; y < screen_size.h; y += scanline_interval)
{
Dqn_V2 start = Dqn_V2_InitNx2(0, y);
Dqn_V2 end = Dqn_V2_InitNx2(screen_size.w, y);
TELY_Render_LineColourV4(renderer, start, end, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, 0.1f), scanline_thickness);
}
}
static void FP_GameRenderCameraFollowScanlines(TELY_Renderer *renderer,
Dqn_V2 screen_size,
Dqn_V2 camera_offset,
Dqn_f32 scanline_gap,
Dqn_f32 scanline_thickness)
{
Dqn_f32 y_offset = camera_offset.y;
// Adjust starting y to be more negative
Dqn_f32 starting_y = -screen_size.h - 150 - y_offset;
for (Dqn_f32 y = starting_y; y < screen_size.h; y += scanline_gap + scanline_thickness) {
Dqn_V2 start = Dqn_V2_InitNx2(camera_offset.x, y + camera_offset.y);
Dqn_V2 end = Dqn_V2_InitNx2(screen_size.w + camera_offset.x, y + camera_offset.y);
TELY_Render_LineColourV4(renderer, start, end, TELY_Colour_V4Alpha(TELY_COLOUR_BLACK_V4, 0.1f), scanline_thickness);
}
}
+30 -71
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
enum FP_GameEntityFlag
@@ -17,13 +17,13 @@ enum FP_GameEntityFlag
FP_GameEntityFlag_Attackable = 1 << 9,
FP_GameEntityFlag_RespondsToBuildings = 1 << 10,
FP_GameEntityFlag_OccupiedInBuilding = 1 << 11,
FP_GameEntityFlag_CameraTracking = 1 << 12,
FP_GameEntityFlag_BuildZone = 1 << 13,
FP_GameEntityFlag_TTL = 1 << 14,
FP_GameEntityFlag_Friendly = 1 << 15,
FP_GameEntityFlag_Foe = 1 << 16,
FP_GameEntityFlag_NoClip = 1 << 17,
FP_GameEntityFlag_RecoversHP = 1 << 18,
FP_GameEntityFlag_PointOfInterestHeart = 1 << 12,
FP_GameEntityFlag_CameraTracking = 1 << 13,
FP_GameEntityFlag_BuildZone = 1 << 14,
FP_GameEntityFlag_TTL = 1 << 15,
FP_GameEntityFlag_Friendly = 1 << 16,
FP_GameEntityFlag_Foe = 1 << 17,
FP_GameEntityFlag_NoClip = 1 << 18,
};
enum FP_GameShapeType
@@ -45,16 +45,15 @@ struct FP_GameShape
TELY_RenderShapeMode render_mode;
};
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT = 16;
const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MASK = DQN_USIZE_MAX >> FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK = ~FP_GAME_ENTITY_HANDLE_INDEX_MASK;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = (sizeof(Dqn_usize) * 8) - FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MASK = 0xFFFF'0000'0000'0000;
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = 48;
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MASK = 0x0000'FFFF'FFFF'FFFF;
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK - 1;
struct FP_GameEntityHandle
{
Dqn_usize id;
uint64_t id;
};
enum FP_GameWaypointArrive
@@ -77,7 +76,7 @@ enum FP_GameWaypointType
FP_GameWaypointType_At, // Move to the specified entity
FP_GameWaypointType_Side, // Move to the side of the entity specified by the direction
FP_GameWaypointType_ClosestSide, // Move to the side of the entity closest to us
FP_GameWaypointType_Queue, // Queue at the target entity
FP_GameWaypointType_Offset, // Move to the designed offset from the entity
};
enum FP_GameDirection
@@ -89,8 +88,14 @@ enum FP_GameDirection
FP_GameDirection_Count,
};
enum FP_GameWaypointFlag
{
FP_GameWaypointFlag_NonInterruptible = 1 << 0,
};
struct FP_GameWaypoint
{
uint32_t flags;
FP_GameWaypointType type;
FP_GameDirection type_direction; // Used if type is `FP_GameWaypointType_Side`
FP_GameEntityHandle entity; // The entity to move to
@@ -215,29 +220,19 @@ struct FP_GameEntity
Dqn_usize terry_mobile_data_plan;
Dqn_usize terry_mobile_data_plan_cap;
Dqn_usize clinger_next_dash_timestamp;
bool smoochie_has_teleported;
Dqn_usize smoochie_teleport_timestamp;
Dqn_usize coins;
FP_GameInventory inventory;
uint32_t hp;
uint32_t hp_cap;
uint32_t stamina;
uint32_t stamina_cap;
uint32_t hp_recover_every_n_ticks;
uint32_t base_attack;
Dqn_f32 hp;
uint16_t hp_cap;
Dqn_f32 stamina;
uint16_t stamina_cap;
bool is_drunk;
bool converted_faction;
FP_GameEntityFaction faction;
uint32_t count_of_entities_targetting_sides[FP_GameDirection_Count];
FP_GameEntityHandle carried_monkey;
Dqn_FArray<FP_GameEntityHandle, 3> building_queue;
uint64_t building_queue_next_sort_timestamp_ms;
FP_GameEntityHandle queued_at_building;
};
struct FP_GameEntityIterator
@@ -255,7 +250,6 @@ struct FP_GameEntityIterator
struct FP_GameCamera
{
Dqn_V2 size;
Dqn_V2 world_pos;
Dqn_f32 rotate_rads;
Dqn_V2 scale;
@@ -263,21 +257,9 @@ struct FP_GameCamera
enum FP_GameAudio
{
FP_GameAudio_TestAudio,
FP_GameAudio_TerryHit,
FP_GameAudio_Smooch,
FP_GameAudio_Woosh,
FP_GameAudio_Ching,
FP_GameAudio_Church,
FP_GameAudio_Plane,
FP_GameAudio_Club,
FP_GameAudio_Dog,
FP_GameAudio_MerchantTerry,
FP_GameAudio_MerchantGhost,
FP_GameAudio_MerchantGym,
FP_GameAudio_MerchantPhone,
FP_GameAudio_Message,
FP_GameAudio_Monkey,
FP_GameAudio_PortalDestroy,
FP_GameAudio_Count,
};
@@ -292,9 +274,7 @@ enum FP_GameState
{
FP_GameState_IntroScreen,
FP_GameState_Play,
FP_GameState_Pause,
FP_GameState_WinGame,
FP_GameState_LoseGame,
};
struct FP_GamePlay
@@ -314,7 +294,6 @@ struct FP_GamePlay
FP_GameRenderSprite player_merchant_menu;
uint64_t player_trigger_purchase_upgrade_timestamp;
uint64_t player_trigger_purchase_building_timestamp;
FP_GameEntityHandle heart;
FP_GameEntityHandle merchant_terry;
FP_GameEntityHandle merchant_graveyard;
@@ -335,7 +314,6 @@ struct FP_GamePlay
Dqn_PCG32 rng;
bool debug_ui;
bool debug_hide_hud;
bool god_mode;
FP_GameInGameMenu in_game_menu;
bool build_mode_can_place_building;
@@ -352,25 +330,6 @@ struct FP_GamePlay
FP_GameState state;
};
struct FP_GameKeyBind
{
TELY_PlatformInputScanCode scan_code;
TELY_PlatformInputGamepadKey gamepad_key;
};
struct FP_GameControls
{
FP_GameKeyBind up;
FP_GameKeyBind down;
FP_GameKeyBind left;
FP_GameKeyBind right;
FP_GameKeyBind attack;
FP_GameKeyBind range_attack;
FP_GameKeyBind build_mode;
FP_GameKeyBind strafe;
FP_GameKeyBind dash;
};
struct FP_Game
{
TELY_AssetFontHandle inter_regular_font_large;
@@ -379,12 +338,12 @@ struct FP_Game
TELY_AssetFontHandle jetbrains_mono_font;
TELY_AssetFontHandle talkco_font;
TELY_AssetFontHandle talkco_font_large;
TELY_AssetFontHandle talkco_font_xlarge;
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
TELY_AssetSpriteSheet hero_sprite_sheet;
TELY_AssetSpriteSheet atlas_sprite_sheet;
TELY_RFui rfui;
FP_GamePlay play;
FP_GameControls controls;
};
struct FP_GameAStarNode
+3 -3
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
void FP_UnitTests(TELY_Platform *platform)
+1 -1
View File
@@ -58,7 +58,7 @@ static Dqn_String8 SpriteAnimNameFromFilePath(Dqn_String8 path)
int main(int argc, char const *argv[])
{
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
Dqn_Library_Init();
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
if (argc != 4) {
+6 -13
View File
@@ -1,6 +1,6 @@
#if defined(_CLANGD)
#pragma once
#include "feely_pona_unity.h"
#if defined(__clang__)
#pragma once
#include "feely_pona_unity.h"
#endif
template <typename T>
@@ -115,21 +115,14 @@ FP_SentinelListLink<T> *FP_SentinelList_Erase(FP_SentinelList<T> *list, FP_Senti
}
template <typename T>
void FP_SentinelList_Clear(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
void FP_SentinelList_Deinit(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
{
if (!list || !pool)
return;
for (FP_SentinelListLink<T> *link = nullptr; FP_SentinelList_Iterate(list, &link); )
link = FP_SentinelList_Erase(list, link, pool);
}
template <typename T>
void FP_SentinelList_Deinit(FP_SentinelList<T> *list, TELY_ChunkPool *pool)
{
if (!list || !pool)
return;
FP_SentinelList_Clear(list, pool);
TELY_ChunkPool_Dealloc(pool, list->sentinel);
*list = {};
}
@@ -138,8 +131,8 @@ template <typename T>
FP_SentinelListLink<T> *FP_SentinelList_Find(FP_SentinelList<T> const *list, T const &find)
{
FP_SentinelListLink<T> *result = nullptr;
for (FP_SentinelListLink<T> *link = nullptr;
!result && FP_SentinelList_Iterate<T>(DQN_CAST(FP_SentinelList<T> *)list, &link); ) {
for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr;
!result && FP_SentinelList_Iterate<FP_GameEntityHandle>(DQN_CAST(FP_SentinelList<T> *)list, &link); ) {
if (link->data == find)
result = link;
}
-2
View File
@@ -40,7 +40,6 @@
// NOTE: TELY ======================================================================================
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
#include "External/tely/tely_profile.h"
#include "External/tely/tely_platform_input.h"
@@ -71,4 +70,3 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
#include "feely_pona_entity_create.cpp"
#include "feely_pona_misc.cpp"
#include "feely_pona.cpp"
DQN_MSVC_WARNING_POP
-1
View File
@@ -1 +0,0 @@
#include "feely_pona_unity_nodll.h"
-102
View File
@@ -1,102 +0,0 @@
// =================================================================================================
// NOTE(doyle): Work-around for clangd to correctly resolve symbols in unity
// builds by providing symbol definition and prototypes by including this
// mega-header in all files and using the "#pragma once" directive to
// avoid multiple defined symbols when compiling the unity build itself.
//
// See: https://www.frogtoss.com/labs/clangd-with-unity-builds.html
#pragma once
// NOTE: DQN =======================================================================================
// NOTE: C-strings declared in a ternary cause global-buffer-overflow in
// MSVC2022.
// stb_sprintf assumes c-string literals are 4 byte aligned which is always
// true, however, reading past the end of a string whose size is not a multiple
// of 4 is UB causing ASAN to complain.
#if defined(_MSC_VER) && !defined(__clang__)
#define STBSP__ASAN __declspec(no_sanitize_address)
#endif
#define DQN_ASAN_POISON 0
#define DQN_ASAN_VET_POISON 1
#define DQN_ONLY_RECT
#define DQN_ONLY_V2
#define DQN_ONLY_V3
#define DQN_ONLY_V4
#define DQN_ONLY_WIN
#define DQN_ONLY_FARRAY
#define DQN_ONLY_PROFILER
#define DQN_ONLY_SLICE
#define DQN_ONLY_LIST
#define DQN_ONLY_VARRAY
#define DQN_ONLY_DSMAP
#define DQN_ONLY_FS
#define _CRT_SECURE_NO_WARNINGS
#define DQN_IMPLEMENTATION
#include "External/tely/External/dqn/dqn.h"
// NOTE: STB Headers ===============================================================================
DQN_GCC_WARNING_PUSH
DQN_GCC_WARNING_DISABLE(-Wunused-function)
#include "External/tely/External/stb/stb_image.h"
DQN_GCC_WARNING_POP
// =================================================================================================
#include "External/tely/External/raylib/raylib.h"
#include "External/tely/External/raylib/rlgl.h"
#include "External/tely/External/raylib/external/glfw/include/GLFW/glfw3.h"
// NOTE: TELY ======================================================================================
DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
DQN_GCC_WARNING_PUSH
DQN_GCC_WARNING_DISABLE(-Wunused-function)
#include "External/tely/tely_profile.h"
#include "External/tely/tely_platform_input.h"
#include "External/tely/tely_tools.h"
#include "External/tely/tely_asset.h"
#include "External/tely/tely_colour.h"
#include "External/tely/tely_render.h"
#include "External/tely/tely_audio.h"
#include "External/tely/tely_platform.h"
#include "External/tely/tely_ui.h"
#include "External/tely/tely_rfui.h"
#include "External/tely/tely_tools.cpp"
#include "External/tely/tely_asset.cpp"
#include "External/tely/tely_audio.cpp"
#include "External/tely/tely_render.cpp"
#include "External/tely/tely_platform_input.cpp"
#include "External/tely/tely_ui.cpp"
#include "External/tely/tely_rfui.cpp"
// NOTE: feely_pona ================================================================================
#include "feely_pona.h"
#include "feely_pona_stdlib.h"
#include "feely_pona_entity.h"
#include "feely_pona_game.h"
#include "feely_pona_game.cpp"
#include "feely_pona_entity_create.cpp"
#include "feely_pona_misc.cpp"
#include "feely_pona.cpp"
DQN_MSVC_WARNING_POP
DQN_GCC_WARNING_POP
#if defined(DQN_PLATFORM_EMSCRIPTEN)
#include <emscripten.h>
#endif
// NOTE: TELY_Platform =============================================================================
#define TELY_PLATFORM_NO_DLL
#include "External/tely/tely_platform.cpp"
#include "External/tely/tely_platform_raylib.cpp"
BIN
View File
Binary file not shown.