Skip to content

Commit

Permalink
all game files
Browse files Browse the repository at this point in the history
  • Loading branch information
U-i7\bunnies committed Aug 16, 2009
1 parent 81ab636 commit 1602d6f
Show file tree
Hide file tree
Showing 84 changed files with 2,740 additions and 0 deletions.
9 changes: 9 additions & 0 deletions AlkuIkkuna.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Window x:Class="Net.Brotherus.SeikkailuLaakso.AlkuIkkuna"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Seikkailu Laakso" Height="788" Width="1024">
<Canvas>
<Image Canvas.Left="0" Canvas.Top="0" Width="1024" Height="768" Source="file:///E:/programming/SeikkailuLaakso/alkukuva.png" />
<Button Canvas.Left="20" Canvas.Top="190" FontSize="24" Click="Aloitetaan">Aloita</Button>
</Canvas>
</Window>
32 changes: 32 additions & 0 deletions AlkuIkkuna.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Net.Brotherus.SeikkailuLaakso
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class AlkuIkkuna : Window
{
public AlkuIkkuna()
{
InitializeComponent();
}

private void Aloitetaan(object sender, RoutedEventArgs e)
{
new UkkelinMuokkaus().Show();
}
}
}
24 changes: 24 additions & 0 deletions Peli.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Window x:Class="Net.Brotherus.SeikkailuLaakso.Peli"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:L="clr-namespace:Net.Brotherus.SeikkailuLaakso"
Title="Peli" Height="880" Width="1000" WindowState="Maximized">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Menu>
<MenuItem Header="_Game">
<MenuItem Header="_Save" Click="MenuItem_Click"/>
<MenuItem Header="_Play" Click="PlayGame_Click"/>
</MenuItem>
</Menu>
<ScrollViewer Grid.Row="1" Name="view" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<L:SceneCanvas Width="6000" Height="1200" Background="White"/>
</ScrollViewer>
</Grid>
</Window>
129 changes: 129 additions & 0 deletions Peli.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Polygon = System.Windows.Shapes.Polygon;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Net.Brotherus.SeikkailuLaakso
{
/// <summary>
/// Interaction logic for Peli.xaml
/// </summary>
public partial class Peli : Window
{
private SceneCanvas scene;

public Peli() {
InitializeComponent();
if (File.Exists(this.SaveFileName)) {
using (var stream = new FileStream(this.SaveFileName, FileMode.Open)) {
view.Content = XamlReader.Load(stream);
}
}
this.scene = (SceneCanvas) view.Content;
// Create land if no previous content
if (this.scene.Children.Count == 0)
{
for(int x = 0; x < 12; ++x) {
this.scene.AddRectPolygon(900, x * 200, 200, 100);
}
}
scene.MouseMove += scene_MouseMove;
scene.MouseLeftButtonDown += scene_MouseLeftButtonDown;
scene.MouseLeftButtonUp += scene_MouseLeftButtonUp;
}

private void scene_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
scene.StartDrawing(e);
}

private void scene_MouseMove(object sender, MouseEventArgs e)
{
scene.ContinueDrawing(e);
}

private void scene_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
scene.EndDrawing(e);
}

private string SaveFileName
{
get { return Path.Combine(SaveDir, "SeikkailuMaaRata.xml"); }
}

private string SaveDir
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SeikkailuMaa");
}
}

private void PlayGame_Click(object sender, RoutedEventArgs e)
{
using (var game = new SeikkailuLaaksoGame())
{
int i = 1;
foreach (FrameworkElement sceneItem in scene.Children)
{
var encoder = RenderToBitmap(sceneItem);
string picFile = Path.Combine(SaveDir, "scene_item_" + i.ToString() + ".png");
using (var picStream = new FileStream(picFile, FileMode.Create)) {
encoder.Save(picStream);
}
game.AddPolygonObstacle(picFile, Canvas.GetLeft(sceneItem), Canvas.GetTop(sceneItem));
++i;
}
game.Run();
}
}

[STAThread]
public static void Main()
{
//new Application().Run(new AlkuIkkuna());

new Application().Run(new Peli());

//var peli = new Peli();
//peli.PlayGame_Click(null, null);
}

