Skip to content

Commit

Permalink
Merge pull request #1 from reinlmao/master
Browse files Browse the repository at this point in the history
Add support for Camera2D's "zoom" property
  • Loading branch information
sarooptech committed Sep 20, 2023
2 parents 7ef4368 + 0256553 commit 70d38e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions BoxCam2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func _process(_delta):

player_pos = self.get_node(player).position

var current_box = Vector2(floor(player_pos.x/ design_res.x), floor(player_pos.y/ design_res.y))
var current_box = Vector2(floor(player_pos.x / (design_res.x * zoom.x)), floor(player_pos.y / (design_res.y * zoom.y)))

if current_box.x != box.x or current_box.y != box.y:
emit_signal("out_of_the_box")
box = current_box

func set_box_pos():
var box_pos_x = ( design_res.x * floor(player_pos.x/ design_res.x) )
var box_pos_y = ( design_res.y * floor(player_pos.y/ design_res.y) )
var box_pos_x = ((design_res.x * zoom.x) * floor(player_pos.x / (design_res.x * zoom.x)))
var box_pos_y = ((design_res.y * zoom.y) * floor(player_pos.y / (design_res.y * zoom.y)))

self.position.x = design_res.x/2 + box_pos_x
self.position.y = design_res.y/2 + box_pos_y
self.position.x = ((design_res.x / 2) * zoom.x) + box_pos_x
self.position.y = ((design_res.y / 2) * zoom.y) + box_pos_y

0 comments on commit 70d38e9

Please sign in to comment.