Skip to content
Snippets Groups Projects
Commit 38344cd2 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

Yksi kolmio

parent 1020c99e
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Widgets;
namespace KolmionMetsastys;
/// @author Omanimi
/// @version 25.09.2023
/// <summary>
///
/// </summary>
public class KolmionMetsastys : PhysicsGame
{
public override void Begin()
{
Level.Background.Color = Color.Black;
BoundingRectangle alaosa = new BoundingRectangle(new Vector(Level.Left, 0), Level.BoundingRect.BottomRight);
LuoSattunnainenKolmio(this, alaosa);
PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
/// <summary>
/// Luodaan satunnainen kolmio suorakaiteen sisälle. Myös väri ja kulma arvotaan.
/// </summary>
/// <param name="peli">Mihin peliin kolmio luodaan</param>
/// <param name="rect">Minkä suorakaiteen sisälle luodaan</param>
public static void LuoSattunnainenKolmio(PhysicsGame peli, BoundingRectangle rect)
{
double leveys = RandomGen.NextDouble(10, 100);
double korkeus = RandomGen.NextDouble(10, 100);
PhysicsObject kolmio = new PhysicsObject(leveys, korkeus, Shape.Triangle);
kolmio.Position = RandomGen.NextVector(rect);
kolmio.Angle = RandomGen.NextAngle();
kolmio.Color = RandomGen.NextColor();
peli.Add(kolmio);
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.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 KolmionMetsastys
{
/// <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 KolmionMetsastys();
game.Run();
}
}
}
\ No newline at end of file
......@@ -5,19 +5,25 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Laskuja", "Laskuja\Laskuja.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaskujaTest", "LaskujaTest\LaskujaTest.csproj", "{F908170C-A726-4E5A-BCFD-731D2F645223}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KolmionMetsastys", "KolmionMetsastys\KolmionMetsastys.csproj", "{AB465606-ED42-4F68-8B69-6D01D36E88CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2647682B-66A0-4935-9D2E-F3F99876BA0D}.Release|Any CPU.Build.0 = Release|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F908170C-A726-4E5A-BCFD-731D2F645223}.Release|Any CPU.Build.0 = Release|Any CPU
{AB465606-ED42-4F68-8B69-6D01D36E88CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AB465606-ED42-4F68-8B69-6D01D36E88CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB465606-ED42-4F68-8B69-6D01D36E88CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB465606-ED42-4F68-8B69-6D01D36E88CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
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