world switching, re-enable lighting

This commit is contained in:
Zack Buhman 2026-03-23 03:57:14 -05:00
parent 9991b991ab
commit 9b0c118ae1
7 changed files with 47 additions and 10 deletions

View File

@ -73,8 +73,9 @@ all: test.so
%.o: %.cpp
$(CXX) $(ARCH) $(CXXSTD) $(CFLAGS) $(OPT) -c $< -o $@
test.pack: pack_main
./pack_main $@ $(shell cat filenames.txt)
PACK_FILENAMES = $(shell cat filenames.txt)
test.pack: pack_main $(PACK_FILENAMES)
./pack_main $@ $(PACK_FILENAMES)
test.pack.o: test.pack
$(OBJCOPY) -I binary -O $(OBJARCH) $< $@

View File

@ -4,6 +4,8 @@
namespace minecraft {
extern world::state * current_world;
static const int max_world_count = 10;
extern world::state world_state[max_world_count];
void load();
void draw();

View File

@ -26,7 +26,7 @@ void main()
vec3 out_color = color.xyz * 0.1;
if (false) {
if (LightCount != 0) {
for (int i = 0; i < LightCount; i++) {
vec3 light_position = light[i].xzy + vec3(0, 0, 0.5);
float light_distance = length(light_position - position.xyz);

View File

@ -103,10 +103,11 @@ namespace hud {
font::bitmap::draw_string(ter_best, " move: w/a/s/d", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " look: up/down/left/right", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " elevate: q/e", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " warp: l", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, "gamepad:", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " move: right stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " look: left stick", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " elevate: trigger left/right", 10, y); y += ter_best.desc->glyph_height;
font::bitmap::draw_string(ter_best, " warp: a", 10, y); y += ter_best.desc->glyph_height;
if (frame++ > 60 * 10)
return;

View File

@ -45,8 +45,7 @@ namespace minecraft {
static unsigned int texture;
static const int max_world_count = 10;
static world::state world_state[max_world_count];
world::state world_state[max_world_count];
world::state * current_world;
void load_program()
@ -272,7 +271,7 @@ namespace minecraft {
for (int i = 0; i < world::descriptors_length; i++) {
per_world::load_world(&world::descriptors[i], world_state[i]);
}
current_world = &world_state[world::world_id::MIDNIGHTMEADOW];
current_world = &world_state[world::world_id::GRANDLECTURN];
}
static inline int popcount(int x)

View File

@ -292,6 +292,29 @@ void minecraft_view_update(XMVECTOR direction)
view::state.eye = view::state.at - view::state.direction * view::at_distance;
}
static int world_id = 0;
void next_world()
{
world_id += 1;
if (world_id == 2)
world_id = 0;
if (world_id == 0) {
view::state.eye = XMVectorSet(4.71f, 65.30, 57.92, 1);
} else {
// midnightmeadow
view::state.eye = XMVectorSet(13.71f, -3.36, 92.92, 1);
}
view::state.at = view::state.eye + view::state.direction * view::at_distance;
minecraft::current_world = &minecraft::world_state[world_id];
printf("next world\n");
}
static int last_l = 0;
void update_keyboard(int up, int down, int left, int right,
int w, int s, int a, int d,
int t, int g, int f, int h,
@ -327,8 +350,15 @@ void update_keyboard(int up, int down, int left, int right,
if (true) {
minecraft_view_update(direction);
}
if (l && last_l == 0) {
next_world();
}
last_l = l;
}
static int last_a = 0;
void update_joystick(int joystick_index,
float lx, float ly, float rx, float ry, float tl, float tr,
int up, int down, int left, int right,
@ -350,6 +380,11 @@ void update_joystick(int joystick_index,
minecraft_view_update(direction);
}
if (a && last_a == 0) {
next_world();
}
last_a = a;
//view::state.eye = view::state.eye + direction;
//view::state.at = view::state.at - view::state.direction * view::at_distance;

View File

@ -105,11 +105,10 @@ namespace view {
// position
// grandlecturn
//state.eye = XMVectorSet(4.71f, 65.30, 57.92, 1);
state.eye = XMVectorSet(4.71f, 65.30, 57.92, 1);
// midnightmeadow
state.eye = XMVectorSet(13.71f, -3.36, 90.92, 1);
//state.eye = XMVectorSet(13.71f, -3.36, 90.92, 1);
state.at = state.eye + state.direction * at_distance;
//state.at = XMVectorSet(0, 0, 0, 1);
//state.eye = XMVectorSet(0, -100, 0, 1);