2 Commits
Author SHA1 Message Date
haylan 9c806e5a3e chore: added mouse concept 2026-03-15 20:58:50 +01:00
haylan f2fb6bb2e6 feat: created basic mouse and keyboard movement 2026-03-15 20:58:07 +01:00
10 changed files with 147 additions and 6 deletions

No files matched your search

@@ -1,4 +0,0 @@
extends Camera2D
class_name RecurionCamera
@@ -0,0 +1,40 @@
<mxfile host="Electron" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.0.6 Chrome/138.0.7204.100 Electron/37.2.3 Safari/537.36" version="28.0.6">
<diagram name="Seite-1" id="8VUDw9VsU7XZE8zAJI22">
<mxGraphModel dx="575" dy="518" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="U4xH48hkQDtbZK23ePJW-3" value="2D Movement Drag Conept" style="shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;" vertex="1" parent="1">
<mxGeometry x="10" y="10" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-4" value="When&lt;br&gt;Left Click + Hold" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="40" y="120" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-5" value="Save Mouse Pos" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="160" y="130" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-6" value="Movement of mouse" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="40" y="250" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-7" value="New Mouse pos - old pos = move postions" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="160" y="260" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-8" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="440" y="210" as="sourcePoint" />
<mxPoint x="600" y="330" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-10" value="Click&lt;br&gt;PosA" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;" vertex="1" parent="1">
<mxGeometry x="380" y="130" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-11" value="Click Move&lt;br&gt;PosB" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;" vertex="1" parent="1">
<mxGeometry x="540" y="250" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="U4xH48hkQDtbZK23ePJW-12" value="Vector: 10x, -5y" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="540" y="130" width="120" height="60" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file with editors other than draw.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" style="background: transparent; background-color: transparent; color-scheme: light dark;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="652px" height="329px" viewBox="-0.5 -0.5 652 329" content="&lt;mxfile host=&quot;Electron&quot; agent=&quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/28.0.6 Chrome/138.0.7204.100 Electron/37.2.3 Safari/537.36&quot; version=&quot;28.0.6&quot;&gt;&#10; &lt;diagram name=&quot;Seite-1&quot; id=&quot;8VUDw9VsU7XZE8zAJI22&quot;&gt;&#10; &lt;mxGraphModel dx=&quot;575&quot; dy=&quot;518&quot; grid=&quot;1&quot; gridSize=&quot;10&quot; guides=&quot;1&quot; tooltips=&quot;1&quot; connect=&quot;1&quot; arrows=&quot;1&quot; fold=&quot;1&quot; page=&quot;1&quot; pageScale=&quot;1&quot; pageWidth=&quot;827&quot; pageHeight=&quot;1169&quot; math=&quot;0&quot; shadow=&quot;0&quot;&gt;&#10; &lt;root&gt;&#10; &lt;mxCell id=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;1&quot; parent=&quot;0&quot; /&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-3&quot; value=&quot;2D Movement Drag Conept&quot; style=&quot;shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;10&quot; y=&quot;10&quot; width=&quot;120&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-4&quot; value=&quot;When&amp;lt;br&amp;gt;Left Click + Hold&quot; style=&quot;ellipse;whiteSpace=wrap;html=1;aspect=fixed;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;40&quot; y=&quot;120&quot; width=&quot;80&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-5&quot; value=&quot;Save Mouse Pos&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;160&quot; y=&quot;130&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-6&quot; value=&quot;Movement of mouse&quot; style=&quot;ellipse;whiteSpace=wrap;html=1;aspect=fixed;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;40&quot; y=&quot;250&quot; width=&quot;80&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-7&quot; value=&quot;New Mouse pos - old pos = move postions&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;160&quot; y=&quot;260&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-8&quot; value=&quot;&quot; style=&quot;endArrow=classic;html=1;rounded=0;&quot; edge=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry width=&quot;50&quot; height=&quot;50&quot; relative=&quot;1&quot; as=&quot;geometry&quot;&gt;&#10; &lt;mxPoint x=&quot;440&quot; y=&quot;210&quot; as=&quot;sourcePoint&quot; /&gt;&#10; &lt;mxPoint x=&quot;600&quot; y=&quot;330&quot; as=&quot;targetPoint&quot; /&gt;&#10; &lt;/mxGeometry&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-10&quot; value=&quot;Click&amp;lt;br&amp;gt;PosA&quot; style=&quot;shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;380&quot; y=&quot;130&quot; width=&quot;120&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-11&quot; value=&quot;Click Move&amp;lt;br&amp;gt;PosB&quot; style=&quot;shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;540&quot; y=&quot;250&quot; width=&quot;120&quot; height=&quot;80&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;mxCell id=&quot;U4xH48hkQDtbZK23ePJW-12&quot; value=&quot;Vector: 10x, -5y&quot; style=&quot;rounded=0;whiteSpace=wrap;html=1;&quot; vertex=&quot;1&quot; parent=&quot;1&quot;&gt;&#10; &lt;mxGeometry x=&quot;540&quot; y=&quot;130&quot; width=&quot;120&quot; height=&quot;60&quot; as=&quot;geometry&quot; /&gt;&#10; &lt;/mxCell&gt;&#10; &lt;/root&gt;&#10; &lt;/mxGraphModel&gt;&#10; &lt;/diagram&gt;&#10;&lt;/mxfile&gt;&#10;"><defs/><g><g data-cell-id="0"><g data-cell-id="1"><g data-cell-id="U4xH48hkQDtbZK23ePJW-3"><g><path d="M 0 0 L 100 0 L 120 20 L 120 80 L 20 80 L 0 60 L 0 0 Z" fill="Line truncated

