Format files using updated file_format.sh

This commit is contained in:
Aaron Franke
2020-10-01 14:23:54 -04:00
parent fe9fd7d7e4
commit 918a289ee2
79 changed files with 512 additions and 512 deletions

View File

@@ -14,7 +14,7 @@ func _process(delta):
var velocity = Vector2()
velocity.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
velocity.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()

View File

@@ -22,7 +22,7 @@ func initialize(speed, velocity):
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
enter_velocity = velocity
func enter():
var input_direction = get_input_direction()
update_look_direction(input_direction)

View File

@@ -51,20 +51,20 @@ func _ready():
func _process(_delta):
var mouse_pos = get_viewport().get_mouse_position()
# Check if the mouse is currently inside the canvas/drawing-area.
is_mouse_in_drawing_area = false
if mouse_pos.x > TL_node.global_position.x:
if mouse_pos.y > TL_node.global_position.y:
is_mouse_in_drawing_area = true
if Input.is_mouse_button_pressed(BUTTON_LEFT):
# If we do not have a position for when the mouse was first clicked, then this must
# be the first time is_mouse_button_pressed has been called since the mouse button was
# released, so we need to store the position.
if mouse_click_start_pos == null:
mouse_click_start_pos = mouse_pos
# If the mouse is inside the canvas and the mouse is 1px away from the position of the mouse last _process call.
if check_if_mouse_is_inside_canvas():
if mouse_pos.distance_to(last_mouse_pos) >= 1:
@@ -77,11 +77,11 @@ func _process(_delta):
undo_element_list_num = brush_data_list.size()
# Add the brush object to draw_elements_array.
add_brush(mouse_pos, brush_mode)
else:
# We've finished our stroke, so we can set a new undo (if a new storke is made).
undo_set = false
# If the mouse is inside the canvas.
if check_if_mouse_is_inside_canvas():
# If we're using either the circle shape mode, or the rectangle shape mode, then
@@ -94,7 +94,7 @@ func _process(_delta):
# Since we've released the left mouse, we need to get a new mouse_click_start_pos next time
#is_mouse_button_pressed is true.
mouse_click_start_pos = null
# Store mouse_pos as last_mouse_pos now that we're done with _process.
last_mouse_pos = mouse_pos
@@ -117,17 +117,17 @@ func undo_stroke():
# Only undo a stroke if we have one.
if undo_element_list_num == UNDO_NONE:
return
# If we are undoing a shape, then we can just remove the latest brush.
if undo_element_list_num == UNDO_MODE_SHAPE:
if brush_data_list.size() > 0:
brush_data_list.remove(brush_data_list.size() - 1)
# Now that we've undone a shape, we cannot undo again until another stoke is added.
undo_element_list_num = UNDO_NONE
# NOTE: if we only had shape brushes, then we could remove the above line and could let the user
# undo until we have a empty element list.
# Otherwise we're removing a either a pencil stroke or a eraser stroke.
else:
# Figure out how many elements/brushes we've added in the last stroke.
@@ -136,7 +136,7 @@ func undo_stroke():
#warning-ignore:unused_variable
for elment_num in range(0, elements_to_remove):
brush_data_list.pop_back()
# Now that we've undone a stoke, we cannot undo again until another stoke is added.
undo_element_list_num = UNDO_NONE
@@ -147,7 +147,7 @@ func undo_stroke():
func add_brush(mouse_pos, type):
# Make new brush dictionary that will hold all of the data we need for the brush.
var new_brush = {}
# Populate the dictionary with values based on the global brush variables.
# We will override these as needed if the brush is a rectange or circle.
new_brush.brush_type = type
@@ -155,13 +155,13 @@ func add_brush(mouse_pos, type):
new_brush.brush_shape = brush_shape
new_brush.brush_size = brush_size
new_brush.brush_color = brush_color
# If the new bursh is a rectangle shape, we need to calculate the top left corner of the rectangle and the
# bottom right corner of the rectangle.
if type == BrushModes.RECTANGLE_SHAPE:
var TL_pos = Vector2()
var BR_pos = Vector2()
# Figure out the left and right positions of the corners and assign them to the proper variable.
if mouse_pos.x < mouse_click_start_pos.x:
TL_pos.x = mouse_pos.x
@@ -169,7 +169,7 @@ func add_brush(mouse_pos, type):
else:
TL_pos.x = mouse_click_start_pos.x
BR_pos.x = mouse_pos.x
# Figure out the top and bottom positions of the corners and assign them to the proper variable.
if mouse_pos.y < mouse_click_start_pos.y:
TL_pos.y = mouse_pos.y
@@ -177,11 +177,11 @@ func add_brush(mouse_pos, type):
else:
TL_pos.y = mouse_click_start_pos.y
BR_pos.y = mouse_pos.y
# Assign the positions to the brush.
new_brush.brush_pos = TL_pos
new_brush.brush_shape_rect_pos_BR = BR_pos
# If the brush isa circle shape, then we need to calculate the radius of the circle.
if type == BrushModes.CIRCLE_SHAPE:
# Get the center point inbetween the mouse position and the position of the mouse when we clicked.
@@ -190,7 +190,7 @@ func add_brush(mouse_pos, type):
# the center to the top/bottom positon of the mouse.
new_brush.brush_pos = center_pos
new_brush.brush_shape_circle_radius = center_pos.distance_to(Vector2(center_pos.x, mouse_pos.y))
# Add the brush and update/draw all of the brushes.
brush_data_list.append(new_brush)
update()
@@ -214,7 +214,7 @@ func _draw():
BrushModes.ERASER:
# NOTE: this is a really cheap way of erasing that isn't really erasing!
# However, this gives similar results in a fairy simple way!
# Erasing works exactly the same was as pencil does for both the rectangle shape and the circle shape,
# but instead of using brush.brush_color, we instead use bg_color instead.
if brush.brush_shape == BrushShapes.RECTANGLE:
@@ -235,13 +235,13 @@ func _draw():
func save_picture(path):
# Wait until the frame has finished before getting the texture.
yield(VisualServer, "frame_post_draw")
# Get the viewport image.
var img = get_viewport().get_texture().get_data()
# Crop the image so we only have canvas area.
var cropped_image = img.get_rect(Rect2(TL_node.global_position, IMAGE_SIZE))
# Flip the image on the Y-axis (it's flipped upside down by default).
cropped_image.flip_y()
# Save the image with the passed in path we got from the save dialog.
cropped_image.save_png(path)

