Many tweaks thanks to IAmActuallyCthulhu

Also change apostrophes to double quotes and update C# projects
This commit is contained in:
Aaron Franke
2020-06-28 03:29:20 -04:00
parent 866f826124
commit 006309bd6f
64 changed files with 216 additions and 188 deletions

View File

@@ -13,7 +13,7 @@ func show_game_over():
yield($MessageTimer, "timeout")
$MessageLabel.text = "Dodge the\nCreeps"
$MessageLabel.show()
yield(get_tree().create_timer(1), 'timeout')
yield(get_tree().create_timer(1), "timeout")
$StartButton.show()

View File

@@ -1,6 +1,6 @@
extends Node
export (PackedScene) var Mob
export(PackedScene) var Mob
var score
func _ready():
@@ -28,9 +28,9 @@ func _on_MobTimer_timeout():
$MobPath/MobSpawnLocation.offset = randi()
var mob = Mob.instance()
add_child(mob)
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
var direction = $MobPath/MobSpawnLocation.rotation + TAU / 4
mob.position = $MobPath/MobSpawnLocation.position
direction += rand_range(-PI / 4, PI / 4)
direction += rand_range(-TAU / 8, TAU / 8)
mob.rotation = direction
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction)
# warning-ignore:return_value_discarded

View File

@@ -7,8 +7,8 @@ func _process(_delta):
var numbers = ""
var index = 0
for state in fsm_node.states_stack:
states_names += state.get_name() + '\n'
numbers += str(index) + '\n'
states_names += state.get_name() + "\n"
numbers += str(index) + "\n"
index += 1
$States.text = states_names
$Numbers.text = numbers

View File

@@ -3,12 +3,14 @@ extends KinematicBody2D
var direction = Vector2()
export(float) var speed = 1000.0
onready var root = get_tree().root
func _ready():
set_as_toplevel(true)
func _physics_process(delta):
if is_outside_view_bounds():
if not root.get_visible_rect().has_point(position):
queue_free()
var motion = direction * speed * delta
@@ -17,10 +19,5 @@ func _physics_process(delta):
queue_free()
func is_outside_view_bounds():
return position.x > OS.get_screen_size().x or position.x < 0.0 \
or position.y > OS.get_screen_size().y or position.y < 0.0
func _draw():
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)

View File

@@ -1,12 +1,18 @@
extends "res://state_machine/state_machine.gd"
onready var idle = $Idle
onready var move = $Move
onready var jump = $Jump
onready var stagger = $Stagger
onready var attack = $Attack
func _ready():
states_map = {
"idle": $Idle,
"move": $Move,
"jump": $Jump,
"stagger": $Stagger,
"attack": $Attack,
"idle": idle,
"move": move,
"jump": jump,
"stagger": stagger,
"attack": attack,
}
@@ -16,8 +22,8 @@ func _change_state(state_name):
return
if state_name in ["stagger", "jump", "attack"]:
states_stack.push_front(states_map[state_name])
if state_name == "jump" and current_state == $Move:
$Jump.initialize($Move.speed, $Move.velocity)
if state_name == "jump" and current_state == move:
jump.initialize(move.speed, move.velocity)
._change_state(state_name)
@@ -25,7 +31,7 @@ func _unhandled_input(event):
# Here we only handle input that can interrupt states, attacking in this case,
# otherwise we let the state node handle it.
if event.is_action_pressed("attack"):
if current_state in [$Attack, $Stagger]:
if current_state in [attack, stagger]:
return
_change_state("attack")
return

View File

@@ -22,6 +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)
@@ -31,6 +32,7 @@ func enter():
owner.get_node("AnimationPlayer").play("idle")
func update(delta):
var input_direction = get_input_direction()
update_look_direction(input_direction)
@@ -40,6 +42,7 @@ func update(delta):
if height <= 0.0:
emit_signal("finished", "previous")
func move_horizontally(delta, direction):
if direction:
horizontal_speed += air_acceleration * delta
@@ -53,6 +56,7 @@ func move_horizontally(delta, direction):
owner.move_and_slide(horizontal_velocity)
func animate_jump_height(delta):
vertical_speed -= gravity * delta
height += vertical_speed * delta

View File

