Merge branch 'main' of https://github.com/MarcEricMartel/MAD
This commit is contained in:
commit
b5201b3c16
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ public partial class start_game_menu : Control {
|
|||||||
|
|
||||||
private const string _path = "/root/StartGameMenu/";
|
private const string _path = "/root/StartGameMenu/";
|
||||||
private Button _localMulti, _single, _LANMulti, _join, _host, _cancel, _quit, _yes, _no;
|
private Button _localMulti, _single, _LANMulti, _join, _host, _cancel, _quit, _yes, _no;
|
||||||
private TextEdit _ip;
|
private LineEdit _ip;
|
||||||
private Label _error, _lip;
|
private Label _error, _lip;
|
||||||
|
|
||||||
private string Error { set { _error.Set("text", value); } }
|
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");
|
_host = GetNode<Button>(_path + "Btn_Host");
|
||||||
_join = GetNode<Button>(_path + "Btn_Join");
|
_join = GetNode<Button>(_path + "Btn_Join");
|
||||||
_error = GetNode<Label>(_path + "lbl_err");
|
_error = GetNode<Label>(_path + "lbl_err");
|
||||||
_ip = GetNode<TextEdit>(_path + "txt_IP");
|
_ip = GetNode<LineEdit>(_path + "txt_IP");
|
||||||
_lip = GetNode<Label>(_path + "lbl_IP");
|
_lip = GetNode<Label>(_path + "lbl_IP");
|
||||||
_single.Pressed += () => startGame(_gameType.SINGLE);
|
_single.Pressed += () => startGame(_gameType.SINGLE);
|
||||||
_localMulti.Pressed += () => startGame(_gameType.LOCAL);
|
_localMulti.Pressed += () => startGame(_gameType.LOCAL);
|
||||||
@ -135,7 +135,7 @@ public partial class start_game_menu : Control {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case _gameType.LAN:
|
case _gameType.LAN:
|
||||||
Error = "YIPPE! " + id.ToString();
|
|
||||||
break;
|
break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public partial class start_game_menu : Control {
|
|||||||
const string ERR = "Invalid IP address.";
|
const string ERR = "Invalid IP address.";
|
||||||
if (isHost) {
|
if (isHost) {
|
||||||
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
||||||
peer.CreateServer(666, 2);
|
peer.CreateServer(6666);
|
||||||
Multiplayer.MultiplayerPeer = peer;
|
Multiplayer.MultiplayerPeer = peer;
|
||||||
peer.PeerConnected += (long id) => startGame(_gameType.LAN, id);
|
peer.PeerConnected += (long id) => startGame(_gameType.LAN, id);
|
||||||
State = _state.HOST;
|
State = _state.HOST;
|
||||||
@ -169,7 +169,7 @@ public partial class start_game_menu : Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
ENetMultiplayerPeer peer = new ENetMultiplayerPeer();
|
||||||
peer.CreateClient(ip, 666);
|
peer.CreateClient(ip, 6666);
|
||||||
Multiplayer.MultiplayerPeer = peer;
|
Multiplayer.MultiplayerPeer = peer;
|
||||||
State = _state.JOIN;
|
State = _state.JOIN;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ offset_bottom = 779.0
|
|||||||
text = "Join
|
text = "Join
|
||||||
"
|
"
|
||||||
|
|
||||||
[node name="txt_IP" type="TextEdit" parent="."]
|
[node name="txt_IP" type="LineEdit" parent="."]
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 1034.0
|
offset_left = 1034.0
|
||||||
|
71
player/player.cs
Normal file
71
player/player.cs
Normal 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
14
player/player.tscn
Normal 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."
|
@ -11,6 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Mad"
|
config/name="Mad"
|
||||||
|
run/main_scene="res://menu/start_game_menu.tscn"
|
||||||
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.0", "C#", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user