Skip to content

Commit

Permalink
Merge pull request #89 from aaronfranke/gitignore-format-meta
Browse files Browse the repository at this point in the history
Update gitignore, CI script, and repo metadata
  • Loading branch information
aaronfranke authored Oct 29, 2020
2 parents 32cefad + a0bdb57 commit ca31fb3
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml → .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
name: Continuous integration
name: Static Checks
on: [push, pull_request]

jobs:
build:
format:
name: File formatting (file_format.sh)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Lint demo (format.sh)
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -qq dos2unix recode
bash ./format.sh
- name: File formatting checks (file_format.sh)
run: |
bash ./file_format.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Godot 4+ specific ignores
.godot/

# Godot-specific ignores
.import/
Expand Down
8 changes: 2 additions & 6 deletions enemies/red_robot/parts/ray.shader
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,24 @@ uniform float clip = 1000.0;
varying float dist;

void vertex() {

float deform_amount = 0.01 * deform;
vec2 offset = vec2(sin(VERTEX.z*1.4321),sin(VERTEX.z*2.12351));
VERTEX.xy+=deform_amount * offset;
VERTEX.xy*=1.0+deform;
dist = abs(VERTEX.z);

}

void fragment() {

if (dist > clip) {
discard;
}
vec4 ray_color = texture(ray_texture,UV);
vec4 smoke_color = texture(smoke_texture,UV);

vec4 col = mix(ray_color,smoke_color,smoke);

ALBEDO=col.rgb * energy;
ALPHA=col.a * transparency;
//ALBEDO=ray_color.rgb;
//ALPHA=ray_color.a;

}
32 changes: 16 additions & 16 deletions enemies/red_robot/red_robot.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func hit():
death.visible = true
$CollisionShape.disabled = true
death.get_node(@"Particles").emitting = true

shield1.get_node(@"Col1").disabled = false
shield1.get_node(@"Col2").disabled = false
shield1.mode = RigidBody.MODE_RIGID
Expand All @@ -81,7 +81,7 @@ func hit():
shield3.get_node(@"Col1").disabled = false
shield3.get_node(@"Col2").disabled = false
shield3.mode = RigidBody.MODE_RIGID

shield2.linear_velocity = 3 * (Vector3.UP + base_xf.x).normalized()
shield3.linear_velocity = 3 * (Vector3.UP).normalized()
shield1.linear_velocity = 3 * (Vector3.UP - base_xf.x).normalized()
Expand All @@ -96,7 +96,7 @@ func shoot():
var ray_origin = ray_from.global_transform.origin
var ray_dir = -gt.basis.z
var max_dist = 1000

var col = get_world().direct_space_state.intersect_ray(ray_origin, ray_origin + ray_dir * max_dist, [self])
if not col.empty():
max_dist = ray_origin.distance_to(col.position)
Expand All @@ -112,21 +112,21 @@ func _physics_process(delta):
if test_shoot:
shoot()
test_shoot = false

if dead:
return

if not player:
animation_tree["parameters/state/current"] = 0 # Go idle.
return

if state == State.APPROACH:
if aim_preparing > 0:
aim_preparing -= delta
if aim_preparing < 0:
aim_preparing = 0
animation_tree["parameters/aiming/blend_amount"] = aim_preparing / AIM_PREPARE_TIME

var to_player_local = global_transform.xform_inv(player.global_transform.origin)
# The front of the robot is +Z, and atan2 is zero at +X, so we need to use the Z for the X parameter (second one).
var angle_to_player = atan2(to_player_local.x, to_player_local.z)
Expand All @@ -152,13 +152,13 @@ func _physics_process(delta):
else:
# Player not in sight, do nothing.
shoot_countdown = SHOOT_WAIT

elif state == State.AIM or state == State.SHOOTING:
if aim_preparing < AIM_PREPARE_TIME:
aim_preparing += delta
if aim_preparing > AIM_PREPARE_TIME:
aim_preparing = AIM_PREPARE_TIME

animation_tree["parameters/aiming/blend_amount"] = clamp(aim_preparing / AIM_PREPARE_TIME, 0, 1)
aim_countdown -= delta
if aim_countdown < 0 and state == State.AIM:
Expand All @@ -170,7 +170,7 @@ func _physics_process(delta):
shoot_animation.play("shoot")
else:
resume_approach()

if animation_tree.active:
var to_cannon_local = ray_mesh.global_transform.xform_inv(player.global_transform.origin + Vector3.UP)
var h_angle = rad2deg(atan2( to_cannon_local.x, -to_cannon_local.z ))
Expand All @@ -179,25 +179,25 @@ func _physics_process(delta):
var h_motion = BLEND_AIM_SPEED * delta * -h_angle
blend_pos.x += h_motion
blend_pos.x = clamp(blend_pos.x, -1, 1)

var v_motion = BLEND_AIM_SPEED * delta * v_angle
blend_pos.y += v_motion
blend_pos.y = clamp(blend_pos.y, -1, 1)

animation_tree["parameters/aim/blend_position"] = blend_pos

# Apply root motion to orientation.
orientation *= animation_tree.get_root_motion_transform()

var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity += gravity * delta
velocity = move_and_slide(velocity, Vector3.UP)

orientation.origin = Vector3() # Clear accumulated root motion displacement (was applied to speed).
orientation = orientation.orthonormalized() # orthonormalize orientation.

global_transform.basis = orientation.basis


Expand Down
29 changes: 20 additions & 9 deletions format.sh → file_format.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
#!/usr/bin/env bash

# This script ensures proper POSIX text file formatting and a few other things.

set -uo pipefail
IFS=$'\n\t'

# Loops through all text files tracked by Git.
git grep -zIl '' |
while IFS= read -rd '' f; do
# Exclude csproj and hdr files.
# Exclude some types of files.
if [[ "$f" == *"csproj" ]]; then
continue
elif [[ "$f" == *"hdr" ]]; then
continue
fi
# Ensures that files are UTF-8 formatted.
# Ensure that files are UTF-8 formatted.
recode UTF-8 "$f" 2> /dev/null
# Ensures that files have LF line endings.
# Ensure that files have LF line endings and do not contain a BOM.
dos2unix "$f" 2> /dev/null
# Ensures that files do not contain a BOM.
sed -i '1s/^\xEF\xBB\xBF//' "$f"
# Ensures that files end with newline characters.
tail -c1 < "$f" | read -r _ || echo >> "$f";
# Remove trailing space characters.
sed -z -i 's/\x20\x0A/\x0A/g' "$f"
# Remove trailing space characters and ensures that files end
# with newline characters. -l option handles newlines conveniently.
perl -i -ple 's/\s*$//g' "$f"
# Remove the character sequence "== true" if it has a leading space.
perl -i -pe 's/\x20== true//g' "$f"
# We don't want to change lines around braces in godot/tscn files.
if [[ "$f" == *"godot" ]]; then
continue
elif [[ "$f" == *"tscn" ]]; then
continue
fi
# Disallow empty lines after the opening brace.
sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f"
# Disallow some empty lines before the closing brace.
sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f"
done

git diff > patch.patch
Expand Down
2 changes: 1 addition & 1 deletion level/debug.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Label
func _process(_delta):
if Input.is_action_just_pressed("toggle_debug"):
visible = !visible

text = "FPS: " + str(Engine.get_frames_per_second())
text += "\nVSync: " + ("on" if ProjectSettings.get_setting("display/window/vsync/use_vsync") else "off")
text += "\nMemory: " + "%3.2f" % (OS.get_static_memory_usage() / 1048576.0) + " MiB"
2 changes: 1 addition & 1 deletion player/bullet/bullet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ onready var collision_shape = $CollisionShape
func _process(delta):
if hit:
return

time_alive -= delta
if time_alive < 0:
hit = true
Expand Down
2 changes: 1 addition & 1 deletion player/camera_noise_shake_effect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func _ready():
noise.period = 256.0
noise.persistence = 0.5
noise.lacunarity = 1.0

# This variable is reset if the camera position is changed by other scripts,
# such as when zooming in/out or focusing on a different position.
# This should NOT be done when the camera shake is happening.
Expand Down
44 changes: 22 additions & 22 deletions player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,42 @@ func _physics_process(delta):
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward"))
motion = motion.linear_interpolate(motion_target, MOTION_INTERPOLATE_SPEED * delta)

var camera_basis = camera_rot.global_transform.basis
var camera_z = camera_basis.z
var camera_x = camera_basis.x

camera_z.y = 0
camera_z = camera_z.normalized()
camera_x.y = 0
camera_x = camera_x.normalized()

var current_aim = Input.is_action_pressed("aim")

if aiming != current_aim:
aiming = current_aim
if aiming:
camera_animation.play("shoot")
else:
camera_animation.play("far")

# Jump/in-air logic.
airborne_time += delta
if is_on_floor():
if airborne_time > 0.5:
sound_effect_land.play()
airborne_time = 0

var on_air = airborne_time > MIN_AIRBORNE_TIME

if not on_air and Input.is_action_just_pressed("jump"):
velocity.y = JUMP_SPEED
on_air = true
# Increase airborne time so next frame on_air is still true
airborne_time = MIN_AIRBORNE_TIME
animation_tree["parameters/state/current"] = 2
sound_effect_jump.play()

if on_air:
if (velocity.y > 0):
animation_tree["parameters/state/current"] = 2
Expand All @@ -121,39 +121,39 @@ func _physics_process(delta):
elif aiming:
# Change state to strafe.
animation_tree["parameters/state/current"] = 0

# Change aim according to camera rotation.
if camera_x_rot >= 0: # Aim up.
animation_tree["parameters/aim/add_amount"] = -camera_x_rot / deg2rad(CAMERA_X_ROT_MAX)
else: # Aim down.
animation_tree["parameters/aim/add_amount"] = camera_x_rot / deg2rad(CAMERA_X_ROT_MIN)

# Convert orientation to quaternions for interpolating rotation.
var q_from = orientation.basis.get_rotation_quat()
var q_to = camera_base.global_transform.basis.get_rotation_quat()
# Interpolate current rotation with desired one.
orientation.basis = Basis(q_from.slerp(q_to, delta * ROTATION_INTERPOLATE_SPEED))

# The animation's forward/backward axis is reversed.
animation_tree["parameters/strafe/blend_position"] = Vector2(motion.x, -motion.y)

root_motion = animation_tree.get_root_motion_transform()

if Input.is_action_pressed("shoot") and fire_cooldown.time_left == 0:
var shoot_origin = shoot_from.global_transform.origin

var ch_pos = crosshair.rect_position + crosshair.rect_size * 0.5
var ray_from = camera_camera.project_ray_origin(ch_pos)
var ray_dir = camera_camera.project_ray_normal(ch_pos)

var shoot_target
var col = get_world().direct_space_state.intersect_ray(ray_from, ray_from + ray_dir * 1000, [self], 0b11)
if col.empty():
shoot_target = ray_from + ray_dir * 1000
else:
shoot_target = col.position
var shoot_dir = (shoot_target - shoot_origin).normalized()

var bullet = preload("res://player/bullet/bullet.tscn").instance()
get_parent().add_child(bullet)
bullet.global_transform.origin = shoot_origin
Expand All @@ -171,28 +171,28 @@ func _physics_process(delta):
var q_to = Transform().looking_at(target, Vector3.UP).basis.get_rotation_quat()
# Interpolate current rotation with desired one.
orientation.basis = Basis(q_from.slerp(q_to, delta * ROTATION_INTERPOLATE_SPEED))

# Aim to zero (no aiming while walking).
animation_tree["parameters/aim/add_amount"] = 0
# Change state to walk.
animation_tree["parameters/state/current"] = 1
# Blend position for walk speed based on motion.
animation_tree["parameters/walk/blend_position"] = Vector2(motion.length(), 0)

root_motion = animation_tree.get_root_motion_transform()

# Apply root motion to orientation.
orientation *= root_motion

var h_velocity = orientation.origin / delta
velocity.x = h_velocity.x
velocity.z = h_velocity.z
velocity += gravity * delta
velocity = move_and_slide(velocity, Vector3.UP)

orientation.origin = Vector3() # Clear accumulated root motion displacement (was applied to speed).
orientation = orientation.orthonormalized() # Orthonormalize orientation.

player_model.global_transform.basis = orientation.basis


Expand Down

0 comments on commit ca31fb3

Please sign in to comment.