Hello,
I'm trying to create a tile based(32*32) diamond shape on the map but I'm having a hard time. At first I wanted an ellipse but then figured out that it didn't work/look so well, except for movement(in a TBS).
Here is the ellipse:
Here is what I want:
http://www.unknowncoders.com/rmxp/scree ... elpdim.PNG[/img]
Here is the ellipse code/formula:
I'm trying to create a tile based(32*32) diamond shape on the map but I'm having a hard time. At first I wanted an ellipse but then figured out that it didn't work/look so well, except for movement(in a TBS).
Here is the ellipse:
http://www.unknowncoders.com/rmxp/screenshots/ellipse.PNG[/img]
Here is what I want:
http://www.unknowncoders.com/rmxp/scree ... elpdim.PNG[/img]
Here is the ellipse code/formula:
Code:
#-----------------------------------------------------------------------------
# * Calculate Tiles - Ellipse
#-----------------------------------------------------------------------------
def calculate_tiles(h_r, v_r, center,c_pass=true)
@current_tiles = {}
if v_r >= h_r
for current_v in 1..v_r
for current_h in 1..h_r
calculate_tile(current_h,current_v, center,c_pass)
end
end
else
for current_h in 1..h_r
for current_v in 1..v_r
calculate_tile(current_h,current_v, center,c_pass)
end
end
end
end
#-----------------------------------------------------------------------------
# * Calculate Tile Pos
#-----------------------------------------------------------------------------
def calculate_tile(h_r, v_r, center,c_pass)
for angle in 0...360
x = Math.cos(angle)*h_r + center.x
y = Math.sin(angle)*v_r + center.y
# Check if passible
next unless center.tbs_passable?(x.round,y.round,0,c_pass)
@current_tiles.push([x.round, y.round])
end
end