diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 deleted file mode 100644 index f3656be..0000000 --- a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 +++ /dev/null @@ -1,3 +0,0 @@ -source_md5="ae7e641067601e2184afcade49abd283" -dest_md5="84511021bbc8c9d37c7f0f4d181de883" - diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex deleted file mode 100644 index 1f08a3c..0000000 Binary files a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex and /dev/null differ diff --git a/Scenes/Column.gd b/Scenes/Column.gd index ce2e387..ec1692d 100644 --- a/Scenes/Column.gd +++ b/Scenes/Column.gd @@ -8,14 +8,7 @@ func _ready(): set_process(true) func receive_input (rot): - return player._on_set_rotation (rot * 3) + return player._on_set_rotation (rot) func lock_rot(): - player.lock_rot() - -func _process(delta): - if (Input.is_action_pressed("ui_left")): - player._on_set_rotation (-0.002) - elif (Input.is_action_pressed("ui_right")): - player._on_set_rotation (0.002) - \ No newline at end of file + player.lock_rot() \ No newline at end of file diff --git a/Scenes/Player.gd b/Scenes/Player.gd index af7395b..2e245ce 100644 --- a/Scenes/Player.gd +++ b/Scenes/Player.gd @@ -23,11 +23,11 @@ onready var acceleration_sound = get_node("AccelerationSound") var colliding = false +var prev_frame_rotation = 0 + var decal = preload("res://Scenes/decal.tscn") -onready var rotation = axis.get_rotation_deg() -onready var last_safe_rotation = axis.get_rotation() -onready var collision_rotation = axis.get_rotation() +onready var last_safe_rotation = axis.get_rotation().y var counter = 0 var rotation_range = Vector2(0,0) @@ -82,39 +82,33 @@ func block_camera(): func release_camera(): rigid_2.set_sleeping(false) -func on_platform_passed(): +func on_platform_passed(): release_camera() - rigid_2.set_linear_velocity(rigid.get_linear_velocity()) + rigid_2.set_linear_velocity(rigid.get_linear_velocity()) global.update_points((counter + 1) * 10) global.update_progress() - if (counter == 1 and global.sound_enabled): + if (counter == 1 and global.sound_enabled): acceleration_sound.play(1.5) counter += 1 if (counter == n_platforms_to_meteorize - 1): rigid.set_gravity_scale(0) - if (counter >= n_platforms_to_meteorize): + if (counter >= n_platforms_to_meteorize): meteor_particles.set_emitting(true) meteorize() -func lock_rot(): - last_safe_rotation = axis.get_rotation_deg() - rotation = axis.get_rotation_deg() - -func normalize_rot(rot): - var changed = true - while (changed): - changed = false - if (rot >= 360): - rot -= 360 - changed = true - elif (rot < 0): - rot += 360 - changed = true +func lock_rot(): + last_safe_rotation = axis.get_rotation_deg().y + +func normalize_rot(rot): + while (rot < 0): + rot += 360 + while (rot > 360): + rot -= 360 return rot @@ -122,51 +116,69 @@ func set_player_rotation (value): axis.set_rotation_deg(Vector3(0,value,0)) camera_axis.set_rotation_deg(Vector3(0,value,0)) + func is_in_range (v, r_a, r_b): - # Hay bloqueo - if (r_a - r_b > 40): - if (r_a < r_b): - return (v < r_a or v > r_b) - else: - return (v < r_b or v > r_a) - else: - if (r_a < r_b): - return (v > r_a and v < r_b) - else: - return (v > r_b and v < r_a) + return v > r_a and v < r_b + + +func _on_set_rotation (rot): + var intent_rotation = rot + last_safe_rotation + var current_rotation = axis.get_rotation_deg().y; -func _on_set_rotation (rot): - var intent_rotation = rot + last_safe_rotation.y - var rot_dir = axis.get_rotation_deg().y; + var has_collided = false + var is_left = true - if (movement_limited): + if (movement_limited): + # "Change basis" so first wall is at 180 degrees + var adjustment_offset = -rotation_range.x + var local_normalized_intent_rotation = normalize_rot(intent_rotation + adjustment_offset) + var local_current_rotation = normalize_rot(current_rotation + adjustment_offset) + var local_rotation_range = Vector2 (0, 0) + + # "Change basis" so second wall is at 180 degrees + adjustment_offset = -rotation_range.y + var local_normalized_intent_rotation_2 = normalize_rot(intent_rotation + adjustment_offset) + var local_current_rotation_2 = normalize_rot(current_rotation + adjustment_offset) + var local_rotation_range_2 = Vector2(0, 0) + + #print ("R ", local_rotation_range, " ", intent_rotation, " ", current_rotation) + + if (intent_rotation > prev_frame_rotation): + is_left = false - # CASE IN BETWEEN - if (is_in_range(intent_rotation, rotation_range.x, rotation_range.y)): - var diff_a = abs(rot_dir - rotation_range.x) - var diff_b = abs(rot_dir - rotation_range.y) + if (is_in_range(local_current_rotation, local_rotation_range.x, local_rotation_range.y) and 100 < 8): + var diff_a = abs(local_current_rotation - local_rotation_range.x) + var diff_b = abs(local_current_rotation - local_rotation_range.y) if (diff_a < diff_b): intent_rotation = rotation_range.x else: intent_rotation = rotation_range.y - - - if (rotation_range.x < rotation_range.y): - # REGULAR CASE - if (rot_dir <= rotation_range.x and intent_rotation >= rotation_range.x): # PLAYER IS PRE WALL - return false; - elif (rot_dir >= rotation_range.y and intent_rotation <= rotation_range.y): # PLAYER IS POST WALL - return false; - else: # INVERTED CASE - var aux_norm = normalize_rot(intent_rotation) - if (rot_dir <= rotation_range.y and aux_norm <= rotation_range.y): # PLAYER IS POST WALL - return false; - elif (rot_dir <= rotation_range.x and intent_rotation >= rotation_range.x): # PLAYER IS PRE WALL - return false; - + + if (!is_left): + if (local_normalized_intent_rotation >= local_current_rotation and + local_normalized_intent_rotation < 360): + #print ("GOOD A") + pass + else: + print ("BAD A", rotation_range.x) + intent_rotation = rotation_range.x + has_collided = true + else: + if (local_normalized_intent_rotation_2 > 0 and + local_normalized_intent_rotation_2 <= local_current_rotation_2): + #print ("GOOD B") + pass + else: + print ("BAD B") + intent_rotation = rotation_range.y + has_collided = true + + #print ("moviendo a ", intent_rotation, " desde ", current_rotation) + + prev_frame_rotation = intent_rotation set_player_rotation(normalize_rot(intent_rotation)) - return true + return !has_collided func end_animation(): ball.queue_free() @@ -238,9 +250,9 @@ func meteorize(): func _on_Timer_timeout(): global.handle_lose() -func _on_Area_body_exit( body ): +func _on_Area_body_exit( body ): colliding = false -func _on_Area_area_enter( area ): +func _on_Area_area_enter( area ): if (area.is_in_group("deleter") and !meteor): block_camera() diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index 53bcf36..39a3488 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -555,7 +555,7 @@ input/ray_pickable = false input/capture_on_drag = false shape_count = 1 shapes/0/shape = SubResource( 2 ) -shapes/0/transform = Transform( 0.019017, 0, 0, 0, 0.019017, 0, 0, 0, 0.019017, 0, -0.594566, -0.108771 ) +shapes/0/transform = Transform( 0.019017, 0, 0, 0, 0.019017, 0, 0, 0, 0.019017, 0, -0.571903, -0.108771 ) shapes/0/trigger = true space_override = 0 gravity_point = false @@ -573,7 +573,7 @@ collision/mask = 3 [node name="CollisionShape" type="CollisionShape" parent="RigidBody/Axis/Group/Area"] _import_transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) -transform/local = Transform( 0.019017, 0, 0, 0, 0.019017, 0, 0, 0, 0.019017, 0, -0.594566, -0.108771 ) +transform/local = Transform( 0.019017, 0, 0, 0, 0.019017, 0, 0, 0, 0.019017, 0, -0.571903, -0.108771 ) shape = SubResource( 2 ) trigger = true _update_shape_index = 0 diff --git a/Scenes/decal.gd b/Scenes/decal.gd index 7c43190..63e0644 100644 --- a/Scenes/decal.gd +++ b/Scenes/decal.gd @@ -1,14 +1,14 @@ extends Quad -# class member variables go here, for example: -# var a = 2 -# var b = "textvar" +onready var color = Color (get_tree().get_nodes_in_group("player")[0].color) -func _ready(): - var color = get_tree().get_nodes_in_group("player")[0].color +func _ready(): + var mat = get_material_override().duplicate() + set_material_override(mat) get_material_override().set_parameter(FixedMaterial.PARAM_DIFFUSE, color) - pass - -func _on_Timer_timeout(): - queue_free() +func _on_OpacityTimer_timeout(): + if (color.a <= 0): + queue_free() + color.a -= 0.001 + get_material_override().set_parameter(FixedMaterial.PARAM_DIFFUSE, color) diff --git a/Scenes/decal.tscn b/Scenes/decal.tscn index aca2f37..5e3fcec 100644 --- a/Scenes/decal.tscn +++ b/Scenes/decal.tscn @@ -65,13 +65,13 @@ quad/offset = Vector2( 0, 0 ) quad/centered = true script/script = ExtResource( 2 ) -[node name="Timer" type="Timer" parent="."] +[node name="OpacityTimer" type="Timer" parent="."] process_mode = 1 -wait_time = 10.0 -one_shot = true +wait_time = 0.01 +one_shot = false autostart = true -[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"] +[connection signal="timeout" from="OpacityTimer" to="." method="_on_OpacityTimer_timeout"] diff --git a/Scenes/platform.gd b/Scenes/platform.gd index 5953fb4..dc3f535 100644 --- a/Scenes/platform.gd +++ b/Scenes/platform.gd @@ -13,7 +13,7 @@ func _ready(): for i in range(0, 14): var aux = null - var rand = (randi()%20+1) + var rand = (randi()% 20+1) var rot = ((offset * i) + angle_offset) + 7 if (rand >= 17): diff --git a/engine.cfg b/engine.cfg index fad76f8..84c0601 100644 --- a/engine.cfg +++ b/engine.cfg @@ -35,6 +35,7 @@ motion_fix_enabled=true [rasterizer] +low_memory_2d_mode=true anisotropic_filter_level=2.0 shadow_filter=1 diff --git a/export.cfg b/export.cfg index cbcda5e..329c109 100644 --- a/export.cfg +++ b/export.cfg @@ -33,14 +33,14 @@ architecture/x86=false command_line/extra_args="" custom_package/debug="" custom_package/release="" -debug/debugging_enabled=false +debug/debugging_enabled=true keystore/release="" keystore/release_password="" keystore/release_user="" one_click_deploy/clear_previous_install=true package/icon="res://icon.png" package/name="TowerJumper" -package/signed=false +package/signed=true package/unique_name="org.pipoypipagames.towerjumper" permissions/access_checkin_properties=false permissions/access_coarse_location=false diff --git a/input_handler.gd b/input_handler.gd index 04ec72c..4cab384 100644 --- a/input_handler.gd +++ b/input_handler.gd @@ -8,20 +8,21 @@ var touchs_vec = {} func _ready(): get_node("LevelLabel").set_text("Level " + str(global.level)) - set_process_input(true) + set_process_input(true) func handle_pos (pos): - if (!game.receive_input (pos)): - last_pos = get_local_mouse_pos().x - game.lock_rot(); - -func _input(event): - if (event.type==InputEvent.SCREEN_TOUCH): + if (!game.receive_input (pos)): + game.lock_rot(); + last_pos = get_local_mouse_pos().x + +func _input(event): + if (event.type==InputEvent.SCREEN_TOUCH): if (event.pressed): touchs_vec[event.index] = event.pos.x if (touchs_vec.size() == 1): last_pos = event.pos.x game.lock_rot(); + else: touchs_vec.erase(event.index) if (touchs_vec.size() == 1): @@ -29,10 +30,7 @@ func _input(event): game.lock_rot(); elif (event.type==InputEvent.SCREEN_DRAG): + touchs_vec[event.index] = event.pos.x + var a = event.pos.x if (touchs_vec.size() == 1): - handle_pos (float(-(event.pos.x - last_pos) * 100) / width) - else: - touchs_vec[event.index] = event.pos.x - - - + handle_pos (stepify(((-(event.pos.x - last_pos) * 300) / width), 0.01)) \ No newline at end of file