@@ -7,9 +7,10 @@ func handle_input(event):
func get_input_direction():
var input_direction = Vector2()
input_direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
input_direction.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
var input_direction = Vector2(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
)
return input_direction

View File

@@ -21,7 +21,9 @@ func _ready():
if not start_state:
start_state = get_child(0).get_path()
for child in get_children():
child.connect("finished", self, "_change_state")
var err = child.connect("finished", self, "_change_state")
if err:
printerr(err)
initialize(start_state)

View File

@@ -232,11 +232,9 @@ func _draw():
draw_circle(brush.brush_pos, brush.brush_shape_circle_radius, brush.brush_color)
func save_picture(path):
# Wait a couple frames so the save dialog isn't in the way.
yield (get_tree(), "idle_frame")
yield (get_tree(), "idle_frame")
# 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()

View File

@@ -1,8 +1,8 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://PaintControl.gd" type="Script" id=1]
[ext_resource path="res://ToolsPanel.gd" type="Script" id=2]
[ext_resource path="res://PaintTools.png" type="Texture" id=3]
[ext_resource path="res://paint_control.gd" type="Script" id=1]
[ext_resource path="res://tools_panel.gd" type="Script" id=2]
[ext_resource path="res://paint_tools.png" type="Texture" id=3]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 1, 1, 1, 1 )

View File

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 440 B

View File

@@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex"
path="res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://PaintTools.png"
dest_files=[ "res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex" ]
source_file="res://paint_tools.png"
dest_files=[ "res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.stex" ]
[params]

View File

@@ -19,7 +19,7 @@ config/name="GD Paint"
config/description="GD Paint is a simple image editor made using Godot and GDScript.
It supports different types of 'brushes': a basic pen/pencil
and eraser, as well as a rectangle and a circle brush."
run/main_scene="res://Paint_root.tscn"
run/main_scene="res://paint_root.tscn"
config/icon="res://icon.png"
[display]

View File

@@ -1,20 +1,16 @@
extends Panel
var paint_control
onready var brush_settings = $BrushSettings
onready var label_tools = $LabelTools
onready var label_brush_size = $BrushSettings/LabelBrushSize
onready var label_brush_shape = $BrushSettings/LabelBrushShape
onready var label_brush_size = brush_settings.get_node(@"LabelBrushSize")
onready var label_brush_shape = brush_settings.get_node(@"LabelBrushShape")
onready var label_stats = $LabelStats
onready var label_tools = $LabelTools
var save_dialog
onready var _parent = get_parent()
onready var save_dialog = _parent.get_node(@"SaveFileDialog")
onready var paint_control = _parent.get_node(@"PaintControl")
func _ready():
# Get PaintControl and SaveFileDialog.
paint_control = get_parent().get_node("PaintControl")
save_dialog = get_parent().get_node("SaveFileDialog")
# warning-ignore-all:return_value_discarded
# Assign all of the needed signals for the oppersation buttons.
$ButtonUndo.connect("pressed", self, "button_pressed", ["undo_stroke"])
@@ -34,7 +30,7 @@ func _ready():
$ColorPickerBackground.connect("color_changed", self, "background_color_changed")
$BrushSettings/HScrollBarBrushSize.connect("value_changed", self, "brush_size_changed")
# Assign the 'file_selected' signal in SaveFileDialog.
# Assign the "file_selected" signal in SaveFileDialog.
save_dialog.connect("file_selected", self, "save_file_selected")
# Set physics process so we can update the status label.

View File

@@ -1,12 +1,13 @@
extends KinematicBody2D
const MOTION_SPEED = 160 # Pixels/second.
const TAN30DEG = tan(deg2rad(30))
func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
motion.y *= 0.57735056839 # tan(30 degrees).
motion.y *= TAN30DEG
motion = motion.normalized() * MOTION_SPEED
#warning-ignore:return_value_discarded
move_and_slide(motion)

View File

@@ -6,7 +6,7 @@ func _physics_process(_delta):
var motion = Vector2()
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
motion.y *= 0.5
motion.y /= 2
motion = motion.normalized() * MOTION_SPEED
#warning-ignore:return_value_discarded
move_and_slide(motion)

View File

