jam entry, attempted to add things but couldnt figure it out

This commit is contained in:
magicalfeyfenny 2021-07-10 20:21:52 -04:00
parent 11d2c6096c
commit bd0ff931dc
11 changed files with 177 additions and 101 deletions

View File

@ -3,7 +3,7 @@
{"id":{"name":"spr_testtex_bottom","path":"sprites/spr_testtex_bottom/spr_testtex_bottom.yy",},"order":9,},
{"id":{"name":"obj_player","path":"objects/obj_player/obj_player.yy",},"order":0,},
{"id":{"name":"scr_vertex_add_point","path":"scripts/scr_vertex_add_point/scr_vertex_add_point.yy",},"order":3,},
{"id":{"name":"Script3","path":"scripts/Script3/Script3.yy",},"order":7,},
{"id":{"name":"scr_model_load_block","path":"scripts/scr_model_load_block/scr_model_load_block.yy",},"order":7,},
{"id":{"name":"spr_testtex_top","path":"sprites/spr_testtex_top/spr_testtex_top.yy",},"order":8,},
{"id":{"name":"scr_initialize","path":"scripts/scr_initialize/scr_initialize.yy",},"order":4,},
{"id":{"name":"obj_block","path":"objects/obj_block/obj_block.yy",},"order":0,},

View File

@ -1,12 +1,21 @@
z = 0;
var s = 64;
var color = c_white;
//var s = 64;
//var color = c_white;
b_tex = spr_testtex_bottom;
b_face = global.model_cube[BOTTOM_FACE];
t_tex = spr_testtex_top;
n_tex = spr_testtex_side;
s_tex = spr_testtex_side;
w_tex = spr_testtex_side;
e_tex = spr_testtex_side;
b_face = global.model_cube[| BOTTOM_FACE];
t_face = global.model_cube[| TOP_FACE];
n_face = global.model_cube[| NORTH_FACE];
s_face = global.model_cube[| SOUTH_FACE];
w_face = global.model_cube[| WEST_FACE];
e_face = global.model_cube[| EAST_FACE];
/*
#region bottom face
b_tex = spr_testtex_bottom;
b_face = vertex_create_buffer();
@ -91,3 +100,4 @@ vertex_add_point( e_face, s, 0, 0, 1, 0, 0, 1, 1, color, 1);
vertex_end( e_face );
#endregion
*/

View File

@ -1,4 +1,7 @@
look_dir = 0;
look_pitch = 0;
placetarget = [-1,-1,-1];
deletetarget = [-1,-1,-1];
z = 70;

View File

View File

