Skip to content

Commit

Permalink
Merge pull request unknown-horizons#30 from unknown-horizons/develop
Browse files Browse the repository at this point in the history
Merge branch 'develop' into 'master' 2019-01-26
  • Loading branch information
aaronfranke authored Jan 30, 2019
2 parents 1840588 + 92d49ad commit 3f01fd9
Show file tree
Hide file tree
Showing 197 changed files with 1,724 additions and 2,427 deletions.
21 changes: 6 additions & 15 deletions Assets/Audio/Music/GameMusic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ extends AudioStreamPlayer

# If this script somehow fails, "lose.ogg" will be played.

var current_music
# Above could possibly be displayed inside a music player/list GUI.
var _music_files = []
var _music_streams = [] # Note: Does not show up in remote inspector.
Expand All @@ -20,28 +19,21 @@ func _ready():
elif file.ends_with(".ogg"):
_music_files.append(file)

for filename in _music_files:
var stream = load("Assets/Audio/Music/Ambient/" + filename)
_music_streams.append(stream)
for i in _music_files:
_music_streams.append(load("Assets/Audio/Music/Ambient/" + i))

# Always play a specific song when the game starts.
stream = preload("res://Assets/Audio/Music/Ambient/newfrontier.ogg")
play()
#play_song_random()

func _on_GameMusic_finished():
play_song_random()

randomize() # Godot will always generate the same random numbers otherwise.

func play_song_random():
randomize() # Godot will always generate the same random numbers otherwise.
var size = _music_streams.size()
var rand = randi() % size
play_song_index(rand)
play_song_index(randi() % _music_streams.size())

func play_song_index(index):
stop()
stream = _music_streams[index]
current_music = _music_files[index]
play()

# All the functions below are untested.
Expand All @@ -52,8 +44,7 @@ func add_song(file_name):
load("res://Assets/Audio/Music/Ambient/" + file_name))

func remove_song(file_name):
var i = _music_files.find(file_name)
remove_song_index(i)
remove_song_index(_music_files.find(file_name))

func remove_song_index(index):
_music_streams.remove(index)
Expand Down
58 changes: 58 additions & 0 deletions Assets/Player/PlayerCamera.gd
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
32 changes: 32 additions & 0 deletions Assets/Player/PlayerCamera.tscn
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" ]


Binary file added Assets/UI/Images/Buttons/mainmenu_button_mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Assets/UI/Images/Buttons/mainmenu_button_mask.png.import
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 removed Assets/UI/Images/Logos/uh_32.png
Binary file not shown.
29 changes: 0 additions & 29 deletions Assets/UI/Images/Logos/uh_32.png.import

This file was deleted.

Binary file removed Assets/UI/Images/Logos/uh_emblem.png
Binary file not shown.
29 changes: 0 additions & 29 deletions Assets/UI/Images/Logos/uh_emblem.png.import

This file was deleted.

Loading

0 comments on commit 3f01fd9

Please sign in to comment.