commit d5c822811b93d0aa38e34587f0f5b95c87ceafa5 Author: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Mon Sep 9 13:31:59 2019 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64bb62d --- /dev/null +++ b/.gitignore @@ -0,0 +1,516 @@ +#Soundtrack data +Soundtrack.aup +Soundtrack_data/* + + +# Created by https://www.gitignore.io/api/csharp,visualstudio +# Edit at https://www.gitignore.io/?templates=csharp,visualstudio + +### Csharp ### +## 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/ + +### VisualStudio ### + +# User-specific files + +# User-specific files (MonoDevelop/Xamarin Studio) + +# Mono auto generated files + +# Build results + +# Visual Studio 2015/2017 cache/options directory +# Uncomment if you have tasks that create the project's static files in wwwroot + +# Visual Studio 2017 auto generated files + +# MSTest test Results + +# NUnit + +# Build Results of an ATL Project + +# Benchmark Results + +# .NET Core + +# StyleCop + +# Files built by Visual Studio + +# Chutzpah Test files + +# Visual C++ cache files + +# Visual Studio profiler + +# Visual Studio Trace Files + +# TFS 2012 Local Workspace + +# Guidance Automation Toolkit + +# ReSharper is a .NET coding add-in + +# JustCode is a .NET coding add-in + +# TeamCity is a build add-in + +# DotCover is a Code Coverage Tool + +# AxoCover is a Code Coverage Tool + +# Visual Studio code coverage results + +# NCrunch + +# MightyMoose + +# Web workbench (sass) + +# Installshield output folder + +# DocProject is a documentation generator add-in + +# Click-Once directory + +# Publish Web Output +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted + +# 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 + +# NuGet Packages +# NuGet Symbol Packages +# The packages folder can be ignored because of Package Restore +# except build/, which is used as an MSBuild target. +# Uncomment if necessary however generally it will be regenerated when needed +# NuGet v3's project.json files produces more ignorable files + +# Microsoft Azure Build Output + +# Microsoft Azure Emulator + +# Windows Store app package directories and files + +# Visual Studio cache files +# files ending in .cache can be ignored +# but keep track of directories ending in .cache + +# Others + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) + +# RIA/Silverlight projects + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) + +# SQL Server files + +# Business Intelligence projects + +# Microsoft Fakes + +# GhostDoc plugin setting file + +# Node.js Tools for Visual Studio + +# Visual Studio 6 build log + +# Visual Studio 6 workspace options file + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) + +# Visual Studio LightSwitch build output + +# Paket dependency manager + +# FAKE - F# Make + +# CodeRush personal settings + +# Python Tools for Visual Studio (PTVS) + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio + +# Telerik's JustMock configuration file + +# BizTalk build output + +# OpenCover UI analysis results + +# Azure Stream Analytics local run output + +# MSBuild Binary and Structured Log + +# NVidia Nsight GPU debugger configuration file + +# MFractors (Xamarin productivity tool) working folder + +# Local History for Visual Studio + +# BeatPulse healthcheck temp database + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 + +# End of https://www.gitignore.io/api/csharp,visualstudio diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0b82c9 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# testexetrisathlon diff --git a/testexetrisathlon.sln b/testexetrisathlon.sln new file mode 100644 index 0000000..92330b3 --- /dev/null +++ b/testexetrisathlon.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.489 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testexetrisathlon", "testexetrisathlon\testexetrisathlon.csproj", "{6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59}.Debug|x86.ActiveCfg = Debug|x86 + {6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59}.Debug|x86.Build.0 = Debug|x86 + {6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59}.Release|x86.ActiveCfg = Release|x86 + {6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4C16C2C9-FF64-4E36-82DE-C2C035FDF0D8} + EndGlobalSection +EndGlobal diff --git a/testexetrisathlon/GameOver.wav b/testexetrisathlon/GameOver.wav new file mode 100644 index 0000000..b4e25f1 Binary files /dev/null and b/testexetrisathlon/GameOver.wav differ diff --git a/testexetrisathlon/InGame.wav b/testexetrisathlon/InGame.wav new file mode 100644 index 0000000..39995c5 Binary files /dev/null and b/testexetrisathlon/InGame.wav differ diff --git a/testexetrisathlon/Intro.wav b/testexetrisathlon/Intro.wav new file mode 100644 index 0000000..ff35eda Binary files /dev/null and b/testexetrisathlon/Intro.wav differ diff --git a/testexetrisathlon/Program.cs b/testexetrisathlon/Program.cs new file mode 100644 index 0000000..8f1d974 --- /dev/null +++ b/testexetrisathlon/Program.cs @@ -0,0 +1,330 @@ +using System; +using System.Linq; +using System.Diagnostics; +using System.Media; +using static System.Console; +using System.Reflection; + +//┌─┐ +//│ │ +//└─┘ + +// ▀▀▀██████▄▄▄ +// ▀▀▀████▄ +// ▄███████▀ ▀███▄ +// ▄███████▀ ▀███▄ +// ▄████████ ███▄ +// ██████████▄ ███▌ +// ▀█████▀ ▀███▄ ▐███ +// ▀█▀ ▀███▄ ▐███ +// ▀███▄ ███▌ +// ▄██▄ ▀███▄ ▐███ +// ▄██████▄ ▀███▄███ +// █████▀▀████▄▄ ▄█████ +// ████▀ ▀▀█████▄▄▄▄█████████▄ +// ▀▀ ▀▀██████▀▀ ▀▀██ + +namespace testexetrisathlon +{ + class Program + { + public static string sqr = "■"; + public static int[,] grid = new int[23, 10]; + public static int[,] droppedtetrominoeLocationGrid = new int[23, 10]; + public static Stopwatch dropTimer = new Stopwatch(); + public static Stopwatch inputTimer = new Stopwatch(); + public static int dropTime, dropRate = 300; + public static bool isDropped = false; + static Tetrominoe tet; + static Tetrominoe nexttet; + public static ConsoleKeyInfo key; + public static bool isKeyPressed = false; + public static int linesCleared = 0, score = 0, level = 1; + static readonly Assembly assembly = Assembly.GetExecutingAssembly(); + static ConsoleColor[] colors; + public static bool debug; + public static Random rnd; + static void Main(string[] args) + { + rnd = new Random(); + colors = new ConsoleColor[2] { BackgroundColor, ForegroundColor }; + BackgroundColor = ConsoleColor.Red; + ForegroundColor = ConsoleColor.Yellow; + SetCursorPosition(0, 0); + Clear(); +#if (DEBUG) + debug = true; +#else + debug = args.Contains("debug"); +#endif + if (debug) + SetWindowSize(50, 40); + new Program().MainN( + new SoundPlayer(assembly.GetManifestResourceStream("testexetrisathlon.Intro.wav")), + new SoundPlayer(assembly.GetManifestResourceStream("testexetrisathlon.InGame.wav")), + new SoundPlayer(assembly.GetManifestResourceStream("testexetrisathlon.GameOver.wav"))); + BackgroundColor = colors[0]; + ForegroundColor = colors[1]; + SetCursorPosition(0, 0); + Clear(); + } + enum GameState { exit, menu, game, gameOver } + void MainN(SoundPlayer intro, SoundPlayer inGame, SoundPlayer gameOver) + { + bool playing = true; + GameState state = GameState.menu; + while (playing) + { + switch (state) + { + case GameState.menu: + Clear(); + gameOver.Stop(); + intro.PlayLooping(); + SetCursorPosition(0, 1); + Write( + " ▀▀▀██████▄▄▄\r\n" + + " ▀▀▀████▄\r\n" + + " ▄███████▀ ▀███▄\r\n" + + " ▄███████▀ ▀███▄\r\n" + + " ▄████████ ███▄\r\n" + + " ██████████▄ ███▌\r\n" + + " ▀█████▀ ▀███▄ ▐███\r\n" + + " ▀█▀ ▀███▄ ▐███\r\n" + + " ▀███▄ ███▌\r\n" + + " ▄██▄ ▀███▄ ▐███\r\n" + + " ▄██████▄ ▀███▄███\r\n" + + " █████▀▀████▄▄ ▄█████\r\n" + + " ████▀ ▀▀█████▄▄▄▄█████████▄\r\n" + + " ▀▀ ▀▀██████▀▀ ▀▀██\r\n\r\n" + + + "testexetrisathlon v." + assembly.GetName().Version.ToString()); + SetCursorPosition(7, 18); + WriteLine("Controls: Space"); + SetCursorPosition(8, 19); + WriteLine("Up, Down, Right"); + SetCursorPosition(8, 20); + WriteLine("Left"); + SetCursorPosition(7, 22); + WriteLine("Press s to start"); + SetCursorPosition(7, 23); + WriteLine("Press x to exit"); + string tmp = ReadKey(true).KeyChar.ToString().ToLower(); + switch (tmp) + { + case "s": + intro.Stop(); + state = GameState.game; + Clear(); + DrawBorder(); + break; + case "x": + state = GameState.exit; + break; + } + break; + case GameState.game: + inGame.PlayLooping(); + dropTimer.Start(); + SetCursorPosition(25, 0); + WriteLine("Level " + level); + SetCursorPosition(25, 1); + WriteLine("Score " + score); + SetCursorPosition(25, 2); + WriteLine("LinesCleared " + linesCleared); + nexttet = new Tetrominoe(); + tet = nexttet; + tet.Spawn(); + nexttet = new Tetrominoe(); + Update(); + inGame.Stop(); + state = GameState.gameOver; + break; + case GameState.gameOver: + gameOver.PlayLooping(); + string input = ""; + while ((input != "y") && (input != "n")) + { + Clear(); + DrawBorder(); + Draw(); + SetCursorPosition(0, 0); + WriteLine("┌───────────────────┐"); + WriteLine("│ Game Over │"); + WriteLine("│ Replay? (Y/N) │"); + WriteLine("├───────────────────┤"); + input = ReadKey().KeyChar.ToString().ToLower(); + } + grid = new int[23, 10]; + droppedtetrominoeLocationGrid = new int[23, 10]; + dropTimer = new Stopwatch(); + inputTimer = new Stopwatch(); + dropRate = 300; + isDropped = false; + isKeyPressed = false; + linesCleared = 0; + score = 0; + level = 1; + GC.Collect(); + Clear(); + DrawBorder(); + if (input == "y") + state = GameState.game; + else + state = GameState.menu; + break; + default: + playing = false; + break; + } + } + } + private static void Update() + { + while (true) + { + dropTime = (int)dropTimer.ElapsedMilliseconds; + if (dropTime > dropRate) + { + dropTime = 0; dropTimer.Restart(); tet.Drop(); + } + if (isDropped == true) + { + tet = nexttet; + nexttet = new Tetrominoe(); + tet.Spawn(); + isDropped = false; + score += 10; + } + int j; for (j = 0; j < 10; j++) + { + if (droppedtetrominoeLocationGrid[0, j] == 1) + return; + } + if (debug) + { + SetCursorPosition(0, 25); + WriteLine("!DEBUG MODE ENABLED!"); + } + Input(); + ClearBlock(); + } + } + private static void ClearBlock() + { + int combo = 0; + for (int i = 0; i < 23; i++) + { + int j; for (j = 0; j < 10; j++) + { + if (droppedtetrominoeLocationGrid[i, j] == 0) + break; + } + if (j == 10) + { + linesCleared++; + combo++; + Beep(400, 200); + for (j = 0; j < 10; j++) + { + droppedtetrominoeLocationGrid[i, j] = 0; + } + int[,] newdroppedtetrominoeLocationGrid = new int[23, 10]; + for (int k = 1; k < i; k++) + { + for (int l = 0; l < 10; l++) + { + newdroppedtetrominoeLocationGrid[k + 1, l] = droppedtetrominoeLocationGrid[k, l]; + } + } + for (int k = 1; k < i; k++) + { + for (int l = 0; l < 10; l++) + { + droppedtetrominoeLocationGrid[k, l] = 0; + } + } + for (int k = 0; k < 23; k++) + for (int l = 0; l < 10; l++) + if (newdroppedtetrominoeLocationGrid[k, l] == 1) + droppedtetrominoeLocationGrid[k, l] = 1; + Draw(); + } + } + score += (int)Math.Round(Math.Sqrt(Math.Max(combo * 50 - 50, 0)) * 5); + level = (int)Math.Round(Math.Sqrt(score * 0.01)) + 1; + dropRate = 300 - 22 * level; + } + private static void Input() + { + isKeyPressed = KeyAvailable; + SetCursorPosition(0, 24); + if (isKeyPressed) + key = ReadKey(); + if (key.Key == ConsoleKey.LeftArrow & !tet.isSomethingLeft() & isKeyPressed) + { + for (int i = 0; i < 4; i++) + tet.location[i][1] -= 1; + tet.Update(); + } + else if (key.Key == ConsoleKey.RightArrow & !tet.isSomethingRight() & isKeyPressed) + { + for (int i = 0; i < 4; i++) + tet.location[i][1] += 1; + tet.Update(); + } + if (key.Key == ConsoleKey.DownArrow & isKeyPressed) + tet.Drop(); + if (key.Key == ConsoleKey.UpArrow & isKeyPressed) + for (; tet.isSomethingBelow() != true;) + tet.Drop(); + if (key.Key == ConsoleKey.Spacebar & isKeyPressed) + { + tet.Rotate(); + tet.Update(); + } + } + public static void Draw() + { + for (int i = 0; i < 23; ++i) + { + for (int j = 0; j < 10; j++) + { + SetCursorPosition(1 + 2 * j, i); + if (grid[i, j] == 1 | droppedtetrominoeLocationGrid[i, j] == 1) + { + SetCursorPosition(1 + 2 * j, i); + Write(sqr); + } + else + { + Write(" "); + } + } + } + SetCursorPosition(25, 0); + WriteLine("Level " + level); + SetCursorPosition(25, 1); + WriteLine("Score " + score); + SetCursorPosition(25, 2); + WriteLine("LinesCleared " + linesCleared); + } + public static void DrawBorder() + { + for (int lengthCount = 0; lengthCount <= 22; lengthCount++) + { + SetCursorPosition(0, lengthCount); + Write("│"); + SetCursorPosition(20, lengthCount); + Write("│"); + } + SetCursorPosition(0, 23); + Write("└"); + for (int widthCount = 0; widthCount <= 18; widthCount++) + { + Write("─"); + } + Write("┘"); + } + } +} diff --git a/testexetrisathlon/Properties/AssemblyInfo.cs b/testexetrisathlon/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dd7c139 --- /dev/null +++ b/testexetrisathlon/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("Testexetrisathlon")] +[assembly: AssemblyDescription("Testexetrisathlon is one of the most innovative games i have played in years.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("CreepyCrafter24 ft. Company X")] +[assembly: AssemblyProduct("Testexetrisathlon")] +[assembly: AssemblyCopyright("${AuthorCopyright}")] +[assembly: AssemblyTrademark("© 20XX Company X")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.2.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/testexetrisathlon/Tetrominoe.cs b/testexetrisathlon/Tetrominoe.cs new file mode 100644 index 0000000..ed678bd --- /dev/null +++ b/testexetrisathlon/Tetrominoe.cs @@ -0,0 +1,307 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using static System.Console; +#pragma warning disable IDE1006 +namespace testexetrisathlon +{ + public class Tetrominoe + { + public static int[,] I = new int[1, 4] { { 1, 1, 1, 1 } }; + + public static int[,] O = new int[2, 2] { { 1, 1 }, + { 1, 1 } }; + + public static int[,] T = new int[2, 3] { { 0, 1, 0 }, + { 1, 1, 1 } }; + + public static int[,] S = new int[2, 3] { { 0, 1, 1 }, + { 1, 1, 0 } }; + + public static int[,] Z = new int[2, 3] { { 1, 1, 0 }, + { 0, 1, 1 } }; + + public static int[,] J = new int[2, 3] { { 1, 0, 0 }, + { 1, 1, 1 } }; + + public static int[,] L = new int[2, 3] { { 0, 0, 1 }, + { 1, 1, 1 } }; + public static List tetrominoes = new List() { I, O, T, S, Z, J, L }; + private readonly int[,] shape; + public List location = new List(); + public Tetrominoe() + { + shape = tetrominoes[Program.rnd.Next(0, tetrominoes.Count)]; + for (int i = 23; i < 33; ++i) + { + for (int j = 3; j < 10; j++) + { + SetCursorPosition(i, j); + Write(" "); + } + } + Program.DrawBorder(); + for (int i = 0; i < shape.GetLength(0); i++) + { + for (int j = 0; j < shape.GetLength(1); j++) + { + if (shape[i, j] == 1) + { + SetCursorPosition(((10 - shape.GetLength(1)) / 2 + j) * 2 + 20, i + 5); + Write(Program.sqr); + } + } + } + } + public void Spawn() + { + for (int i = 0; i < shape.GetLength(0); i++) + { + for (int j = 0; j < shape.GetLength(1); j++) + { + if (shape[i, j] == 1) + { + location.Add(new int[] { i, (10 - shape.GetLength(1)) / 2 + j }); + } + } + } + Update(); + } + public void Drop() + { + if (isSomethingBelow()) + { + for (int i = 0; i < 4; i++) + { + Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] = 1; + } + Program.isDropped = true; + Beep(800, 200); + } + else + { + for (int numCount = 0; numCount < 4; numCount++) + { + location[numCount][0] += 1; + } + Update(); + } + } + public void Rotate() + { + List templocation = new List(); + for (int i = 0; i < shape.GetLength(0); i++) + { + for (int j = 0; j < shape.GetLength(1); j++) + { + if (shape[i, j] == 1) + { + templocation.Add(new int[] { i, (10 - shape.GetLength(1)) / 2 + j }); + } + } + } + if (shape == tetrominoes[0]) + { + for (int i = 0; i < location.Count; i++) + { + templocation[i] = TransformMatrix(location[i], location[2]); + } + } + else if (shape == tetrominoes[3]) + { + for (int i = 0; i < location.Count; i++) + { + templocation[i] = TransformMatrix(location[i], location[3]); + } + } + else if (shape == tetrominoes[1]) + return; + else + { + for (int i = 0; i < location.Count; i++) + { + templocation[i] = TransformMatrix(location[i], location[2]); + } + } + for (int count = 0; isOverlayLeft(templocation) != false | isOverlayRight(templocation) != false | isOverlayBelow(templocation) != false; count++) + { + if (isOverlayLeft(templocation) == true) + { + for (int i = 0; i < location.Count; i++) + { + templocation[i][1] += 1; + } + } + if (isOverlayRight(templocation) == true) + { + for (int i = 0; i < location.Count; i++) + { + templocation[i][1] -= 1; + } + } + if (isOverlayBelow(templocation) == true) + { + for (int i = 0; i < location.Count; i++) + { + templocation[i][0] -= 1; + } + } + if (count == 3) + { + return; + } + } + location = templocation; + } + public bool notFalse(bool? inp) => (inp ?? true); + public int[] TransformMatrix(int[] coord, int[] axis) => new int[] { axis[0] - axis[1] + coord[1], axis[0] + axis[1] - coord[0] }; + public bool isSomethingBelow() + { + for (int i = 0; i < 4; i++) + { + if (location[i][0] + 1 >= 23) + return true; + if (location[i][0] + 1 < 23 & Program.droppedtetrominoeLocationGrid[location[i][0] + 1, location[i][1]] == 1) + return true; + } + return false; + } + public bool? isOverlayBelow(List location) + { + List ycoords = new List(); + for (int i = 0; i < 4; i++) + { + ycoords.Add(location[i][0]); + if (location[i][0] >= 23) + return true; + if (location[i][0] < 0 | location[i][1] < 0 | location[i][1] > 9) + return null; + } + for (int i = 0; i < 4; i++) + { + if (ycoords.Max() - ycoords.Min() == 3) + { + if ((ycoords.Max() == location[i][0] | ycoords.Max() - 1 == location[i][0]) & (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1)) + { + return true; + } + } + else + { + if ((ycoords.Max() == location[i][0]) & (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1)) + { + return true; + } + } + } + return false; + } + public bool isSomethingLeft() + { + for (int i = 0; i < 4; i++) + { + if (location[i][1] == 0) + return true; + else if (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1] - 1] == 1) + return true; + } + return false; + } + public bool? isOverlayLeft(List location) + { + List xcoords = new List(); + for (int i = 0; i < 4; i++) + { + xcoords.Add(location[i][1]); + if (location[i][1] < 0) + return true; + if (location[i][1] > 9) + return false; + if (location[i][0] >= 23 | location[i][0] < 0) + return null; + } + for (int i = 0; i < 4; i++) + { + if (xcoords.Max() - xcoords.Min() == 3) + { + if (xcoords.Min() == location[i][1] | xcoords.Min() + 1 == location[i][1]) + { + if (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1) + { + return true; + } + } + } + else + { + if (xcoords.Min() == location[i][1]) + { + if (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1) + { + return true; + } + } + } + } + return false; + } + public bool isSomethingRight() + { + for (int i = 0; i < 4; i++) + { + if (location[i][1] == 9) + return true; + else if (Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1] + 1] == 1) + return true; + } + return false; + } + public bool? isOverlayRight(List location) + { + List xcoords = new List(); + for (int i = 0; i < 4; i++) + { + xcoords.Add(location[i][1]); + if (location[i][1] > 9) + return true; + if (location[i][1] < 0) + return false; + if (location[i][0] >= 23 | location[i][0] < 0) + return null; + } + for (int i = 0; i < 4; i++) + { + if (xcoords.Max() - xcoords.Min() == 3) + { + if ((xcoords.Max() == location[i][1] | xcoords.Max() - 1 == location[i][1]) & Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1) + { + return true; + } + } + else + { + if (xcoords.Max() == location[i][1] & Program.droppedtetrominoeLocationGrid[location[i][0], location[i][1]] == 1) + { + return true; + } + } + } + return false; + } + public void Update() + { + for (int i = 0; i < 23; i++) + { + for (int j = 0; j < 10; j++) + { + Program.grid[i, j] = 0; + } + } + for (int i = 0; i < 4; i++) + { + Program.grid[location[i][0], location[i][1]] = 1; + } + Program.Draw(); + } + } +} diff --git a/testexetrisathlon/app.config b/testexetrisathlon/app.config new file mode 100644 index 0000000..312bb3f --- /dev/null +++ b/testexetrisathlon/app.config @@ -0,0 +1,3 @@ + + + diff --git a/testexetrisathlon/testexetrisathlon.csproj b/testexetrisathlon/testexetrisathlon.csproj new file mode 100644 index 0000000..1811134 --- /dev/null +++ b/testexetrisathlon/testexetrisathlon.csproj @@ -0,0 +1,85 @@ + + + + Debug + x86 + {6B0BD176-D6E3-49F5-8CA1-AE5F1535AC59} + Exe + testexetrisathlon + testexetrisathlon + v4.7.2 + + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + x86 + + + true + bin\Release + prompt + 4 + true + x86 + + + true + bin\Debug\ + DEBUG; + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + true + + + bin\Release\ + true + AnyCPU + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x64\Debug\ + DEBUG; + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x64\Release\ + true + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file