@ -2,6 +2,50 @@ look_dir -= ( window_mouse_get_x() - WINDOW_WIDTH / 2 ) / CAMERA_SENSITIVITY;
look_pitch -= ( window_mouse_get_y() - WINDOW_HEIGHT / 2 ) / CAMERA_SENSITIVITY;
look_pitch = clamp( look_pitch, -CAMERA_PITCH_MAX, CAMERA_PITCH_MAX );
placetarget = [-1,-1,-1];
deletetarget = [-1,-1,-1];
var deleteobj = noone;
var i = 0;
do {
var xtest = x + ((i + 32) * dcos( look_dir ));
var ytest = y + ((i + 32) * dsin( look_dir ));
var ztest = z + ((i + 32) * dsin( look_pitch ));
var xto = x + i * dcos( look_dir );
var yto = y + i * dsin( look_dir );
var zto = z + i * dsin( look_pitch );
var blockstack = ds_list_create();
var blockbuild = ds_list_create();
var blocknum = instance_position_list(xtest, ytest, obj_block, blockstack, false);
var buildnum = instance_position_list(xto, yto, obj_block, blockbuild, false);
if ( blocknum > 0 ) {
for (var j = 0; j < blocknum; j++) {
if ( ztest > blockstack[|j].z && ztest < blockstack[|j].z + 64 && point_distance_3d(x, y, z, xtest, ytest, ztest) < 256 ) {
deletetarget[0] = blockstack[|j].x div 64;
deletetarget[1] = blockstack[|j].y div 64;
deletetarget[2] = blockstack[|j].z div 64;
deleteobj = blockstack[|j];
if (buildnum == 0) {
placetarget[0] = xto div 64;
placetarget[1] = yto div 64;
placetarget[2] = zto div 64;
} else {
for (var k = 0; k < buildnum; k++) {
if (!(zto > blockbuild[|k].z && zto < blockbuild[|k].z + 64)) {
placetarget[0] = xto div 64;
placetarget[1] = yto div 64;
placetarget[2] = zto div 64;
}
}
}
}
}
}
if ((placetarget[0] < 0 || placetarget[1] < 0 || placetarget[2] < 0) || (placetarget[0] >= CHUNK_SIZE || placetarget[1] >= CHUNK_SIZE || placetarget[2] >= CHUNK_SIZE)) {
placetarget = [-1,-1,-1];
}
i += 32;
} until ( deletetarget != [-1,-1,-1] || i >= 256 );
window_mouse_set( WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 );
var move_speed = 5;
@ -12,6 +56,8 @@ var left = 0;
var right = 0;
var ascend = 0;
var descend = 0;
var place = 0;
var del = 0;
if ( keyboard_check( ord("W") ) ) {
up = 1;
@ -34,6 +80,12 @@ if ( keyboard_check( vk_control ) ) {
if ( keyboard_check( vk_escape ) ) {
game_end();
}
if ( mouse_check_button_pressed( mb_left ) ) {
place = 1;
}
if ( mouse_check_button_pressed( mb_right ) ) {
del = 1;
}
dir_mod = point_direction( 0, 0, (up - down), (right - left) );
@ -44,5 +96,16 @@ if ( up || down || left || right ) {
}
if ( ascend ^^ descend ) {
z = z + ascend - descend;
z = z + 4 * (ascend - descend);
}
if ( place && placetarget != [-1,-1,-1] ) {
with (deleteobj.chunk_id) {
chunk[obj_player.placetarget[0]][obj_player.placetarget[1]][obj_player.placetarget[2]] = BLOCKS_TEST;
var brick = instance_create_layer(x + BLOCK_SIZE * obj_player.placetarget[0], y + BLOCK_SIZE * obj_player.placetarget[1], "Terrain", obj_block);
with ( brick ) {
chunk_id = deleteobj.chunk_id;
z = other.z + BLOCK_SIZE * obj_player.placetarget[2];
}
}
}

View File

@ -20,6 +20,7 @@
"eventList": [
{"isDnD":false,"eventNum":0,"eventType":0,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
{"isDnD":false,"eventNum":0,"eventType":3,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
{"isDnD":false,"eventNum":0,"eventType":8,"collisionObjectId":null,"resourceVersion":"1.0","name":"","tags":[],"resourceType":"GMEvent",},
],
"properties": [],
"overriddenProperties": [],

View File

@ -14,7 +14,7 @@
],
"layers": [
{"instances":[
{"properties":[],"isDnd":false,"objectId":{"name":"obj_world","path":"objects/obj_world/obj_world.yy",},"inheritCode":false,"hasCreationCode":false,"colour":4294967295,"rotation":0.0,"scaleX":1.0,"scaleY":1.0,"imageIndex":0,"imageSpeed":1.0,"inheritedItemId":null,"frozen":false,"ignore":false,"inheritItemSettings":false,"x":0.0,"y":0.0,"resourceVersion":"1.0","name":"inst_5DBB2C44","tags":[],"resourceType":"GMRInstance",},
{"properties":[],"isDnd":false,"objectId":{"name":"obj_chunk","path":"objects/obj_chunk/obj_chunk.yy",},"inheritCode":false,"hasCreationCode":false,"colour":4294967295,"rotation":0.0,"scaleX":1.0,"scaleY":1.0,"imageIndex":0,"imageSpeed":1.0,"inheritedItemId":null,"frozen":false,"ignore":false,"inheritItemSettings":false,"x":0.0,"y":0.0,"resourceVersion":"1.0","name":"inst_5DBB2C44","tags":[],"resourceType":"GMRInstance",},
],"visible":true,"depth":0,"userdefinedDepth":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"gridX":32,"gridY":32,"layers":[],"hierarchyFrozen":false,"resourceVersion":"1.0","name":"Terrain","tags":[],"resourceType":"GMRInstanceLayer",},
{"instances":[
{"properties":[],"isDnd":false,"objectId":{"name":"obj_camera","path":"objects/obj_camera/obj_camera.yy",},"inheritCode":false,"hasCreationCode":false,"colour":4294967295,"rotation":0.0,"scaleX":1.0,"scaleY":1.0,"imageIndex":0,"imageSpeed":1.0,"inheritedItemId":null,"frozen":false,"ignore":false,"inheritItemSettings":false,"x":0.0,"y":0.0,"resourceVersion":"1.0","name":"inst_78CCA660","tags":[],"resourceType":"GMRInstance",},

View File

@ -1,91 +0,0 @@
/// @function
/// @param
function Script3(){
//TODO: Create a DS list for the model and return it
#region bottom face
b_face = vertex_create_buffer();
vertex_begin( b_face, global.vertex_format );
vertex_add_point( b_face, 0, 0, 0, 0, 0, -1, 0, 0, color, 1);
vertex_add_point( b_face, s, 0, 0, 0, 0, -1, 1, 0, color, 1);
vertex_add_point( b_face, s, s, 0, 0, 0, -1, 1, 1, color, 1);
vertex_add_point( b_face, s, s, 0, 0, 0, -1, 1, 1, color, 1);
vertex_add_point( b_face, 0, s, 0, 0, 0, -1, 0, 1, color, 1);
vertex_add_point( b_face, 0, 0, 0, 0, 0, -1, 0, 0, color, 1);
vertex_end( b_face );
#endregion
#region top face
t_tex = spr_testtex_top;
t_face = vertex_create_buffer();
vertex_begin( t_face, global.vertex_format );
vertex_add_point( t_face, 0, 0, s, 0, 0, 1, 0, 0, color, 1);
vertex_add_point( t_face, s, 0, s, 0, 0, 1, 1, 0, color, 1);
vertex_add_point( t_face, s, s, s, 0, 0, 1, 1, 1, color, 1);
vertex_add_point( t_face, s, s, s, 0, 0, 1, 1, 1, color, 1);
vertex_add_point( t_face, 0, s, s, 0, 0, 1, 0, 1, color, 1);
vertex_add_point( t_face, 0, 0, s, 0, 0, 1, 0, 0, color, 1);
vertex_end( t_face );
#endregion
#region north face
n_tex = spr_testtex_side;
n_face = vertex_create_buffer();
vertex_begin( n_face, global.vertex_format );
vertex_add_point( n_face, 0, 0, 0, 0, -1, 0, 1, 1, color, 1);
vertex_add_point( n_face, s, 0, 0, 0, -1, 0, 0, 1, color, 1);
vertex_add_point( n_face, s, 0, s, 0, -1, 0, 0, 0, color, 1);
vertex_add_point( n_face, s, 0, s, 0, -1, 0, 0, 0, color, 1);
vertex_add_point( n_face, 0, 0, s, 0, -1, 0, 1, 0, color, 1);
vertex_add_point( n_face, 0, 0, 0, 0, -1, 0, 1, 1, color, 1);
vertex_end( n_face );
#endregion
#region south face
s_tex = spr_testtex_side;
s_face = vertex_create_buffer();
vertex_begin( s_face, global.vertex_format );
vertex_add_point( s_face, 0, s, 0, 0, 1, 0, 1, 1, color, 1);
vertex_add_point( s_face, s, s, 0, 0, 1, 0, 0, 1, color, 1);
vertex_add_point( s_face, s, s, s, 0, 1, 0, 0, 0, color, 1);
vertex_add_point( s_face, s, s, s, 0, 1, 0, 0, 0, color, 1);
vertex_add_point( s_face, 0, s, s, 0, 1, 0, 1, 0, color, 1);
vertex_add_point( s_face, 0, s, 0, 0, 1, 0, 1, 1, color, 1);
vertex_end( s_face );
#endregion
#region west face
w_tex = spr_testtex_side;
w_face = vertex_create_buffer();
vertex_begin( w_face, global.vertex_format );
vertex_add_point( w_face, 0, 0, 0, -1, 0, 0, 1, 1, color, 1);
vertex_add_point( w_face, 0, s, 0, -1, 0, 0, 0, 1, color, 1);
vertex_add_point( w_face, 0, s, s, -1, 0, 0, 0, 0, color, 1);
vertex_add_point( w_face, 0, s, s, -1, 0, 0, 0, 0, color, 1);
vertex_add_point( w_face, 0, 0, s, -1, 0, 0, 1, 0, color, 1);
vertex_add_point( w_face, 0, 0, 0, -1, 0, 0, 1, 1, color, 1);
vertex_end( w_face );
#endregion
#region east face
e_tex = spr_testtex_side;
e_face = vertex_create_buffer();
vertex_begin( e_face, global.vertex_format );
vertex_add_point( e_face, s, 0, 0, 1, 0, 0, 1, 1, color, 1);
vertex_add_point( e_face, s, s, 0, 1, 0, 0, 0, 1, color, 1);
vertex_add_point( e_face, s, s, s, 1, 0, 0, 0, 0, color, 1);
vertex_add_point( e_face, s, s, s, 1, 0, 0, 0, 0, color, 1);
vertex_add_point( e_face, s, 0, s, 1, 0, 0, 1, 0, color, 1);
vertex_add_point( e_face, s, 0, 0, 1, 0, 0, 1, 1, color, 1);
vertex_end( e_face );
#endregion
}

View File

@ -22,6 +22,13 @@
#macro BLOCKS_TEST 1
#macro CHUNKS_TEST 1
#macro BOTTOM_FACE 0
#macro TOP_FACE 1
#macro NORTH_FACE 2
#macro SOUTH_FACE 3
#macro WEST_FACE 4
#macro EAST_FACE 5
#endregion
gml_pragma( "global", "scr_initialize()" );
@ -39,7 +46,7 @@ function scr_initialize() {
gpu_set_zwriteenable( true );
global.fog = gpu_get_fog();
global.model_cube = scr_model_load_block( BLOCK_SIZE, c_white );
return 0;
}

View File

@ -0,0 +1,83 @@
/// @function scr_model_load_block();
/// @param {real} _size
/// @param {color} _col
function scr_model_load_block( _size, _col ){
#region bottom face
var b_face = vertex_create_buffer();
vertex_begin( b_face, global.vertex_format );
vertex_add_point( b_face, 0, 0, 0, 0, 0, -1, 0, 0, _col, 1);
vertex_add_point( b_face, _size, 0, 0, 0, 0, -1, 1, 0, _col, 1);
vertex_add_point( b_face, _size, _size, 0, 0, 0, -1, 1, 1, _col, 1);
vertex_add_point( b_face, _size, _size, 0, 0, 0, -1, 1, 1, _col, 1);
vertex_add_point( b_face, 0, _size, 0, 0, 0, -1, 0, 1, _col, 1);
vertex_add_point( b_face, 0, 0, 0, 0, 0, -1, 0, 0, _col, 1);
vertex_end( b_face );
#endregion
#region top face
var t_face = vertex_create_buffer();
vertex_begin( t_face, global.vertex_format );
vertex_add_point( t_face, 0, 0, _size, 0, 0, 1, 0, 0, _col, 1);
vertex_add_point( t_face, _size, 0, _size, 0, 0, 1, 1, 0, _col, 1);
vertex_add_point( t_face, _size, _size, _size,0, 0, 1, 1, 1, _col, 1);
vertex_add_point( t_face, _size, _size, _size,0, 0, 1, 1, 1, _col, 1);
vertex_add_point( t_face, 0, _size, _size, 0, 0, 1, 0, 1, _col, 1);
vertex_add_point( t_face, 0, 0, _size, 0, 0, 1, 0, 0, _col, 1);
vertex_end( t_face );
#endregion
#region north face
var n_face = vertex_create_buffer();
vertex_begin( n_face, global.vertex_format );
vertex_add_point( n_face, 0, 0, 0, 0, -1, 0, 1, 1, _col, 1);
vertex_add_point( n_face, _size, 0, 0, 0, -1, 0, 0, 1, _col, 1);
vertex_add_point( n_face, _size, 0, _size, 0, -1, 0, 0, 0, _col, 1);
vertex_add_point( n_face, _size, 0, _size, 0, -1, 0, 0, 0, _col, 1);
vertex_add_point( n_face, 0, 0, _size, 0, -1, 0, 1, 0, _col, 1);
vertex_add_point( n_face, 0, 0, 0, 0, -1, 0, 1, 1, _col, 1);
vertex_end( n_face );
#endregion
#region south face
var s_face = vertex_create_buffer();
vertex_begin( s_face, global.vertex_format );
vertex_add_point( s_face, 0, _size, 0, 0, 1, 0, 1, 1, _col, 1);
vertex_add_point( s_face, _size, _size, 0, 0, 1, 0, 0, 1, _col, 1);
vertex_add_point( s_face, _size, _size, _size,0, 1, 0, 0, 0, _col, 1);
vertex_add_point( s_face, _size, _size, _size,0, 1, 0, 0, 0, _col, 1);
vertex_add_point( s_face, 0, _size, _size, 0, 1, 0, 1, 0, _col, 1);
vertex_add_point( s_face, 0, _size, 0, 0, 1, 0, 1, 1, _col, 1);
vertex_end( s_face );
#endregion
#region west face
var w_face = vertex_create_buffer();
vertex_begin( w_face, global.vertex_format );
vertex_add_point( w_face, 0, 0, 0, -1, 0, 0, 1, 1, _col, 1);
vertex_add_point( w_face, 0, _size, 0, -1, 0, 0, 0, 1, _col, 1);
vertex_add_point( w_face, 0, _size, _size, -1, 0, 0, 0, 0, _col, 1);
vertex_add_point( w_face, 0, _size, _size, -1, 0, 0, 0, 0, _col, 1);
vertex_add_point( w_face, 0, 0, _size, -1, 0, 0, 1, 0, _col, 1);
vertex_add_point( w_face, 0, 0, 0, -1, 0, 0, 1, 1, _col, 1);
vertex_end( w_face );
#endregion
#region east face
var e_face = vertex_create_buffer();
vertex_begin( e_face, global.vertex_format );
vertex_add_point( e_face, _size, 0, 0, 1, 0, 0, 1, 1, _col, 1);
vertex_add_point( e_face, _size, _size, 0, 1, 0, 0, 0, 1, _col, 1);
vertex_add_point( e_face, _size, _size, _size, 1, 0, 0, 0, 0, _col, 1);
vertex_add_point( e_face, _size, _size, _size, 1, 0, 0, 0, 0, _col, 1);
vertex_add_point( e_face, _size, 0, _size, 1, 0, 0, 1, 0, _col, 1);
vertex_add_point( e_face, _size, 0, 0, 1, 0, 0, 1, 1, _col, 1);
vertex_end( e_face );
#endregion
var model = ds_list_create();
ds_list_add( model, b_face, t_face, n_face, s_face, w_face, e_face );
return model;
}

View File

@ -6,7 +6,7 @@
"path": "minecraft-in-24h-jam.yyp",
},
"resourceVersion": "1.0",
"name": "Script3",
"name": "scr_model_load_block",
"tags": [],
"resourceType": "GMScript",
}