Skip to content

Commit

Permalink
Allow movement over vertical walls
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariasteam committed Feb 19, 2019
1 parent 149788e commit 557320b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
13 changes: 7 additions & 6 deletions Scenes/Player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@ var decal = preload("res://Scenes/decal.tscn")
onready var last_safe_rotation = axis.get_rotation().y

var platforms_counter = 0
var rotation_range = Vector2(0,0)
var rotation_range = Vector3(0,0,0)
var movement_limited = false

export (int) var n_platforms_to_meteorize = 3

var meteor = false
var color

func limit_rotation_range(allowed_range):
# z is the height
func limit_rotation_range(allowed_range):
movement_limited = true
var first = normalize_rot(allowed_range.x)
var second = normalize_rot(allowed_range.y)
rotation_range = Vector2(first, second)
rotation_range = Vector3(first, second, allowed_range.z)


func unlimit_rotation_range():
Expand Down Expand Up @@ -126,9 +127,9 @@ func is_in_range (v, r_a, r_b):
func _on_set_rotation (rot):
var intent_rotation = rot + last_safe_rotation
var current_rotation = axis.get_rotation_deg().y;
var has_collided = false

if (movement_limited):
var has_collided = false
if (movement_limited and ball.get_global_transform().origin.y < rotation_range.z): # check altitude of the ball
var local_rotation_range = Vector2(0,0)

if (current_rotation >= 0):
Expand Down
6 changes: 3 additions & 3 deletions Scenes/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func _ready():
aux.set_translation(Vector3(0,rand_range(-0.01, 0.01), 0))
aux.set_material (global.mat_regular)
elif (rand == 15 and !cant_move):
var segment_width = offset / 2;
allowed_range = Vector2(rot - offset - segment_width, rot - 2)
var segment_width = offset / 2;
allowed_range = Vector3(rot - offset - segment_width, rot - 2, get_translation().y + get_parent().space)
cant_move = true
aux = segment_tall.instance()
aux.set_material (global.mat_regular)
Expand All @@ -52,7 +52,7 @@ func _process(delta):
rotate(Vector3(0,1,0), velocity * 0.0003)

func send_next_platform_limits():
if (next_platform.allowed_range != Vector2(-1,-1)):
if (next_platform.allowed_range != Vector3(-1,-1,-1)):
global.player.limit_rotation_range(next_platform.allowed_range)
else:
global.player.unlimit_rotation_range()
Expand Down
4 changes: 2 additions & 2 deletions abstract_platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ var segment = preload ("res://Scenes/Regular_Segment.tscn")

var next_platform

var allowed_range = Vector2(-1,-1)
var allowed_range = Vector3(-1,-1, -1)

const SEGMENTS = 16
onready var offset = float(360) / SEGMENTS

func send_next_platform_limits():
if (next_platform.allowed_range != Vector2(-1,-1)):
if (next_platform.allowed_range != Vector3(-1,-1,-1)):
global.player.limit_rotation_range(next_platform.allowed_range)
else:
global.player.unlimit_rotation_range()
Expand Down

0 comments on commit 557320b

Please sign in to comment.