forked from unknown-horizons/godot-port
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unknown-horizons#30 from unknown-horizons/develop
Merge branch 'develop' into 'master' 2019-01-26
- Loading branch information
Showing
197 changed files
with
1,724 additions
and
2,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
extends Spatial | ||
|
||
const ZOOM_IN_LIMIT = 5 | ||
const ZOOM_OUT_LIMIT = 35 | ||
const ZOOM_VALUE = 5 | ||
|
||
const MOVE_SPEED = 10 | ||
const MOVE_FASTER_MULT = 3 | ||
const MOVE_VERTICAL_MULT = 1.5 | ||
|
||
var _directions = [Vector3(), Vector3(), Vector3(), Vector3()] # : Array | ||
|
||
onready var _rotation_y = $RotationY # as Spatial | ||
onready var _camera = $RotationY/Camera # as Camera | ||
|
||
func _ready(): | ||
recalculate_directions() | ||
|
||
func _process(delta): | ||
# Camera movement. | ||
var movement_scale = delta * MOVE_SPEED | ||
if Input.is_action_pressed("move_faster"): | ||
movement_scale *= MOVE_FASTER_MULT | ||
|
||
# Not elif because movement should cancel out if both are pressed. | ||
if Input.is_action_pressed("move_up"): | ||
translate(_directions[0] * movement_scale * MOVE_VERTICAL_MULT) | ||
if Input.is_action_pressed("move_down"): | ||
translate(_directions[1] * movement_scale * MOVE_VERTICAL_MULT) | ||
if Input.is_action_pressed("move_left"): | ||
translate(_directions[2] * movement_scale) | ||
if Input.is_action_pressed("move_right"): | ||
translate(_directions[3] * movement_scale) | ||
|
||
func _input(event): | ||
# Camera rotation. | ||
if event.is_action_pressed("rotate_left"): | ||
_rotation_y.rotate_y(- PI/2) | ||
recalculate_directions() | ||
elif event.is_action_pressed("rotate_right"): | ||
_rotation_y.rotate_y(PI / 2) | ||
recalculate_directions() | ||
|
||
# Camera zooming. | ||
elif event.is_action_pressed("zoom_in"): | ||
if _camera.size > ZOOM_IN_LIMIT: | ||
_camera.size -= ZOOM_VALUE | ||
elif event.is_action_pressed("zoom_out"): | ||
if _camera.size < ZOOM_OUT_LIMIT: | ||
_camera.size += ZOOM_VALUE | ||
|
||
func recalculate_directions(): | ||
# We could always hard-code the directions, but this is better. | ||
var basis = _rotation_y.get_transform().basis | ||
_directions[0] = -basis.z | ||
_directions[1] = basis.z | ||
_directions[2] = -basis.x | ||
_directions[3] = basis.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://Assets/Player/PlayerCamera.gd" type="Script" id=1] | ||
|
||
[node name="PlayerCamera" type="Spatial"] | ||
|
||
script = ExtResource( 1 ) | ||
_sections_unfolded = [ "Transform" ] | ||
|
||
[node name="RotationY" type="Spatial" parent="." index="0"] | ||
|
||
transform = Transform( 0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, 0, 0, 0 ) | ||
_sections_unfolded = [ "Transform" ] | ||
|
||
[node name="Camera" type="Camera" parent="RotationY" index="0"] | ||
|
||
transform = Transform( 1, -2.98023e-08, -2.98023e-08, 0, 0.819152, 0.573577, 0, -0.573577, 0.819152, 0, 100, 143 ) | ||
keep_aspect = 1 | ||
cull_mask = 1048575 | ||
environment = null | ||
h_offset = 0.0 | ||
v_offset = 0.0 | ||
doppler_tracking = 0 | ||
projection = 1 | ||
current = true | ||
fov = 70.0 | ||
size = 20.0 | ||
near = 0.05 | ||
far = 1000.0 | ||
_sections_unfolded = [ "Transform" ] | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[remap] | ||
|
||
importer="bitmap" | ||
type="BitMap" | ||
path="res://.import/mainmenu_button_mask.png-e3854ec51a5f7498e33c465d58465e61.res" | ||
|
||
[deps] | ||
|
||
source_file="res://Assets/UI/Images/Buttons/mainmenu_button_mask.png" | ||
dest_files=[ "res://.import/mainmenu_button_mask.png-e3854ec51a5f7498e33c465d58465e61.res" ] | ||
|
||
[params] | ||
|
||
create_from=1 | ||
threshold=0.0 |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.