@@ -3,33 +3,35 @@ extends Navigation2D
export(float) var character_speed = 400.0
var path = []
onready var character = $Character
func _process(delta):
var walk_distance = character_speed * delta
move_along_path(walk_distance)
# The 'click' event is a custom input action defined in
# The "click" event is a custom input action defined in
# Project > Project Settings > Input Map tab.
func _unhandled_input(event):
if not event.is_action_pressed("click"):
return
_update_navigation_path($Character.position, get_local_mouse_position())
_update_navigation_path(character.position, get_local_mouse_position())
func move_along_path(distance):
var last_point = $Character.position
var last_point = character.position
while path.size():
var distance_between_points = last_point.distance_to(path[0])
# The position to move to falls between two points.
if distance <= distance_between_points:
$Character.position = last_point.linear_interpolate(path[0], distance / distance_between_points)
character.position = last_point.linear_interpolate(path[0], distance / distance_between_points)
return
# The position is past the end of the segment.
distance -= distance_between_points
last_point = path[0]
path.remove(0)
# The character reached the end of the path.
$Character.position = last_point
character.position = last_point
set_process(false)

View File

@@ -2,6 +2,9 @@ extends Node2D
enum States { IDLE, FOLLOW }
const MASS = 10.0
const ARRIVE_DISTANCE = 10.0
export(float) var speed = 200.0
var _state = null
@@ -38,9 +41,6 @@ func _unhandled_input(event):
func _move_to(world_position):
var MASS = 10.0
var ARRIVE_DISTANCE = 10.0
var desired_velocity = (world_position - position).normalized() * speed
var steering = desired_velocity - _velocity
_velocity += steering / MASS
@@ -55,7 +55,7 @@ func _change_state(new_state):
if not _path or len(_path) == 1:
_change_state(States.IDLE)
return
# The index 0 is the starting cell
# we don't want the character to move back to it in this example
# The index 0 is the starting cell.
# We don't want the character to move back to it in this example.
_target_point_world = _path[1]
_state = new_state

View File

@@ -47,6 +47,13 @@ var shoot_time = 1e20
var Bullet = preload("res://player/Bullet.tscn")
var Enemy = preload("res://enemy/Enemy.tscn")
onready var sound_jump = $SoundJump
onready var sound_shoot = $SoundShoot
onready var sprite = $Sprite
onready var sprite_smoke = sprite.get_node(@"Smoke")
onready var animation_player = $AnimationPlayer
onready var bullet_shoot = $BulletShoot
func _integrate_forces(s):
var lv = s.get_linear_velocity()
var step = s.get_step()
@@ -54,7 +61,7 @@ func _integrate_forces(s):
var new_anim = anim
var new_siding_left = siding_left
# Get the controls.
# 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")
@@ -124,7 +131,7 @@ func _integrate_forces(s):
lv.y = -JUMP_VELOCITY
jumping = true
stopping_jump = false
($SoundJump as AudioStreamPlayer2D).play()
sound_jump.play()
# Check siding.
if lv.x < 0 and move_left:
@@ -173,16 +180,16 @@ func _integrate_forces(s):
# Update siding.
if new_siding_left != siding_left:
if new_siding_left:
($Sprite as Sprite).scale.x = -1
sprite.scale.x = -1
else:
($Sprite as Sprite).scale.x = 1
sprite.scale.x = 1
siding_left = new_siding_left
# Change animation.
if new_anim != anim:
anim = new_anim
($AnimationPlayer as AnimationPlayer).play(anim)
animation_player.play(anim)
shooting = shoot
@@ -204,15 +211,15 @@ func _shot_bullet():
ss = -1.0
else:
ss = 1.0
var pos = position + ($BulletShoot as Position2D).position * Vector2(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 as Particles2D).restart()
($SoundShoot as AudioStreamPlayer2D).play()
sprite_smoke.restart()
sound_shoot.play()
add_collision_exception_with(bi) # Make bullet and this not collide.

View File

