diff --git a/demo.mk b/demo.mk index 615abe3..b7080fc 100644 --- a/demo.mk +++ b/demo.mk @@ -11,8 +11,14 @@ TEXTURE_OBJ = \ texture/walking/frame0003_128.data.o \ texture/walking/frame0004_128.data.o \ texture/walking/frame0005_128.data.o \ - texture/walking/frame0006_128.data.o - + texture/walking/frame0006_128.data.o \ + texture/turning/frame0000_128.data.o \ + texture/turning/frame0001_128.data.o \ + texture/turning/frame0002_128.data.o \ + texture/turning/frame0003_128.data.o \ + texture/turning/frame0004_128.data.o \ + texture/turning/frame0005_128.data.o \ + texture/turning/frame0006_128.data.o DEMO_OBJ = \ $(LIB)/holly/core.o \ $(LIB)/holly/region_array.o \ @@ -56,5 +62,8 @@ texture/igh25_box_%.data: texture/igh25_box_%.png texture/walking/%.data: texture/walking/%.png python ../model_generator/color_convert.py $< argb4444 twiddled non_mipmapped $@ +texture/turning/%.data: texture/turning/%.png + python ../model_generator/color_convert.py $< argb4444 twiddled non_mipmapped $@ + font/ter_u12n.data: $(LIB)/tools/ttf_bitmap2 20 7f 128 64 /usr/share/fonts/terminus/ter-u12n.otb $@ > /dev/null diff --git a/src/demo/lizard/levels.hpp b/src/demo/lizard/levels.hpp index b94a1b9..587eec0 100644 --- a/src/demo/lizard/levels.hpp +++ b/src/demo/lizard/levels.hpp @@ -3,6 +3,34 @@ namespace demo { world::platform level1_platforms[] = { + { + .position = vec3( 23.500, -28.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 30.500, -35.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 37.500, -42.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 44.500, -51.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 51.500, -58.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 59.500, -66.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 68.500, -77.000, 7.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, { .position = vec3( 7.500, 0.000, 7.500), .scale = vec3( 3.000, 1.000, 3.000), @@ -15,10 +43,82 @@ namespace demo { .position = vec3( 17.500, 0.000, 7.500), .scale = vec3( 3.000, 1.000, 3.000), }, + { + .position = vec3( 77.500, -91.000, 9.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, { .position = vec3( 12.500, 0.000, 12.500), .scale = vec3( 3.000, 1.000, 3.000), }, + { + .position = vec3( 39.500, 3.000, 18.500), + .scale = vec3( 37.000, 1.000, 13.000), + }, + { + .position = vec3( 84.500, -101.000, 15.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 8.500, 1.000, 18.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 91.500, -109.000, 22.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 14.500, 2.000, 24.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 28.500, 4.000, 45.500), + .scale = vec3( 7.000, 1.000, 37.000), + }, + { + .position = vec3( 41.500, 2.000, 45.500), + .scale = vec3( 7.000, 1.000, 37.000), + }, + { + .position = vec3( 53.500, 0.000, 45.500), + .scale = vec3( 7.000, 1.000, 37.000), + }, + { + .position = vec3( 20.500, 3.000, 30.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 98.500, -117.000, 31.500), + .scale = vec3( 5.000, 1.000, 5.000), + }, + { + .position = vec3( 106.500, -117.000, 52.500), + .scale = vec3( 29.000, 1.000, 29.000), + }, + { + .position = vec3( 14.500, -2.000, 73.500), + .scale = vec3( 11.000, 1.000, 3.000), + }, + { + .position = vec3( 27.500, -2.000, 73.500), + .scale = vec3( 11.000, 1.000, 3.000), + }, + { + .position = vec3( 40.500, -2.000, 73.500), + .scale = vec3( 11.000, 1.000, 3.000), + }, + { + .position = vec3( 53.500, -2.000, 73.500), + .scale = vec3( 11.000, 1.000, 3.000), + }, + { + .position = vec3( 66.500, -2.000, 73.500), + .scale = vec3( 11.000, 1.000, 3.000), + }, + { + .position = vec3( 27.500, -5.000, 91.500), + .scale = vec3( 41.000, 1.000, 21.000), + }, }; world::level level1_level = { .platforms = level1_platforms, diff --git a/src/demo/lizard/main.cpp b/src/demo/lizard/main.cpp index 37f74e2..6eae0ed 100644 --- a/src/demo/lizard/main.cpp +++ b/src/demo/lizard/main.cpp @@ -13,7 +13,7 @@ extern float alpha_mul; -const int lizard_frames[] = { +const int lizard_walking_frames[] = { texture::offset::walking_frame0000, texture::offset::walking_frame0001, texture::offset::walking_frame0002, @@ -22,7 +22,19 @@ const int lizard_frames[] = { texture::offset::walking_frame0005, texture::offset::walking_frame0006, }; -const int lizard_frames_count = (sizeof (lizard_frames)) / (sizeof (lizard_frames[0])); +const int lizard_walking_frames_count = (sizeof (lizard_walking_frames)) / (sizeof (lizard_walking_frames[0])); + +const int lizard_turning_frames[] = { + texture::offset::turning_frame0000, + texture::offset::turning_frame0001, + texture::offset::turning_frame0002, + texture::offset::turning_frame0003, + texture::offset::turning_frame0004, + texture::offset::turning_frame0005, + texture::offset::turning_frame0006, +}; +const int lizard_turning_frames_count = (sizeof (lizard_turning_frames)) / (sizeof (lizard_turning_frames[0])); + int last_drawn_frame; namespace demo { @@ -62,6 +74,11 @@ namespace demo { if (!collided) lizard_velocity.y -= 0.01; */ + lizard_rotation *= 0.8; + + lizard_turning_frame += lizard_rotation * 10; + + lizard_heading += lizard_rotation; if (abs(lizard_velocity.x) > 0.05) lizard_velocity.x = 0.05 * sign(lizard_velocity.x); @@ -74,7 +91,7 @@ namespace demo { lizard_velocity.y *= 0.8; lizard_velocity.z *= 0.8; - lizard_frame += magnitude(lizard_velocity) * 15; + lizard_walking_frame += magnitude(lizard_velocity) * 15; lizard_position.x += lizard_velocity.x; lizard_position.y += lizard_velocity.y; @@ -106,12 +123,12 @@ namespace demo { void lizard::x() { - lizard_heading -= pi * (1.0f / 160); + lizard_rotation += pi * (1.0f / 160); } void lizard::b() { - lizard_heading += pi * (1.0f / 160); + lizard_rotation -= pi * (1.0f / 160); } void lizard::analog(float dl, float dr, float dx, float dy) @@ -192,14 +209,25 @@ namespace demo { t, vec3(1, 0.5, 0)); */ - int frame = ((int)lizard_frame) % lizard_frames_count; - if (frame < 0) - frame = lizard_frames_count + frame; - last_drawn_frame = frame; + if (abs(lizard_rotation) > 0) { + int frame = ((int)lizard_turning_frame) % lizard_turning_frames_count; + if (frame < 0) + frame = lizard_turning_frames_count + frame; + last_drawn_frame = frame; - draw_textured_voxel(writer, - t, - lizard_frames[frame]); + draw_textured_voxel(writer, + t, + lizard_turning_frames[frame]); + } else { + int frame = ((int)lizard_walking_frame) % lizard_walking_frames_count; + if (frame < 0) + frame = lizard_walking_frames_count + frame; + last_drawn_frame = frame; + + draw_textured_voxel(writer, + t, + lizard_walking_frames[frame]); + } } void lizard::draw(ta_parameter_writer& writer, const mat4x4& _) diff --git a/src/demo/lizard/main.hpp b/src/demo/lizard/main.hpp index 7f58461..41e2595 100644 --- a/src/demo/lizard/main.hpp +++ b/src/demo/lizard/main.hpp @@ -10,7 +10,9 @@ namespace demo { vec3 lizard_position; vec3 lizard_velocity; float lizard_heading; - float lizard_frame; + float lizard_rotation; + float lizard_walking_frame; + float lizard_turning_frame; bool collided; diff --git a/src/demo/lizard/maps/level1.png b/src/demo/lizard/maps/level1.png index c45f563..595f060 100644 Binary files a/src/demo/lizard/maps/level1.png and b/src/demo/lizard/maps/level1.png differ diff --git a/src/platform/texture.cpp b/src/platform/texture.cpp index 0dd91d8..5304efb 100644 --- a/src/platform/texture.cpp +++ b/src/platform/texture.cpp @@ -18,6 +18,13 @@ #include "texture/walking/frame0004_128.data.h" #include "texture/walking/frame0005_128.data.h" #include "texture/walking/frame0006_128.data.h" +#include "texture/turning/frame0000_128.data.h" +#include "texture/turning/frame0001_128.data.h" +#include "texture/turning/frame0002_128.data.h" +#include "texture/turning/frame0003_128.data.h" +#include "texture/turning/frame0004_128.data.h" +#include "texture/turning/frame0005_128.data.h" +#include "texture/turning/frame0006_128.data.h" namespace texture { struct entry { @@ -82,6 +89,41 @@ namespace texture { .size = reinterpret_cast(&_binary_texture_walking_frame0006_128_data_size), .offset = offset::walking_frame0006, }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0000_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0000_128_data_size), + .offset = offset::turning_frame0000, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0001_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0001_128_data_size), + .offset = offset::turning_frame0001, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0002_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0002_128_data_size), + .offset = offset::turning_frame0002, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0003_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0003_128_data_size), + .offset = offset::turning_frame0003, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0004_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0004_128_data_size), + .offset = offset::turning_frame0004, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0005_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0005_128_data_size), + .offset = offset::turning_frame0005, + }, + { + .start = reinterpret_cast(&_binary_texture_turning_frame0006_128_data_start), + .size = reinterpret_cast(&_binary_texture_turning_frame0006_128_data_size), + .offset = offset::turning_frame0006, + }, }; const int textures_length = (sizeof (textures)) / (sizeof (textures[0])); diff --git a/src/platform/texture.hpp b/src/platform/texture.hpp index c6576c5..9701941 100644 --- a/src/platform/texture.hpp +++ b/src/platform/texture.hpp @@ -6,6 +6,7 @@ namespace texture { constexpr int igh25_box_top_32 = ter_u12n + 4096; constexpr int igh25_box_bottom_32 = igh25_box_top_32 + 2048; constexpr int igh25_box_side_32 = igh25_box_bottom_32 + 2048; + constexpr int walking_frame0000 = igh25_box_side_32 + 2048; constexpr int walking_frame0001 = walking_frame0000 + 8192; constexpr int walking_frame0002 = walking_frame0001 + 8192; @@ -13,6 +14,14 @@ namespace texture { constexpr int walking_frame0004 = walking_frame0003 + 8192; constexpr int walking_frame0005 = walking_frame0004 + 8192; constexpr int walking_frame0006 = walking_frame0005 + 8192; + + constexpr int turning_frame0000 = walking_frame0006 + 8192; + constexpr int turning_frame0001 = turning_frame0000 + 8192; + constexpr int turning_frame0002 = turning_frame0001 + 8192; + constexpr int turning_frame0003 = turning_frame0002 + 8192; + constexpr int turning_frame0004 = turning_frame0003 + 8192; + constexpr int turning_frame0005 = turning_frame0004 + 8192; + constexpr int turning_frame0006 = turning_frame0005 + 8192; } struct cube_texture_offsets { diff --git a/texture/turning/frame0000.png b/texture/turning/frame0000.png new file mode 100644 index 0000000..f6f3137 Binary files /dev/null and b/texture/turning/frame0000.png differ diff --git a/texture/turning/frame0000_128.data.h b/texture/turning/frame0000_128.data.h new file mode 100644 index 0000000..e0007bc --- /dev/null +++ b/texture/turning/frame0000_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0000_128_data_start __asm("_binary_texture_turning_frame0000_128_data_start"); +extern uint32_t _binary_texture_turning_frame0000_128_data_end __asm("_binary_texture_turning_frame0000_128_data_end"); +extern uint32_t _binary_texture_turning_frame0000_128_data_size __asm("_binary_texture_turning_frame0000_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0001.png b/texture/turning/frame0001.png new file mode 100644 index 0000000..ce90571 Binary files /dev/null and b/texture/turning/frame0001.png differ diff --git a/texture/turning/frame0001_128.data.h b/texture/turning/frame0001_128.data.h new file mode 100644 index 0000000..73dc901 --- /dev/null +++ b/texture/turning/frame0001_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0001_128_data_start __asm("_binary_texture_turning_frame0001_128_data_start"); +extern uint32_t _binary_texture_turning_frame0001_128_data_end __asm("_binary_texture_turning_frame0001_128_data_end"); +extern uint32_t _binary_texture_turning_frame0001_128_data_size __asm("_binary_texture_turning_frame0001_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0002.png b/texture/turning/frame0002.png new file mode 100644 index 0000000..abe42d0 Binary files /dev/null and b/texture/turning/frame0002.png differ diff --git a/texture/turning/frame0002_128.data.h b/texture/turning/frame0002_128.data.h new file mode 100644 index 0000000..8533ee2 --- /dev/null +++ b/texture/turning/frame0002_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0002_128_data_start __asm("_binary_texture_turning_frame0002_128_data_start"); +extern uint32_t _binary_texture_turning_frame0002_128_data_end __asm("_binary_texture_turning_frame0002_128_data_end"); +extern uint32_t _binary_texture_turning_frame0002_128_data_size __asm("_binary_texture_turning_frame0002_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0003.png b/texture/turning/frame0003.png new file mode 100644 index 0000000..cd7a08d Binary files /dev/null and b/texture/turning/frame0003.png differ diff --git a/texture/turning/frame0003_128.data.h b/texture/turning/frame0003_128.data.h new file mode 100644 index 0000000..2356cfe --- /dev/null +++ b/texture/turning/frame0003_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0003_128_data_start __asm("_binary_texture_turning_frame0003_128_data_start"); +extern uint32_t _binary_texture_turning_frame0003_128_data_end __asm("_binary_texture_turning_frame0003_128_data_end"); +extern uint32_t _binary_texture_turning_frame0003_128_data_size __asm("_binary_texture_turning_frame0003_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0004.png b/texture/turning/frame0004.png new file mode 100644 index 0000000..3debcb2 Binary files /dev/null and b/texture/turning/frame0004.png differ diff --git a/texture/turning/frame0004_128.data.h b/texture/turning/frame0004_128.data.h new file mode 100644 index 0000000..a2f4129 --- /dev/null +++ b/texture/turning/frame0004_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0004_128_data_start __asm("_binary_texture_turning_frame0004_128_data_start"); +extern uint32_t _binary_texture_turning_frame0004_128_data_end __asm("_binary_texture_turning_frame0004_128_data_end"); +extern uint32_t _binary_texture_turning_frame0004_128_data_size __asm("_binary_texture_turning_frame0004_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0005.png b/texture/turning/frame0005.png new file mode 100644 index 0000000..2f6a9b8 Binary files /dev/null and b/texture/turning/frame0005.png differ diff --git a/texture/turning/frame0005_128.data.h b/texture/turning/frame0005_128.data.h new file mode 100644 index 0000000..ea145ff --- /dev/null +++ b/texture/turning/frame0005_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0005_128_data_start __asm("_binary_texture_turning_frame0005_128_data_start"); +extern uint32_t _binary_texture_turning_frame0005_128_data_end __asm("_binary_texture_turning_frame0005_128_data_end"); +extern uint32_t _binary_texture_turning_frame0005_128_data_size __asm("_binary_texture_turning_frame0005_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/texture/turning/frame0006.png b/texture/turning/frame0006.png new file mode 100644 index 0000000..622c69d Binary files /dev/null and b/texture/turning/frame0006.png differ diff --git a/texture/turning/frame0006_128.data.h b/texture/turning/frame0006_128.data.h new file mode 100644 index 0000000..66e0c08 --- /dev/null +++ b/texture/turning/frame0006_128.data.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_texture_turning_frame0006_128_data_start __asm("_binary_texture_turning_frame0006_128_data_start"); +extern uint32_t _binary_texture_turning_frame0006_128_data_end __asm("_binary_texture_turning_frame0006_128_data_end"); +extern uint32_t _binary_texture_turning_frame0006_128_data_size __asm("_binary_texture_turning_frame0006_128_data_size"); + +#ifdef __cplusplus +} +#endif diff --git a/tools/parse_map.py b/tools/parse_map.py index 02d1f01..2408791 100644 --- a/tools/parse_map.py +++ b/tools/parse_map.py @@ -122,9 +122,9 @@ def generate_level(name, platforms): yield "};" def generate_file(name_platforms_list): - yield '#include "demo/platform/world.hpp"' + yield '#include "demo/lizard/world.hpp"' yield "" - yield f"namespace demo::map {{" + yield f"namespace demo {{" yield "" for name, platforms in name_platforms_list: yield from generate_level(name, platforms)