mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
Many tweaks thanks to IAmActuallyCthulhu
Also change apostrophes to double quotes and update C# projects
This commit is contained in:
@@ -13,7 +13,7 @@ func show_game_over():
|
|||||||
yield($MessageTimer, "timeout")
|
yield($MessageTimer, "timeout")
|
||||||
$MessageLabel.text = "Dodge the\nCreeps"
|
$MessageLabel.text = "Dodge the\nCreeps"
|
||||||
$MessageLabel.show()
|
$MessageLabel.show()
|
||||||
yield(get_tree().create_timer(1), 'timeout')
|
yield(get_tree().create_timer(1), "timeout")
|
||||||
$StartButton.show()
|
$StartButton.show()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
export (PackedScene) var Mob
|
export(PackedScene) var Mob
|
||||||
var score
|
var score
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -28,9 +28,9 @@ func _on_MobTimer_timeout():
|
|||||||
$MobPath/MobSpawnLocation.offset = randi()
|
$MobPath/MobSpawnLocation.offset = randi()
|
||||||
var mob = Mob.instance()
|
var mob = Mob.instance()
|
||||||
add_child(mob)
|
add_child(mob)
|
||||||
var direction = $MobPath/MobSpawnLocation.rotation + PI / 2
|
var direction = $MobPath/MobSpawnLocation.rotation + TAU / 4
|
||||||
mob.position = $MobPath/MobSpawnLocation.position
|
mob.position = $MobPath/MobSpawnLocation.position
|
||||||
direction += rand_range(-PI / 4, PI / 4)
|
direction += rand_range(-TAU / 8, TAU / 8)
|
||||||
mob.rotation = direction
|
mob.rotation = direction
|
||||||
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction)
|
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0).rotated(direction)
|
||||||
# warning-ignore:return_value_discarded
|
# warning-ignore:return_value_discarded
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ func _process(_delta):
|
|||||||
var numbers = ""
|
var numbers = ""
|
||||||
var index = 0
|
var index = 0
|
||||||
for state in fsm_node.states_stack:
|
for state in fsm_node.states_stack:
|
||||||
states_names += state.get_name() + '\n'
|
states_names += state.get_name() + "\n"
|
||||||
numbers += str(index) + '\n'
|
numbers += str(index) + "\n"
|
||||||
index += 1
|
index += 1
|
||||||
$States.text = states_names
|
$States.text = states_names
|
||||||
$Numbers.text = numbers
|
$Numbers.text = numbers
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ extends KinematicBody2D
|
|||||||
var direction = Vector2()
|
var direction = Vector2()
|
||||||
export(float) var speed = 1000.0
|
export(float) var speed = 1000.0
|
||||||
|
|
||||||
|
onready var root = get_tree().root
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_as_toplevel(true)
|
set_as_toplevel(true)
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
if is_outside_view_bounds():
|
if not root.get_visible_rect().has_point(position):
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
var motion = direction * speed * delta
|
var motion = direction * speed * delta
|
||||||
@@ -17,10 +19,5 @@ func _physics_process(delta):
|
|||||||
queue_free()
|
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():
|
func _draw():
|
||||||
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)
|
draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.white)
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
extends "res://state_machine/state_machine.gd"
|
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():
|
func _ready():
|
||||||
states_map = {
|
states_map = {
|
||||||
"idle": $Idle,
|
"idle": idle,
|
||||||
"move": $Move,
|
"move": move,
|
||||||
"jump": $Jump,
|
"jump": jump,
|
||||||
"stagger": $Stagger,
|
"stagger": stagger,
|
||||||
"attack": $Attack,
|
"attack": attack,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -16,8 +22,8 @@ func _change_state(state_name):
|
|||||||
return
|
return
|
||||||
if state_name in ["stagger", "jump", "attack"]:
|
if state_name in ["stagger", "jump", "attack"]:
|
||||||
states_stack.push_front(states_map[state_name])
|
states_stack.push_front(states_map[state_name])
|
||||||
if state_name == "jump" and current_state == $Move:
|
if state_name == "jump" and current_state == move:
|
||||||
$Jump.initialize($Move.speed, $Move.velocity)
|
jump.initialize(move.speed, move.velocity)
|
||||||
._change_state(state_name)
|
._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,
|
# Here we only handle input that can interrupt states, attacking in this case,
|
||||||
# otherwise we let the state node handle it.
|
# otherwise we let the state node handle it.
|
||||||
if event.is_action_pressed("attack"):
|
if event.is_action_pressed("attack"):
|
||||||
if current_state in [$Attack, $Stagger]:
|
if current_state in [attack, stagger]:
|
||||||
return
|
return
|
||||||
_change_state("attack")
|
_change_state("attack")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func initialize(speed, velocity):
|
|||||||
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
|
max_horizontal_speed = speed if speed > 0.0 else base_max_horizontal_speed
|
||||||
enter_velocity = velocity
|
enter_velocity = velocity
|
||||||
|
|
||||||
|
|
||||||
func enter():
|
func enter():
|
||||||
var input_direction = get_input_direction()
|
var input_direction = get_input_direction()
|
||||||
update_look_direction(input_direction)
|
update_look_direction(input_direction)
|
||||||
@@ -31,6 +32,7 @@ func enter():
|
|||||||
|
|
||||||
owner.get_node("AnimationPlayer").play("idle")
|
owner.get_node("AnimationPlayer").play("idle")
|
||||||
|
|
||||||
|
|
||||||
func update(delta):
|
func update(delta):
|
||||||
var input_direction = get_input_direction()
|
var input_direction = get_input_direction()
|
||||||
update_look_direction(input_direction)
|
update_look_direction(input_direction)
|
||||||
@@ -40,6 +42,7 @@ func update(delta):
|
|||||||
if height <= 0.0:
|
if height <= 0.0:
|
||||||
emit_signal("finished", "previous")
|
emit_signal("finished", "previous")
|
||||||
|
|
||||||
|
|
||||||
func move_horizontally(delta, direction):
|
func move_horizontally(delta, direction):
|
||||||
if direction:
|
if direction:
|
||||||
horizontal_speed += air_acceleration * delta
|
horizontal_speed += air_acceleration * delta
|
||||||
@@ -53,6 +56,7 @@ func move_horizontally(delta, direction):
|
|||||||
|
|
||||||
owner.move_and_slide(horizontal_velocity)
|
owner.move_and_slide(horizontal_velocity)
|
||||||
|
|
||||||
|
|
||||||
func animate_jump_height(delta):
|
func animate_jump_height(delta):
|
||||||
vertical_speed -= gravity * delta
|
vertical_speed -= gravity * delta
|
||||||
height += vertical_speed * delta
|
height += vertical_speed * delta
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ func handle_input(event):
|
|||||||
|
|
||||||
|
|
||||||
func get_input_direction():
|
func get_input_direction():
|
||||||
var input_direction = Vector2()
|
var input_direction = Vector2(
|
||||||
input_direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
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")
|
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||||
|
)
|
||||||
return input_direction
|
return input_direction
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ func _ready():
|
|||||||
if not start_state:
|
if not start_state:
|
||||||
start_state = get_child(0).get_path()
|
start_state = get_child(0).get_path()
|
||||||
for child in get_children():
|
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)
|
initialize(start_state)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -232,11 +232,9 @@ func _draw():
|
|||||||
draw_circle(brush.brush_pos, brush.brush_shape_circle_radius, brush.brush_color)
|
draw_circle(brush.brush_pos, brush.brush_shape_circle_radius, brush.brush_color)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func save_picture(path):
|
func save_picture(path):
|
||||||
# Wait a couple frames so the save dialog isn't in the way.
|
# Wait until the frame has finished before getting the texture.
|
||||||
yield (get_tree(), "idle_frame")
|
yield(VisualServer, "frame_post_draw")
|
||||||
yield (get_tree(), "idle_frame")
|
|
||||||
|
|
||||||
# Get the viewport image.
|
# Get the viewport image.
|
||||||
var img = get_viewport().get_texture().get_data()
|
var img = get_viewport().get_texture().get_data()
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://PaintControl.gd" type="Script" id=1]
|
[ext_resource path="res://paint_control.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://ToolsPanel.gd" type="Script" id=2]
|
[ext_resource path="res://tools_panel.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://PaintTools.png" type="Texture" id=3]
|
[ext_resource path="res://paint_tools.png" type="Texture" id=3]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id=1]
|
[sub_resource type="StyleBoxFlat" id=1]
|
||||||
bg_color = Color( 1, 1, 1, 1 )
|
bg_color = Color( 1, 1, 1, 1 )
|
||||||
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex"
|
path="res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.stex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://PaintTools.png"
|
source_file="res://paint_tools.png"
|
||||||
dest_files=[ "res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex" ]
|
dest_files=[ "res://.import/paint_tools.png-224b64b7ddb26189a369199f6d686b79.stex" ]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ config/name="GD Paint"
|
|||||||
config/description="GD Paint is a simple image editor made using Godot and GDScript.
|
config/description="GD Paint is a simple image editor made using Godot and GDScript.
|
||||||
It supports different types of 'brushes': a basic pen/pencil
|
It supports different types of 'brushes': a basic pen/pencil
|
||||||
and eraser, as well as a rectangle and a circle brush."
|
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"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
extends Panel
|
extends Panel
|
||||||
|
|
||||||
var paint_control
|
|
||||||
|
|
||||||
onready var brush_settings = $BrushSettings
|
onready var brush_settings = $BrushSettings
|
||||||
onready var label_tools = $LabelTools
|
onready var label_brush_size = brush_settings.get_node(@"LabelBrushSize")
|
||||||
onready var label_brush_size = $BrushSettings/LabelBrushSize
|
onready var label_brush_shape = brush_settings.get_node(@"LabelBrushShape")
|
||||||
onready var label_brush_shape = $BrushSettings/LabelBrushShape
|
|
||||||
onready var label_stats = $LabelStats
|
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():
|
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
|
# warning-ignore-all:return_value_discarded
|
||||||
# Assign all of the needed signals for the oppersation buttons.
|
# Assign all of the needed signals for the oppersation buttons.
|
||||||
$ButtonUndo.connect("pressed", self, "button_pressed", ["undo_stroke"])
|
$ButtonUndo.connect("pressed", self, "button_pressed", ["undo_stroke"])
|
||||||
@@ -34,7 +30,7 @@ func _ready():
|
|||||||
$ColorPickerBackground.connect("color_changed", self, "background_color_changed")
|
$ColorPickerBackground.connect("color_changed", self, "background_color_changed")
|
||||||
$BrushSettings/HScrollBarBrushSize.connect("value_changed", self, "brush_size_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")
|
save_dialog.connect("file_selected", self, "save_file_selected")
|
||||||
|
|
||||||
# Set physics process so we can update the status label.
|
# Set physics process so we can update the status label.
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
const MOTION_SPEED = 160 # Pixels/second.
|
const MOTION_SPEED = 160 # Pixels/second.
|
||||||
|
const TAN30DEG = tan(deg2rad(30))
|
||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
var motion = Vector2()
|
var motion = Vector2()
|
||||||
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
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 = 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
|
motion = motion.normalized() * MOTION_SPEED
|
||||||
#warning-ignore:return_value_discarded
|
#warning-ignore:return_value_discarded
|
||||||
move_and_slide(motion)
|
move_and_slide(motion)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ func _physics_process(_delta):
|
|||||||
var motion = Vector2()
|
var motion = Vector2()
|
||||||
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
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 = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
||||||
motion.y *= 0.5
|
motion.y /= 2
|
||||||
motion = motion.normalized() * MOTION_SPEED
|
motion = motion.normalized() * MOTION_SPEED
|
||||||
#warning-ignore:return_value_discarded
|
#warning-ignore:return_value_discarded
|
||||||
move_and_slide(motion)
|
move_and_slide(motion)
|
||||||
|
|||||||
@@ -3,33 +3,35 @@ extends Navigation2D
|
|||||||
export(float) var character_speed = 400.0
|
export(float) var character_speed = 400.0
|
||||||
var path = []
|
var path = []
|
||||||
|
|
||||||
|
onready var character = $Character
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
var walk_distance = character_speed * delta
|
var walk_distance = character_speed * delta
|
||||||
move_along_path(walk_distance)
|
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.
|
# Project > Project Settings > Input Map tab.
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if not event.is_action_pressed("click"):
|
if not event.is_action_pressed("click"):
|
||||||
return
|
return
|
||||||
_update_navigation_path($Character.position, get_local_mouse_position())
|
_update_navigation_path(character.position, get_local_mouse_position())
|
||||||
|
|
||||||
|
|
||||||
func move_along_path(distance):
|
func move_along_path(distance):
|
||||||
var last_point = $Character.position
|
var last_point = character.position
|
||||||
while path.size():
|
while path.size():
|
||||||
var distance_between_points = last_point.distance_to(path[0])
|
var distance_between_points = last_point.distance_to(path[0])
|
||||||
# The position to move to falls between two points.
|
# The position to move to falls between two points.
|
||||||
if distance <= distance_between_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
|
return
|
||||||
# The position is past the end of the segment.
|
# The position is past the end of the segment.
|
||||||
distance -= distance_between_points
|
distance -= distance_between_points
|
||||||
last_point = path[0]
|
last_point = path[0]
|
||||||
path.remove(0)
|
path.remove(0)
|
||||||
# The character reached the end of the path.
|
# The character reached the end of the path.
|
||||||
$Character.position = last_point
|
character.position = last_point
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ extends Node2D
|
|||||||
|
|
||||||
enum States { IDLE, FOLLOW }
|
enum States { IDLE, FOLLOW }
|
||||||
|
|
||||||
|
const MASS = 10.0
|
||||||
|
const ARRIVE_DISTANCE = 10.0
|
||||||
|
|
||||||
export(float) var speed = 200.0
|
export(float) var speed = 200.0
|
||||||
var _state = null
|
var _state = null
|
||||||
|
|
||||||
@@ -38,9 +41,6 @@ func _unhandled_input(event):
|
|||||||
|
|
||||||
|
|
||||||
func _move_to(world_position):
|
func _move_to(world_position):
|
||||||
var MASS = 10.0
|
|
||||||
var ARRIVE_DISTANCE = 10.0
|
|
||||||
|
|
||||||
var desired_velocity = (world_position - position).normalized() * speed
|
var desired_velocity = (world_position - position).normalized() * speed
|
||||||
var steering = desired_velocity - _velocity
|
var steering = desired_velocity - _velocity
|
||||||
_velocity += steering / MASS
|
_velocity += steering / MASS
|
||||||
@@ -55,7 +55,7 @@ func _change_state(new_state):
|
|||||||
if not _path or len(_path) == 1:
|
if not _path or len(_path) == 1:
|
||||||
_change_state(States.IDLE)
|
_change_state(States.IDLE)
|
||||||
return
|
return
|
||||||
# The index 0 is the starting cell
|
# The index 0 is the starting cell.
|
||||||
# we don't want the character to move back to it in this example
|
# We don't want the character to move back to it in this example.
|
||||||
_target_point_world = _path[1]
|
_target_point_world = _path[1]
|
||||||
_state = new_state
|
_state = new_state
|
||||||
|
|||||||
@@ -47,6 +47,13 @@ var shoot_time = 1e20
|
|||||||
var Bullet = preload("res://player/Bullet.tscn")
|
var Bullet = preload("res://player/Bullet.tscn")
|
||||||
var Enemy = preload("res://enemy/Enemy.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):
|
func _integrate_forces(s):
|
||||||
var lv = s.get_linear_velocity()
|
var lv = s.get_linear_velocity()
|
||||||
var step = s.get_step()
|
var step = s.get_step()
|
||||||
@@ -54,7 +61,7 @@ func _integrate_forces(s):
|
|||||||
var new_anim = anim
|
var new_anim = anim
|
||||||
var new_siding_left = siding_left
|
var new_siding_left = siding_left
|
||||||
|
|
||||||
# Get the controls.
|
# Get player input.
|
||||||
var move_left = Input.is_action_pressed("move_left")
|
var move_left = Input.is_action_pressed("move_left")
|
||||||
var move_right = Input.is_action_pressed("move_right")
|
var move_right = Input.is_action_pressed("move_right")
|
||||||
var jump = Input.is_action_pressed("jump")
|
var jump = Input.is_action_pressed("jump")
|
||||||
@@ -124,7 +131,7 @@ func _integrate_forces(s):
|
|||||||
lv.y = -JUMP_VELOCITY
|
lv.y = -JUMP_VELOCITY
|
||||||
jumping = true
|
jumping = true
|
||||||
stopping_jump = false
|
stopping_jump = false
|
||||||
($SoundJump as AudioStreamPlayer2D).play()
|
sound_jump.play()
|
||||||
|
|
||||||
# Check siding.
|
# Check siding.
|
||||||
if lv.x < 0 and move_left:
|
if lv.x < 0 and move_left:
|
||||||
@@ -173,16 +180,16 @@ func _integrate_forces(s):
|
|||||||
# Update siding.
|
# Update siding.
|
||||||
if new_siding_left != siding_left:
|
if new_siding_left != siding_left:
|
||||||
if new_siding_left:
|
if new_siding_left:
|
||||||
($Sprite as Sprite).scale.x = -1
|
sprite.scale.x = -1
|
||||||
else:
|
else:
|
||||||
($Sprite as Sprite).scale.x = 1
|
sprite.scale.x = 1
|
||||||
|
|
||||||
siding_left = new_siding_left
|
siding_left = new_siding_left
|
||||||
|
|
||||||
# Change animation.
|
# Change animation.
|
||||||
if new_anim != anim:
|
if new_anim != anim:
|
||||||
anim = new_anim
|
anim = new_anim
|
||||||
($AnimationPlayer as AnimationPlayer).play(anim)
|
animation_player.play(anim)
|
||||||
|
|
||||||
shooting = shoot
|
shooting = shoot
|
||||||
|
|
||||||
@@ -204,15 +211,15 @@ func _shot_bullet():
|
|||||||
ss = -1.0
|
ss = -1.0
|
||||||
else:
|
else:
|
||||||
ss = 1.0
|
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
|
bi.position = pos
|
||||||
get_parent().add_child(bi)
|
get_parent().add_child(bi)
|
||||||
|
|
||||||
bi.linear_velocity = Vector2(400.0 * ss, -40)
|
bi.linear_velocity = Vector2(400.0 * ss, -40)
|
||||||
|
|
||||||
($Sprite/Smoke as Particles2D).restart()
|
sprite_smoke.restart()
|
||||||
($SoundShoot as AudioStreamPlayer2D).play()
|
sound_shoot.play()
|
||||||
|
|
||||||
add_collision_exception_with(bi) # Make bullet and this not collide.
|
add_collision_exception_with(bi) # Make bullet and this not collide.
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,14 @@ func _ready():
|
|||||||
# - If you split the character into a state machine or more advanced pattern,
|
# - If you split the character into a state machine or more advanced pattern,
|
||||||
# you can easily move individual functions.
|
# you can easily move individual functions.
|
||||||
func _physics_process(_delta):
|
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.
|
# 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
|
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y
|
||||||
@@ -49,22 +56,6 @@ func _physics_process(_delta):
|
|||||||
animation_player.play(animation)
|
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():
|
func destroy():
|
||||||
_state = State.DEAD
|
_state = State.DEAD
|
||||||
_velocity = Vector2.ZERO
|
_velocity = Vector2.ZERO
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ onready var sound_shoot = $Shoot
|
|||||||
onready var timer = $Cooldown
|
onready var timer = $Cooldown
|
||||||
|
|
||||||
|
|
||||||
|
# This method is only called by Player.gd.
|
||||||
func shoot(direction = 1):
|
func shoot(direction = 1):
|
||||||
if not timer.is_stopped():
|
if not timer.is_stopped():
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ const FLOOR_DETECT_DISTANCE = 20.0
|
|||||||
export(String) var action_suffix = ""
|
export(String) var action_suffix = ""
|
||||||
|
|
||||||
onready var platform_detector = $PlatformDetector
|
onready var platform_detector = $PlatformDetector
|
||||||
onready var sprite = $Sprite
|
|
||||||
onready var animation_player = $AnimationPlayer
|
onready var animation_player = $AnimationPlayer
|
||||||
onready var shoot_timer = $ShootAnimation
|
onready var shoot_timer = $ShootAnimation
|
||||||
onready var gun = $Sprite/Gun
|
onready var sprite = $Sprite
|
||||||
|
onready var gun = sprite.get_node(@"Gun")
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ onready var animation_player = $AnimationPlayer
|
|||||||
# The Coins only detects collisions with the Player thanks to its collision mask.
|
# The Coins only detects collisions with the Player thanks to its collision mask.
|
||||||
# This prevents other characters such as enemies from picking up coins.
|
# 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
|
# 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.
|
# collisions and frees it from memory, saving us from writing more complex code.
|
||||||
# Click the AnimationPlayer node to see the animation timeline.
|
# Click the AnimationPlayer node to see the animation timeline.
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[gd_scene load_steps=13 format=2]
|
[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://left_pallete.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://right_pallete.png" type="Texture" id=3]
|
[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://ball.png" type="Texture" id=5]
|
||||||
[ext_resource path="res://separator.png" type="Texture" id=6]
|
[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://logic/wall.gd" type="Script" id=7]
|
||||||
[ext_resource path="res://scripts/ceiling_floor.gd" type="Script" id=8]
|
[ext_resource path="res://logic/ceiling_floor.gd" type="Script" id=8]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 4, 16 )
|
extents = Vector2( 4, 16 )
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends 'Pawn.gd'
|
extends "Pawn.gd"
|
||||||
|
|
||||||
onready var Grid = get_parent()
|
onready var Grid = get_parent()
|
||||||
var lost = false
|
var lost = false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends 'Pawn.gd'
|
extends "Pawn.gd"
|
||||||
|
|
||||||
#warning-ignore:unused_class_variable
|
#warning-ignore:unused_class_variable
|
||||||
export (PackedScene) var combat_actor
|
export(PackedScene) var combat_actor
|
||||||
#warning-ignore:unused_class_variable
|
#warning-ignore:unused_class_variable
|
||||||
var lost = false
|
var lost = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends 'Actor.gd'
|
extends "Actor.gd"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
extends 'Pawn.gd'
|
extends "Pawn.gd"
|
||||||
|
|
||||||
onready var Grid = get_parent()
|
onready var Grid = get_parent()
|
||||||
#warning-ignore:unused_class_variable
|
#warning-ignore:unused_class_variable
|
||||||
export (PackedScene) var combat_actor
|
export(PackedScene) var combat_actor
|
||||||
#warning-ignore:unused_class_variable
|
#warning-ignore:unused_class_variable
|
||||||
var lost = false
|
var lost = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
export (NodePath) var combatants_node
|
export(NodePath) var combatants_node
|
||||||
export (PackedScene) var info_scene
|
export(PackedScene) var info_scene
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
combatants_node = get_node(combatants_node)
|
combatants_node = get_node(combatants_node)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func _ready():
|
|||||||
|
|
||||||
|
|
||||||
func _unhandled_input(ev):
|
func _unhandled_input(ev):
|
||||||
if ev is InputEventMouseButton :
|
if ev is InputEventMouseButton:
|
||||||
if ev.button_index == BUTTON_WHEEL_UP:
|
if ev.button_index == BUTTON_WHEEL_UP:
|
||||||
zoom -= ZOOM_SPEED
|
zoom -= ZOOM_SPEED
|
||||||
if ev.button_index == BUTTON_WHEEL_DOWN:
|
if ev.button_index == BUTTON_WHEEL_DOWN:
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ extends Node
|
|||||||
|
|
||||||
var _tests = [
|
var _tests = [
|
||||||
{
|
{
|
||||||
"id" : "Functional Tests/Shapes",
|
"id": "Functional Tests/Shapes",
|
||||||
"path" : "res://tests/functional/test_shapes.tscn",
|
"path": "res://tests/functional/test_shapes.tscn",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Functional Tests/Compound Shapes",
|
"id": "Functional Tests/Compound Shapes",
|
||||||
"path" : "res://tests/functional/test_compound_shapes.tscn",
|
"path": "res://tests/functional/test_compound_shapes.tscn",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Functional Tests/Friction",
|
"id": "Functional Tests/Friction",
|
||||||
"path" : "res://tests/functional/test_friction.tscn",
|
"path": "res://tests/functional/test_friction.tscn",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id" : "Performance Tests/Contacts",
|
"id": "Performance Tests/Contacts",
|
||||||
"path" : "res://tests/performance/test_perf_contacts.tscn",
|
"path": "res://tests/performance/test_perf_contacts.tscn",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends OptionMenu
|
extends OptionMenu
|
||||||
|
|
||||||
|
|
||||||
class TestData :
|
class TestData:
|
||||||
var id
|
var id
|
||||||
var scene_path
|
var scene_path
|
||||||
|
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ func _process(delta):
|
|||||||
var gyro = Input.get_gyroscope()
|
var gyro = Input.get_gyroscope()
|
||||||
|
|
||||||
# Show our base values
|
# Show our base values
|
||||||
get_node("Control/Accelerometer").text = 'Accelerometer: ' + str(acc) + ', gravity: ' + str(grav)
|
get_node("Control/Accelerometer").text = "Accelerometer: " + str(acc) + ", gravity: " + str(grav)
|
||||||
get_node("Control/Magnetometer").text = 'Magnetometer: ' + str(mag)
|
get_node("Control/Magnetometer").text = "Magnetometer: " + str(mag)
|
||||||
get_node("Control/Gyroscope").text = 'Gyroscope: ' + str(gyro)
|
get_node("Control/Gyroscope").text = "Gyroscope: " + str(gyro)
|
||||||
|
|
||||||
# Check if we have all needed data
|
# Check if we have all needed data
|
||||||
if grav.length() < 0.1:
|
if grav.length() < 0.1:
|
||||||
@@ -136,5 +136,3 @@ func _process(delta):
|
|||||||
var gyro_and_grav = get_node("Boxes/GyroAndGrav")
|
var gyro_and_grav = get_node("Boxes/GyroAndGrav")
|
||||||
var new_basis = rotate_by_gyro(gyro, gyro_and_grav.transform.basis, delta).orthonormalized()
|
var new_basis = rotate_by_gyro(gyro, gyro_and_grav.transform.basis, delta).orthonormalized()
|
||||||
gyro_and_grav.transform.basis = drift_correction(new_basis, grav)
|
gyro_and_grav.transform.basis = drift_correction(new_basis, grav)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ func reset_tween():
|
|||||||
tween.interpolate_property(sprite, "rotation_degrees", 360, 0, 2, state.trans, state.eases, 2)
|
tween.interpolate_property(sprite, "rotation_degrees", 360, 0, 2, state.trans, state.eases, 2)
|
||||||
|
|
||||||
if $Modes/Callback.is_pressed():
|
if $Modes/Callback.is_pressed():
|
||||||
tween.interpolate_callback(self, 0.5, "on_callback", "0.5 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 second's after")
|
tween.interpolate_callback(self, 0.2, "on_callback", "1.2 seconds after")
|
||||||
|
|
||||||
if $Modes/Follow.is_pressed():
|
if $Modes/Follow.is_pressed():
|
||||||
follow.show()
|
follow.show()
|
||||||
|
|||||||
@@ -11,10 +11,11 @@
|
|||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
|
||||||
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
|
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
|
||||||
|
<GodotProjectGeneratorVersion>1.0.0.0</GodotProjectGeneratorVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
|
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -63,5 +64,11 @@
|
|||||||
<Compile Include="assets\player\PlayerSprite.cs" />
|
<Compile Include="assets\player\PlayerSprite.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -5,15 +5,15 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
Tools|Any CPU = Tools|Any CPU
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{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}.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}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
{5CA791DB-5050-44D0-989B-41D559AB1D50}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
4
mono/README.md
Normal file
4
mono/README.md
Normal 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.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Tools</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}</ProjectGuid>
|
<ProjectGuid>{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
<GodotProjectGeneratorVersion>1.0.7374.16792</GodotProjectGeneratorVersion>
|
<GodotProjectGeneratorVersion>1.0.7374.16792</GodotProjectGeneratorVersion>
|
||||||
<BaseIntermediateOutputPath>.mono\temp\obj</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath>.mono\temp\obj</BaseIntermediateOutputPath>
|
||||||
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
|
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -43,12 +43,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="GodotSharp">
|
<Reference Include="GodotSharp">
|
||||||
<HintPath>$(ProjectDir)\.mono\assemblies\$(ApiConfiguration)\GodotSharp.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
|
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<HintPath>$(ProjectDir)\.mono\assemblies\$(ApiConfiguration)\GodotSharpEditor.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -59,5 +59,11 @@
|
|||||||
<Compile Include="Player.cs" />
|
<Compile Include="Player.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -5,15 +5,15 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
Tools|Any CPU = Tools|Any CPU
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{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}.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}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Release|Any CPU.Build.0 = Release|Any CPU
|
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
{75CB0382-CCCC-4A4D-ABF0-C6CD04D9F832}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -73,13 +73,13 @@ public class Main : Node
|
|||||||
AddChild(mobInstance);
|
AddChild(mobInstance);
|
||||||
|
|
||||||
// Set the mob's direction perpendicular to the path direction.
|
// 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.
|
// Set the mob's position to a random location.
|
||||||
mobInstance.Position = mobSpawnLocation.Position;
|
mobInstance.Position = mobSpawnLocation.Position;
|
||||||
|
|
||||||
// Add some randomness to the direction.
|
// 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;
|
mobInstance.Rotation = direction;
|
||||||
|
|
||||||
// Choose the velocity.
|
// Choose the velocity.
|
||||||
|
|||||||
@@ -11,10 +11,11 @@
|
|||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
|
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
|
||||||
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
|
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</ApiConfiguration>
|
||||||
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
|
<ApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</ApiConfiguration>
|
||||||
|
<GodotProjectGeneratorVersion>1.0.0.0</GodotProjectGeneratorVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportDebug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ExportRelease|AnyCPU' ">
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<ConsolePause>false</ConsolePause>
|
<ConsolePause>false</ConsolePause>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>portable</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
|
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
|
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -53,10 +54,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Scripts\Ball.cs" />
|
<Compile Include="Logic\Ball.cs" />
|
||||||
<Compile Include="Scripts\CeilingFloor.cs" />
|
<Compile Include="Logic\CeilingFloor.cs" />
|
||||||
<Compile Include="Scripts\Paddle.cs" />
|
<Compile Include="Logic\Paddle.cs" />
|
||||||
<Compile Include="Scripts\Wall.cs" />
|
<Compile Include="Logic\Wall.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies">
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -5,15 +5,15 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
Tools|Any CPU = Tools|Any CPU
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{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}.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}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
{EBA5981B-C37E-48C5-A3B6-4390D9834F9A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[gd_scene load_steps=13 format=2]
|
[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://left_pallete.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://right_pallete.png" type="Texture" id=3]
|
[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://ball.png" type="Texture" id=5]
|
||||||
[ext_resource path="res://separator.png" type="Texture" id=6]
|
[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://Logic/Wall.cs" type="Script" id=7]
|
||||||
[ext_resource path="res://Scripts/CeilingFloor.cs" type="Script" id=8]
|
[ext_resource path="res://Logic/CeilingFloor.cs" type="Script" id=8]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 4, 16 )
|
extents = Vector2( 4, 16 )
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[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]
|
[ext_resource path="res://ball.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[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"]
|
[node name="Lobby" type="Control"]
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=4 format=2]
|
[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]
|
[ext_resource path="res://paddle.png" type="Texture" id=2]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=1]
|
[sub_resource type="CapsuleShape2D" id=1]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[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://separator.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://paddle.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://paddle.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://ball.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://ball.tscn" type="PackedScene" id=4]
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func stop():
|
|||||||
|
|
||||||
|
|
||||||
func _create_peer(id):
|
func _create_peer(id):
|
||||||
var peer : WebRTCPeerConnection = WebRTCPeerConnection.new()
|
var peer: WebRTCPeerConnection = WebRTCPeerConnection.new()
|
||||||
peer.initialize({
|
peer.initialize({
|
||||||
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
|
"iceServers": [ { "urls": ["stun:stun.l.google.com:19302"] } ]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ func _connected(protocol = ""):
|
|||||||
|
|
||||||
|
|
||||||
func _parse_msg():
|
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
|
if req.size() != 2: # Invalid request size
|
||||||
return
|
return
|
||||||
|
|
||||||
var type : String = req[0]
|
var type: String = req[0]
|
||||||
if type.length() < 3: # Invalid type size
|
if type.length() < 3: # Invalid type size
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -69,11 +69,11 @@ func _parse_msg():
|
|||||||
emit_signal("lobby_sealed")
|
emit_signal("lobby_sealed")
|
||||||
return
|
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
|
if not src_str.is_valid_integer(): # Source id is not an integer
|
||||||
return
|
return
|
||||||
|
|
||||||
var src_id : int = int(src_str)
|
var src_id: int = int(src_str)
|
||||||
|
|
||||||
if type.begins_with("I: "):
|
if type.begins_with("I: "):
|
||||||
emit_signal("connected", src_id)
|
emit_signal("connected", src_id)
|
||||||
@@ -91,7 +91,7 @@ func _parse_msg():
|
|||||||
emit_signal("answer_received", src_id, req[1])
|
emit_signal("answer_received", src_id, req[1])
|
||||||
elif type.begins_with("C: "):
|
elif type.begins_with("C: "):
|
||||||
# Candidate received
|
# Candidate received
|
||||||
var candidate : PoolStringArray = req[1].split('\n', false)
|
var candidate: PoolStringArray = req[1].split("\n", false)
|
||||||
if candidate.size() != 3:
|
if candidate.size() != 3:
|
||||||
return
|
return
|
||||||
if not candidate[1].is_valid_integer():
|
if not candidate[1].is_valid_integer():
|
||||||
@@ -124,6 +124,6 @@ func _send_msg(type, id, data) -> int:
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
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:
|
if status == WebSocketClient.CONNECTION_CONNECTING or status == WebSocketClient.CONNECTION_CONNECTED:
|
||||||
client.poll()
|
client.poll()
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ func _mp_server_disconnect():
|
|||||||
_log("Multiplayer is disconnected (I am %d)" % client.rtc_mp.get_unique_id())
|
_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)
|
_log("Multiplayer peer %d connected" % id)
|
||||||
|
|
||||||
|
|
||||||
func _mp_peer_disconnected(id : int):
|
func _mp_peer_disconnected(id: int):
|
||||||
_log("Multiplayer peer %d disconnected" % id)
|
_log("Multiplayer peer %d disconnected" % id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ class Peer extends Reference:
|
|||||||
|
|
||||||
|
|
||||||
class Lobby extends Reference:
|
class Lobby extends Reference:
|
||||||
var peers : Array = []
|
var peers: Array = []
|
||||||
var host : int = -1
|
var host: int = -1
|
||||||
var sealed : bool = false
|
var sealed: bool = false
|
||||||
var time = 0
|
var time = 0
|
||||||
|
|
||||||
func _init(host_id : int):
|
func _init(host_id: int):
|
||||||
host = host_id
|
host = host_id
|
||||||
|
|
||||||
func join(peer_id, server) -> bool:
|
func join(peer_id, server) -> bool:
|
||||||
if sealed: return false
|
if sealed: return false
|
||||||
if not server.has_peer(peer_id): 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())
|
new_peer.put_packet(("I: %d\n" % (1 if peer_id == host else peer_id)).to_utf8())
|
||||||
for p in peers:
|
for p in peers:
|
||||||
if not server.has_peer(p):
|
if not server.has_peer(p):
|
||||||
@@ -156,7 +156,7 @@ func _on_data(id):
|
|||||||
func _parse_msg(id) -> bool:
|
func _parse_msg(id) -> bool:
|
||||||
var pkt_str: String = server.get_peer(id).get_packet().get_string_from_utf8()
|
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
|
if req.size() != 2: # Invalid request size
|
||||||
return false
|
return false
|
||||||
|
|
||||||
@@ -181,11 +181,11 @@ func _parse_msg(id) -> bool:
|
|||||||
# Client is sealing the room
|
# Client is sealing the room
|
||||||
return lobby.seal(id, server)
|
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
|
if not dest_str.is_valid_integer(): # Destination id is not an integer
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var dest_id : int = int(dest_str)
|
var dest_id: int = int(dest_str)
|
||||||
if dest_id == NetworkedMultiplayerPeer.TARGET_PEER_SERVER:
|
if dest_id == NetworkedMultiplayerPeer.TARGET_PEER_SERVER:
|
||||||
dest_id = lobby.host
|
dest_id = lobby.host
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func apply_pressed():
|
|||||||
printerr("Material Creator: Can't apply the material, because there are no nodes selected!")
|
printerr("Material Creator: Can't apply the material, because there are no nodes selected!")
|
||||||
|
|
||||||
var material = _silly_resource_from_values().make_material()
|
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
|
# function (which only MeshInstance has by default). If they do, then set the material
|
||||||
# to the silly material.
|
# to the silly material.
|
||||||
for node in selected_nodes:
|
for node in selected_nodes:
|
||||||
|
|||||||
Reference in New Issue
Block a user