@@ -36,7 +36,14 @@ func _ready():
# - If you split the character into a state machine or more advanced pattern,
# you can easily move individual functions.
func _physics_process(_delta):
_velocity = calculate_move_velocity(_velocity)
# If the enemy encounters a wall or an edge, the horizontal velocity is flipped.
if not floor_detector_left.is_colliding():
_velocity.x = speed.x
elif not floor_detector_right.is_colliding():
_velocity.x = -speed.x
if is_on_wall():
_velocity.x *= -1
# We only update the y value of _velocity as we want to handle the horizontal movement ourselves.
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y
@@ -49,22 +56,6 @@ func _physics_process(_delta):
animation_player.play(animation)
# This function calculates a new velocity whenever you need it.
# If the enemy encounters a wall or an edge, the horizontal velocity is flipped.
func calculate_move_velocity(linear_velocity):
var velocity = linear_velocity
if not floor_detector_left.is_colliding():
velocity.x = speed.x
elif not floor_detector_right.is_colliding():
velocity.x = -speed.x
if is_on_wall():
velocity.x *= -1
return velocity
func destroy():
_state = State.DEAD
_velocity = Vector2.ZERO

View File

@@ -11,6 +11,7 @@ onready var sound_shoot = $Shoot
onready var timer = $Cooldown
# This method is only called by Player.gd.
func shoot(direction = 1):
if not timer.is_stopped():
return false

View File

@@ -7,10 +7,10 @@ const FLOOR_DETECT_DISTANCE = 20.0
export(String) var action_suffix = ""
onready var platform_detector = $PlatformDetector
onready var sprite = $Sprite
onready var animation_player = $AnimationPlayer
onready var shoot_timer = $ShootAnimation
onready var gun = $Sprite/Gun
onready var sprite = $Sprite
onready var gun = sprite.get_node(@"Gun")
func _ready():

View File

@@ -7,7 +7,7 @@ onready var animation_player = $AnimationPlayer
# The Coins only detects collisions with the Player thanks to its collision mask.
# This prevents other characters such as enemies from picking up coins.
# When the player collides with a coin, the coin plays its 'picked' animation.
# When the player collides with a coin, the coin plays its "picked" animation.
# The animation takes cares of making the coin disappear, but also deactivates its
# collisions and frees it from memory, saving us from writing more complex code.
# Click the AnimationPlayer node to see the animation timeline.

View File

@@ -1,13 +1,13 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://scripts/paddle.gd" type="Script" id=1]
[ext_resource path="res://logic/paddle.gd" type="Script" id=1]
[ext_resource path="res://left_pallete.png" type="Texture" id=2]
[ext_resource path="res://right_pallete.png" type="Texture" id=3]
[ext_resource path="res://scripts/ball.gd" type="Script" id=4]
[ext_resource path="res://logic/ball.gd" type="Script" id=4]
[ext_resource path="res://ball.png" type="Texture" id=5]
[ext_resource path="res://separator.png" type="Texture" id=6]
[ext_resource path="res://scripts/wall.gd" type="Script" id=7]
[ext_resource path="res://scripts/ceiling_floor.gd" type="Script" id=8]
[ext_resource path="res://logic/wall.gd" type="Script" id=7]
[ext_resource path="res://logic/ceiling_floor.gd" type="Script" id=8]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 16 )

View File

@@ -1,4 +1,4 @@
extends 'Pawn.gd'
extends "Pawn.gd"
onready var Grid = get_parent()
var lost = false

View File

@@ -1,7 +1,7 @@
extends 'Pawn.gd'
extends "Pawn.gd"
#warning-ignore:unused_class_variable
export (PackedScene) var combat_actor
export(PackedScene) var combat_actor
#warning-ignore:unused_class_variable
var lost = false

View File

@@ -1,4 +1,4 @@
extends 'Actor.gd'
extends "Actor.gd"
func _ready():
set_process(false)

View File

@@ -1,8 +1,8 @@
extends 'Pawn.gd'
extends "Pawn.gd"
onready var Grid = get_parent()
#warning-ignore:unused_class_variable
export (PackedScene) var combat_actor
export(PackedScene) var combat_actor
#warning-ignore:unused_class_variable
var lost = false

View File

@@ -1,7 +1,7 @@
extends Control
export (NodePath) var combatants_node
export (PackedScene) var info_scene
export(NodePath) var combatants_node
export(PackedScene) var info_scene
func _ready():
combatants_node = get_node(combatants_node)

View File

