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

lumiukot

parent 92be7ac4
No related branches found
No related tags found
No related merge requests found
Showing
with 116 additions and 266 deletions
using Jypeli;
/// @author Vesa Lappalainen
/// @version 12.09.2011
///
/// <summary>
/// Ohjelma piirtää näyttöö kolmepalloisen lumiukon
/// </summary>
public class Lumiukko : PhysicsGame
{
/// <summary>
/// Pääohjelmassa laitetaan "peli" käyntiin Jypelille tyypilliseen tapaan
/// </summary>
/// <param name="args">Ei käytössä</param>
public static void Main(string[] args)
{
Lumiukko peli = new Lumiukko();
peli.Run();
}
/// <summary>
/// Aliohjelmassa piirretään ja zoomataan kamera siten että kenttä näkyy hyvin ruudulla.
/// </summary>
public override void Begin()
{
//Camera.ZoomTo(-1000,-1000,1000,1000);
Level.BackgroundColor = Color.Black;
Level.CreateBorders();
PiirraLumiukko(this,0.0,Level.Bottom+200);
PiirraLumiukko(this,200,Level.Bottom+400);
PiirraLumiukko(this,-200,Level.Bottom+400);
Gravity = new Vector(0, -400);
}
/// <summary>
/// Aliohjelma piirtää lumiukon
/// annettuun paikkaan.
/// </summary>
/// <param name="peli">Peli, johon lumiukko tehdään.</param>
/// <param name="x">Lumiukon alimman pallon x-koordinaatti.</param>
/// <param name="y">Lumiukon alimman pallon y-koordinaatti.</param>
public static void PiirraLumiukko(PhysicsGame peli,double x,double y)
{
PhysicsObject p1,p2,p3;
p1 = new PhysicsObject(2 * 100.0, 2 * 100.0, Shape.Circle);
p1.X = x;
p1.Y = y;
peli.Add(p1);
p2 = new PhysicsObject(2 * 50.0, 2 * 50.0, Shape.Circle);
p2.Y = p1.Y + 100.0 + 50.0;
p2.X = x;
peli.Add(p2);
p2.Color = Color.Red;
p3 = new PhysicsObject(2 * 30.0, 2 * 30.0, Shape.Circle);
p3.Y = p2.Y + 50.0 + 30.0;
p3.X = x;
peli.Add(p3);
}
}
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/.idea.Lumiukko.iml
/projectSettingsUpdater.xml
/contentModel.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 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 VisualStudioVersion = 17.0.31912.275
VisualStudioVersion = 16.0.29306.81
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LumiukkoTyhma", "LumiukkoTyhma\LumiukkoTyhma.csproj", "{C388DEDA-59F8-4AB0-85A1-073C936D3132}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LumiukkoTyhma", "LumiukkoTyhma\LumiukkoTyhma.csproj", "{A7FC9323-052B-48FC-94CC-27B3802D7511}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LumiukkoAli", "LumiukkoAli\LumiukkoAli.csproj", "{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LumiukkoAli", "LumiukkoAli\LumiukkoAli.csproj", "{81D1147C-8EE7-4690-83D7-6326497FBC5D}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86 Debug|Any CPU = Debug|Any CPU
Release|x86 = Release|x86 Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Debug|x86.ActiveCfg = Debug|x86 {A7FC9323-052B-48FC-94CC-27B3802D7511}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Debug|x86.Build.0 = Debug|x86 {A7FC9323-052B-48FC-94CC-27B3802D7511}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Release|x86.ActiveCfg = Release|x86 {A7FC9323-052B-48FC-94CC-27B3802D7511}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C388DEDA-59F8-4AB0-85A1-073C936D3132}.Release|x86.Build.0 = Release|x86 {A7FC9323-052B-48FC-94CC-27B3802D7511}.Release|Any CPU.Build.0 = Release|Any CPU
{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}.Debug|x86.ActiveCfg = Debug|x86 {81D1147C-8EE7-4690-83D7-6326497FBC5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}.Debug|x86.Build.0 = Debug|x86 {81D1147C-8EE7-4690-83D7-6326497FBC5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}.Release|x86.ActiveCfg = Release|x86 {81D1147C-8EE7-4690-83D7-6326497FBC5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}.Release|x86.Build.0 = Release|x86 {81D1147C-8EE7-4690-83D7-6326497FBC5D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8A23E4A4-E9AD-4E6A-9FAF-90C53002ED1C} SolutionGuid = {A443115A-7F44-4793-9DE8-E7B5D4AD7BE9}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
using Jypeli; using Jypeli;
namespace LumiukkoAli;
/// @author Vesa Lappalainen /// @author Vesa Lappalainen
/// @version 09.10.2011 /// @version 09.10.2011
/// ///
...@@ -33,22 +35,21 @@ public class LumiukkoAli : PhysicsGame ...@@ -33,22 +35,21 @@ public class LumiukkoAli : PhysicsGame
/// <param name="y">Lumiukon alimman pallon y-koordinaatti.</param> /// <param name="y">Lumiukon alimman pallon y-koordinaatti.</param>
public static void PiirraLumiukko(PhysicsGame peli, double x, double y) public static void PiirraLumiukko(PhysicsGame peli, double x, double y)
{ {
PhysicsObject p1, p2, p3;
double r1 = 100; double r1 = 100;
double r2 = 50; double r2 = 50;
double r3 = 30; double r3 = 30;
p1 = new PhysicsObject(2 * r1, 2 * r1, Shape.Circle); PhysicsObject p1 = new PhysicsObject(2 * r1, 2 * r1, Shape.Circle);
p1.X = x; p1.X = x;
p1.Y = y; p1.Y = y;
peli.Add(p1); peli.Add(p1);
p2 = new PhysicsObject(2 * r2, 2 * r2, Shape.Circle); PhysicsObject p2 = new PhysicsObject(2 * r2, 2 * r2, Shape.Circle);
p2.X = x; p2.X = x;
p2.Y = p1.Y + r1 + r2; p2.Y = p1.Y + r1 + r2;
peli.Add(p2); peli.Add(p2);
p3 = new PhysicsObject(2 * r3, 2 * r3, Shape.Circle); PhysicsObject p3 = new PhysicsObject(2 * r3, 2 * r3, Shape.Circle);
p3.X = x; p3.X = x;
p3.Y = p2.Y + r2 + r3; p3.Y = p2.Y + r2 + r3;
peli.Add(p3); peli.Add(p3);
......
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4D9EF385-AB2E-45D6-A82F-39C39D39DA08}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <TargetFramework>net7.0</TargetFramework>
<RootNamespace>LumiukkoAli</RootNamespace>
<AssemblyName>LumiukkoAli</AssemblyName>
<FileAlignment>512</FileAlignment>
<MonoGamePlatform>Windows</MonoGamePlatform>
<ReferencePath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\Windows</ReferencePath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Windows\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Windows\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Include="LumiukkoAli.cs" />
<Compile Include="Ohjelma.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Jypeli">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.dll</HintPath>
</Reference>
<Reference Include="Jypeli.Physics2d">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.Physics2d.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework">
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Icon.ico" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" /> <PackageReference Include="Jypeli.NET" Version="11.*"/>
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*"/>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Jypeli\MonoJypeli.targets" /> </Project>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
#region Using Statements #region Using Statements
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
#endregion #endregion
namespace Program namespace LumiukkoAli
{ {
#if WINDOWS || LINUX
/// <summary> /// <summary>
/// The main class. /// The main class.
/// </summary> /// </summary>
...@@ -18,9 +19,8 @@ namespace Program ...@@ -18,9 +19,8 @@ namespace Program
[STAThread] [STAThread]
static void Main() static void Main()
{ {
using ( var game = new LumiukkoAli() ) using var game = new LumiukkoAli();
game.Run(); game.Run();
} }
} }
#endif }
} \ No newline at end of file
using Jypeli; using Jypeli;
namespace LumiukkoTyhma;
/// @author Vesa Lappalainen /// @author Vesa Lappalainen
/// @version 09.10.2011 /// @version 09.10.2011
/// ///
...@@ -8,18 +10,6 @@ ...@@ -8,18 +10,6 @@
/// </summary> /// </summary>
public class LumiukkoTyhma : PhysicsGame public class LumiukkoTyhma : PhysicsGame
{ {
/// <summary>
/// Pääohjelmassa laitetaan "peli" käyntiin Jypeli-kirjastolle tyypilliseen tapaan
/// </summary>
/// <param name="args">Ei käytössä</param>
public static void Main(string[] args)
{
using (LumiukkoTyhma peli = new LumiukkoTyhma())
{
peli.Run();
}
}
/// <summary> /// <summary>
/// Aliohjelmassa piirretään ja zoomataan kamera siten, että kenttä näkyy hyvin ruudulla. /// Aliohjelmassa piirretään ja zoomataan kamera siten, että kenttä näkyy hyvin ruudulla.
/// </summary> /// </summary>
...@@ -30,30 +20,30 @@ public class LumiukkoTyhma : PhysicsGame ...@@ -30,30 +20,30 @@ public class LumiukkoTyhma : PhysicsGame
Camera.ZoomToLevel(); Camera.ZoomToLevel();
Level.BackgroundColor = Color.Black; Level.BackgroundColor = Color.Black;
double x, y;
PhysicsObject p1, p2, p3;
// Tehdään ensimmäinen lumiukko // Tehdään ensimmäinen lumiukko
x = 0; y = Level.Bottom + 200.0; double x = 0;
double y = Level.Bottom + 200.0;
p1 = new PhysicsObject(2 * 100.0, 2 * 100.0, Shape.Circle); PhysicsObject p1 = new PhysicsObject(2 * 100.0, 2 * 100.0, Shape.Circle);
p1.X = x; p1.X = x;
p1.Y = y; p1.Y = y;
this.Add(p1); this.Add(p1);
p2 = new PhysicsObject(2 * 50.0, 2 * 50.0, Shape.Circle); PhysicsObject p2 = new PhysicsObject(2 * 50.0, 2 * 50.0, Shape.Circle);
p2.X = x; p2.X = x;
p2.Y = p1.Y + 100 + 50; p2.Y = p1.Y + 100 + 50;
this.Add(p2); this.Add(p2);
p3 = new PhysicsObject(2 * 30.0, 2 * 30.0, Shape.Circle); PhysicsObject p3 = new PhysicsObject(2 * 30.0, 2 * 30.0, Shape.Circle);
p3.X = x; p3.X = x;
p3.Y = p2.Y + 50 + 30; p3.Y = p2.Y + 50 + 30;
this.Add(p3); this.Add(p3);
// Tehdään toinen lumiukko // Tehdään toinen lumiukko
x = 200; y = Level.Bottom + 300.0; x = 200;
y = Level.Bottom + 300.0;
p1 = new PhysicsObject(2 * 100.0, 2 * 100.0, Shape.Circle); p1 = new PhysicsObject(2 * 100.0, 2 * 100.0, Shape.Circle);
p1.X = x; p1.X = x;
p1.Y = y; p1.Y = y;
......
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C388DEDA-59F8-4AB0-85A1-073C936D3132}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <TargetFramework>net7.0</TargetFramework>
<RootNamespace>LumiukkoTyhma</RootNamespace>
<AssemblyName>LumiukkoTyhma</AssemblyName>
<FileAlignment>512</FileAlignment>
<MonoGamePlatform>Windows</MonoGamePlatform>
<ReferencePath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\Windows</ReferencePath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Windows\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Windows\Release\</OutputPath>
<DefineConstants>TRACE;WINDOWS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Compile Include="LumiukkoTyhma.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Jypeli">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.dll</HintPath>
</Reference>
<Reference Include="Jypeli.Physics2d">
<HintPath>$(registry:HKEY_LOCAL_MACHINE\Software\MonoJypeli@Install_Dir)\WindowsGL\Jypeli.Physics2d.dll</HintPath>
</Reference>
<Reference Include="MonoGame.Framework">
<HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="Icon.ico" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<MonoGameContentReference Include="Content\Content.mgcb" /> <PackageReference Include="Jypeli.NET" Version="11.*"/>
<PackageReference Include="Jypeli.FarseerPhysics.NET" Version="2.*"/>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Jypeli\MonoJypeli.targets" /> </Project>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
#region Using Statements
using System;
#endregion
namespace LumiukkoTyhma
{
/// <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 LumiukkoTyhma();
game.Run();
}
}
}
\ No newline at end of file
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