world switching, re-enable lighting
This commit is contained in:
parent
9991b991ab
commit
9b0c118ae1
5
Makefile
5
Makefile
@ -73,8 +73,9 @@ all: test.so
|
|||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) $(ARCH) $(CXXSTD) $(CFLAGS) $(OPT) -c $< -o $@
|
$(CXX) $(ARCH) $(CXXSTD) $(CFLAGS) $(OPT) -c $< -o $@
|
||||||
|
|
||||||
test.pack: pack_main
|
PACK_FILENAMES = $(shell cat filenames.txt)
|
||||||
./pack_main $@ $(shell cat filenames.txt)
|
test.pack: pack_main $(PACK_FILENAMES)
|
||||||
|
./pack_main $@ $(PACK_FILENAMES)
|
||||||
|
|
||||||
test.pack.o: test.pack
|
test.pack.o: test.pack
|
||||||
$(OBJCOPY) -I binary -O $(OBJARCH) $< $@
|
$(OBJCOPY) -I binary -O $(OBJARCH) $< $@
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace minecraft {
|
namespace minecraft {
|
||||||
extern world::state * current_world;
|
extern world::state * current_world;
|
||||||
|
static const int max_world_count = 10;
|
||||||
|
extern world::state world_state[max_world_count];
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
void draw();
|
void draw();
|
||||||
|
|||||||
@ -26,7 +26,7 @@ void main()
|
|||||||
|
|
||||||
vec3 out_color = color.xyz * 0.1;
|
vec3 out_color = color.xyz * 0.1;
|
||||||
|
|
||||||
if (false) {
|
if (LightCount != 0) {
|
||||||
for (int i = 0; i < LightCount; i++) {
|
for (int i = 0; i < LightCount; i++) {
|
||||||
vec3 light_position = light[i].xzy + vec3(0, 0, 0.5);
|
vec3 light_position = light[i].xzy + vec3(0, 0, 0.5);
|
||||||
float light_distance = length(light_position - position.xyz);
|
float light_distance = length(light_position - position.xyz);
|
||||||
|
|||||||
@ -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, " 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, " 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, " 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, "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, " 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, " 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)
|
if (frame++ > 60 * 10)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -45,8 +45,7 @@ namespace minecraft {
|
|||||||
|
|
||||||
static unsigned int texture;
|
static unsigned int texture;
|
||||||
|
|
||||||
static const int max_world_count = 10;
|
world::state world_state[max_world_count];
|
||||||
static world::state world_state[max_world_count];
|
|
||||||
world::state * current_world;
|
world::state * current_world;
|
||||||
|
|
||||||
void load_program()
|
void load_program()
|
||||||
@ -272,7 +271,7 @@ namespace minecraft {
|
|||||||
for (int i = 0; i < world::descriptors_length; i++) {
|
for (int i = 0; i < world::descriptors_length; i++) {
|
||||||
per_world::load_world(&world::descriptors[i], world_state[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)
|
static inline int popcount(int x)
|
||||||
|
|||||||
35
src/test.cpp
35
src/test.cpp
@ -292,6 +292,29 @@ void minecraft_view_update(XMVECTOR direction)
|
|||||||
view::state.eye = view::state.at - view::state.direction * view::at_distance;
|
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,
|
void update_keyboard(int up, int down, int left, int right,
|
||||||
int w, int s, int a, int d,
|
int w, int s, int a, int d,
|
||||||
int t, int g, int f, int h,
|
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) {
|
if (true) {
|
||||||
minecraft_view_update(direction);
|
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,
|
void update_joystick(int joystick_index,
|
||||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||||
int up, int down, int left, int right,
|
int up, int down, int left, int right,
|
||||||
@ -350,6 +380,11 @@ void update_joystick(int joystick_index,
|
|||||||
minecraft_view_update(direction);
|
minecraft_view_update(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a && last_a == 0) {
|
||||||
|
next_world();
|
||||||
|
}
|
||||||
|
last_a = a;
|
||||||
|
|
||||||
//view::state.eye = view::state.eye + direction;
|
//view::state.eye = view::state.eye + direction;
|
||||||
//view::state.at = view::state.at - view::state.direction * view::at_distance;
|
//view::state.at = view::state.at - view::state.direction * view::at_distance;
|
||||||
|
|
||||||
|
|||||||
@ -105,11 +105,10 @@ namespace view {
|
|||||||
|
|
||||||
// position
|
// position
|
||||||
// grandlecturn
|
// grandlecturn
|
||||||
//state.eye = XMVectorSet(4.71f, 65.30, 57.92, 1);
|
state.eye = XMVectorSet(4.71f, 65.30, 57.92, 1);
|
||||||
|
|
||||||
// midnightmeadow
|
// 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 = state.eye + state.direction * at_distance;
|
||||||
//state.at = XMVectorSet(0, 0, 0, 1);
|
//state.at = XMVectorSet(0, 0, 0, 1);
|
||||||
//state.eye = XMVectorSet(0, -100, 0, 1);
|
//state.eye = XMVectorSet(0, -100, 0, 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user