@@ -33,7 +33,7 @@ func _ready():
func _unhandled_input(ev):
if ev is InputEventMouseButton :
if ev is InputEventMouseButton:
if ev.button_index == BUTTON_WHEEL_UP:
zoom -= ZOOM_SPEED
if ev.button_index == BUTTON_WHEEL_DOWN:

View File

@@ -3,20 +3,20 @@ extends Node
var _tests = [
{
"id" : "Functional Tests/Shapes",
"path" : "res://tests/functional/test_shapes.tscn",
"id": "Functional Tests/Shapes",
"path": "res://tests/functional/test_shapes.tscn",
},
{
"id" : "Functional Tests/Compound Shapes",
"path" : "res://tests/functional/test_compound_shapes.tscn",
"id": "Functional Tests/Compound Shapes",
"path": "res://tests/functional/test_compound_shapes.tscn",
},
{
"id" : "Functional Tests/Friction",
"path" : "res://tests/functional/test_friction.tscn",
"id": "Functional Tests/Friction",
"path": "res://tests/functional/test_friction.tscn",
},
{
"id" : "Performance Tests/Contacts",
"path" : "res://tests/performance/test_perf_contacts.tscn",
"id": "Performance Tests/Contacts",
"path": "res://tests/performance/test_perf_contacts.tscn",
},
]

View File

@@ -1,7 +1,7 @@
extends OptionMenu
class TestData :
class TestData:
var id
var scene_path

View File

@@ -98,9 +98,9 @@ func _process(delta):
var gyro = Input.get_gyroscope()
# Show our base values
get_node("Control/Accelerometer").text = 'Accelerometer: ' + str(acc) + ', gravity: ' + str(grav)
get_node("Control/Magnetometer").text = 'Magnetometer: ' + str(mag)
get_node("Control/Gyroscope").text = 'Gyroscope: ' + str(gyro)
get_node("Control/Accelerometer").text = "Accelerometer: " + str(acc) + ", gravity: " + str(grav)
get_node("Control/Magnetometer").text = "Magnetometer: " + str(mag)
get_node("Control/Gyroscope").text = "Gyroscope: " + str(gyro)
# Check if we have all needed data
if grav.length() < 0.1:
@@ -136,5 +136,3 @@ func _process(delta):
var gyro_and_grav = get_node("Boxes/GyroAndGrav")
var new_basis = rotate_by_gyro(gyro, gyro_and_grav.transform.basis, delta).orthonormalized()
gyro_and_grav.transform.basis = drift_correction(new_basis, grav)

View File

@@ -111,8 +111,8 @@ func reset_tween():
tween.interpolate_property(sprite, "rotation_degrees", 360, 0, 2, state.trans, state.eases, 2)
if $Modes/Callback.is_pressed():
tween.interpolate_callback(self, 0.5, "on_callback", "0.5 second's after")
tween.interpolate_callback(self, 0.2, "on_callback", "1.2 second's after")
tween.interpolate_callback(self, 0.5, "on_callback", "0.5 seconds after")
tween.interpolate_callback(self, 0.2, "on_callback", "1.2 seconds after")
if $Modes/Follow.is_pressed():
follow.show()

View File

@@ -11,10 +11,11 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
<GodotProjectGeneratorVersion>1.0.0.0</GodotProjectGeneratorVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -23,7 +24,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
@@ -31,7 +32,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -45,7 +46,7 @@
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
</Reference>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
</Reference>
@@ -63,5 +64,11 @@
<Compile Include="assets\player\PlayerSprite.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
<Version>1.0.0</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -5,15 +5,15 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Tools|Any CPU = Tools|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Release|Any CPU.Build.0 = Release|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.Build.0 = Tools|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

