Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define main
- // Chunks
- chunk_map = ds_map_create();
- chunk_models = 0;
- chunk_index = 0;
- // No arguments... Compromises!
- chunk_create_x = 0;
- chunk_create_y = 0;
- // Textures
- block_tex = background_add("http://i189.photobucket.com/albums/z5/Prince_Deity/DiamondBlock57.png", false, false);
- texture_set_interpolation(false);
- draw_wait = 120; // Wait for the texture to download. May have to adjust based on internet speed...
- // Camera
- x = -20;
- y = -20;
- z = 0;
- zspeed = 0;
- cam_x = 0;
- cam_y = 0;
- cam_z = 0;
- yaw = 0; yaw_to = yaw;
- pitch = 0; pitch_to = pitch;
- mouse_lock();
- // D3D
- d3d_start();
- d3d_set_lighting(true);
- d3d_light_define_ambient(c_dkgray);
- d3d_light_define_direction(0, 0.3, 0.5, -1.0, c_white);
- d3d_light_enable(0, true);
- room_speed = 60;
- #define step
- mouse_look();
- camera_movement();
- // Chunk Generation
- var cx, cy;
- cx = x & -16;
- cy = y & -16;
- var find = ds_map_find_value(chunk_map, string(cx) + "_" + string(cy));
- if (is_undefined(find)) {
- chunk_create_x = cx;
- chunk_create_y = cy;
- create_chunk();
- }
- #define draw
- draw_wait--;
- if (draw_wait < 0) {
- d3d_set_projection_ext(
- x, y, z,
- x + cam_x, y + cam_y, z + cam_z,
- 0, 0, 1, 70, view_wview / view_hview, 0.1, 1000
- );
- // Draw Chunks
- d3d_set_lighting(true);
- draw_set_color(c_white);
- for (var i = 0; i < chunk_index; i++) {
- d3d_model_draw(chunk_models[i], 0, 0, 0, background_get_texture(block_tex));
- }
- d3d_set_lighting(false);
- }
- #define draw_gui
- draw_set_color(c_black);
- if (draw_wait < 0) {
- draw_text(2, 2, "FPS: " + string(fps));
- draw_text(2, 20, "Ha, wow!");
- } else {
- draw_text(2, 2, "Loading...");
- }
- #define game_end
- ds_map_destroy(chunk_map);
- #define mouse_look
- yaw_to -= mouse_delta_x * 0.3;
- pitch_to -= mouse_delta_y * 0.3;
- pitch_to = clamp(pitch_to, -89, 89);
- // Smooth Look
- yaw = lerp(yaw, yaw_to, 0.6);
- pitch = lerp(pitch, pitch_to, 0.6);
- // Update Look Vector
- cam_x = dcos(yaw);
- cam_y = -dsin(yaw);
- cam_z = dtan(pitch);
- #define camera_movement
- var spd = 0.2;
- if (keyboard_check(ord('W'))) motion_add(yaw, spd);
- if (keyboard_check(ord('A'))) motion_add(yaw + 90, spd);
- if (keyboard_check(ord('S'))) motion_add(yaw + 180, spd);
- if (keyboard_check(ord('D'))) motion_add(yaw + 270, spd);
- if (keyboard_check(vk_space)) zspeed += spd;
- if (keyboard_check(vk_shift)) zspeed -= spd;
- speed *= 0.8;
- zspeed *= 0.8;
- // Apply Movement
- z += zspeed;
- #define create_chunk
- ds_map_add(chunk_map, string(chunk_create_x) + "_" + string(chunk_create_y), chunk_index);
- chunk_models[chunk_index] = d3d_model_create();
- for (var xx = chunk_create_x; xx < chunk_create_x + 16; xx++) {
- for (var yy = chunk_create_y; yy < chunk_create_y + 16; yy++) {
- var noise = choose(2, 2, 3);
- for (var zz = 0; zz < noise; zz++) {
- d3d_model_block(chunk_models[chunk_index], xx, yy, zz, xx + 1, yy + 1, zz + 1, 1, 1);
- }
- }
- }
- chunk_index++;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement