mend
testing actions Godot auto build Godot auto build Godot auto build Godot auto build Godot auto build Finished adding items into the game along with auto build for linux.
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
name: Build Godot Project (Linux)
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Step 1: Read project.godot ahead of time to get the version for our cache key
|
||||||
|
- name: Detect Godot Version
|
||||||
|
id: detect-version
|
||||||
|
run: |
|
||||||
|
echo "🔍 Parsing project.godot to identify the target engine version..."
|
||||||
|
VERSION_SHORT=$(grep "config/features" project.godot | sed -E 's/^[^\"]*\"([^\"]+)\".*/\1/' | xargs)
|
||||||
|
|
||||||
|
if [ -z "$VERSION_SHORT" ]; then
|
||||||
|
VERSION_SHORT="4.7"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VERSION_SHORT=${VERSION_SHORT}" >> $GITHUB_OUTPUT
|
||||||
|
echo "VERSION_URL=${VERSION_SHORT}-stable" >> $GITHUB_OUTPUT
|
||||||
|
echo "VERSION_FILE=${VERSION_SHORT}.stable" >> $GITHUB_OUTPUT
|
||||||
|
echo "🎯 Detected Target Version: $VERSION_SHORT"
|
||||||
|
|
||||||
|
# Step 2: Look for the cached Godot folder inside the Gitea Actions cache
|
||||||
|
- name: Cache Godot Engine and Templates
|
||||||
|
id: godot-cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .godot-cache-storage
|
||||||
|
key: godot-${{ steps.detect-version.outputs.VERSION_FILE }}-linux-v1
|
||||||
|
|
||||||
|
# Step 3: Run only on a Cache Miss to download the engine files
|
||||||
|
- name: Download Godot Engine and Templates (On Cache Miss)
|
||||||
|
if: steps.godot-cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
VERSION_URL="${{ steps.detect-version.outputs.VERSION_URL }}"
|
||||||
|
mkdir -p .godot-cache-storage
|
||||||
|
|
||||||
|
echo "📥 Cache Miss. Downloading Godot Engine ($VERSION_URL)..."
|
||||||
|
curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_linux.x86_64.zip" -o godot.zip
|
||||||
|
unzip godot.zip
|
||||||
|
move "Godot_v${VERSION_URL}_linux.x86_64" .godot-cache-storage/godot || mv "Godot_v${VERSION_URL}_linux.x86_64" .godot-cache-storage/godot
|
||||||
|
chmod +x .godot-cache-storage/godot
|
||||||
|
|
||||||
|
echo "📥 Downloading Export Templates ($VERSION_URL)..."
|
||||||
|
curl -L "https://github.com/godotengine/godot/releases/download/${VERSION_URL}/Godot_v${VERSION_URL}_export_templates.tpz" -o templates.zip
|
||||||
|
unzip templates.zip
|
||||||
|
mv templates/linux_release.x86_64 .godot-cache-storage/linux_release.x86_64
|
||||||
|
|
||||||
|
# Clean up download archives
|
||||||
|
rm godot.zip templates.zip
|
||||||
|
rm -rf templates/
|
||||||
|
|
||||||
|
# Step 4: Always map the binaries from our local workspace folder into their final execution paths
|
||||||
|
- name: Map Engine and Templates
|
||||||
|
run: |
|
||||||
|
VERSION_FILE="${{ steps.detect-version.outputs.VERSION_FILE }}"
|
||||||
|
|
||||||
|
# Copy engine executable out to project root
|
||||||
|
cp .godot-cache-storage/godot ./godot
|
||||||
|
|
||||||
|
# Inject template into user profile folder where Godot looks for them during exports
|
||||||
|
mkdir -p ~/.local/share/godot/export_templates/${VERSION_FILE}
|
||||||
|
cp .godot-cache-storage/linux_release.x86_64 ~/.local/share/godot/export_templates/${VERSION_FILE}/linux_release.x86_64
|
||||||
|
echo "🚀 Environment ready for export!"
|
||||||
|
|
||||||
|
# Step 5: Export the binary
|
||||||
|
- name: Export Linux Binary
|
||||||
|
run: |
|
||||||
|
mkdir -p build/linux
|
||||||
|
./godot --headless --export-release "Linux" build/linux/godot_number_factory.x86_64
|
||||||
|
|
||||||
|
# Step 6: Upload artifacts using Gitea-compatible v3 action
|
||||||
|
- name: Upload Linux Build Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: linux-build
|
||||||
|
path: build/linux/
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# Godot 4+ specific ignores
|
# Godot 4+ specific ignores
|
||||||
.godot/
|
.godot/
|
||||||
/android/
|
/android/
|
||||||
|
/build/
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 211 B |
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bg4slrhc7w7yd"
|
||||||
|
path="res://.godot/imported/Consumer.png-c4e405c4380f862f992c983e68e34a86.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/images/Consumer.png"
|
||||||
|
dest_files=["res://.godot/imported/Consumer.png-c4e405c4380f862f992c983e68e34a86.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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene format=3 uid="uid://kw8ughroalov"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://m2en3pg3og4u" path="res://assets/images/belt.png" id="1_susb0"]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" unique_id=1338317761]
|
||||||
|
texture = ExtResource("1_susb0")
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bvytqfap2t478"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bg4slrhc7w7yd" path="res://assets/images/Consumer.png" id="1_xlv53"]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" unique_id=59839044]
|
||||||
|
scale = Vector2(3, 3)
|
||||||
|
texture = ExtResource("1_xlv53")
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
[runnable_presets]
|
||||||
|
|
||||||
|
Android="Android"
|
||||||
|
Linux="Linux"
|
||||||
|
"Windows Desktop"="Windows"
|
||||||
|
|
||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="Linux"
|
||||||
|
platform="Linux"
|
||||||
|
dedicated_server=false
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="build/linux/numberFactory.x86_64"
|
||||||
|
patches=PackedStringArray()
|
||||||
|
patch_delta_encoding=false
|
||||||
|
patch_delta_compression_level_zstd=19
|
||||||
|
patch_delta_min_reduction=0.1
|
||||||
|
patch_delta_include_filters="*"
|
||||||
|
patch_delta_exclude_filters=""
|
||||||
|
encryption_include_filters=""
|
||||||
|
encryption_exclude_filters=""
|
||||||
|
seed=0
|
||||||
|
encrypt_pck=false
|
||||||
|
encrypt_directory=false
|
||||||
|
script_export_mode=2
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
debug/export_console_wrapper=1
|
||||||
|
binary_format/embed_pck=true
|
||||||
|
texture_format/s3tc_bptc=true
|
||||||
|
texture_format/etc2_astc=false
|
||||||
|
shader_baker/enabled=false
|
||||||
|
binary_format/architecture="x86_64"
|
||||||
|
ssh_remote_deploy/enabled=false
|
||||||
|
ssh_remote_deploy/host="user@host_ip"
|
||||||
|
ssh_remote_deploy/port="22"
|
||||||
|
ssh_remote_deploy/extra_args_ssh=""
|
||||||
|
ssh_remote_deploy/extra_args_scp=""
|
||||||
|
ssh_remote_deploy/run_script="#!/usr/bin/env bash
|
||||||
|
export DISPLAY=:0
|
||||||
|
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
|
||||||
|
\"{temp_dir}/{exe_name}\" {cmd_args}"
|
||||||
|
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
|
||||||
|
pkill -x -f \"{temp_dir}/{exe_name} {cmd_args}\"
|
||||||
|
rm -rf \"{temp_dir}\""
|
||||||
|
|
||||||
|
[preset.1]
|
||||||
|
|
||||||
|
name="Windows"
|
||||||
|
platform="Windows Desktop"
|
||||||
|
dedicated_server=false
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="build/windows/numberFactory.exe"
|
||||||
|
patches=PackedStringArray()
|
||||||
|
patch_delta_encoding=false
|
||||||
|
patch_delta_compression_level_zstd=19
|
||||||
|
patch_delta_min_reduction=0.1
|
||||||
|
patch_delta_include_filters="*"
|
||||||
|
patch_delta_exclude_filters=""
|
||||||
|
encryption_include_filters=""
|
||||||
|
encryption_exclude_filters=""
|
||||||
|
seed=0
|
||||||
|
encrypt_pck=false
|
||||||
|
encrypt_directory=false
|
||||||
|
script_export_mode=2
|
||||||
|
|
||||||
|
[preset.1.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
debug/export_console_wrapper=1
|
||||||
|
binary_format/embed_pck=true
|
||||||
|
texture_format/s3tc_bptc=true
|
||||||
|
texture_format/etc2_astc=false
|
||||||
|
shader_baker/enabled=false
|
||||||
|
binary_format/architecture="x86_64"
|
||||||
|
codesign/enable=false
|
||||||
|
codesign/timestamp=true
|
||||||
|
codesign/timestamp_server_url=""
|
||||||
|
codesign/digest_algorithm=1
|
||||||
|
codesign/description=""
|
||||||
|
codesign/custom_options=PackedStringArray()
|
||||||
|
application/modify_resources=true
|
||||||
|
application/icon=""
|
||||||
|
application/console_wrapper_icon=""
|
||||||
|
application/icon_interpolation=4
|
||||||
|
application/file_version=""
|
||||||
|
application/product_version=""
|
||||||
|
application/company_name=""
|
||||||
|
application/product_name=""
|
||||||
|
application/file_description=""
|
||||||
|
application/copyright=""
|
||||||
|
application/trademarks=""
|
||||||
|
application/export_angle=0
|
||||||
|
application/export_d3d12=0
|
||||||
|
application/d3d12_agility_sdk_multiarch=true
|
||||||
|
ssh_remote_deploy/enabled=false
|
||||||
|
ssh_remote_deploy/host="user@host_ip"
|
||||||
|
ssh_remote_deploy/port="22"
|
||||||
|
ssh_remote_deploy/extra_args_ssh=""
|
||||||
|
ssh_remote_deploy/extra_args_scp=""
|
||||||
|
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||||
|
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||||
|
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||||
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
|
||||||
|
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||||
|
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||||
|
Start-ScheduledTask -TaskName godot_remote_debug
|
||||||
|
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||||
|
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||||
|
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||||
|
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||||
|
Remove-Item -Recurse -Force '{temp_dir}'"
|
||||||
+6
-2
@@ -1,7 +1,9 @@
|
|||||||
[gd_scene format=3 uid="uid://613m8wworduk"]
|
[gd_scene format=3 uid="uid://613m8wworduk"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://sb24viemx1mp" path="res://main_game.gd" id="1_mixcd"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bgkhi56a223m2" path="res://assets/images/background_square.png" id="1_mlf6e"]
|
[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="PackedScene" uid="uid://djs8jhub580bq" path="res://producer.tscn" id="2_mixcd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bvytqfap2t478" path="res://consumer.tscn" id="3_mj2jn"]
|
||||||
[ext_resource type="Script" uid="uid://iy6u4txips6p" path="res://main_game_camera.gd" id="3_v1wow"]
|
[ext_resource type="Script" uid="uid://iy6u4txips6p" path="res://main_game_camera.gd" id="3_v1wow"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v1wow"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_v1wow"]
|
||||||
@@ -14,10 +16,12 @@ tile_size = Vector2i(32, 32)
|
|||||||
sources/0 = SubResource("TileSetAtlasSource_v1wow")
|
sources/0 = SubResource("TileSetAtlasSource_v1wow")
|
||||||
|
|
||||||
[node name="main_game" type="Node2D" unique_id=380715108]
|
[node name="main_game" type="Node2D" unique_id=380715108]
|
||||||
|
script = ExtResource("1_mixcd")
|
||||||
|
producer_scene = ExtResource("2_mixcd")
|
||||||
|
consumer_scene = ExtResource("3_mj2jn")
|
||||||
|
|
||||||
[node name="main_game_background_tiles" type="TileMapLayer" parent="." unique_id=643550399]
|
[node name="main_game_background_tiles" type="TileMapLayer" parent="." unique_id=643550399]
|
||||||
tile_set = SubResource("TileSet_ylkns")
|
tile_set = SubResource("TileSet_ylkns")
|
||||||
script = ExtResource("2_po0ka")
|
|
||||||
|
|
||||||
[node name="main_game_camera" type="Camera2D" parent="." unique_id=1094262036]
|
[node name="main_game_camera" type="Camera2D" parent="." unique_id=1094262036]
|
||||||
script = ExtResource("3_v1wow")
|
script = ExtResource("3_v1wow")
|
||||||
|
|||||||
+129
@@ -0,0 +1,129 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@onready var tile_layer: TileMapLayer = $main_game_background_tiles
|
||||||
|
@onready var camera: Camera2D = $main_game_camera
|
||||||
|
|
||||||
|
@export var RENDER_RADIUS: int = 20
|
||||||
|
@export_range(0.0, 1.0) var producer_spawn_chance: float = 0.015 # 1.5% chance per tile
|
||||||
|
|
||||||
|
@export var producer_scene: PackedScene
|
||||||
|
@export var consumer_scene: PackedScene
|
||||||
|
|
||||||
|
var render_radius_x = RENDER_RADIUS
|
||||||
|
var render_radius_y = RENDER_RADIUS
|
||||||
|
|
||||||
|
# --- PHASE 1 DATA STRUCTURES ---
|
||||||
|
# This dictionary tracks what physical entity occupies a grid coordinate.
|
||||||
|
# Format: Vector2i(x, y) : { "type": "consumer" } or { "type": "producer", "value": 10 }
|
||||||
|
var grid_data: Dictionary = {}
|
||||||
|
|
||||||
|
# This dictionary keeps track of where the floor tiles have already been visually placed
|
||||||
|
var rendered_tiles: Dictionary = {}
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
# Explicitly pre-seed the center of the world data structure
|
||||||
|
initialize_world_center()
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if camera:
|
||||||
|
render_radius_x = RENDER_RADIUS / camera.zoom[0]
|
||||||
|
render_radius_y = RENDER_RADIUS / camera.zoom[1]
|
||||||
|
generate_and_render_around_camera()
|
||||||
|
|
||||||
|
|
||||||
|
# Define the absolute center data rule
|
||||||
|
func initialize_world_center() -> void:
|
||||||
|
# Loop from -1 to 1 on both X and Y to cover a 3x3 area
|
||||||
|
for x in range(-1, 2):
|
||||||
|
for y in range(-1, 2):
|
||||||
|
var current_coord = Vector2i(x, y)
|
||||||
|
|
||||||
|
grid_data[current_coord] = {
|
||||||
|
"type": "consumer",
|
||||||
|
"is_center": (x == 0 and y == 0) # Only (0,0) is marked as the visual center
|
||||||
|
}
|
||||||
|
print("World Core Initialized: 3x3 Consumer registered from (-1,-1) to (1,1)")
|
||||||
|
if producer_scene:
|
||||||
|
print("Placing consumer at (0, 0)")
|
||||||
|
# 1. Create a live instance of the saved scene file
|
||||||
|
var consumer = consumer_scene.instantiate()
|
||||||
|
# 2. Add it as a child of the world so it exists in the active game tree
|
||||||
|
add_child(consumer)
|
||||||
|
|
||||||
|
# 3. Convert grid coordinates back to exact engine pixel coordinates
|
||||||
|
# map_to_local gives us the exact center point of that grid tile
|
||||||
|
var pixel_position = tile_layer.map_to_local(Vector2i(0, 0))
|
||||||
|
consumer.global_position = pixel_position
|
||||||
|
|
||||||
|
# Combined loop to manage both world data rules and visual rendering
|
||||||
|
func generate_and_render_around_camera() -> void:
|
||||||
|
var camera_grid_pos = tile_layer.local_to_map(camera.global_position)
|
||||||
|
|
||||||
|
for x in range(camera_grid_pos.x - render_radius_x, camera_grid_pos.x + render_radius_x):
|
||||||
|
for y in range(camera_grid_pos.y - render_radius_y, camera_grid_pos.y + render_radius_y):
|
||||||
|
var tile_coords = Vector2i(x, y)
|
||||||
|
|
||||||
|
# 1. VISUAL RENDERING (Always draw the background floor)
|
||||||
|
if not rendered_tiles.has(tile_coords):
|
||||||
|
# Draw your background tile asset (Source ID: 0, Atlas Coords: 0,0)
|
||||||
|
tile_layer.set_cell(tile_coords, 0, Vector2i(0, 0))
|
||||||
|
rendered_tiles[tile_coords] = true
|
||||||
|
|
||||||
|
# 2. DATA PROCESSING PLACEHOLDER
|
||||||
|
# This is where Phase 2 will plug in to evaluate if a producer should spawn
|
||||||
|
process_grid_data_at(tile_coords)
|
||||||
|
|
||||||
|
# PHASE 2: Distance Math & Random Generation
|
||||||
|
func process_grid_data_at(coords: Vector2i) -> void:
|
||||||
|
# If this coordinate is already occupied (like by our 3x3 Consumer), skip it!
|
||||||
|
if grid_data.has(coords):
|
||||||
|
return
|
||||||
|
|
||||||
|
# Roll the dice to see if a Producer should spawn here
|
||||||
|
if randf() < producer_spawn_chance:
|
||||||
|
|
||||||
|
# Calculate Manhattan Distance from the absolute center (0,0)
|
||||||
|
var distance = abs(coords.x) + abs(coords.y)
|
||||||
|
|
||||||
|
|
||||||
|
# Formula: Start at 1, add 1 extra value for every 10 tiles away
|
||||||
|
var producer_value = 1 + floor(distance / 10.0)
|
||||||
|
|
||||||
|
# Register the producer in our global data registry
|
||||||
|
grid_data[coords] = {
|
||||||
|
"type": "producer",
|
||||||
|
"value": producer_value
|
||||||
|
}
|
||||||
|
|
||||||
|
if producer_scene:
|
||||||
|
print("Placing producer at " + str(coords.x) + ", " + str(coords.y))
|
||||||
|
# 1. Create a live instance of the saved scene file
|
||||||
|
var new_producer = producer_scene.instantiate()
|
||||||
|
new_producer.setup(int(producer_value))
|
||||||
|
|
||||||
|
# 2. Add it as a child of the world so it exists in the active game tree
|
||||||
|
add_child(new_producer)
|
||||||
|
|
||||||
|
# 3. Convert grid coordinates back to exact engine pixel coordinates
|
||||||
|
# map_to_local gives us the exact center point of that grid tile
|
||||||
|
var pixel_position = tile_layer.map_to_local(coords)
|
||||||
|
new_producer.global_position = pixel_position
|
||||||
|
|
||||||
|
# 4. Optional: If your Producer scene has a script on it,
|
||||||
|
# you can pass its distance value directly to it right here!
|
||||||
|
# new_producer.output_value = producer_value
|
||||||
|
## --- VISUAL PLACEMENT ---
|
||||||
|
## Tell your TileMapLayer to draw the Producer asset on top of the floor.
|
||||||
|
## Replace Vector2i(1, 0) with the actual atlas coordinates of your Producer image in your TileSet!
|
||||||
|
#tile_layer.set_cell(coords, 0, Vector2i(1, 0))
|
||||||
|
|
||||||
|
|
||||||
|
# Helper function: Check if a coordinate is occupied by a building
|
||||||
|
func get_object_at_coordinate(coords: Vector2i):
|
||||||
|
if grid_data.has(coords):
|
||||||
|
return grid_data[coords]
|
||||||
|
return null # Returns null if it's just an empty background tile
|
||||||
|
|
||||||
|
# Helper function: Force place an object into the grid data registry
|
||||||
|
func register_object_at_coordinate(coords: Vector2i, object_data: Dictionary) -> void:
|
||||||
|
grid_data[coords] = object_data
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://sb24viemx1mp
|
||||||
+4
-4
@@ -24,13 +24,13 @@ func _process(delta: float) -> void:
|
|||||||
func handle_keyboard_movement(delta: float) -> void:
|
func handle_keyboard_movement(delta: float) -> void:
|
||||||
var velocity = Vector2.ZERO
|
var velocity = Vector2.ZERO
|
||||||
|
|
||||||
if Input.is_key_pressed(KEY_LEFT) or Input.is_key_pressed(KEY_A):
|
if Input.is_key_pressed(KEY_LEFT):
|
||||||
velocity.x -= 1
|
velocity.x -= 1
|
||||||
if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D):
|
if Input.is_key_pressed(KEY_RIGHT):
|
||||||
velocity.x += 1
|
velocity.x += 1
|
||||||
if Input.is_key_pressed(KEY_UP) or Input.is_key_pressed(KEY_W):
|
if Input.is_key_pressed(KEY_UP):
|
||||||
velocity.y -= 1
|
velocity.y -= 1
|
||||||
if Input.is_key_pressed(KEY_DOWN) or Input.is_key_pressed(KEY_S):
|
if Input.is_key_pressed(KEY_DOWN):
|
||||||
velocity.y += 1
|
velocity.y += 1
|
||||||
|
|
||||||
# Move the camera based on direction, speed, and time passed
|
# Move the camera based on direction, speed, and time passed
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
var output_value: int
|
||||||
|
|
||||||
|
func setup(output_value):
|
||||||
|
print("Producer spawned physically with a value of: ", output_value)
|
||||||
|
$text_value.text = str(output_value)
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://ijy7vx56hsil
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene format=3 uid="uid://djs8jhub580bq"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b42vpifsywiux" path="res://assets/images/producer.png" id="1_px2oa"]
|
||||||
|
[ext_resource type="Script" uid="uid://ijy7vx56hsil" path="res://producer.gd" id="2_7keub"]
|
||||||
|
|
||||||
|
[node name="Producer" type="Sprite2D" unique_id=1400462977]
|
||||||
|
texture = ExtResource("1_px2oa")
|
||||||
|
script = ExtResource("2_7keub")
|
||||||
|
|
||||||
|
[node name="text_value" type="RichTextLabel" parent="." unique_id=2082396076]
|
||||||
|
offset_left = -16.0
|
||||||
|
offset_top = -16.0
|
||||||
|
offset_right = 16.0
|
||||||
|
offset_bottom = 16.0
|
||||||
|
theme_override_colors/default_color = Color(0.2343004, 3.2536387e-05, 0.88633025, 1)
|
||||||
|
text = "-99"
|
||||||
|
autowrap_mode = 0
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
+1
-1
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="numberFactory"
|
config/name="numberFactory"
|
||||||
run/main_scene="res://game_scene.tscn"
|
run/main_scene="uid://613m8wworduk"
|
||||||
config/features=PackedStringArray("4.7", "GL Compatibility")
|
config/features=PackedStringArray("4.7", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user