From 8a6004af24941c07d95c723f78cfd87995af69a1 Mon Sep 17 00:00:00 2001 From: rogo Date: Mon, 16 Oct 2023 13:46:42 +0200 Subject: [PATCH] init --- .gitattributes | 2 + .gitignore | 356 ++++++++++++++++++++++++++++++++++++ FOU.csproj | 6 + FOU.sln | 19 ++ Scenes/main.tscn | 16 ++ Scripts/Elements/Dirt.cs | 9 + Scripts/Elements/Element.cs | 7 + Scripts/Elements/Solid.cs | 5 + Scripts/Level.cs | 44 +++++ Scripts/Main.cs | 26 +++ icon.svg | 1 + icon.svg.import | 37 ++++ project.godot | 24 +++ 13 files changed, 552 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 FOU.csproj create mode 100644 FOU.sln create mode 100644 Scenes/main.tscn create mode 100644 Scripts/Elements/Dirt.cs create mode 100644 Scripts/Elements/Element.cs create mode 100644 Scripts/Elements/Solid.cs create mode 100644 Scripts/Level.cs create mode 100644 Scripts/Main.cs create mode 100644 icon.svg create mode 100644 icon.svg.import create mode 100644 project.godot 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..cb598ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,356 @@ +# Rider +.idea/ + +# Visual Studio Code +.vscode/ + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/# Godot 4+ specific ignores +.godot/ diff --git a/FOU.csproj b/FOU.csproj new file mode 100644 index 0000000..347d21f --- /dev/null +++ b/FOU.csproj @@ -0,0 +1,6 @@ + + + net6.0 + true + + \ No newline at end of file diff --git a/FOU.sln b/FOU.sln new file mode 100644 index 0000000..efafff9 --- /dev/null +++ b/FOU.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FOU", "FOU.csproj", "{5330B866-43AD-474E-B27D-B1BA6C473D5C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {5330B866-43AD-474E-B27D-B1BA6C473D5C}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/Scenes/main.tscn b/Scenes/main.tscn new file mode 100644 index 0000000..9ae3504 --- /dev/null +++ b/Scenes/main.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=2 format=3 uid="uid://cf34vk5r055dx"] + +[ext_resource type="Script" path="res://Scripts/Main.cs" id="1_k1i8e"] + +[node name="Node2D" type="Node2D"] +script = ExtResource("1_k1i8e") + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="LevelDrawer" type="TextureRect" parent="CanvasLayer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +expand_mode = 2 diff --git a/Scripts/Elements/Dirt.cs b/Scripts/Elements/Dirt.cs new file mode 100644 index 0000000..d061c8e --- /dev/null +++ b/Scripts/Elements/Dirt.cs @@ -0,0 +1,9 @@ +using Godot; + +namespace FOU.Scripts.Elements; + +public class Dirt : Solid { + public Dirt() { + Color = Colors.Brown; + } +} diff --git a/Scripts/Elements/Element.cs b/Scripts/Elements/Element.cs new file mode 100644 index 0000000..5df907f --- /dev/null +++ b/Scripts/Elements/Element.cs @@ -0,0 +1,7 @@ +using Godot; + +namespace FOU.Scripts.Elements; + +public abstract class Element { + public Color Color = Colors.Black; +} diff --git a/Scripts/Elements/Solid.cs b/Scripts/Elements/Solid.cs new file mode 100644 index 0000000..02ccf3f --- /dev/null +++ b/Scripts/Elements/Solid.cs @@ -0,0 +1,5 @@ +namespace FOU.Scripts.Elements; + +public abstract class Solid : Element { + +} diff --git a/Scripts/Level.cs b/Scripts/Level.cs new file mode 100644 index 0000000..a5d724f --- /dev/null +++ b/Scripts/Level.cs @@ -0,0 +1,44 @@ +using FOU.Scripts.Elements; +using Godot; + +namespace FOU.Scripts; + +public class Level { + private int mSizeX; + private int mSizeY; + private Image mImage; + + private Element[,] mPixels; + + public Level(int x, int y) { + GD.Print($"Generating level ({x}:{y})"); + + mSizeX = x; + mSizeY = y; + + mPixels = new Element[x, y]; + mImage = Image.Create(mSizeX, mSizeY, false, Image.Format.Rgb8); + mImage.Fill(Colors.Black); + } + + public void WritePixel(int x, int y, int size) { + for (int i = -size/2; i < size/2; i++) { + for (int j = -size/2; j < size/2; j++) { + int X = Mathf.Clamp(x + i, 0, mSizeX); + int Y = Mathf.Clamp(y + j, 0, mSizeY); + mPixels[X,Y] = new Dirt(); + } + } + } + + public Image DrawLevel() { + for (int x = 0; x < mSizeX; x++) { + for (int y = 0; y < mSizeY; y++) { + if (mPixels[x,y] == null) continue; + + mImage.SetPixel(x,y, mPixels[x,y].Color); + } + } + return mImage; + } +} diff --git a/Scripts/Main.cs b/Scripts/Main.cs new file mode 100644 index 0000000..3d17374 --- /dev/null +++ b/Scripts/Main.cs @@ -0,0 +1,26 @@ +using FOU.Scripts; +using Godot; + +public partial class Main : Node2D { + [Export] public int BrushSize = 10; + + private TextureRect mLevelDrawer; + private Level mLevel; + + public override void _Ready() { + mLevel = new Level((int)GetViewportRect().Size.X, (int)GetViewportRect().Size.Y); + mLevelDrawer = GetNode("CanvasLayer/LevelDrawer"); + } + + public override void _Process(double delta) { + mLevelDrawer.Texture = ImageTexture.CreateFromImage(mLevel.DrawLevel()); + } + + public override void _Input(InputEvent @event) { + if (@event is InputEventMouseButton eventMouseButton) { + + Vector2 mouse = GetViewport().GetMousePosition(); + mLevel.WritePixel((int)mouse.X, (int)mouse.Y, BrushSize); + } + } +} diff --git a/icon.svg b/icon.svg new file mode 100644 index 0000000..b370ceb --- /dev/null +++ b/icon.svg @@ -0,0 +1 @@ + diff --git a/icon.svg.import b/icon.svg.import new file mode 100644 index 0000000..52d13f2 --- /dev/null +++ b/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c1n68cqilodne" +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/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +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/project.godot b/project.godot new file mode 100644 index 0000000..cbf0918 --- /dev/null +++ b/project.godot @@ -0,0 +1,24 @@ +; 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="FOU" +run/main_scene="res://Scenes/main.tscn" +config/features=PackedStringArray("4.1", "C#", "Forward Plus") +config/icon="res://icon.svg" + +[dotnet] + +project/assembly_name="FOU" + +[rendering] + +textures/canvas_textures/default_texture_filter=0