Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | moyles |
Here is my code for map generation. I want to make particles emit from
Dirtwall to produce a smoke-like effect from them. I’m considerably
far in my game development, but the further I get, the more confused I
am(guess thats learning, though.) How would i do this? I have a
particle scene ready to call but even then I don’t know how i would
specifically set EACH particle on each Dirtwall generated.
func make_map():
loadingbar.update_percent(load_percent)
#core of map floor / rock
for x in range(1, current_map_size.x - 1):
for y in range(1, current_map_size.y -1):
var num = rand_range(0.0, 100.0)
if num < percentage_floors:
set_cell(x,y, TILES.Wispfloor)
update_bitmask_region(Vector2(0.0, 0.0), Vector2(current_map_size.x, current_map_size.y))
else:
set_cell(x,y, TILES.Dirtwall)
#Rockborder set L/R Sides
for x in [0, current_map_size.x - 1]:
for y in current_map_size.y:
set_cell(x, y, TILES.Dirtwall)
#Top n Bot Sides
for x in current_map_size.x:
for y in [0, current_map_size.y - 1]:
set_cell(x, y, TILES.Dirtwall)
func smooth_map():
load_percent += 10
loadingbar.update_percent(load_percent)
#
for x in range(1, current_map_size.x - 1):
for y in range(1, current_map_size.y - 1):
var number_of_neighbor_walls = 0
for direction in neighbor_dir:
var current_tile = Vector2(x,y) + direction
if get_cell(current_tile.x, current_tile.y) == TILES.Dirtwall:
number_of_neighbor_walls += 1
#check if we should change tile based on neighboring tiles
if number_of_neighbor_walls > 4:
set_cell(x,y, TILES.Dirtwall)
elif number_of_neighbor_walls < 4:
set_cell(x,y, TILES.Wispfloor)
update_bitmask_region(Vector2(0.0, 0.0), Vector2(current_map_size.x, current_map_size.y))
From your code it’s not apparent when and where you want to spawn the particles. In principle this is as easy as setting the global_position
-property of the Particle2D to the global_position
of the tile which you can get by the following line:
to_global($TileMap.map_to_world(Vector2(x, y)))
Edit: map_to_world
expects a Vector2() instead of two variables for x
and y
njamster | 2020-06-18 13:03
I haven’t included any code that has to do about the particle generation, but that makes sense. would that apply the particles to each and every specific Dirtwall generated block?
Thats what i’m trying to pull off
moyles | 2020-06-19 00:14