Skip to content

Commit

Permalink
made camera spawn at player position
Browse files Browse the repository at this point in the history
  • Loading branch information
jaschutte committed Apr 10, 2022
1 parent 72db4b3 commit 07675e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
32 changes: 16 additions & 16 deletions actors/camera_area/camera_area.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ onready var collision = $StaticBody2D/CollisionPolygon2D
onready var body = $KinematicBody2D
onready var body_collision: CollisionPolygon2D = $KinematicBody2D/CollisionPolygon2D

export var spawn_position: Vector2 setget force_draw
#export var spawn_position: Vector2 setget force_draw

var window_prev_length: float
var shrink_number = 0

func force_draw(val):
spawn_position = val
update()

func _draw():
if Engine.editor_hint:
draw_rect(Rect2(
spawn_position - Vector2(Singleton.DEFAULT_SIZE.x * 2, Singleton.DEFAULT_SIZE.y) / 2,
Vector2(Singleton.DEFAULT_SIZE.x * 2, Singleton.DEFAULT_SIZE.y)
), Color(1, 0, 1, 0.5))
draw_rect(Rect2(
spawn_position - Vector2(Singleton.DEFAULT_SIZE.x, Singleton.DEFAULT_SIZE.y) / 2,
Vector2(Singleton.DEFAULT_SIZE.x, Singleton.DEFAULT_SIZE.y)
), Color(0, 0, 1, 0.5))
#func force_draw(val):
# spawn_position = val
# update()
#
#func _draw():
# if Engine.editor_hint:
# draw_rect(Rect2(
# spawn_position - Vector2(Singleton.DEFAULT_SIZE.x * 2, Singleton.DEFAULT_SIZE.y) / 2,
# Vector2(Singleton.DEFAULT_SIZE.x * 2, Singleton.DEFAULT_SIZE.y)
# ), Color(1, 0, 1, 0.5))
# draw_rect(Rect2(
# spawn_position - Vector2(Singleton.DEFAULT_SIZE.x, Singleton.DEFAULT_SIZE.y) / 2,
# Vector2(Singleton.DEFAULT_SIZE.x, Singleton.DEFAULT_SIZE.y)
# ), Color(0, 0, 1, 0.5))

func get_rect(poly, margin = 0):
var min_v = Vector2.INF
Expand Down Expand Up @@ -138,7 +138,7 @@ func _ready():
set_hitbox_extends(OS.window_size)
shrink_number = 0

body.position = spawn_position
body.position = player.position # spawn_position
#make it invisible
color = Color(0, 0, 0, 0)

Expand Down
1 change: 0 additions & 1 deletion scenes/tutorial_1/tutorial_1_4.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ shader_param/color5 = Color( 0.713726, 0.278431, 0.156863, 1 )

[node name="CameraArea" parent="." instance=ExtResource( 36 )]
polygon = PoolVector2Array( -389, -160, -1008, -160, -1008, -848, 1168, -848, 1168, -400, 816, -400, 747.278, -319.208, 752, 288, -320, 288, -322, -92 )
spawn_position = Vector2( 600, 0 )

[node name="Player" parent="." instance=ExtResource( 18 )]
position = Vector2( -81, 193 )
Expand Down

0 comments on commit 07675e0

Please sign in to comment.