View File

@@ -46,7 +46,7 @@ func button_pressed(button_name):
# If a brush mode button is pressed.
var tool_name = null
var shape_name = null
if button_name == "mode_pencil":
paint_control.brush_mode = paint_control.BrushModes.PENCIL
brush_settings.modulate = Color(1, 1, 1, 1)
@@ -80,7 +80,7 @@ func button_pressed(button_name):
save_dialog.popup_centered()
elif button_name == "undo_stroke":
paint_control.undo_stroke()
# Update the labels (in case the brush mode or brush shape has changed).
if tool_name != null:
label_tools.text = "Selected tool: " + tool_name

View File

@@ -26,24 +26,24 @@ func _integrate_forces(s):
new_anim = "explode"
elif state == State.WALKING:
new_anim = "walk"
var wall_side = 0.0
for i in range(s.get_contact_count()):
var cc = s.get_contact_collider_object(i)
var dp = s.get_contact_local_normal(i)
if cc:
if cc is Bullet and not cc.disabled:
# enqueue call
call_deferred("_bullet_collider", cc, s, dp)
break
if dp.x > 0.9:
wall_side = 1.0
elif dp.x < -0.9:
wall_side = -1.0
if wall_side != 0 and wall_side != direction:
direction = -direction
($Sprite as Sprite).scale.x = -direction
@@ -53,13 +53,13 @@ func _integrate_forces(s):
elif direction > 0 and not rc_right.is_colliding() and rc_left.is_colliding():
direction = -direction
($Sprite as Sprite).scale.x = -direction
lv.x = direction * WALK_SPEED
if anim != new_anim:
anim = new_anim
($AnimationPlayer as AnimationPlayer).play(anim)
s.set_linear_velocity(lv)
@@ -72,7 +72,7 @@ func _pre_explode():
$Shape1.queue_free()
$Shape2.queue_free()
$Shape3.queue_free()
# Stay there
mode = MODE_STATIC
($SoundExplode as AudioStreamPlayer2D).play()
@@ -81,7 +81,7 @@ func _pre_explode():
func _bullet_collider(cc, s, dp):
mode = MODE_RIGID
state = State.DYING
s.set_angular_velocity(sign(dp.x) * 33.0)
physics_material_override.friction = 1
cc.disable()