4
mono/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Note: Godot 3.2.2 or newer is required
While most of the demos work with any 3.2.x version, these demos require
at least Godot 3.2.2 since there are large C#-specific changes in 3.2.2.

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Tools</Configuration>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -12,10 +12,10 @@
<GodotProjectGeneratorVersion>1.0.7374.16792</GodotProjectGeneratorVersion>
<BaseIntermediateOutputPath>.mono\temp\obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -24,7 +24,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
@@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -43,12 +43,12 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="GodotSharp">
<HintPath>$(ProjectDir)\.mono\assemblies\$(ApiConfiguration)\GodotSharp.dll</HintPath>
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
</Reference>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
<HintPath>$(ProjectDir)\.mono\assemblies\$(ApiConfiguration)\GodotSharpEditor.dll</HintPath>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
@@ -59,5 +59,11 @@
<Compile Include="Player.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
<Version>1.0.0</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -5,15 +5,15 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Tools|Any CPU = Tools|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Release|Any CPU.Build.0 = Release|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Tools|Any CPU.Build.0 = Tools|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -73,13 +73,13 @@ public class Main : Node
AddChild(mobInstance);
// Set the mob's direction perpendicular to the path direction.
float direction = mobSpawnLocation.Rotation + Mathf.Pi / 2;
float direction = mobSpawnLocation.Rotation + Mathf.Tau / 4;
// Set the mob's position to a random location.
mobInstance.Position = mobSpawnLocation.Position;
// Add some randomness to the direction.
direction += RandRange(-Mathf.Pi / 4, Mathf.Pi / 4);
direction += RandRange(-Mathf.Tau / 8, Mathf.Tau / 8);
mobInstance.Rotation = direction;
// Choose the velocity.

View File

@@ -11,10 +11,11 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
<GodotProjectGeneratorVersion>1.0.0.0</GodotProjectGeneratorVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -23,7 +24,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
@@ -31,7 +32,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
@@ -45,7 +46,7 @@
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
</Reference>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
<Private>False</Private>
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
</Reference>
@@ -53,10 +54,16 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scripts\Ball.cs" />
<Compile Include="Scripts\CeilingFloor.cs" />
<Compile Include="Scripts\Paddle.cs" />
<Compile Include="Scripts\Wall.cs" />
<Compile Include="Logic\Ball.cs" />
<Compile Include="Logic\CeilingFloor.cs" />
<Compile Include="Logic\Paddle.cs" />
<Compile Include="Logic\Wall.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
<Version>1.0.0</Version>
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -5,15 +5,15 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Tools|Any CPU = Tools|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Release|Any CPU.Build.0 = Release|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Tools|Any CPU.Build.0 = Tools|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -1,13 +1,13 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://Scripts/Paddle.cs" type="Script" id=1]
[ext_resource path="res://Logic/Paddle.cs" type="Script" id=1]
[ext_resource path="res://left_pallete.png" type="Texture" id=2]
[ext_resource path="res://right_pallete.png" type="Texture" id=3]
[ext_resource path="res://Scripts/Ball.cs" type="Script" id=4]
[ext_resource path="res://Logic/Ball.cs" type="Script" id=4]
[ext_resource path="res://ball.png" type="Texture" id=5]
[ext_resource path="res://separator.png" type="Texture" id=6]
[ext_resource path="res://Scripts/Wall.cs" type="Script" id=7]
[ext_resource path="res://Scripts/CeilingFloor.cs" type="Script" id=8]
[ext_resource path="res://Logic/Wall.cs" type="Script" id=7]
[ext_resource path="res://Logic/CeilingFloor.cs" type="Script" id=8]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4, 16 )

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scripts/ball.gd" type="Script" id=1]
[ext_resource path="res://logic/ball.gd" type="Script" id=1]
[ext_resource path="res://ball.png" type="Texture" id=2]
[sub_resource type="CircleShape2D" id=1]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scripts/lobby.gd" type="Script" id=1]
[ext_resource path="res://logic/lobby.gd" type="Script" id=1]
[node name="Lobby" type="Control"]
anchor_left = 0.5

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scripts/paddle.gd" type="Script" id=1]
[ext_resource path="res://logic/paddle.gd" type="Script" id=1]
[ext_resource path="res://paddle.png" type="Texture" id=2]
[sub_resource type="CapsuleShape2D" id=1]

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scripts/pong.gd" type="Script" id=1]
[ext_resource path="res://logic/pong.gd" type="Script" id=1]
[ext_resource path="res://separator.png" type="Texture" id=2]
[ext_resource path="res://paddle.tscn" type="PackedScene" id=3]
[ext_resource path="res://ball.tscn" type="PackedScene" id=4]

View File

@@ -30,7 +30,7 @@ func stop():
func _create_peer(id):
var peer : WebRTCPeerConnection = WebRTCPeerConnection.new()
var peer: WebRTCPeerConnection = WebRTCPeerConnection.new()
peer.initialize({
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
})

