Movin'
This commit is contained in:
parent
cbe4523af4
commit
100bac9f97
File diff suppressed because one or more lines are too long
66
player/player.cs
Normal file
66
player/player.cs
Normal file
@ -0,0 +1,66 @@
|
||||
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;
|
||||
|
||||
this.Rotation -= rot;
|
||||
if (_mLeft)
|
||||
this.Translate(new Vector3((float)-delta*10, 0, 0));
|
||||
if (_mRight)
|
||||
this.Translate(new Vector3((float)delta*10, 0, 0));
|
||||
if (_mUp)
|
||||
this.Translate(new Vector3(0, 0, (float)-delta*10));
|
||||
if (_mDown)
|
||||
this.Translate(new Vector3(0, 0, (float)delta*10));
|
||||
this.Rotation += rot;
|
||||
|
||||
if (_wIn)
|
||||
this.Translate(new Vector3(0, 0, (float)-delta*10));
|
||||
if (_wOut)
|
||||
this.Translate(new Vector3(0, 0, (float)delta*10));
|
||||
|
||||
_con.Set("text", this.Rotation);
|
||||
}
|
||||
|
||||
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."
|
Loading…
x
Reference in New Issue
Block a user