Skip to content

Commit

Permalink
Added depth and Z-index management.
Browse files Browse the repository at this point in the history
  • Loading branch information
StraToN committed Apr 5, 2016
1 parent e5c8309 commit 1855aca
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 14 deletions.
Binary file added Assets/rooms/desk/bureau.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assets/rooms/desk/desk.scn
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/rooms/desk/desk_hide.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

extends CollisionPolygon2D

func _ready():
set_trigger(true)
pass


Binary file added Assets/rooms/desk/spot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/rooms/desk/table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Assets/rooms/lab/bg.jpg
Binary file not shown.
Binary file removed Assets/rooms/lab/lab.scn
Binary file not shown.
Binary file modified Assets/sprites/guybrush.scn
Binary file not shown.
1 change: 1 addition & 0 deletions Assets/sprites/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends KinematicBody2D
func interact(target):
pass


func _ready():
set_process(true)

Expand Down
15 changes: 8 additions & 7 deletions Assets/sprites/scripts/CharacterClickMovement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
extends Navigation2D

export(NodePath) var playerPath
var player
var terrain
onready var player = get_node(playerPath)
onready var terrain = get_parent()

var begin=Vector2()
var end=Vector2()
Expand All @@ -20,7 +20,7 @@ var speed = DEFAULT_SPEED

func _process(delta):
if (path.size()>1):
print(speed)
#print(speed)
var to_walk = delta*speed

while(to_walk>0 and path.size()>=2):
Expand Down Expand Up @@ -80,7 +80,12 @@ func _process(delta):
player.set_pos(atpos)

# rescale selon la profondeur donnée par le terrain
print("Terrain Depth = ", terrain.get_scale(atpos))
player.set_scale(terrain.get_scale(atpos))
# modif du Z-index selon la profondeur donnée par le terrain.
player.set_z(terrain.get_scale(atpos).x/0.5*2.2)
print("ScaleX = ", terrain.get_scale(atpos).x/0.5)
print("PlayerZ = ", player.get_z())


if (path.size()<2):
Expand Down Expand Up @@ -141,12 +146,8 @@ func _ready():
##for nodesGrp in arrNodesInGrp:
## if nodesGrp.get_name() == "player":
## player = nodesGrp
player = get_node(playerPath)

player.get_node("sprite/anim").set_current_animation("idle_right")

terrain = get_parent()

set_process_input(true)
pass

12 changes: 5 additions & 7 deletions Assets/terrain.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Sprite


export(Image) var depthFile
export(float) var nearScale = 1.0
export(float) var nearScale = 0.9
export(float) var farScale = 0.5
var originalScale = farScale + (nearScale-farScale)/2

Expand All @@ -16,15 +16,13 @@ func _get_scale_range(r):
return Vector2(dr, dr)

func get_scale_diff(begin, end):
printt("BEGIN", begin, get_scale(begin))
printt("END", end, get_scale(end))
printt("DIFF", abs((get_scale(begin) - get_scale(end)).x) )
print()
#printt("BEGIN", begin, get_scale(begin))
#printt("END", end, get_scale(end))
#printt("DIFF", abs((get_scale(begin) - get_scale(end)).x) )
#print()
return abs( (get_scale(begin) - get_scale(end)).x)

func _ready():
# Initialization here

pass


0 comments on commit 1855aca

Please sign in to comment.