After

Width:  |  Height:  |  Size: 15 KiB

@@ -0,0 +1,39 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pyvdyr3pes5o"
valid=false
[deps]
source_file="res://Games/SpaceResources/Planing/Movement 2D.svg"
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
@@ -0,0 +1,52 @@
extends Camera2D
class_name RecurionCamera
@export var movement_speed: float = 1
var mouse_pos_a: Vector2 = Vector2.ZERO
var mouse_pos_b: Vector2 = Vector2.ZERO
func _process(delta: float) -> void:
process_keyboard_input(delta)
process_mouse_input()
func process_keyboard_input(delta: float):
var direction: Vector2 = Vector2.ZERO
if (Input.is_action_pressed("w")):
direction += Vector2.UP
if (Input.is_action_pressed("s")):
direction += Vector2.DOWN
if (Input.is_action_pressed("a")):
direction += Vector2.LEFT
if (Input.is_action_pressed("d")):
direction += Vector2.RIGHT
direction = direction.normalized() * movement_speed
position += direction * delta * 100
func process_mouse_input():
if (Input.is_action_just_pressed("mouse_down")):
mouse_pos_a = get_global_mouse_position()
mouse_pos_b = mouse_pos_a
elif (Input.is_action_pressed("mouse_down")):
mouse_pos_b = get_global_mouse_position()
position = mouse_pos_a - mouse_pos_b + position
elif (Input.is_action_just_released("mouse_down")):
mouse_pos_a = Vector2.ZERO
mouse_pos_b = Vector2.ZERO
mouse_pos_b = mouse_pos_a
func _input(event: InputEvent) -> void:
if (event is InputEventMouseButton):
var zoom_value = Input.get_axis("scroll_down", "scroll_up")
if (zoom.y + zoom_value > 0.0):
zoom += Vector2.ONE * zoom_value
+8 -2
View File
@@ -1,10 +1,16 @@
[gd_scene format=3 uid="uid://cycayd4l7k7s4"] [gd_scene format=3 uid="uid://cycayd4l7k7s4"]
[ext_resource type="Script" uid="uid://bqslv86lm78ci" path="res://Games/SpaceResources/Assets/RecurionCamera.gd" id="1_002bs"] [ext_resource type="Script" uid="uid://bqslv86lm78ci" path="res://Games/SpaceResources/Scripts/RecurionCamera.gd" id="1_002bs"]
[ext_resource type="Texture2D" uid="uid://dng410xo7qqfv" path="res://Assets/PixelPlanets/a-moon.png" id="2_qgdyp"]
[node name="Recuration" type="Node2D" unique_id=1741828961] [node name="Recuration" type="Node2D" unique_id=1741828961]
[node name="RecurionCamera" type="Camera2D" parent="." unique_id=997983592] [node name="RecurionCamera" type="Camera2D" parent="." unique_id=997983592]
position_smoothing_enabled = true
script = ExtResource("1_002bs") script = ExtResource("1_002bs")
movement_speed = 10.0
metadata/_custom_type_script = "uid://bqslv86lm78ci" metadata/_custom_type_script = "uid://bqslv86lm78ci"
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=45756830]
texture_filter = 1
texture_repeat = 1
texture = ExtResource("2_qgdyp")
+4
View File
@@ -85,3 +85,7 @@ mouse_down={
3d/default_angular_damp=0.0 3d/default_angular_damp=0.0
3d/sleep_threshold_linear=0.01 3d/sleep_threshold_linear=0.01
3d/sleep_threshold_angular=0.00872665 3d/sleep_threshold_angular=0.00872665
[rendering]
environment/defaults/default_clear_color=Color(0, 0, 0, 1)