commit b4e374608dc4aaeb649550221ec484e421293d5c Author: bionickatana Date: Sun Jun 21 21:45:24 2026 -0600 Setup background and scrolling stuff diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f28239b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +charset = utf-8 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0af181c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Godot 4+ specific ignores +.godot/ +/android/ diff --git a/.main_game_camera.gd.kate-swp b/.main_game_camera.gd.kate-swp new file mode 100644 index 0000000..00a92ee Binary files /dev/null and b/.main_game_camera.gd.kate-swp differ diff --git a/assets/images/adder.png b/assets/images/adder.png new file mode 100644 index 0000000..2bbf7fb Binary files /dev/null and b/assets/images/adder.png differ diff --git a/assets/images/adder.png.import b/assets/images/adder.png.import new file mode 100644 index 0000000..41c353a --- /dev/null +++ b/assets/images/adder.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://j8q05ybgrs5q" +path="res://.godot/imported/adder.png-c6817b6cb0ecceb4f58621e8d6b9cd73.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/adder.png" +dest_files=["res://.godot/imported/adder.png-c6817b6cb0ecceb4f58621e8d6b9cd73.ctex"] + +[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 diff --git a/assets/images/adder.xcf b/assets/images/adder.xcf new file mode 100644 index 0000000..6f6bd10 Binary files /dev/null and b/assets/images/adder.xcf differ diff --git a/assets/images/background_square.png b/assets/images/background_square.png new file mode 100644 index 0000000..56623a0 Binary files /dev/null and b/assets/images/background_square.png differ diff --git a/assets/images/background_square.png.import b/assets/images/background_square.png.import new file mode 100644 index 0000000..86008af --- /dev/null +++ b/assets/images/background_square.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgkhi56a223m2" +path="res://.godot/imported/background_square.png-306eff29231e30e2ac7b1d91004537d6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/background_square.png" +dest_files=["res://.godot/imported/background_square.png-306eff29231e30e2ac7b1d91004537d6.ctex"] + +[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 diff --git a/assets/images/background_square.xcf b/assets/images/background_square.xcf new file mode 100644 index 0000000..4302437 Binary files /dev/null and b/assets/images/background_square.xcf differ diff --git a/assets/images/belt.png b/assets/images/belt.png new file mode 100644 index 0000000..1edd967 Binary files /dev/null and b/assets/images/belt.png differ diff --git a/assets/images/belt.png.import b/assets/images/belt.png.import new file mode 100644 index 0000000..d0ee440 --- /dev/null +++ b/assets/images/belt.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://m2en3pg3og4u" +path="res://.godot/imported/belt.png-8861f7fad4159b650cda9b982d2aece4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/belt.png" +dest_files=["res://.godot/imported/belt.png-8861f7fad4159b650cda9b982d2aece4.ctex"] + +[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 diff --git a/assets/images/belt.xcf b/assets/images/belt.xcf new file mode 100644 index 0000000..320a918 Binary files /dev/null and b/assets/images/belt.xcf differ diff --git a/assets/images/cursor.png b/assets/images/cursor.png new file mode 100644 index 0000000..c5dbb41 Binary files /dev/null and b/assets/images/cursor.png differ diff --git a/assets/images/cursor.png.import b/assets/images/cursor.png.import new file mode 100644 index 0000000..c7de85b --- /dev/null +++ b/assets/images/cursor.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bbfcwhptgy5b4" +path="res://.godot/imported/cursor.png-4d4d2873251adf804542218d6a948c51.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/cursor.png" +dest_files=["res://.godot/imported/cursor.png-4d4d2873251adf804542218d6a948c51.ctex"] + +[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 diff --git a/assets/images/cursor.xcf b/assets/images/cursor.xcf new file mode 100644 index 0000000..d210f87 Binary files /dev/null and b/assets/images/cursor.xcf differ diff --git a/assets/images/delete.png b/assets/images/delete.png new file mode 100644 index 0000000..35ad042 Binary files /dev/null and b/assets/images/delete.png differ diff --git a/assets/images/delete.png.import b/assets/images/delete.png.import new file mode 100644 index 0000000..f6fc1cd --- /dev/null +++ b/assets/images/delete.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvss8ahosx14f" +path="res://.godot/imported/delete.png-361a3d8bd528480177d17c7ccba5320e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/delete.png" +dest_files=["res://.godot/imported/delete.png-361a3d8bd528480177d17c7ccba5320e.ctex"] + +[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 diff --git a/assets/images/delete.xcf b/assets/images/delete.xcf new file mode 100644 index 0000000..394260f Binary files /dev/null and b/assets/images/delete.xcf differ diff --git a/assets/images/extractor.png b/assets/images/extractor.png new file mode 100644 index 0000000..30d4f7a Binary files /dev/null and b/assets/images/extractor.png differ diff --git a/assets/images/extractor.png.import b/assets/images/extractor.png.import new file mode 100644 index 0000000..bbc30a6 --- /dev/null +++ b/assets/images/extractor.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://lq8htcre3uve" +path="res://.godot/imported/extractor.png-57c73c715eda94d889b9ddaf12cbf193.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/extractor.png" +dest_files=["res://.godot/imported/extractor.png-57c73c715eda94d889b9ddaf12cbf193.ctex"] + +[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 diff --git a/assets/images/extractor.xcf b/assets/images/extractor.xcf new file mode 100644 index 0000000..415930f Binary files /dev/null and b/assets/images/extractor.xcf differ diff --git a/assets/images/producer.png b/assets/images/producer.png new file mode 100644 index 0000000..690638b Binary files /dev/null and b/assets/images/producer.png differ diff --git a/assets/images/producer.png.import b/assets/images/producer.png.import new file mode 100644 index 0000000..408d9b0 --- /dev/null +++ b/assets/images/producer.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b42vpifsywiux" +path="res://.godot/imported/producer.png-e26feb6b05cf077ab10f2111035e19bb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/images/producer.png" +dest_files=["res://.godot/imported/producer.png-e26feb6b05cf077ab10f2111035e19bb.ctex"] + +[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 diff --git a/assets/images/producer.xcf b/assets/images/producer.xcf new file mode 100644 index 0000000..13a44f0 Binary files /dev/null and b/assets/images/producer.xcf differ diff --git a/game_scene.tscn b/game_scene.tscn new file mode 100644 index 0000000..61c265d --- /dev/null +++ b/game_scene.tscn @@ -0,0 +1,23 @@ +[gd_scene format=3 uid="uid://613m8wworduk"] + +[ext_resource type="Texture2D" uid="uid://bgkhi56a223m2" path="res://assets/images/background_square.png" id="1_mlf6e"] +[ext_resource type="Script" uid="uid://clf21ltbqb0vq" path="res://main_game_background_tiles.gd" id="2_po0ka"] +[ext_resource type="Script" uid="uid://iy6u4txips6p" path="res://main_game_camera.gd" id="3_v1wow"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v1wow"] +texture = ExtResource("1_mlf6e") +texture_region_size = Vector2i(32, 32) +0:0/0 = 0 + +[sub_resource type="TileSet" id="TileSet_ylkns"] +tile_size = Vector2i(32, 32) +sources/0 = SubResource("TileSetAtlasSource_v1wow") + +[node name="main_game" type="Node2D" unique_id=380715108] + +[node name="main_game_background_tiles" type="TileMapLayer" parent="." unique_id=643550399] +tile_set = SubResource("TileSet_ylkns") +script = ExtResource("2_po0ka") + +[node name="main_game_camera" type="Camera2D" parent="." unique_id=1094262036] +script = ExtResource("3_v1wow") diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..c6bbb7d --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..dece5b2 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://sojq4mpjlqq7" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[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 diff --git a/main_game_background_tiles.gd b/main_game_background_tiles.gd new file mode 100644 index 0000000..db73adb --- /dev/null +++ b/main_game_background_tiles.gd @@ -0,0 +1,36 @@ +extends TileMapLayer + +@onready var camera: Camera2D = $"../main_game_camera" + +@export var render_radius: int = 20 # How many tiles out from the center to draw +var tile_size: Vector2i = Vector2i(32, 32) # Change this to your actual asset square size (e.g., 32x32, 64x64) + +# Keep track of which grid coordinates we've already loaded +var loaded_tiles: Dictionary = {} + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + if camera: + generate_tiles_around_camera() + +func generate_tiles_around_camera() -> void: + # 1. Convert the camera's pixel position into grid coordinates + var camera_grid_pos = self.local_to_map(camera.global_position) + + # 2. Loop through a square grid area around the camera + for x in range(camera_grid_pos.x - render_radius / camera.zoom[0], camera_grid_pos.x + render_radius / camera.zoom[0]): + for y in range(camera_grid_pos.y - render_radius / camera.zoom[1], camera_grid_pos.y + render_radius / camera.zoom[1]): + var tile_coords = Vector2i(x, y) + + # 3. Only place a tile if we haven't already placed one there + if not loaded_tiles.has(tile_coords): + # set_cell(coords, source_id, atlas_coords) + # Assumes your source_id is 0 and your square tile is at (0,0) in the atlas + self.set_cell(tile_coords, 0, Vector2i(0, 0)) + loaded_tiles[tile_coords] = true diff --git a/main_game_background_tiles.gd.uid b/main_game_background_tiles.gd.uid new file mode 100644 index 0000000..357cc04 --- /dev/null +++ b/main_game_background_tiles.gd.uid @@ -0,0 +1 @@ +uid://clf21ltbqb0vq diff --git a/main_game_camera.gd b/main_game_camera.gd new file mode 100644 index 0000000..e7b6fce --- /dev/null +++ b/main_game_camera.gd @@ -0,0 +1,72 @@ +extends Camera2D + +# --- Movement Settings --- +@export var KEYBOARD_SPEED: float = 500.0 # Pixels per second using keys +@export var EDGE_SPEED: float = 600.0 # Pixels per second using mouse edge +@export var EDGE_MARGIN: float = 20.0 # How close to the screen edge (in pixels) to trigger scroll + +# --- Zoom Settings --- +@export var MIN_ZOOM: float = 0.5 # Furthest zoomed out +@export var MAX_ZOOM: float = 3.0 # Closest zoomed in +@export var ZOOM_SPEED: float = 0.1 # How fast it zooms per scroll tick +var target_zoom: float = 1.0 # Smoothly interpolate to this value + +func _ready() -> void: + # Ensures the camera uses its actual starting zoom + target_zoom = zoom.x + +func _process(delta: float) -> void: + handle_keyboard_movement(delta) + handle_edge_scrolling(delta) + handle_smooth_zoom(delta) + +# 1. ARROW KEYS / WASD MOVEMENT +func handle_keyboard_movement(delta: float) -> void: + var velocity = Vector2.ZERO + + if Input.is_key_pressed(KEY_LEFT) or Input.is_key_pressed(KEY_A): + velocity.x -= 1 + if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D): + velocity.x += 1 + if Input.is_key_pressed(KEY_UP) or Input.is_key_pressed(KEY_W): + velocity.y -= 1 + if Input.is_key_pressed(KEY_DOWN) or Input.is_key_pressed(KEY_S): + velocity.y += 1 + + # Move the camera based on direction, speed, and time passed + global_position += velocity.normalized() * KEYBOARD_SPEED * delta + +# 2. MOUSE EDGE SCROLLING +func handle_edge_scrolling(delta: float) -> void: + var mouse_pos = get_viewport().get_mouse_position() + var window_size = get_viewport().get_visible_rect().size + var velocity = Vector2.ZERO + + # Check Left/Right edges + if mouse_pos.x < EDGE_MARGIN: + velocity.x -= 1 + elif mouse_pos.x > window_size.x - EDGE_MARGIN: + velocity.x += 1 + + # Check Top/Bottom edges + if mouse_pos.y < EDGE_MARGIN: + velocity.y -= 1 + elif mouse_pos.y > window_size.y - EDGE_MARGIN: + velocity.y += 1 + + global_position += velocity.normalized() * EDGE_SPEED * delta + +# 3. MOUSE WHEEL ZOOM (Detecting the inputs) +func _unhandled_input(event: InputEvent) -> void: + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed: + target_zoom = clamp(target_zoom + ZOOM_SPEED, MIN_ZOOM, MAX_ZOOM) + elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed: + target_zoom = clamp(target_zoom - ZOOM_SPEED, MIN_ZOOM, MAX_ZOOM) + +# 4. SMOOTH ZOOMING ANIMATION +func handle_smooth_zoom(delta: float) -> void: + # Lerp smoothly transitions the current zoom to our target_zoom over time + var current_zoom = zoom.x + var new_zoom = lerp(current_zoom, target_zoom, 10.0 * delta) + zoom = Vector2(new_zoom, new_zoom) diff --git a/main_game_camera.gd.uid b/main_game_camera.gd.uid new file mode 100644 index 0000000..ba90be4 --- /dev/null +++ b/main_game_camera.gd.uid @@ -0,0 +1 @@ +uid://iy6u4txips6p diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..771deef --- /dev/null +++ b/project.godot @@ -0,0 +1,31 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="numberFactory" +run/main_scene="res://game_scene.tscn" +config/features=PackedStringArray("4.7", "GL Compatibility") +config/icon="res://icon.svg" + +[display] + +window/stretch/mode="canvas_items" +window/stretch/aspect="expand" + +[physics] + +3d/physics_engine="Jolt Physics" + +[rendering] + +rendering_device/driver.windows="d3d12" +renderer/rendering_method="gl_compatibility" +renderer/rendering_method.mobile="gl_compatibility"