private static PngBitmapEncoder RenderToBitmap(FrameworkElement sceneItem)
{
UIElement dupItem = (UIElement)XamlReader.Parse(XamlWriter.Save(sceneItem));
Window renderWindow = new Window { Top = 10, Left = 10 };
renderWindow.SizeToContent = SizeToContent.WidthAndHeight;
renderWindow.Content = dupItem;
renderWindow.Show();
var targetBmp = new RenderTargetBitmap(
Convert.ToInt32(sceneItem.ActualWidth), Convert.ToInt32(sceneItem.ActualHeight),
96, 96, PixelFormats.Default);
targetBmp.Render(dupItem);
renderWindow.Close();
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(targetBmp));
return encoder;
}

private void MenuItem_Click(object sender, RoutedEventArgs e)
{
if (!Directory.Exists(SaveDir)) Directory.CreateDirectory(SaveDir);
using (var stream = new FileStream(this.SaveFileName, FileMode.Create))
{
XamlWriter.Save(scene, stream);
}
}

} // class

} // namespace
40 changes: 40 additions & 0 deletions PeliXNA/AngleTargetLimitJoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Dynamics.Joints;
using FarseerGames.FarseerPhysics.Factories;

namespace Net.Brotherus
{
public class AngleTargetLimitJoint
{
AngleJoint _angleJoint;
AngleLimitJoint _limitJoint;

public AngleTargetLimitJoint(PhysicsSimulator physicsSimulator, Body a, Body b, double minDegrees, double targetDegrees, double maxDegrees)
{
_angleJoint = JointFactory.Instance.CreateAngleJoint(physicsSimulator, a, b);
_angleJoint.TargetAngle = MathExt.ToRadians(targetDegrees);
_angleJoint.Softness = 0.5f;
_angleJoint.MaxImpulse = 3000.0f;
_limitJoint = JointFactory.Instance.CreateAngleLimitJoint(
physicsSimulator, a, b, MathExt.ToRadians(minDegrees), MathExt.ToRadians(maxDegrees));
}

public float MaxImpulse { set { _angleJoint.MaxImpulse = value; } }

public float TargetAngleRadians
{
get { return _angleJoint.TargetAngle; }
set
{
if ((value > _limitJoint.LowerLimit) && (value < _limitJoint.UpperLimit))
{
_angleJoint.TargetAngle = value;
}
}
}

public float TargetAngleDegrees { set { TargetAngleRadians = MathExt.ToRadians(value); } }
}
}
Binary file added PeliXNA/Content/Common/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PeliXNA/Content/Common/blank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PeliXNA/Content/Common/gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added PeliXNA/Content/Common/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions PeliXNA/Content/Content.contentproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>d02ca378-a184-49ad-91d5-c017d1559cac</ProjectGuid>
<ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<XnaFrameworkVersion>v3.0</XnaFrameworkVersion>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\$(Platform)\$(Configuration)</OutputPath>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<XnaPlatform>Windows</XnaPlatform>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<XnaPlatform>Windows</XnaPlatform>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Common\background.png">
<Name>background</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="Common\blank.png">
<Name>blank</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="Common\gradient.png">
<Name>gradient</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="Common\logo.png">
<Name>logo</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Fonts\detailsFont.spritefont">
<Name>detailsFont</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
<Compile Include="Fonts\diagnosticFont.spritefont">
<Name>diagnosticFont</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
<Compile Include="Fonts\frameRateCounterFont.spritefont">
<Name>frameRateCounterFont</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
<Compile Include="Fonts\gamefont.spritefont">
<Name>gamefont</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
<Compile Include="Fonts\menufont.spritefont">
<Name>menufont</Name>
<Importer>FontDescriptionImporter</Importer>
<Processor>FontDescriptionProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v3.0\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- 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>
1 change: 1 addition & 0 deletions PeliXNA/Content/Content.contentproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
10 changes: 10 additions & 0 deletions PeliXNA/Content/Content.contentproj.vspscc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}
15 changes: 15 additions & 0 deletions PeliXNA/Content/Fonts/detailsFont.spritefont
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<FontName>Courier New</FontName>
<Size>10</Size>
<Spacing>1</Spacing>
<Style>Bold</Style>
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
15 changes: 15 additions & 0 deletions PeliXNA/Content/Fonts/diagnosticFont.spritefont
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<FontName>Courier New</FontName>
<Size>10</Size>
<Spacing>1</Spacing>
<Style>Bold</Style>
<CharacterRegions>
<CharacterRegion>
<Start>&#32;</Start>
<End>&#126;</End>
</CharacterRegion>
</CharacterRegions>
</Asset>
</XnaContent>
Loading

0 comments on commit 1602d6f

Please sign in to comment.