Compare commits
11 Commits
dca59a1241
...
billboards
| Author | SHA1 | Date | |
|---|---|---|---|
| 629c9d9b27 | |||
| ba9014756b | |||
| 2d509d15d3 | |||
| d03d4b285d | |||
| 84314221b8 | |||
| 3a26bbf84f | |||
| a09d0896d6 | |||
| 83cac2afa1 | |||
| 65604f0a93 | |||
| 2c28850150 | |||
| 173a487d22 |
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
+649
@@ -0,0 +1,649 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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 */
|
||||||
Vendored
+91
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
Vendored
+1
-1
Submodule External/tely updated: 29843741bf...135fd17839
+1
-1
@@ -10,4 +10,4 @@ if not exist "%sprite_packer%" (
|
|||||||
exit /B 1
|
exit /B 1
|
||||||
)
|
)
|
||||||
|
|
||||||
%sprite_packer% 6144x6144 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
|
%sprite_packer% 5100x5100 %script_dir%\Data\Textures\sprite_spec.txt %script_dir%\Data\Textures\atlas || exit /b 1
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@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
|
||||||
+150
-116
@@ -220,6 +220,7 @@ static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle,
|
|||||||
case FP_EntityType_AirportTerryPlane:
|
case FP_EntityType_AirportTerryPlane:
|
||||||
case FP_EntityType_MobSpawner:
|
case FP_EntityType_MobSpawner:
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity_collides_with_collider)
|
if (!entity_collides_with_collider)
|
||||||
@@ -325,7 +326,6 @@ static void FP_PlayReset(FP_Game *game, TELY_Platform *platform)
|
|||||||
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale;
|
||||||
|
|
||||||
entity->local_hit_box_size = sprite_rect_scaled;
|
entity->local_hit_box_size = sprite_rect_scaled;
|
||||||
FP_Entity_AddDebugEditorFlags(game, entity->handle);
|
|
||||||
FP_Game_EntityActionReset(game, entity->handle, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, render_data.sprite);
|
FP_Game_EntityActionReset(game, entity->handle, FP_GAME_ENTITY_ACTION_INFINITE_TIMER, render_data.sprite);
|
||||||
play->map = entity;
|
play->map = entity;
|
||||||
}
|
}
|
||||||
@@ -472,6 +472,13 @@ static void FP_PlayReset(FP_Game *game, TELY_Platform *platform)
|
|||||||
game->play.heart = FP_Entity_CreateHeart(game, base_mid_p, "Heart");
|
game->play.heart = FP_Entity_CreateHeart(game, base_mid_p, "Heart");
|
||||||
play->tile_size = 37;
|
play->tile_size = 37;
|
||||||
|
|
||||||
|
// NOTE: Create billboads ======================================================================
|
||||||
|
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2( 511, 451), FP_EntityBillboardState_Dash, "Dash Billboard");
|
||||||
|
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2( 511, -451), FP_EntityBillboardState_Attack, "Attack Billboard");
|
||||||
|
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2(2047, -720), FP_EntityBillboardState_RangeAttack, "Range Attack Billboard");
|
||||||
|
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2(-936, -500), FP_EntityBillboardState_Monkey, "Monkey Billboard");
|
||||||
|
FP_Entity_CreateBillboard(game, Dqn_V2_InitNx2(1898, 771), FP_EntityBillboardState_Strafe, "Strafe Billboard");
|
||||||
|
|
||||||
// NOTE: Camera ================================================================================
|
// NOTE: Camera ================================================================================
|
||||||
play->camera.world_pos = base_mid_p - Dqn_V2_InitV2I(platform->core.window_size * .5f);
|
play->camera.world_pos = base_mid_p - Dqn_V2_InitV2I(platform->core.window_size * .5f);
|
||||||
play->camera.scale = Dqn_V2_InitNx1(1);
|
play->camera.scale = Dqn_V2_InitNx1(1);
|
||||||
@@ -505,69 +512,44 @@ void TELY_DLL_Init(void *user_data)
|
|||||||
FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes);
|
FP_Game *game = Dqn_Arena_New(&platform->arena, FP_Game, Dqn_ZeroMem_Yes);
|
||||||
|
|
||||||
uint16_t font_size = 18;
|
uint16_t font_size = 18;
|
||||||
game->inter_regular_font_large = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size * 5.f));
|
game->inter_regular_font_large = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Fonts/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size * 5.f));
|
||||||
game->inter_regular_font = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size));
|
game->inter_regular_font = platform->func_load_font(assets, DQN_STRING8("Inter (Regular)"), DQN_STRING8("Data/Fonts/Inter-Regular.otf"), DQN_CAST(uint16_t)(font_size));
|
||||||
game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Inter-Italic.otf"), font_size);
|
game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Fonts/Inter-Italic.otf"), font_size);
|
||||||
game->jetbrains_mono_font = platform->func_load_font(assets, DQN_STRING8("JetBrains Mono NL (Regular)"), DQN_STRING8("Data/JetBrainsMonoNL-Regular.ttf"), font_size);
|
game->jetbrains_mono_font = platform->func_load_font(assets, DQN_STRING8("JetBrains Mono NL (Regular)"), DQN_STRING8("Data/Fonts/JetBrainsMonoNL-Regular.ttf"), font_size);
|
||||||
game->talkco_font = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Talkco.otf"), font_size);
|
game->talkco_font = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Fonts/Talkco.otf"), font_size);
|
||||||
game->talkco_font_large = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Talkco.otf"), DQN_CAST(uint16_t)(font_size * 1.5f));
|
game->talkco_font_large = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Fonts/Talkco.otf"), DQN_CAST(uint16_t)(font_size * 1.5f));
|
||||||
game->audio[FP_GameAudio_TestAudio] = platform->func_load_audio(assets, DQN_STRING8("Test Audio"), DQN_STRING8("Data/Audio/Purrple Cat - Moonwinds.qoa"));
|
game->talkco_font_xlarge = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Fonts/Talkco.otf"), DQN_CAST(uint16_t)(font_size * 2.f));
|
||||||
game->audio[FP_GameAudio_TerryHit] = platform->func_load_audio(assets, DQN_STRING8("Terry Hit"), DQN_STRING8("Data/Audio/terry_hit.ogg"));
|
game->audio[FP_GameAudio_TerryHit] = platform->func_load_audio(assets, DQN_STRING8("Terry Hit"), DQN_STRING8("Data/Audio/terry_hit.ogg"));
|
||||||
game->audio[FP_GameAudio_Smooch] = platform->func_load_audio(assets, DQN_STRING8("Smooch"), DQN_STRING8("Data/Audio/smooch.mp3"));
|
|
||||||
game->audio[FP_GameAudio_Woosh] = platform->func_load_audio(assets, DQN_STRING8("Woosh"), DQN_STRING8("Data/Audio/woosh.ogg"));
|
|
||||||
game->audio[FP_GameAudio_Ching] = platform->func_load_audio(assets, DQN_STRING8("Ching"), DQN_STRING8("Data/Audio/ching.ogg"));
|
game->audio[FP_GameAudio_Ching] = platform->func_load_audio(assets, DQN_STRING8("Ching"), DQN_STRING8("Data/Audio/ching.ogg"));
|
||||||
game->audio[FP_GameAudio_Church] = platform->func_load_audio(assets, DQN_STRING8("Church"), DQN_STRING8("Data/Audio/church.ogg"));
|
game->audio[FP_GameAudio_Church] = platform->func_load_audio(assets, DQN_STRING8("Church"), DQN_STRING8("Data/Audio/church.ogg"));
|
||||||
game->audio[FP_GameAudio_Plane] = platform->func_load_audio(assets, DQN_STRING8("Plane"), DQN_STRING8("Data/Audio/airport.ogg"));
|
|
||||||
game->audio[FP_GameAudio_Club] = platform->func_load_audio(assets, DQN_STRING8("Club"), DQN_STRING8("Data/Audio/club_terry.ogg"));
|
game->audio[FP_GameAudio_Club] = platform->func_load_audio(assets, DQN_STRING8("Club"), DQN_STRING8("Data/Audio/club_terry.ogg"));
|
||||||
game->audio[FP_GameAudio_Dog] = platform->func_load_audio(assets, DQN_STRING8("Dog"), DQN_STRING8("Data/Audio/dog.ogg"));
|
game->audio[FP_GameAudio_Dog] = platform->func_load_audio(assets, DQN_STRING8("Dog"), DQN_STRING8("Data/Audio/dog.ogg"));
|
||||||
game->audio[FP_GameAudio_MerchantTerry] = platform->func_load_audio(assets, DQN_STRING8("Door"), DQN_STRING8("Data/Audio/merchant_terry.ogg"));
|
|
||||||
game->audio[FP_GameAudio_MerchantGhost] = platform->func_load_audio(assets, DQN_STRING8("Ghost"), DQN_STRING8("Data/Audio/merchant_ghost.ogg"));
|
game->audio[FP_GameAudio_MerchantGhost] = platform->func_load_audio(assets, DQN_STRING8("Ghost"), DQN_STRING8("Data/Audio/merchant_ghost.ogg"));
|
||||||
game->audio[FP_GameAudio_MerchantGym] = platform->func_load_audio(assets, DQN_STRING8("Gym"), DQN_STRING8("Data/Audio/merchant_gym.ogg"));
|
game->audio[FP_GameAudio_MerchantGym] = platform->func_load_audio(assets, DQN_STRING8("Gym"), DQN_STRING8("Data/Audio/merchant_gym.ogg"));
|
||||||
game->audio[FP_GameAudio_MerchantPhone] = platform->func_load_audio(assets, DQN_STRING8("Phone"), DQN_STRING8("Data/Audio/merchant_tech.ogg"));
|
game->audio[FP_GameAudio_MerchantPhone] = platform->func_load_audio(assets, DQN_STRING8("Phone"), DQN_STRING8("Data/Audio/merchant_tech.ogg"));
|
||||||
|
game->audio[FP_GameAudio_MerchantTerry] = platform->func_load_audio(assets, DQN_STRING8("Door"), DQN_STRING8("Data/Audio/merchant_terry.ogg"));
|
||||||
game->audio[FP_GameAudio_Message] = platform->func_load_audio(assets, DQN_STRING8("Message"), DQN_STRING8("Data/Audio/message.ogg"));
|
game->audio[FP_GameAudio_Message] = platform->func_load_audio(assets, DQN_STRING8("Message"), DQN_STRING8("Data/Audio/message.ogg"));
|
||||||
game->audio[FP_GameAudio_Monkey] = platform->func_load_audio(assets, DQN_STRING8("Monkey"), DQN_STRING8("Data/Audio/monkey.ogg"));
|
game->audio[FP_GameAudio_Monkey] = platform->func_load_audio(assets, DQN_STRING8("Monkey"), DQN_STRING8("Data/Audio/monkey.ogg"));
|
||||||
|
game->audio[FP_GameAudio_Plane] = platform->func_load_audio(assets, DQN_STRING8("Plane"), DQN_STRING8("Data/Audio/airport.ogg"));
|
||||||
game->audio[FP_GameAudio_PortalDestroy] = platform->func_load_audio(assets, DQN_STRING8("Portal Destroy"), DQN_STRING8("Data/Audio/portal_destroy.ogg"));
|
game->audio[FP_GameAudio_PortalDestroy] = platform->func_load_audio(assets, DQN_STRING8("Portal Destroy"), DQN_STRING8("Data/Audio/portal_destroy.ogg"));
|
||||||
|
game->audio[FP_GameAudio_Smooch] = platform->func_load_audio(assets, DQN_STRING8("Smooch"), DQN_STRING8("Data/Audio/smooch.ogg"));
|
||||||
platform->user_data = game;
|
game->audio[FP_GameAudio_Woosh] = platform->func_load_audio(assets, DQN_STRING8("Woosh"), DQN_STRING8("Data/Audio/woosh.ogg"));
|
||||||
{
|
|
||||||
TELY_AssetSpriteSheet *sheet = &game->hero_sprite_sheet;
|
|
||||||
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
|
||||||
Dqn_String8 sheet_path = Dqn_FsPath_ConvertF(scratch.arena, "%.*s/adventurer-v1.5-sheet.png", DQN_STRING_FMT(assets->textures_dir));
|
|
||||||
sheet->tex_handle = platform->func_load_texture(assets, DQN_STRING8("Hero"), sheet_path);
|
|
||||||
sheet->sprite_count = 109;
|
|
||||||
sheet->sprites_per_row = 7;
|
|
||||||
sheet->sprite_size = Dqn_V2I_InitNx2(50, 37);
|
|
||||||
|
|
||||||
TELY_AssetSpriteAnimation hero_anims[] = {
|
|
||||||
{DQN_STRING8("Everything"), /*index*/ 0, /*count*/ sheet->sprite_count, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Idle"), /*index*/ 0, /*count*/ 3, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 4.f)},
|
|
||||||
{DQN_STRING8("Run"), /*index*/ 8, /*count*/ 6, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 8.f)},
|
|
||||||
{DQN_STRING8("Jump"), /*index*/ 14, /*count*/ 10, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Floor slide"), /*index*/ 24, /*count*/ 5, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Unknown"), /*index*/ 29, /*count*/ 9, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Attack A"), /*index*/ 42, /*count*/ 7, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Attack B"), /*index*/ 49, /*count*/ 4, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 8.f)},
|
|
||||||
{DQN_STRING8("Attack C"), /*index*/ 53, /*count*/ 6, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Hurt A"), /*index*/ 59, /*count*/ 5, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Hurt B"), /*index*/ 64, /*count*/ 5, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Unsheath sword"), /*index*/ 69, /*count*/ 4, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Sheath sword"), /*index*/ 73, /*count*/ 4, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Air drift"), /*index*/ 77, /*count*/ 2, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Air drop"), /*index*/ 79, /*count*/ 2, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Ladder climb"), /*index*/ 81, /*count*/ 4, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Chi push"), /*index*/ 85, /*count*/ 8, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Leap slice A"), /*index*/ 93, /*count*/ 7, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Leap slice B"), /*index*/ 100, /*count*/ 3, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
{DQN_STRING8("Leap slice C"), /*index*/ 103, /*count*/ 6, /*ms_per_frame*/ DQN_CAST(uint32_t)(1000.f / 12.f)},
|
|
||||||
};
|
|
||||||
|
|
||||||
game->hero_sprite_anims = Dqn_Slice_Alloc<TELY_AssetSpriteAnimation>(&platform->arena, DQN_ARRAY_UCOUNT(hero_anims), Dqn_ZeroMem_No);
|
|
||||||
DQN_MEMCPY(game->hero_sprite_anims.data, &hero_anims, sizeof(hero_anims[0]) * DQN_ARRAY_UCOUNT(hero_anims));
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Load sprite sheets ====================================================================
|
// NOTE: Load sprite sheets ====================================================================
|
||||||
|
platform->user_data = game;
|
||||||
game->atlas_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("atlas"));
|
game->atlas_sprite_sheet = FP_LoadSpriteSheetFromSpec(platform, assets, &platform->arena, DQN_STRING8("atlas"));
|
||||||
FP_PlayReset(game, platform);
|
FP_PlayReset(game, platform);
|
||||||
|
|
||||||
|
FP_GameControls *controls = &game->controls;
|
||||||
|
controls->up.scan_code = TELY_PlatformInputScanCode_W;
|
||||||
|
controls->down.scan_code = TELY_PlatformInputScanCode_S;
|
||||||
|
controls->left.scan_code = TELY_PlatformInputScanCode_A;
|
||||||
|
controls->right.scan_code = TELY_PlatformInputScanCode_D;
|
||||||
|
controls->attack.scan_code = TELY_PlatformInputScanCode_J;
|
||||||
|
controls->range_attack.scan_code = TELY_PlatformInputScanCode_K;
|
||||||
|
controls->build_mode.scan_code = TELY_PlatformInputScanCode_H;
|
||||||
|
controls->strafe.scan_code = TELY_PlatformInputScanCode_L;
|
||||||
|
controls->dash.scan_code = TELY_PlatformInputScanCode_N;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FP_GetClosestPortalMonkeyResult
|
struct FP_GetClosestPortalMonkeyResult
|
||||||
@@ -638,6 +620,8 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
bool const action_has_finished = !entering_new_state && game->play.clock_ms >= action->end_at_clock_ms;
|
bool const action_has_finished = !entering_new_state && game->play.clock_ms >= action->end_at_clock_ms;
|
||||||
action->state = action->next_state;
|
action->state = action->next_state;
|
||||||
|
|
||||||
|
FP_GameControls const *controls = &game->controls;
|
||||||
|
|
||||||
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, entity->type, entity->action.state, entity->direction);
|
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, entity->type, entity->action.state, entity->direction);
|
||||||
switch (entity->type) {
|
switch (entity->type) {
|
||||||
case FP_EntityType_Terry: {
|
case FP_EntityType_Terry: {
|
||||||
@@ -672,7 +656,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
// NOTE: Check if we are nearby a monkey and picking it up
|
// NOTE: Check if we are nearby a monkey and picking it up
|
||||||
FP_GetClosestPortalMonkeyResult closest_monkey = FP_GetClosestPortalMonkey(game, entity->handle);
|
FP_GetClosestPortalMonkeyResult closest_monkey = FP_GetClosestPortalMonkey(game, entity->handle);
|
||||||
if (closest_monkey.dist < DQN_SQUARED(FP_Game_MetersToPixelsNx1(game->play, 2.f))) {
|
if (closest_monkey.dist < DQN_SQUARED(FP_Game_MetersToPixelsNx1(game->play, 2.f))) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code)) {
|
||||||
entity->carried_monkey = closest_monkey.entity;
|
entity->carried_monkey = closest_monkey.entity;
|
||||||
picked_up_monkey_this_frame = true;
|
picked_up_monkey_this_frame = true;
|
||||||
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Monkey], 1.f);
|
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Monkey], 1.f);
|
||||||
@@ -681,15 +665,15 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Attack);
|
||||||
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_K) ||
|
} else if (TELY_Platform_InputScanCodeIsPressed(input, controls->range_attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_Y)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_Y)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_RangeAttack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_RangeAttack);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!picked_up_monkey_this_frame && TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
if (!picked_up_monkey_this_frame && TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code)) {
|
||||||
FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, entity->carried_monkey);
|
FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, entity->carried_monkey);
|
||||||
portal_monkey->local_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
portal_monkey->local_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||||
entity->carried_monkey = {};
|
entity->carried_monkey = {};
|
||||||
@@ -739,7 +723,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
// NOTE: Check if we are nearby a monkey and picking it up
|
// NOTE: Check if we are nearby a monkey and picking it up
|
||||||
FP_GetClosestPortalMonkeyResult closest_monkey = FP_GetClosestPortalMonkey(game, entity->handle);
|
FP_GetClosestPortalMonkeyResult closest_monkey = FP_GetClosestPortalMonkey(game, entity->handle);
|
||||||
if (closest_monkey.dist < DQN_SQUARED(FP_Game_MetersToPixelsNx1(game->play, 2.f))) {
|
if (closest_monkey.dist < DQN_SQUARED(FP_Game_MetersToPixelsNx1(game->play, 2.f))) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code)) {
|
||||||
entity->carried_monkey = closest_monkey.entity;
|
entity->carried_monkey = closest_monkey.entity;
|
||||||
picked_up_monkey_this_frame = true;
|
picked_up_monkey_this_frame = true;
|
||||||
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Monkey], 1.f);
|
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Monkey], 1.f);
|
||||||
@@ -748,10 +732,10 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Attack);
|
||||||
} else if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_K) ||
|
} else if (TELY_Platform_InputScanCodeIsPressed(input, controls->range_attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_Y)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_Y)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_RangeAttack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_RangeAttack);
|
||||||
}
|
}
|
||||||
@@ -759,12 +743,12 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
if (FP_Game_IsNilEntityHandle(game, entity->carried_monkey)) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_LeftControl) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->dash.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_A)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_A)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Dash);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Dash);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!picked_up_monkey_this_frame && TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
if (!picked_up_monkey_this_frame && TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code)) {
|
||||||
FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, entity->carried_monkey);
|
FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, entity->carried_monkey);
|
||||||
portal_monkey->local_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
portal_monkey->local_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||||
entity->carried_monkey = {};
|
entity->carried_monkey = {};
|
||||||
@@ -845,7 +829,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntitySmoochieState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntitySmoochieState_Attack);
|
||||||
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
||||||
@@ -939,7 +923,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntitySmoochieState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntitySmoochieState_Attack);
|
||||||
}
|
}
|
||||||
@@ -966,7 +950,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityClingerState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityClingerState_Attack);
|
||||||
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
||||||
@@ -1009,7 +993,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityClingerState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityClingerState_Attack);
|
||||||
}
|
}
|
||||||
@@ -1220,7 +1204,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityCatfishState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityCatfishState_Attack);
|
||||||
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
} else if (acceleration_meters_per_s->x || acceleration_meters_per_s->y) {
|
||||||
@@ -1262,7 +1246,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (we_are_clicked_entity) {
|
if (we_are_clicked_entity) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J) ||
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code) ||
|
||||||
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
TELY_Platform_InputGamepadKeyIsPressed(input, 0, TELY_PlatformInputGamepadKey_X)) {
|
||||||
FP_Game_EntityTransitionState(game, entity, FP_EntityCatfishState_Attack);
|
FP_Game_EntityTransitionState(game, entity, FP_EntityCatfishState_Attack);
|
||||||
}
|
}
|
||||||
@@ -1353,6 +1337,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (entity->type) {
|
switch (entity->type) {
|
||||||
@@ -1438,6 +1423,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
case FP_EntityType_AirportTerryPlane: break;
|
case FP_EntityType_AirportTerryPlane: break;
|
||||||
case FP_EntityType_MobSpawner:
|
case FP_EntityType_MobSpawner:
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1445,7 +1431,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
{
|
{
|
||||||
Dqn_Profiler_ZoneScopeWithIndex("FP_Update", FP_ProfileZone_FPUpdate);
|
Dqn_Profiler_ZoneScopeWithIndex("FP_Update", FP_ProfileZone_FPUpdate);
|
||||||
|
|
||||||
FP_GameCameraM2x3 const camera_xforms = FP_Game_CameraModelViewM2x3(game->play.camera);
|
FP_GameControls const *controls = &game->controls;
|
||||||
|
|
||||||
game->play.update_counter++;
|
game->play.update_counter++;
|
||||||
game->play.clock_ms = DQN_CAST(uint64_t)(platform->input.timer_s * 1000.f);
|
game->play.clock_ms = DQN_CAST(uint64_t)(platform->input.timer_s * 1000.f);
|
||||||
Dqn_ProfilerZone update_zone = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: Entity loop"), FP_ProfileZone_FPUpdate_EntityLoop);
|
Dqn_ProfilerZone update_zone = Dqn_Profiler_BeginZoneWithIndex(DQN_STRING8("FP_Update: Entity loop"), FP_ProfileZone_FPUpdate_EntityLoop);
|
||||||
@@ -1455,13 +1442,13 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
game->play.clicked_entity = game->play.prev_active_entity;
|
game->play.clicked_entity = game->play.prev_active_entity;
|
||||||
|
|
||||||
// NOTE: Keyboard movement input
|
// NOTE: Keyboard movement input
|
||||||
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_W))
|
if (TELY_Platform_InputScanCodeIsDown(input, controls->up.scan_code))
|
||||||
dir_vector.y = -1.f;
|
dir_vector.y = -1.f;
|
||||||
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_A))
|
if (TELY_Platform_InputScanCodeIsDown(input, controls->left.scan_code))
|
||||||
dir_vector.x = -1.f;
|
dir_vector.x = -1.f;
|
||||||
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_S))
|
if (TELY_Platform_InputScanCodeIsDown(input, controls->down.scan_code))
|
||||||
dir_vector.y = +1.f;
|
dir_vector.y = +1.f;
|
||||||
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_D))
|
if (TELY_Platform_InputScanCodeIsDown(input, controls->right.scan_code))
|
||||||
dir_vector.x = +1.f;
|
dir_vector.x = +1.f;
|
||||||
|
|
||||||
// NOTE: Gamepad movement input
|
// NOTE: Gamepad movement input
|
||||||
@@ -1565,12 +1552,13 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
case FP_EntityType_AirportTerryPlane: break;
|
case FP_EntityType_AirportTerryPlane: break;
|
||||||
case FP_EntityType_MobSpawner:
|
case FP_EntityType_MobSpawner:
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move_entity) {
|
if (move_entity) {
|
||||||
acceleration_meters_per_s = dir_vector * entity->base_acceleration_per_s.meters;
|
acceleration_meters_per_s = dir_vector * entity->base_acceleration_per_s.meters;
|
||||||
if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_Space))
|
// if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_Space))
|
||||||
acceleration_meters_per_s *= 2.5f;
|
// acceleration_meters_per_s *= 2.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1981,6 +1969,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
case FP_EntityType_AirportTerryPlane:
|
case FP_EntityType_AirportTerryPlane:
|
||||||
case FP_EntityType_MobSpawner:
|
case FP_EntityType_MobSpawner:
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2001,7 +1990,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
|
|
||||||
if (game->play.clicked_entity == entity->handle) {
|
if (game->play.clicked_entity == entity->handle) {
|
||||||
if (game->play.in_game_menu == FP_GameInGameMenu_Nil || game->play.in_game_menu == FP_GameInGameMenu_Build) {
|
if (game->play.in_game_menu == FP_GameInGameMenu_Nil || game->play.in_game_menu == FP_GameInGameMenu_Build) {
|
||||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_H))
|
if (TELY_Platform_InputScanCodeIsPressed(input, controls->build_mode.scan_code))
|
||||||
game->play.in_game_menu = DQN_CAST(FP_GameInGameMenu)(DQN_CAST(uint32_t)game->play.in_game_menu ^ FP_GameInGameMenu_Build);
|
game->play.in_game_menu = DQN_CAST(FP_GameInGameMenu)(DQN_CAST(uint32_t)game->play.in_game_menu ^ FP_GameInGameMenu_Build);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2057,7 +2046,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (game->play.build_mode_can_place_building &&
|
if (game->play.build_mode_can_place_building &&
|
||||||
TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
TELY_Platform_InputScanCodeIsPressed(input, controls->attack.scan_code)) {
|
||||||
if (placeable_building.type == FP_EntityType_ClubTerry) {
|
if (placeable_building.type == FP_EntityType_ClubTerry) {
|
||||||
FP_Entity_CreateClubTerry(game, placement_pos, "Club Terry");
|
FP_Entity_CreateClubTerry(game, placement_pos, "Club Terry");
|
||||||
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Club], 1.f);
|
TELY_Audio_Play(audio, game->audio[FP_GameAudio_Club], 1.f);
|
||||||
@@ -2090,8 +2079,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
acceleration_meters_per_s *= 1.f; // TODO(doyle): Penalise the player
|
acceleration_meters_per_s *= 1.f; // TODO(doyle): Penalise the player
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Left-shift lets us strafe in the same direction
|
if (!TELY_Platform_InputScanCodeIsDown(input, controls->strafe.scan_code)) {
|
||||||
if (!TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_LeftShift)) {
|
|
||||||
if (acceleration_meters_per_s.x)
|
if (acceleration_meters_per_s.x)
|
||||||
entity->direction = acceleration_meters_per_s.x > 0.f ? FP_GameDirection_Right : FP_GameDirection_Left;
|
entity->direction = acceleration_meters_per_s.x > 0.f ? FP_GameDirection_Right : FP_GameDirection_Left;
|
||||||
else if (acceleration_meters_per_s.y)
|
else if (acceleration_meters_per_s.y)
|
||||||
@@ -2165,7 +2153,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Mob spawner =======================================================================
|
// NOTE: Mob spawner =======================================================================
|
||||||
if (entity->type == FP_EntityType_MobSpawner && 0) {
|
if (entity->type == FP_EntityType_MobSpawner) {
|
||||||
// NOTE: Flush any spawn entities that are dead
|
// NOTE: Flush any spawn entities that are dead
|
||||||
for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr; FP_SentinelList_Iterate<FP_GameEntityHandle>(&entity->spawn_list, &link); ) {
|
for (FP_SentinelListLink<FP_GameEntityHandle> *link = nullptr; FP_SentinelList_Iterate<FP_GameEntityHandle>(&entity->spawn_list, &link); ) {
|
||||||
FP_GameEntity *spawned_entity = FP_Game_GetEntity(game, link->data);
|
FP_GameEntity *spawned_entity = FP_Game_GetEntity(game, link->data);
|
||||||
@@ -2623,6 +2611,54 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity->type == FP_EntityType_Billboard) {
|
||||||
|
FP_EntityBillboardState state = DQN_CAST(FP_EntityBillboardState)entity->action.state;
|
||||||
|
FP_GameKeyBind const *key_bind = nullptr;
|
||||||
|
Dqn_V2 draw_p = {};
|
||||||
|
Dqn_V4 colour = TELY_COLOUR_BLACK_V4;
|
||||||
|
switch (state) {
|
||||||
|
case FP_EntityBillboardState_Attack: {
|
||||||
|
key_bind = &game->controls.attack;
|
||||||
|
draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.65f, 0.2f));
|
||||||
|
colour = TELY_Colour_V4InitRGBU32(0xFFE726);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityBillboardState_Dash: {
|
||||||
|
key_bind = &game->controls.dash;
|
||||||
|
draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.62f, -0.07f));
|
||||||
|
colour = TELY_Colour_V4InitRGBU32(0xFFE726);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityBillboardState_Monkey: {
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityBillboardState_RangeAttack: {
|
||||||
|
key_bind = &game->controls.range_attack;
|
||||||
|
draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.33f, -0.2f));
|
||||||
|
colour = TELY_Colour_V4InitRGBU32(0x364659);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FP_EntityBillboardState_Strafe: {
|
||||||
|
key_bind = &game->controls.dash;
|
||||||
|
draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.52f, -0.15f));
|
||||||
|
colour = TELY_Colour_V4InitRGBU32(0xFF68A8);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key_bind) {
|
||||||
|
TELY_Render_PushColourV4(renderer, colour);
|
||||||
|
TELY_Render_PushFont(renderer, game->talkco_font_xlarge);
|
||||||
|
DQN_DEFER {
|
||||||
|
TELY_Render_PopFont(renderer);
|
||||||
|
TELY_Render_PopColourV4(renderer);
|
||||||
|
};
|
||||||
|
|
||||||
|
DQN_ASSERT(key_bind->scan_code >= TELY_PlatformInputScanCode_A && key_bind->scan_code <= TELY_PlatformInputScanCode_Z);
|
||||||
|
char scan_code_ch = DQN_CAST(char)('A' + (key_bind->scan_code - TELY_PlatformInputScanCode_A));
|
||||||
|
TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx1(0.5f), "[%c]", scan_code_ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Render overlay UI =====================================================================
|
// NOTE: Render overlay UI =====================================================================
|
||||||
@@ -2711,7 +2747,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
bool const have_enough_coins = player->coins >= *mapping.building_base_price;
|
bool const have_enough_coins = player->coins >= *mapping.building_base_price;
|
||||||
// NOTE: Buy trigger + animation ===============================
|
// NOTE: Buy trigger + animation ===============================
|
||||||
{
|
{
|
||||||
TELY_PlatformInputScanCode key = TELY_PlatformInputScanCode_J;
|
TELY_PlatformInputScanCode key = game->controls.attack.scan_code;
|
||||||
bool trigger_buy_anim = false;
|
bool trigger_buy_anim = false;
|
||||||
|
|
||||||
if (have_enough_coins) {
|
if (have_enough_coins) {
|
||||||
@@ -2798,7 +2834,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
bool const have_enough_coins = player->coins >= *mapping.upgrade_base_price;
|
bool const have_enough_coins = player->coins >= *mapping.upgrade_base_price;
|
||||||
// NOTE: Buy trigger + animation ===============================
|
// NOTE: Buy trigger + animation ===============================
|
||||||
{
|
{
|
||||||
TELY_PlatformInputScanCode key = TELY_PlatformInputScanCode_K;
|
TELY_PlatformInputScanCode key = game->controls.range_attack.scan_code;
|
||||||
bool trigger_buy_anim = false;
|
bool trigger_buy_anim = false;
|
||||||
|
|
||||||
if (have_enough_coins) {
|
if (have_enough_coins) {
|
||||||
@@ -3277,27 +3313,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
{
|
{
|
||||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_terry);
|
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_terry);
|
||||||
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||||
Dqn_f32 desired_width = window_rect.size.x;
|
Dqn_f32 desired_width = window_rect.size.x * .25f;
|
||||||
tex_scalar = desired_width / tex_rect.size.w;
|
tex_scalar = desired_width / tex_rect.size.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Draw title text ===========================================================
|
|
||||||
{
|
|
||||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_title);
|
|
||||||
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
|
||||||
Dqn_Rect dest_rect = {};
|
|
||||||
dest_rect.size = tex_rect.size * tex_scalar;
|
|
||||||
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.5f)) - (dest_rect.size * .5f);
|
|
||||||
|
|
||||||
TELY_Render_TextureColourV4(renderer,
|
|
||||||
game->atlas_sprite_sheet.tex_handle,
|
|
||||||
tex_rect,
|
|
||||||
dest_rect,
|
|
||||||
Dqn_V2_Zero /*rotate origin*/,
|
|
||||||
0.f /*rotation*/,
|
|
||||||
TELY_COLOUR_WHITE_V4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game->play.state == FP_GameState_IntroScreen) {
|
if (game->play.state == FP_GameState_IntroScreen) {
|
||||||
// NOTE: Draw terry logo ===========================================================
|
// NOTE: Draw terry logo ===========================================================
|
||||||
{
|
{
|
||||||
@@ -3315,29 +3333,12 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
0.f /*rotation*/,
|
0.f /*rotation*/,
|
||||||
TELY_COLOUR_WHITE_V4);
|
TELY_COLOUR_WHITE_V4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Draw title subtitle =======================================================
|
|
||||||
{
|
|
||||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_subtitle);
|
|
||||||
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
|
||||||
Dqn_Rect dest_rect = {};
|
|
||||||
dest_rect.size = tex_rect.size * tex_scalar;
|
|
||||||
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.5f)) - (dest_rect.size * .5f);
|
|
||||||
|
|
||||||
TELY_Render_TextureColourV4(renderer,
|
|
||||||
game->atlas_sprite_sheet.tex_handle,
|
|
||||||
tex_rect,
|
|
||||||
dest_rect,
|
|
||||||
Dqn_V2_Zero /*rotate origin*/,
|
|
||||||
0.f /*rotation*/,
|
|
||||||
TELY_COLOUR_WHITE_V4);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// NOTE: Draw end screen logo ======================================================
|
// NOTE: Draw end screen logo ======================================================
|
||||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.end_screen);
|
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.end_screen);
|
||||||
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||||
Dqn_Rect dest_rect = {};
|
Dqn_Rect dest_rect = {};
|
||||||
dest_rect.size = tex_rect.size * tex_scalar;
|
dest_rect.size = tex_rect.size * (tex_scalar * 1.5f);
|
||||||
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.5f)) - (dest_rect.size * .5f);
|
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.5f)) - (dest_rect.size * .5f);
|
||||||
|
|
||||||
TELY_Render_TextureColourV4(renderer,
|
TELY_Render_TextureColourV4(renderer,
|
||||||
@@ -3366,11 +3367,44 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
TELY_COLOUR_WHITE_V4);
|
TELY_COLOUR_WHITE_V4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: Draw title text ===============================================================
|
||||||
|
{
|
||||||
|
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_title);
|
||||||
|
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||||
|
Dqn_Rect dest_rect = {};
|
||||||
|
dest_rect.size = tex_rect.size * (tex_scalar * 1.5f);
|
||||||
|
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.20f)) - (dest_rect.size * .5f);
|
||||||
|
|
||||||
|
TELY_Render_TextureColourV4(renderer,
|
||||||
|
game->atlas_sprite_sheet.tex_handle,
|
||||||
|
tex_rect,
|
||||||
|
dest_rect,
|
||||||
|
Dqn_V2_Zero /*rotate origin*/,
|
||||||
|
0.f /*rotation*/,
|
||||||
|
TELY_COLOUR_WHITE_V4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: Draw title subtitle ===========================================================
|
||||||
|
if (game->play.state == FP_GameState_IntroScreen) {
|
||||||
|
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.intro_screen_subtitle);
|
||||||
|
Dqn_Rect tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||||
|
Dqn_Rect dest_rect = {};
|
||||||
|
dest_rect.size = tex_rect.size * tex_scalar;
|
||||||
|
dest_rect.pos = Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.8f)) - (dest_rect.size * .5f);
|
||||||
|
|
||||||
|
TELY_Render_TextureColourV4(renderer,
|
||||||
|
game->atlas_sprite_sheet.tex_handle,
|
||||||
|
tex_rect,
|
||||||
|
dest_rect,
|
||||||
|
Dqn_V2_Zero /*rotate origin*/,
|
||||||
|
0.f /*rotation*/,
|
||||||
|
TELY_COLOUR_WHITE_V4);
|
||||||
|
}
|
||||||
|
|
||||||
TELY_Render_PushFont(renderer, game->inter_regular_font);
|
TELY_Render_PushFont(renderer, game->inter_regular_font);
|
||||||
Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f;
|
Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f;
|
||||||
TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t));
|
TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t));
|
||||||
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_Play ? "start" : "restart");
|
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_IntroScreen ? "start" : "restart");
|
||||||
TELY_Render_PopColourV4(renderer);
|
TELY_Render_PopColourV4(renderer);
|
||||||
TELY_Render_PopFont(renderer);
|
TELY_Render_PopFont(renderer);
|
||||||
|
|
||||||
|
|||||||
+78
-14
@@ -88,7 +88,7 @@ int main(int argc, char const **argv)
|
|||||||
bool dry_run = false;
|
bool dry_run = false;
|
||||||
bool target_web = false;
|
bool target_web = false;
|
||||||
for (Dqn_usize arg_index = 1; arg_index < argc; arg_index++) {
|
for (Dqn_usize arg_index = 1; arg_index < argc; arg_index++) {
|
||||||
Dqn_String8 arg = Dqn_String8_InitCString8(argv[1]);
|
Dqn_String8 arg = Dqn_String8_InitCString8(argv[arg_index]);
|
||||||
if (arg == DQN_STRING8("--help")) {
|
if (arg == DQN_STRING8("--help")) {
|
||||||
PRINT_HELP;
|
PRINT_HELP;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -135,11 +135,17 @@ int main(int argc, char const **argv)
|
|||||||
{
|
{
|
||||||
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
|
robocopy_timings[0] = Dqn_OS_PerfCounterNow();
|
||||||
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
|
DQN_DEFER { robocopy_timings[1] = Dqn_OS_PerfCounterNow(); };
|
||||||
Dqn_String8 robocopy_cmd = Dqn_String8_InitF(scratch.allocator, "robocopy /MIR /NJH /NJS /NDL /NP %.*s\\Data %.*s\\Data", DQN_STRING_FMT(exe_dir), DQN_STRING_FMT(build_dir));
|
Dqn_String8 robocopy_cmd[] = {
|
||||||
if (dry_run) {
|
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_Print_StdLnF(Dqn_PrintStd_Out, "%.*s\n", DQN_STRING_FMT(robocopy_cmd));
|
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)),
|
||||||
} else {
|
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)),
|
||||||
Dqn_OS_Exec(robocopy_cmd, /*working_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*/ {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +226,31 @@ int main(int argc, char const **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 ==============================================================
|
// NOTE: Feely Pona Sprite Packer ==============================================================
|
||||||
uint64_t feely_pona_sprite_packer_timings[2] = {};
|
uint64_t feely_pona_sprite_packer_timings[2] = {};
|
||||||
{
|
{
|
||||||
@@ -229,15 +260,20 @@ int main(int argc, char const **argv)
|
|||||||
Dqn_CPPBuildContext build_context = {};
|
Dqn_CPPBuildContext build_context = {};
|
||||||
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
build_context.compiler = Dqn_CPPBuildCompiler_MSVC;
|
||||||
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
build_context.compile_files = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_sprite_packer.h", DQN_STRING_FMT(code_dir)) },
|
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.compile_flags = common_compile_flags;
|
||||||
build_context.link_flags = common_link_flags;
|
build_context.link_flags = common_link_flags;
|
||||||
build_context.build_dir = build_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);
|
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Feely Pona No DLL =====================================================================
|
// NOTE: Feely Pona No DLL =====================================================================
|
||||||
uint64_t feely_pona_no_dll_timings[2] = {};
|
uint64_t feely_pona_no_dll_timings[2] = {};
|
||||||
@@ -422,21 +458,23 @@ int main(int argc, char const **argv)
|
|||||||
Dqn_CPPBuildCompileFile{{}, Dqn_FsPath_ConvertF(scratch.arena, "%.*s/feely_pona_unity_nodll.cpp", DQN_STRING_FMT(code_dir)) },
|
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, {
|
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
|
||||||
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
|
DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
|
||||||
DQN_STRING8("-o"), DQN_STRING8("feely_pona.html"),
|
DQN_STRING8("-o"), Dqn_String8_InitF(scratch.allocator, "%.*s.html", DQN_STRING_FMT(prefix)),
|
||||||
// DQN_STRING8("-Os"), // Optimize for size
|
DQN_STRING8("-Os"), // Optimize for size
|
||||||
DQN_STRING8("-Wall"),
|
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_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("USE_GLFW=3"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=2"),
|
// DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=2"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("SAFE_HEAP=0"),
|
// DQN_STRING8("-s"), DQN_STRING8("SAFE_HEAP=0"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=512MB"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("TOTAL_STACK=32MB"),
|
DQN_STRING8("-s"), DQN_STRING8("TOTAL_STACK=32MB"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("ALLOW_MEMORY_GROWTH"),
|
DQN_STRING8("-s"), DQN_STRING8("ALLOW_MEMORY_GROWTH"),
|
||||||
DQN_STRING8("-s"), DQN_STRING8("STACK_OVERFLOW_CHECK=2"),
|
// DQN_STRING8("-s"), DQN_STRING8("STACK_OVERFLOW_CHECK=2"),
|
||||||
DQN_STRING8("--profiling-funcs"), // Expose function names in stack trace
|
// DQN_STRING8("--profiling-funcs"), // Expose function names in stack trace
|
||||||
DQN_STRING8("-g"), // Debug symbols
|
// DQN_STRING8("-g"), // Debug symbols
|
||||||
// NOTE: Must be relative path such that fopen("Data/...") works
|
// NOTE: Must be relative path such that fopen("Data/...") works
|
||||||
// otherwise the VFS will encode the full absolute path to the
|
// otherwise the VFS will encode the full absolute path to the
|
||||||
// assets
|
// assets
|
||||||
@@ -452,6 +490,31 @@ int main(int argc, char const **argv)
|
|||||||
} else {
|
} else {
|
||||||
Dqn_CPPBuild_ExecOrAbort(build_context, Dqn_CPPBuildMode_CacheBuild);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,6 +523,7 @@ int main(int argc, char const **argv)
|
|||||||
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, "\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, " 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, " 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 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 (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 (dll): %.2fms", Dqn_OS_PerfCounterMs(feely_pona_dll_timings[0], feely_pona_dll_timings[1]));
|
||||||
|
|||||||
@@ -0,0 +1,328 @@
|
|||||||
|
<!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, "&");
|
||||||
|
//text = text.replace(/</g, "<");
|
||||||
|
//text = text.replace(/>/g, ">");
|
||||||
|
//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>
|
||||||
@@ -24,6 +24,7 @@ enum FP_EntityType
|
|||||||
FP_EntityType_Smoochie,
|
FP_EntityType_Smoochie,
|
||||||
FP_EntityType_Terry,
|
FP_EntityType_Terry,
|
||||||
FP_EntityType_PhoneMessageProjectile,
|
FP_EntityType_PhoneMessageProjectile,
|
||||||
|
FP_EntityType_Billboard,
|
||||||
FP_EntityType_Count,
|
FP_EntityType_Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,6 +128,15 @@ enum FP_EntityHeartState
|
|||||||
FP_EntityHeartState_Idle,
|
FP_EntityHeartState_Idle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FP_EntityBillboardState
|
||||||
|
{
|
||||||
|
FP_EntityBillboardState_Attack,
|
||||||
|
FP_EntityBillboardState_Dash,
|
||||||
|
FP_EntityBillboardState_Monkey,
|
||||||
|
FP_EntityBillboardState_RangeAttack,
|
||||||
|
FP_EntityBillboardState_Strafe,
|
||||||
|
};
|
||||||
|
|
||||||
struct FP_EntityRenderData
|
struct FP_EntityRenderData
|
||||||
{
|
{
|
||||||
FP_Meters height;
|
FP_Meters height;
|
||||||
|
|||||||
@@ -39,20 +39,20 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
|
|||||||
|
|
||||||
case FP_EntityTerryState_Attack: {
|
case FP_EntityTerryState_Attack: {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_up; break;
|
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; 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; 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.flip = TELY_AssetFlip_X; 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_Count: DQN_INVALID_CODE_PATH; break;
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_EntityTerryState_RangeAttack: {
|
case FP_EntityTerryState_RangeAttack: {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_attack_phone_up; break;
|
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; 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.flip = TELY_AssetFlip_X; 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; break;
|
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_attack_phone_side; result.height.meters *= 1.25f; break;
|
||||||
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -129,7 +129,7 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FP_EntityType_MerchantPhoneCompany: {
|
case FP_EntityType_MerchantPhoneCompany: {
|
||||||
result.height.meters = 3.66f;
|
result.height.meters = 5.f;
|
||||||
FP_EntityMerchantPhoneCompanyState state = DQN_CAST(FP_EntityMerchantPhoneCompanyState)raw_state;
|
FP_EntityMerchantPhoneCompanyState state = DQN_CAST(FP_EntityMerchantPhoneCompanyState)raw_state;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case FP_EntityMerchantPhoneCompanyState_Idle: result.anim_name = g_anim_names.merchant_phone_company; break;
|
case FP_EntityMerchantPhoneCompanyState_Idle: result.anim_name = g_anim_names.merchant_phone_company; break;
|
||||||
@@ -263,6 +263,18 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
|
|||||||
result.anim_name = g_anim_names.portal_monk; break;
|
result.anim_name = g_anim_names.portal_monk; break;
|
||||||
} 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;
|
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,3 +831,27 @@ static FP_GameEntityHandle FP_Entity_CreateAirportTerryPlane(FP_Game *game, Dqn_
|
|||||||
entity->base_acceleration_per_s.meters = 32.f;
|
entity->base_acceleration_per_s.meters = 32.f;
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -912,6 +912,7 @@ static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity,
|
|||||||
case FP_EntityType_AirportTerryPlane:
|
case FP_EntityType_AirportTerryPlane:
|
||||||
case FP_EntityType_MobSpawner:
|
case FP_EntityType_MobSpawner:
|
||||||
case FP_EntityType_PortalMonkey: break;
|
case FP_EntityType_PortalMonkey: break;
|
||||||
|
case FP_EntityType_Billboard: break;
|
||||||
}
|
}
|
||||||
// NOTE: If no returns are hit above we proceed with the state change
|
// NOTE: If no returns are hit above we proceed with the state change
|
||||||
entity->action.next_state = desired_state;
|
entity->action.next_state = desired_state;
|
||||||
|
|||||||
+21
-3
@@ -263,7 +263,6 @@ struct FP_GameCamera
|
|||||||
|
|
||||||
enum FP_GameAudio
|
enum FP_GameAudio
|
||||||
{
|
{
|
||||||
FP_GameAudio_TestAudio,
|
|
||||||
FP_GameAudio_TerryHit,
|
FP_GameAudio_TerryHit,
|
||||||
FP_GameAudio_Smooch,
|
FP_GameAudio_Smooch,
|
||||||
FP_GameAudio_Woosh,
|
FP_GameAudio_Woosh,
|
||||||
@@ -353,6 +352,25 @@ struct FP_GamePlay
|
|||||||
FP_GameState state;
|
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
|
struct FP_Game
|
||||||
{
|
{
|
||||||
TELY_AssetFontHandle inter_regular_font_large;
|
TELY_AssetFontHandle inter_regular_font_large;
|
||||||
@@ -361,12 +379,12 @@ struct FP_Game
|
|||||||
TELY_AssetFontHandle jetbrains_mono_font;
|
TELY_AssetFontHandle jetbrains_mono_font;
|
||||||
TELY_AssetFontHandle talkco_font;
|
TELY_AssetFontHandle talkco_font;
|
||||||
TELY_AssetFontHandle talkco_font_large;
|
TELY_AssetFontHandle talkco_font_large;
|
||||||
|
TELY_AssetFontHandle talkco_font_xlarge;
|
||||||
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
||||||
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
|
|
||||||
TELY_AssetSpriteSheet hero_sprite_sheet;
|
|
||||||
TELY_AssetSpriteSheet atlas_sprite_sheet;
|
TELY_AssetSpriteSheet atlas_sprite_sheet;
|
||||||
TELY_RFui rfui;
|
TELY_RFui rfui;
|
||||||
FP_GamePlay play;
|
FP_GamePlay play;
|
||||||
|
FP_GameControls controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FP_GameAStarNode
|
struct FP_GameAStarNode
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static Dqn_String8 SpriteAnimNameFromFilePath(Dqn_String8 path)
|
|||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
Dqn_Library_Init();
|
Dqn_Library_Init(Dqn_LibraryOnInit_Nil);
|
||||||
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr);
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user