View File

@@ -52,13 +52,13 @@ func _connected(protocol = ""):
func _parse_msg():
var pkt_str : String = client.get_peer(1).get_packet().get_string_from_utf8()
var pkt_str: String = client.get_peer(1).get_packet().get_string_from_utf8()
var req : PoolStringArray = pkt_str.split('\n', true, 1)
var req: PoolStringArray = pkt_str.split("\n", true, 1)
if req.size() != 2: # Invalid request size
return
var type : String = req[0]
var type: String = req[0]
if type.length() < 3: # Invalid type size
return
@@ -69,11 +69,11 @@ func _parse_msg():
emit_signal("lobby_sealed")
return
var src_str : String = type.substr(3, type.length() - 3)
var src_str: String = type.substr(3, type.length() - 3)
if not src_str.is_valid_integer(): # Source id is not an integer
return
var src_id : int = int(src_str)
var src_id: int = int(src_str)
if type.begins_with("I: "):
emit_signal("connected", src_id)
@@ -91,7 +91,7 @@ func _parse_msg():
emit_signal("answer_received", src_id, req[1])
elif type.begins_with("C: "):
# Candidate received
var candidate : PoolStringArray = req[1].split('\n', false)
var candidate: PoolStringArray = req[1].split("\n", false)
if candidate.size() != 3:
return
if not candidate[1].is_valid_integer():
@@ -124,6 +124,6 @@ func _send_msg(type, id, data) -> int:
func _process(delta):
var status : int = client.get_connection_status()
var status: int = client.get_connection_status()
if status == WebSocketClient.CONNECTION_CONNECTING or status == WebSocketClient.CONNECTION_CONNECTED:
client.poll()

View File

@@ -43,11 +43,11 @@ func _mp_server_disconnect():
_log("Multiplayer is disconnected (I am %d)" % client.rtc_mp.get_unique_id())
func _mp_peer_connected(id : int):
func _mp_peer_connected(id: int):
_log("Multiplayer peer %d connected" % id)
func _mp_peer_disconnected(id : int):
func _mp_peer_disconnected(id: int):
_log("Multiplayer peer %d disconnected" % id)

View File

@@ -22,18 +22,18 @@ class Peer extends Reference:
class Lobby extends Reference:
var peers : Array = []
var host : int = -1
var sealed : bool = false
var peers: Array = []
var host: int = -1
var sealed: bool = false
var time = 0
func _init(host_id : int):
func _init(host_id: int):
host = host_id
func join(peer_id, server) -> bool:
if sealed: return false
if not server.has_peer(peer_id): return false
var new_peer : WebSocketPeer = server.get_peer(peer_id)
var new_peer: WebSocketPeer = server.get_peer(peer_id)
new_peer.put_packet(("I: %d\n" % (1 if peer_id == host else peer_id)).to_utf8())
for p in peers:
if not server.has_peer(p):
@@ -156,7 +156,7 @@ func _on_data(id):
func _parse_msg(id) -> bool:
var pkt_str: String = server.get_peer(id).get_packet().get_string_from_utf8()
var req = pkt_str.split('\n', true, 1)
var req = pkt_str.split("\n", true, 1)
if req.size() != 2: # Invalid request size
return false
@@ -181,11 +181,11 @@ func _parse_msg(id) -> bool:
# Client is sealing the room
return lobby.seal(id, server)
var dest_str : String = type.substr(3, type.length() - 3)
var dest_str: String = type.substr(3, type.length() - 3)
if not dest_str.is_valid_integer(): # Destination id is not an integer
return false
var dest_id : int = int(dest_str)
var dest_id: int = int(dest_str)
if dest_id == NetworkedMultiplayerPeer.TARGET_PEER_SERVER:
dest_id = lobby.host

View File

@@ -31,7 +31,7 @@ func apply_pressed():
printerr("Material Creator: Can't apply the material, because there are no nodes selected!")
var material = _silly_resource_from_values().make_material()
# Go through the selected nodes and see if they have the 'set_surface_material'
# Go through the selected nodes and see if they have the "set_surface_material"
# function (which only MeshInstance has by default). If they do, then set the material
# to the silly material.
for node in selected_nodes: