I
iMilchshake
Guest
Hey !
So im currently programming a roguelike top-down space-shooter where you should be able to build your Ship by yourself. But something s up at placing the blocks at the right location.
GIF:
https://gyazo.com/992827aa832d7081533dbd0ceade7819
Here's my code:
Create event (just for testing, later on the arrays will be written with informations automatically)
so basically each block has one entry in each ds_list.
"block" is for saving their id's
block_x is for saving their x_offset
block_y is for saving their y_offset
now reading out goes as following:
Where is my mistake? why are the blocks acting so weird?
So im currently programming a roguelike top-down space-shooter where you should be able to build your Ship by yourself. But something s up at placing the blocks at the right location.
GIF:
https://gyazo.com/992827aa832d7081533dbd0ceade7819
Here's my code:
Create event (just for testing, later on the arrays will be written with informations automatically)
Code:
cockpit=instance_create(x,y,basicCP) //Cockpit Object
cockpit_x=0; //Cockpit offset
cockpit_y=0;
blocks = ds_list_create();
block_x = ds_list_create();
block_y = ds_list_create();
ds_list_insert(blocks,0,instance_create(x,y,armor))
ds_list_insert(block_x,0,0)
ds_list_insert(block_y,0,64)
ds_list_insert(blocks,1,instance_create(x,y,armor))
ds_list_insert(block_x,1,-32)
ds_list_insert(block_y,1,0)
ds_list_insert(blocks,2,instance_create(x,y,armor))
ds_list_insert(block_x,2,32)
ds_list_insert(block_y,2,0)
ds_list_insert(blocks,3,instance_create(x,y,armor))
ds_list_insert(block_x,3,32)
ds_list_insert(block_y,3,-32)
ds_list_insert(blocks,4,instance_create(x,y,armor))
ds_list_insert(block_x,4,-32)
ds_list_insert(block_y,4,-32)
"block" is for saving their id's
block_x is for saving their x_offset
block_y is for saving their y_offset
now reading out goes as following:
Code:
dir=point_direction(x,y,mouse_x,mouse_y)
for (var a=0;a<ds_list_size(blocks);a+=1)
{
current_obj=ds_list_find_value(blocks,a)
current_obj.x=x+lengthdir_x(ds_list_find_value(block_x,a),dir)
current_obj.y=y+lengthdir_y(ds_list_find_value(block_y,a),dir)
current_obj.image_angle=dir
}
//Code for cockpit is basically the same