movement
parent
6f558eb49f
commit
dc05a9b974
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
public partial class Area : Area2D
|
||||
{
|
||||
public override void _PhysicsProcess(double delta) {
|
||||
// BodyEntered += OnBodyEntered;
|
||||
// BodyExited += OnBodyExited;
|
||||
}
|
||||
|
||||
private void OnBodyEntered(Node2D body) {
|
||||
if (body is Ball) {
|
||||
GD.Print("Ball entered the area!");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBodyExited(Node2D body) {
|
||||
if (body is Ball) {
|
||||
GD.Print("Ball left the area!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Ball : Node2D {
|
||||
private int direction = 1;
|
||||
[Export] private int speed = 500;
|
||||
[Export] private Area2D area;
|
||||
|
||||
public override void _Ready() {
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta) {
|
||||
Vector2 position = Position;
|
||||
position.X += Mathf.RoundToInt(direction * speed * delta);
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public void ChangeDirection() => direction *= -1;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c5jcxyyyd0m60"
|
||||
path="res://.godot/imported/Ball.png-3e5e22496e5c9e9b08e902070a717137.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Ball.png"
|
||||
dest_files=["res://.godot/imported/Ball.png-3e5e22496e5c9e9b08e902070a717137.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class GameManager : Node2D {
|
||||
[Export] private Player player1;
|
||||
[Export] private Player player2;
|
||||
[Export] private Ball ball;
|
||||
|
||||
public override void _Ready() {
|
||||
// ball.ChangeDirection();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 186 B |
Binary file not shown.
@ -1,11 +1,20 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bxkg2ri346c2o"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bxkg2ri346c2o"]
|
||||
|
||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_toecu"]
|
||||
size = Vector2(30, 30)
|
||||
[ext_resource type="Texture2D" uid="uid://c5jcxyyyd0m60" path="res://Ball.png" id="1_ihs8s"]
|
||||
[ext_resource type="Script" path="res://Ball.cs" id="1_jhuit"]
|
||||
|
||||
[node name="Ball" type="Node2D"]
|
||||
script = ExtResource("1_jhuit")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="RigidBody2D"]
|
||||
position = Vector2(16, 16)
|
||||
scale = Vector2(1, 1.14)
|
||||
texture = ExtResource("1_ihs8s")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="RigidBody2D"]
|
||||
position = Vector2(16, 16)
|
||||
scale = Vector2(1, 1.14)
|
||||
texture = SubResource("PlaceholderTexture2D_toecu")
|
||||
polygon = PackedVector2Array(16, -11.7, 16, 10, 10.7, 16, -11, 16, -16, 11.8, -16, -10, -10, -15.8, 10, -16)
|
||||
|
||||
@ -1,11 +1,18 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dbgbygehmmopa"]
|
||||
|
||||
[ext_resource type="Script" path="res://Player.cs" id="1_cs5ta"]
|
||||
[ext_resource type="Texture2D" uid="uid://4fir02w0nns3" path="res://Player.png" id="2_jdmud"]
|
||||
[ext_resource type="Texture2D" uid="uid://1aivwap6lvr4" path="res://Player.png" id="2_jdmud"]
|
||||
|
||||
[node name="Player1" type="Node2D"]
|
||||
script = ExtResource("1_cs5ta")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(16, 200)
|
||||
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||
gravity_scale = 0.0
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, 64)
|
||||
texture = ExtResource("2_jdmud")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="RigidBody2D"]
|
||||
position = Vector2(0, 64)
|
||||
polygon = PackedVector2Array(5, -63.7, 5, 64, -4, 64, -4, 63.3, -5, 61, -5, -61.1, -4, -63.4, -4, -64, 4.2, -64)
|
||||
|
||||
Loading…
Reference in New Issue