Skip to content

Commit

Permalink
corrections de plusieurs bugs liés à l'auto_cam, 543dffa & 258f9f5. A…
Browse files Browse the repository at this point in the history
…jout de F11 pour le fullscreen
  • Loading branch information
CorentinBrule committed Aug 21, 2024
1 parent e30db39 commit a4aea82
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
35 changes: 27 additions & 8 deletions Niveau/CameraController.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var auto_cam = false
var joystick_zoom = false

var avatar
var GUI
var middle_pos = Vector2(192, 192)
var target_pos
var zoom_val = 1
var zoom_val = 0.5
var zoom_speed = 0.1
var max_zoom = Vector2(0.2, 0.2)
var min_zoom = Vector2(2,2)
Expand All @@ -24,16 +25,22 @@ var zooming = false

func _ready():
avatar = get_parent().get_node("Avatar")
GUI = get_parent().get_node("GUI")
get_tree().get_root().connect("size_changed", self, "on_resize_window")
clip_left_position_dest = $ClipGauche.rect_position.x
clip_left_width_dest = $ClipGauche.rect_size.x
$"%Reveal_actions_touch_overflow".scale.x = $ClipGauche.rect_position.x
$"%Reveal_actions_touch_overflow".position.x = $ClipGauche.rect_position.x + ($"%Reveal_actions_touch_overflow".scale.x/2)
clip_right_position_dest = $ClipDroite.rect_position.x
clip_right_width_dest = $ClipDroite.rect_size.x
init()
#init()

func init():
update_mid_zoom(GUI.width_out_game_interface)
if !auto_cam:
zoom_val = 0.5
zoom_to_game()
if zoom_val == 0.5:
zoom_dest = mid_zoom
zoom = mid_zoom
open_clip_controls()
else:
clip_open_left = true
Expand Down Expand Up @@ -121,7 +128,7 @@ func calc_zoom_dest(max_zoom,min_zoom,zoom_val):
return _zoom_dest

func zoom_to_game():
print(mid_zoom)
# print(mid_zoom)
zoom_dest = mid_zoom
zoom_val = 0.5
clip_open_right = false
Expand All @@ -145,7 +152,7 @@ func update_mid_zoom(width_out_game_interface):
# valeurs arbitraires mais fonctionne pour la plus part des ratios
var zoom = 0.7+(1/width_ratio)
#var zoom = (384/width_out_game_interface)
mid_zoom = Vector2(zoom, zoom)
mid_zoom = Vector2(zoom, zoom)
else:
mid_zoom = Vector2(1.0,1.0)

Expand All @@ -171,10 +178,10 @@ func adapt_clips():
func update_clip():
if(abs($ClipGauche.rect_size.x - clip_left_width_dest) > 0.5):
$ClipGauche.rect_size.x = lerp($ClipGauche.rect_size.x, clip_left_width_dest, 0.05)
$"%Reveal_actions_touch_overflow".scale.x = lerp($ClipGauche.rect_size.x, clip_left_width_dest, 0.05)
$"%Reveal_actions_touch_overflow".scale.x = $ClipGauche.rect_size.x
if(abs($ClipGauche.rect_position.x - clip_left_position_dest) > 0.5):
$ClipGauche.rect_position.x = lerp($ClipGauche.rect_position.x, clip_left_position_dest, 0.05)
$"%Reveal_actions_touch_overflow".position.x = $ClipGauche.rect_position.x + ($"%Reveal_actions_touch_overflow".scale.x/2)
$"%Reveal_actions_touch_overflow".position.x = $ClipGauche.rect_position.x + ($"%Reveal_actions_touch_overflow".scale.x/2)
if(abs($ClipDroite.rect_position.x - clip_right_position_dest) > 0.5):
$ClipDroite.rect_position.x = lerp($ClipDroite.rect_position.x, clip_right_position_dest, 0.05)
if(abs($ClipDroite.rect_size.x - clip_right_width_dest) > 0.5):
Expand All @@ -183,6 +190,8 @@ func update_clip():
func force_update_clip():
$ClipGauche.rect_position.x = clip_left_position_dest
$ClipGauche.rect_size.x = clip_left_width_dest
$"%Reveal_actions_touch_overflow".scale.x = clip_left_width_dest
$"%Reveal_actions_touch_overflow".position.x = $ClipGauche.rect_position.x + ($"%Reveal_actions_touch_overflow".scale.x/2)
$ClipDroite.rect_position.x = clip_right_position_dest
$ClipDroite.rect_size.x = clip_right_width_dest

Expand All @@ -194,3 +203,13 @@ func open_clips():
func open_clip_controls():
clip_open_right = true
adapt_clips()

func on_resize_window():
if not Engine.editor_hint:
update_mid_zoom(GUI.width_out_game_interface)
adapt_clips()
force_update_clip()
if zoom_val == 0.5:
zoom_to_game()
else:
zoom_to_out()
3 changes: 0 additions & 3 deletions Niveau/GUI/GUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ func adapt_interface():
func on_resize_window():
if not Engine.editor_hint:
adapt_interface()
get_parent().get_node("Camera2D").update_mid_zoom(width_out_game_interface)
get_parent().get_node("Camera2D").adapt_clips()
get_parent().get_node("Camera2D").force_update_clip()

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
Expand Down
9 changes: 6 additions & 3 deletions Niveau/trigger_end.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ func _on_Trigger_end_body_entered(body):
var camera = get_parent().get_node('Camera2D')
avatar.set_process(false)
avatar.set_physics_process(false)
camera.auto_cam = false
camera.zoom_to_out()
var auto_cam = camera.auto_cam
if auto_cam:
camera.auto_cam = false
camera.zoom_to_out()
transition = true
yield(get_tree().create_timer(1), "timeout")
transition = false
camera.auto_cam = true
if auto_cam:
camera.auto_cam = true
Global.next_save()
else:
get_parent().get_node("GUI").get_node("%win").show()
3 changes: 2 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ menu={
}
toggle_full_screen={
"deadzone": 0.5,
"events": [ ]
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777254,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}

[layer_names]
Expand Down
2 changes: 1 addition & 1 deletion tools.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func _ready():
camera = get_node("Niveau/Camera2D")
camera.auto_cam = auto_cam
camera.joystick_zoom = joystick_zoom

camera.init()

if(Global.has_touch_screen):
OS.window_fullscreen = true
Expand Down

0 comments on commit a4aea82

Please sign in to comment.