View File

@@ -9,9 +9,9 @@ var accum = 0.0
func _physics_process(delta):
accum += delta * (1.0 / cycle) * TAU
accum = fmod(accum, TAU)
var d = sin(accum)
var xf = Transform2D()
xf[2]= motion * d
($Platform as RigidBody2D).transform = xf

View File

@@ -10,6 +10,6 @@ func _ready():
func disable():
if disabled:
return
($AnimationPlayer as AnimationPlayer).play("shutdown")
disabled = true

View File

@@ -57,47 +57,47 @@ onready var bullet_shoot = $BulletShoot
func _integrate_forces(s):
var lv = s.get_linear_velocity()
var step = s.get_step()
var new_anim = anim
var new_siding_left = siding_left
# Get player input.
var move_left = Input.is_action_pressed("move_left")
var move_right = Input.is_action_pressed("move_right")
var jump = Input.is_action_pressed("jump")
var shoot = Input.is_action_pressed("shoot")
var spawn = Input.is_action_pressed("spawn")
if spawn:
call_deferred("_spawn_enemy_above")
# Deapply prev floor velocity.
lv.x -= floor_h_velocity
floor_h_velocity = 0.0
# Find the floor (a contact with upwards facing collision normal).
var found_floor = false
var floor_index = -1
for x in range(s.get_contact_count()):
var ci = s.get_contact_local_normal(x)
if ci.dot(Vector2(0, -1)) > 0.6:
found_floor = true
floor_index = x
# A good idea when implementing characters of all kinds,
# compensates for physics imprecision, as well as human reaction delay.
if shoot and not shooting:
call_deferred("_shot_bullet")
else:
shoot_time += step
if found_floor:
airborne_time = 0.0
else:
airborne_time += step # Time it spent in the air.
var on_floor = airborne_time < MAX_FLOOR_AIRBORNE_TIME
# Process jump.
@@ -107,10 +107,10 @@ func _integrate_forces(s):
jumping = false
elif not jump:
stopping_jump = true
if stopping_jump:
lv.y += STOP_JUMP_FORCE * step
if on_floor:
# Process logic when character is on floor.
if move_left and not move_right:
@@ -125,14 +125,14 @@ func _integrate_forces(s):
if xv < 0:
xv = 0
lv.x = sign(lv.x) * xv
# Check jump.
if not jumping and jump:
lv.y = -JUMP_VELOCITY
jumping = true
stopping_jump = false
sound_jump.play()
# Check siding.
if lv.x < 0 and move_left:
new_siding_left = true
@@ -161,11 +161,11 @@ func _integrate_forces(s):
else:
var xv = abs(lv.x)
xv -= AIR_DEACCEL * step
if xv < 0:
xv = 0
lv.x = sign(lv.x) * xv
if lv.y < 0:
if shoot_time < MAX_SHOOT_POSE_TIME:
new_anim = "jumping_weapon"
@@ -176,28 +176,28 @@ func _integrate_forces(s):
new_anim = "falling_weapon"
else:
new_anim = "falling"
# Update siding.
if new_siding_left != siding_left:
if new_siding_left:
sprite.scale.x = -1
else:
sprite.scale.x = 1
siding_left = new_siding_left
# Change animation.
if new_anim != anim:
anim = new_anim
animation_player.play(anim)
shooting = shoot
# Apply floor velocity.
if found_floor:
floor_h_velocity = s.get_contact_collider_velocity_at_position(floor_index).x
lv.x += floor_h_velocity
# Finally, apply gravity and set back the linear velocity.
lv += s.get_total_gravity() * step
s.set_linear_velocity(lv)
@@ -212,15 +212,15 @@ func _shot_bullet():
else:
ss = 1.0
var pos = position + bullet_shoot.position * Vector2(ss, 1.0)
bi.position = pos
get_parent().add_child(bi)
bi.linear_velocity = Vector2(400.0 * ss, -40)
sprite_smoke.restart()
sound_shoot.play()
add_collision_exception_with(bi) # Make bullet and this not collide.

View File

@@ -37,7 +37,7 @@ func _unhandled_input(event):
else:
_pause_menu.close()
get_tree().set_input_as_handled()
elif event.is_action_pressed("splitscreen"):
if name == "Splitscreen":
# We need to clean up a little bit first to avoid Viewport errors.

View File

@@ -19,7 +19,7 @@ func get_cell_pawn(cell, type = CellType.ACTOR):
func request_move(pawn, direction):
var cell_start = world_to_map(pawn.position)
var cell_target = cell_start + direction
var cell_tile_id = get_cellv(cell_target)
match cell_tile_id:
-1:
@@ -29,7 +29,7 @@ func request_move(pawn, direction):
CellType.OBJECT, CellType.ACTOR:
var target_pawn = get_cell_pawn(cell_target, cell_tile_id)
print("Cell %s contains %s" % [cell_target, target_pawn.name])
if not target_pawn.has_node("DialoguePlayer"):
return
get_node(dialogue_ui).show_dialogue(pawn, target_pawn.get_node("DialoguePlayer"))

View File

@@ -7,7 +7,7 @@ func get_input_direction():
return Vector2()
var random_x = DIRECTIONS[randi() % DIRECTIONS.size()]
var random_y = DIRECTIONS[randi() % DIRECTIONS.size()]
var random_axis = randi() % 2
if random_axis > 0:
random_x = 0

View File

@@ -42,9 +42,9 @@ func move_to(target_position):
$Tween.interpolate_property($Pivot, "position", move_direction * 32, Vector2(), $AnimationPlayer.current_animation_length, Tween.TRANS_LINEAR, Tween.EASE_IN)
$Pivot/Sprite.position = position - target_position
position = target_position
yield($AnimationPlayer, "animation_finished")
set_process(true)

View File

@@ -10,7 +10,7 @@ func set_active(value):
.set_active(value)
if not active:
return
$Timer.start()
yield($Timer, \"timeout\")
var target

View File

@@ -10,7 +10,7 @@ func set_active(value):
active = value
set_process(value)
set_process_input(value)
if not active:
return
if $Health.armor >= $Health.base_armor + defense:

View File

@@ -4,7 +4,7 @@ func set_active(value):
.set_active(value)
if not active:
return
$Timer.start()
yield($Timer, "timeout")
var target

View File

@@ -6,10 +6,10 @@ uniform float saturation = 1.8;
void fragment() {
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
c.rgb = mix(vec3(0.0), c.rgb, brightness);
c.rgb = mix(vec3(0.5), c.rgb, contrast);
c.rgb = mix(vec3(dot(vec3(1.0), c.rgb) * 0.33333), c.rgb, saturation);
COLOR.rgb = c;
}

View File

@@ -8,6 +8,6 @@ void fragment() {
uv.x += sin(uv.y * frequency + TIME) * depth;
uv.x = clamp(uv.x, 0.0, 1.0);
vec3 c = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;
COLOR.rgb = c;
}

View File

@@ -15,17 +15,17 @@ float make_grain(float time, vec2 uv) {
void fragment() {
vec3 c = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0).rgb;
//float v = max(c.r, max(c.g, c.b));
float v = dot(c, vec3(0.33333, 0.33333, 0.33333));
v = sqrt(v);
//v *= v;
float f = 1.0 / fps;
float g = make_grain(TIME - mod(TIME, f), UV);
g = max(g, make_grain(TIME - mod(TIME, f) + f, UV) * 0.5);
g = max(g, make_grain(TIME - mod(TIME, f) + f * 2.0, UV) * 0.25);
COLOR.rgb = base.rgb * v - vec3(g) * grain_strength;
COLOR.rgb *= texture(vignette, UV).r;
float ft = TIME * 0.002;

View File

@@ -6,6 +6,6 @@ uniform float size_y = 0.008;
void fragment() {
vec2 uv = SCREEN_UV;
uv -= mod(uv, vec2(size_x, size_y));
COLOR.rgb = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;
}