This commit is contained in:
Victor Turgeon 2023-06-10 17:14:58 -04:00
commit b5201b3c16
6 changed files with 98 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ public partial class start_game_menu : Control {
private const string _path = "/root/StartGameMenu/";
private Button _localMulti, _single, _LANMulti, _join, _host, _cancel, _quit, _yes, _no;
private TextEdit _ip;
private LineEdit _ip;
private Label _error, _lip;
private string Error { set { _error.Set("text", value); } }
@ -112,7 +112,7 @@ public partial class start_game_menu : Control {
_host = GetNode<Button>(_path + "Btn_Host");
_join = GetNode<Button>(_path + "Btn_Join");
_error = GetNode<Label>(_path + "lbl_err");
_ip = GetNode<TextEdit>(_path + "txt_IP");
_ip = GetNode<LineEdit>(_path + "txt_IP");
_lip = GetNode<Label>(_path + "lbl_IP");
_single.Pressed += () => startGame(_gameType.SINGLE);
_localMulti.Pressed += () => startGame(_gameType.LOCAL);
@ -135,7 +135,7 @@ public partial class start_game_menu : Control {
break;
case _gameType.LAN:
Error = "YIPPE! " + id.ToString();
break;
default: return;
}
@ -145,7 +145,7 @@ public partial class start_game_menu : Control {
const string ERR = "Invalid IP address.";
if (isHost) {
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
peer.CreateServer(666, 2);
peer.CreateServer(6666);
Multiplayer.MultiplayerPeer = peer;
peer.PeerConnected += (long id) => startGame(_gameType.LAN, id);
State = _state.HOST;
@ -169,7 +169,7 @@ public partial class start_game_menu : Control {
}
}
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
peer.CreateClient(ip, 666);
peer.CreateClient(ip, 6666);
Multiplayer.MultiplayerPeer = peer;
State = _state.JOIN;
}

View File

@ -114,7 +114,7 @@ offset_bottom = 779.0
text = "Join
"
[node name="txt_IP" type="TextEdit" parent="."]
[node name="txt_IP" type="LineEdit" parent="."]
visible = false
layout_mode = 0
offset_left = 1034.0

71
player/player.cs Normal file
View File

@ -0,0 +1,71 @@
using Godot;
using System;
public partial class player : Camera3D
{
private const string _path = "/root/player/";
//private Camera3D _cam;
[Export]
private Label _con;
private Vector2 _screen;
private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
//_cam = GetNode<Camera3D>(_path + "Camera3D");
//_con = GetNode<Label>(_path + "Camera3D/Label");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
Vector3 rot = this.Rotation;
bool zin = true, zout = true;
this.Rotation -= rot;
if (this.Position.Y < 5)
zin = false;
else if (this.Position.Y > 20)
zout = false;
if (_mLeft && this.Position.X > -30)
this.Translate(new Vector3((float)-delta*10, 0, 0));
if (_mRight && this.Position.X < 30)
this.Translate(new Vector3((float)delta*10, 0, 0));
if (_mUp && this.Position.Z > -25)
this.Translate(new Vector3(0, 0, (float)-delta*10));
if (_mDown && this.Position.Z < 25)
this.Translate(new Vector3(0, 0, (float)delta*10));
this.Rotation += rot;
if (_wIn && zin)
this.Translate(new Vector3(0, 0, (float)-delta*10));
if (_wOut && zout)
this.Translate(new Vector3(0, 0, (float)delta*10));
_con.Set("text", this.Position);
}
public override void _Input(InputEvent @event)
{
_mLeft = _mRight = _mUp = _mDown = _wIn = _wOut = false;
if (@event is InputEventMouseMotion mouse) {
Vector2 vec = mouse.Position;
if (vec.X < 5)
_mLeft = true;
else if (vec.X > 1915)
_mRight = true;
if (vec.Y < 20)
_mUp = true;
else if (vec.Y > 1060)
_mDown = true;
}
else if (@event is InputEventMouseButton mousebtn) {
if (mousebtn.ButtonIndex == MouseButton.WheelUp)
_wIn = true;
else if (mousebtn.ButtonIndex == MouseButton.WheelDown)
_wOut = true;
}
}
}

14
player/player.tscn Normal file
View File

@ -0,0 +1,14 @@
[gd_scene load_steps=2 format=3 uid="uid://b5gb5paiupum"]
[ext_resource type="Script" path="res://player/player.cs" id="1_of2l4"]
[node name="player" type="Camera3D" node_paths=PackedStringArray("_con")]
script = ExtResource("1_of2l4")
_con = NodePath("Label")
[node name="Label" type="Label" parent="."]
offset_left = 313.0
offset_top = 156.0
offset_right = 402.0
offset_bottom = 182.0
text = "Eat ze caca."

View File

@ -11,6 +11,7 @@ config_version=5
[application]
config/name="Mad"
run/main_scene="res://menu/start_game_menu.tscn"
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
config/icon="res://icon.svg"