Skip to content

Commit a7e1df1

Browse files
committed
Post-jam version
- Version actually used for Ludum Dare and Low-Rez jams. - "Cherchez" has been made with this version: https://martincohen.itch.io/cherchez - All the configuration macros are now prefixed with PUN_ - Fixed bug in sound mixing. - All rendering properties are now stored in dedicated `Canvas` struct. - Added simple randomization functions (see the documentation). - Added `file_write` function to accompany `file_read`. - Added basic `V2f` struct and functions. - Added vertical flipping for `bitmap_draw` function. - Reworked `bitmap_draw` function. - Added drawing list support (see the documentation). - Added `*_push` functions for pushing draw operations to draw list (see the documentation)
1 parent 710ae89 commit a7e1df1

File tree

5 files changed

+1088
-397
lines changed

5 files changed

+1088
-397
lines changed

build.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
echo off
1+
@echo off
22
set compiler=cl
33
setlocal enableextensions enabledelayedexpansion
44

@@ -14,7 +14,7 @@ if "%1"=="gcc" (
1414

1515
if "%compiler%"=="cl" (
1616
echo Using MSVC
17-
set common_c=..\main.c -nologo -D_WIN32_WINNT=0x0501 -MTd -TC -EHa- -I..\ -I..\lib
17+
set common_c=..\main.c -nologo -D_WIN32_WINNT=0x0501 -MTd -TC -FC -EHa- -I..\ -I..\lib
1818
set common_l=/link /OPT:REF user32.lib gdi32.lib winmm.lib main.res
1919

2020
echo Building resources...
@@ -31,7 +31,6 @@ if "%compiler%"=="cl" (
3131
cl !common_c! -O2 -DRELEASE_BUILD /Gy /Oy /Z7 !common_l!
3232
) else (
3333
echo Building debug...
34-
echo cl !common_c! -O2 -DRELEASE_BUILD /Gy /Oy !common_l!
3534
cl !common_c! -Od -Z7 !common_l!
3635
)
3736
popd

config.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#define WINDOW_TITLE "Punity"
2-
#define CANVAS_WIDTH 128
3-
#define CANVAS_HEIGHT 128
4-
#define CANVAS_SCALE 3
1+
#define PUN_WINDOW_TITLE "Punity"
2+
#define PUN_CANVAS_WIDTH 128
3+
#define PUN_CANVAS_HEIGHT 128
4+
#define PUN_CANVAS_SCALE 3
55

6-
#define STACK_CAPACITY megabytes(16)
7-
#define STORAGE_CAPACITY megabytes(16)
6+
#define PUN_STACK_CAPACITY megabytes(16)
7+
#define PUN_STORAGE_CAPACITY megabytes(16)
88

9-
#define USE_STB_IMAGE 1
10-
#define USE_STB_VORBIS 1
9+
#define PUN_USE_STB_IMAGE 1
10+
#define PUN_USE_STB_VORBIS 1

main.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ static Sound sound2;
1111
void
1212
init()
1313
{
14-
CORE->palette.colors[0] = color_make(0x00, 0x00, 0x00, 0x00);
15-
CORE->palette.colors[1] = color_make(0x00, 0x00, 0x00, 0xff);
16-
CORE->palette.colors[2] = color_make(0xff, 0xff, 0xff, 0xff);
17-
CORE->palette.colors[3] = color_make(0x63, 0x9b, 0xff, 0xff);
14+
CORE->canvas.palette.colors[0] = color_make(0x00, 0x00, 0x00, 0x00);
15+
CORE->canvas.palette.colors[1] = color_make(0x00, 0x00, 0x00, 0xff);
16+
CORE->canvas.palette.colors[2] = color_make(0xff, 0xff, 0xff, 0xff);
17+
CORE->canvas.palette.colors[3] = color_make(0x63, 0x9b, 0xff, 0xff);
1818

19-
CORE->palette.colors_count = 4;
19+
CORE->canvas.palette.colors_count = 4;
2020
canvas_clear(1);
2121

2222
bitmap_load_resource(&splash, "splash.png");
@@ -27,9 +27,8 @@ init()
2727

2828
sound_load_resource(&sound1, "sound1.ogg");
2929
sound_load_resource(&sound2, "sound2.ogg");
30-
// sound2.rate = 48000;
3130

32-
CORE->font = &font;
31+
CORE->canvas.font = &font;
3332
}
3433

3534
void
@@ -40,19 +39,19 @@ step()
4039
}
4140

4241
if (key_down(KEY_RIGHT)) {
43-
CORE->translate_x++;
42+
CORE->canvas.translate_x++;
4443
}
4544

4645
if (key_down(KEY_LEFT)) {
47-
CORE->translate_x--;
46+
CORE->canvas.translate_x--;
4847
}
4948

5049
if (key_down(KEY_DOWN)) {
51-
CORE->translate_y++;
50+
CORE->canvas.translate_y++;
5251
}
5352

5453
if (key_down(KEY_UP)) {
55-
CORE->translate_y--;
54+
CORE->canvas.translate_y--;
5655
}
5756

5857
if (key_pressed(KEY_ESCAPE)) {
@@ -62,15 +61,13 @@ step()
6261

6362
canvas_clear(0);
6463

65-
bitmap_draw(0, 0, 0, 0, &splash, 0, 0, 0);
66-
67-
text_draw(0, 0, "\n\nHELLO\nWORLD", 3);
68-
64+
bitmap_draw(&splash, 0, 0, 0, 0, 0, 0, 0);
65+
text_draw("\n\nHELLO\nWORLD", 0, 0, 3);
6966
rect_draw(rect_make_size(32, 32, 8, 8), 2);
7067

7168
static char buf[256];
7269
sprintf(buf, "%03f %05d", CORE->perf_step.delta, (i32)CORE->frame);
73-
text_draw(0, 0, buf, 2);
70+
text_draw(buf, 0, 0, 2);
7471

75-
CORE->canvas->pixels[0] = COLOR_WHITE;
72+
CORE->canvas.bitmap->pixels[0] = COLOR_WHITE;
7673
}

0 commit comments

Comments
 (0)