Skip to content

Commit

Permalink
fixed torches attaching to correct wall
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Jul 29, 2024
1 parent 66dbdd2 commit db0b1f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Autoload/Utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func load_external_texture(path):
var img = Image.new()
img.load(path)
var texture = ImageTexture.new()
texture.create_from_image(img)
texture.create_from_image(img, Texture.FLAG_MIPMAPS+Texture.FLAG_ANISOTROPIC_FILTER)
return texture

func get_filetype_in_directory(directory_path: String, file_extension: String) -> Array:
Expand Down
20 changes: 8 additions & 12 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,14 @@ func place_new_thing(newThingType, newSubtype, newPosition, newOwnership): # Pla
elif id.subtype == 133: # Mysterious Box
id.boxNumber = oPlacingSettings.boxNumber
elif id.subtype in [2,7]: # Torch and Unlit Torch
if Slabs.data[oDataSlab.get_cell(xSlab+1,ySlab)][Slabs.IS_SOLID] == true:
id.locationX += 0.25
id.parentTile = (xSlab+1) + ((ySlab) * M.xSize) # Should this be M.ySize ???
if Slabs.data[oDataSlab.get_cell(xSlab-1,ySlab)][Slabs.IS_SOLID] == true:
id.locationX -= 0.25
id.parentTile = (xSlab-1) + ((ySlab) * M.xSize) # Should this be M.ySize ???
if Slabs.data[oDataSlab.get_cell(xSlab,ySlab+1)][Slabs.IS_SOLID] == true:
id.locationY += 0.25
id.parentTile = (xSlab) + ((ySlab+1) * M.xSize) # Should this be M.ySize ???
if Slabs.data[oDataSlab.get_cell(xSlab,ySlab-1)][Slabs.IS_SOLID] == true:
id.locationY -= 0.25
id.parentTile = (xSlab) + ((ySlab-1) * M.xSize) # Should this be M.ySize ???
for direction in [Vector2(1, 0), Vector2(-1, 0), Vector2(0, 1), Vector2(0, -1)]:
var getParentSlabX = floor((newPosition.x + direction.x) / 3)
var getParentSlabY = floor((newPosition.y + direction.y) / 3)
if Slabs.data[oDataSlab.get_cell(getParentSlabX, getParentSlabY)][Slabs.IS_SOLID] == true:
id.locationX += direction.x * 0.25
id.locationY += direction.y * 0.25
id.parentTile = getParentSlabX + (getParentSlabY * M.xSize)
break # We only want to adjust for one solid slab
update_stray_torch_height(id)
elif id.subtype in Things.LIST_OF_GOLDPILES:
match id.subtype:
Expand Down
12 changes: 9 additions & 3 deletions Scenes/OverheadGraphics.gd
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ func overhead2d_update_rect_single_threaded(shapePositionArray):
overheadTexData.create_from_image(overheadImgData, 0)
emit_signal("column_graphics_completed")

const subtile3x3 = [
Vector2(0,0), Vector2(1,0), Vector2(2,0),
Vector2(0,1), Vector2(1,1), Vector2(2,1),
Vector2(0,2), Vector2(1,2), Vector2(2,2)
]

func generate_pixel_data(pixData, shapePositionArray):
var CODETIME_START = OS.get_ticks_msec()
var width = M.xSize * 3
Expand All @@ -61,9 +67,9 @@ func generate_pixel_data(pixData, shapePositionArray):
var basePosX = pos.x * 3
var basePosY = pos.y * 3
var slabID = oDataSlab.get_cellv(pos)
for i in range(9): # 3x3 subtiles
var x = basePosX + (i % 3)
var y = basePosY + (i / 3)
for offset in subtile3x3: # 3x3 subtiles
var x = basePosX + offset.x
var y = basePosY + offset.y
var clmIndex = oDataClmPos.get_cell_clmpos(x, y)
var cubeFace = oDataClm.get_top_cube_face(clmIndex, slabID)
var pixelIndex = ((y * width) + x) * 3
Expand Down

0 comments on commit db0b1f2

Please sign in to comment.