Setup background and scrolling stuff

This commit is contained in:
2026-06-21 21:45:24 -06:00
commit b4e374608d
33 changed files with 497 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8
+2
View File
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
+3
View File
@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

+40
View File
@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

+40
View File
@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

+40
View File
@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

+40
View File
@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

+40
View File
@@ -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
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

+40
View File
@@ -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
Binary file not shown.
+23
View File
@@ -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")
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 995 B

+43
View File
@@ -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
+36
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
uid://clf21ltbqb0vq
+72
View File
@@ -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)
+1
View File
@@ -0,0 +1 @@
uid://iy6u4txips6p
+31
View File
@@ -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"