Skip to content
Snippets Groups Projects
Commit 7e23a71d authored by Limma Sakari Antti's avatar Limma Sakari Antti
Browse files

viimestelyä

parent 6d1718d7
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 400 deletions
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.App1.iml
/projectSettingsUpdater.xml
/contentModel.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App1", "App1\App1.csproj", "{9C15D0BE-45A8-422B-93E3-2BBBFFA7E1F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C15D0BE-45A8-422B-93E3-2BBBFFA7E1F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C15D0BE-45A8-422B-93E3-2BBBFFA7E1F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C15D0BE-45A8-422B-93E3-2BBBFFA7E1F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C15D0BE-45A8-422B-93E3-2BBBFFA7E1F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
/// @author sakar
/// @version 04.03.2025
/// <summary>
///
/// </summary>
public class App1
{
/// <summary>
///
/// </summary>
static void Main(string[] args)
{
Random random = new Random();
int targetNumber = random.Next(1, 101);
int attempts = 5;
bool guessed = false;
Console.WriteLine("Tervetuloa DEMOn Escape -peliin!");
Console.WriteLine("Pelin idea: Arvaa luku väliltä 1-100.");
Console.WriteLine($"Sinulla on {attempts} yritystä.");
while (attempts > 0 && !guessed)
{
Console.Write("Arvauksesi: ");
string input = Console.ReadLine();
int guess;
if (int.TryParse(input, out guess))
{
if (guess == targetNumber)
{
Console.WriteLine("Onnittelut! Arvasit oikein ja pääsit pakoon DEMOn kynsistä!");
guessed = true;
}
else if (guess < targetNumber)
{
Console.WriteLine("DEMOn kuiskaus: Luku on suurempi...");
}
else
{
Console.WriteLine("DEMOn kuiskaus: Luku on pienempi...");
}
attempts--;
if (attempts > 0 && !guessed)
{
Console.WriteLine($"Yrityksiä jäljellä: {attempts}");
}
}
else
{
Console.WriteLine("Syötä kelvollinen numero!");
}
}
if (!guessed)
{
Console.WriteLine($"Hävisit! Oikea luku oli {targetNumber}. DEMOn vangiksi jäit...");
}
Console.WriteLine("Paina Enter lopettaaksesi...");
Console.ReadLine();
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
</Project>

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App2", "App2\App2.csproj", "{A88BF983-4078-4A1F-9BC1-EFA39E2104C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A88BF983-4078-4A1F-9BC1-EFA39E2104C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A88BF983-4078-4A1F-9BC1-EFA39E2104C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A88BF983-4078-4A1F-9BC1-EFA39E2104C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A88BF983-4078-4A1F-9BC1-EFA39E2104C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Widgets;
namespace App2;
/// @author sakar
/// @version 04.03.2025
/// <summary>
///
/// </summary>
public class App2 : Game
{
public override void Begin()
{
// Kirjoita ohjelmakoodisi tähän
PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jypeli.NET" Version="11.*"/>
</ItemGroup>
</Project>
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace App2
{
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using var game = new App2();
game.Run();
}
}
}
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/.idea.App3.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App3", "App3\App3.csproj", "{53DAF4CF-D0A6-4931-A5B9-5A1ABF38B857}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53DAF4CF-D0A6-4931-A5B9-5A1ABF38B857}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53DAF4CF-D0A6-4931-A5B9-5A1ABF38B857}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53DAF4CF-D0A6-4931-A5B9-5A1ABF38B857}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53DAF4CF-D0A6-4931-A5B9-5A1ABF38B857}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Widgets;
namespace App3;
/// @author sakar
/// @version 04.03.2025
/// <summary>
///
/// </summary>
using System;
using Jypeli;
public class App3 : PhysicsGame
{
private int targetNumber;
private int attempts;
private Label infoLabel;
private IntMeter guessMeter;
public override void Begin()
{
Level.Background.Color = Color.White;
StartGame();
}
private void StartGame()
{
targetNumber = RandomGen.NextInt(1, 101);
attempts = 5;
ClearAll();
infoLabel = new Label();
infoLabel.Text = "Tervetuloa DEMOn Escape -peliin!\nArvaa luku väliltä 1-100.\nSinulla on 5 yritystä.";
infoLabel.Position = new Vector(0, Screen.Top - 50);
infoLabel.Font = Font.DefaultBold;
Add(infoLabel);
guessMeter = new IntMeter(1, 1, 100);
Label guessLabel = new Label();
guessLabel.BindTo(guessMeter);
guessLabel.Position = new Vector(0, 0);
guessLabel.Font = Font.DefaultBold;
Add(guessLabel);
Keyboard.Listen(Key.Enter, ButtonState.Pressed, CheckGuess, "Tarkista arvaus");
Keyboard.Listen(Key.Up, ButtonState.Down, () => { if (guessMeter.Value < 100) guessMeter.Value++; }, "Lisää arvausta");
Keyboard.Listen(Key.Down, ButtonState.Down, () => { if (guessMeter.Value > 1) guessMeter.Value--; }, "Vähennä arvausta");
Keyboard.Listen(Key.R, ButtonState.Pressed, StartGame, "Pelaa uudelleen");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli");
MessageDisplay.Add("Peli alkaa! Paina Enter arvauksen vahvistamiseksi.");
}
private void CheckGuess()
{
if (attempts > 0)
{
int guess = guessMeter.Value;
if (guess == targetNumber)
{
infoLabel.Text = "Onnittelut! Arvasit oikein ja pääsit pakoon DEMOn kynsistä!\nPaina R pelataksesi uudelleen.";
MessageDisplay.Add("Voitit pelin!");
return;
}
else if (guess < targetNumber)
{
infoLabel.Text = "DEMOn kuiskaus: Luku on suurempi...";
}
else
{
infoLabel.Text = "DEMOn kuiskaus: Luku on pienempi...";
}
attempts--;
MessageDisplay.Add($"Yrityksiä jäljellä: {attempts}");
}
if (attempts == 0)
{
infoLabel.Text = $"Hävisit! Oikea luku oli {targetNumber}. DEMOn vangiksi jäit...\nPaina R pelataksesi uudelleen.";
MessageDisplay.Add("Peli päättyi.");
}
}
public static void PelaaUudelleen()
{
new App3().Run();
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jypeli.NET" Version="11.*"/>
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*"/>
</ItemGroup>
</Project>
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#endregion
namespace App3
{
/// <summary>
/// The main class.
/// </summary>
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using var game = new App3();
game.Run();
}
}
}
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/.idea.Arvaaluku.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment