Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
GoneBananas example WinDX version
Browse files Browse the repository at this point in the history
  • Loading branch information
netonjm committed Aug 25, 2014
1 parent 00ad318 commit 68e4202
Show file tree
Hide file tree
Showing 15 changed files with 452 additions and 7 deletions.
45 changes: 38 additions & 7 deletions GoneBananas/GoneBananasShared/GameLayer.cs
Expand Up @@ -4,6 +4,10 @@
using CocosSharp;
using System.Linq;

#if NETFX_CORE

#endif

using Box2D.Common;
using Box2D.Dynamics;
using Box2D.Collision.Shapes;
Expand Down Expand Up @@ -196,17 +200,40 @@ void MoveClouds (float dy)

void CheckCollision ()
{

#if !NETFX_CORE
visibleBananas.ForEach (banana => {
bool hit = banana.BoundingBoxTransformedToParent.IntersectsRect (monkey.BoundingBoxTransformedToParent);
if (hit) {
hitBananas.Add (banana);
CCSimpleAudioEngine.SharedEngine.PlayEffect ("Sounds/tap");
Explode (banana.Position);
banana.RemoveFromParent ();
#else
foreach (var banana in visibleBananas)
{
#endif
bool hit = banana.BoundingBoxTransformedToParent.IntersectsRect(monkey.BoundingBoxTransformedToParent);
if (hit)
{
hitBananas.Add(banana);
CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/tap");
Explode(banana.Position);
banana.RemoveFromParent();
}
#if !NETFX_CORE
});
#else
}
#endif

hitBananas.ForEach (banana => visibleBananas.Remove (banana));
#if !NETFX_CORE
hitBananas.ForEach (banana => {
#else
foreach (var banana in hitBananas)
{
#endif
visibleBananas.Remove(banana);
#if !NETFX_CORE
});
#else
}
#endif
int ballHitCount = ballsBatch.Children.Count (ball => ball.BoundingBoxTransformedToParent.IntersectsRect (monkey.BoundingBoxTransformedToParent));
Expand Down Expand Up @@ -329,7 +356,11 @@ void AddBall ()
sprite.PhysicsBody = body;
#if !NETFX_CORE
Console.WriteLine ("sprite batch node count = {0}", ballsBatch.ChildrenCount);
#else
#endif
}
public override void OnEnter ()
Expand Down
34 changes: 34 additions & 0 deletions GoneBananas/GoneBananasWindowsDX.sln
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoneBananas", "win32\GoneBananas.csproj", "{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Debug|Any CPU.ActiveCfg = Debug|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Debug|ARM.ActiveCfg = Debug|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Debug|x64.ActiveCfg = Debug|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Debug|x86.ActiveCfg = Debug|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Debug|x86.Build.0 = Debug|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Release|Any CPU.ActiveCfg = Release|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Release|ARM.ActiveCfg = Release|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Release|x64.ActiveCfg = Release|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Release|x86.ActiveCfg = Release|x86
{C2AA92EF-1C66-4100-B17B-613EA7CB7BCC}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added GoneBananas/win32/Content/Sounds/tap.xnb
Binary file not shown.
Binary file added GoneBananas/win32/Content/fonts/MarkerFelt-22.xnb
Binary file not shown.
Binary file added GoneBananas/win32/Content/fonts/arial-22.xnb
Binary file not shown.
139 changes: 139 additions & 0 deletions GoneBananas/win32/Content/hd/animations/monkey.plist
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>Banana-hd.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{44,108}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{44,108}}</string>
<key>sourceSize</key>
<string>{44,108}</string>
</dict>
<key>frame-1.png</key>
<dict>
<key>frame</key>
<string>{{48,2},{391,555}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{391,555}}</string>
<key>sourceSize</key>
<string>{391,555}</string>
</dict>
<key>frame-2.png</key>
<dict>
<key>frame</key>
<string>{{441,2},{390,553}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{390,553}}</string>
<key>sourceSize</key>
<string>{390,553}</string>
</dict>
<key>frame-3.png</key>
<dict>
<key>frame</key>
<string>{{833,2},{387,566}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{387,566}}</string>
<key>sourceSize</key>
<string>{387,566}</string>
</dict>
<key>frame-4.png</key>
<dict>
<key>frame</key>
<string>{{1222,2},{386,579}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{386,579}}</string>
<key>sourceSize</key>
<string>{386,579}</string>
</dict>
<key>frame-5.png</key>
<dict>
<key>frame</key>
<string>{{1610,2},{387,573}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{387,573}}</string>
<key>sourceSize</key>
<string>{387,573}</string>
</dict>
<key>frame-6.png</key>
<dict>
<key>frame</key>
<string>{{2,583},{389,560}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{389,560}}</string>
<key>sourceSize</key>
<string>{389,560}</string>
</dict>
<key>frame-7.png</key>
<dict>
<key>frame</key>
<string>{{393,583},{390,553}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{390,553}}</string>
<key>sourceSize</key>
<string>{390,553}</string>
</dict>
<key>frame-8.png</key>
<dict>
<key>frame</key>
<string>{{785,583},{389,557}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{389,557}}</string>
<key>sourceSize</key>
<string>{389,557}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>monkey.png</string>
<key>size</key>
<string>{2048,2048}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:c63ac17999f746ee253cb9e63215058f:7b9d55d9c4db1e73987b80a4545fa776:c408e1678cc8476d89ba18c5256b3484$</string>
<key>textureFileName</key>
<string>monkey.png</string>
</dict>
</dict>
</plist>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GoneBananas/win32/Content/hd/balls.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GoneBananas/win32/Content/hd/cloud.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GoneBananas/win32/Content/hd/grass.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added GoneBananas/win32/Game.ico
Binary file not shown.
82 changes: 82 additions & 0 deletions GoneBananas/win32/Game1.cs
@@ -0,0 +1,82 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using CocosSharp;

namespace SkyDefense.Windows
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Game
{
private readonly GraphicsDeviceManager graphics;

public Game1()
{
graphics = new GraphicsDeviceManager(this);
//#if MACOS
// Content.RootDirectory = "AngryNinjas/Content";
//#else
Content.RootDirectory = "Content";
//#endif
//
//#if XBOX || OUYA
// graphics.IsFullScreen = true;
//#else
graphics.IsFullScreen = false;
//#endif

// Frame rate is 30 fps by default for Windows Phone.
TargetElapsedTime = TimeSpan.FromTicks(333333 / 2);

// Extend battery life under lock.
//InactiveSleepTime = TimeSpan.FromSeconds(1);

CCApplication application = new AppDelegate(this, graphics);
Components.Add(application);
//#if XBOX || OUYA
// CCDirector.SharedDirector.GamePadEnabled = true;


// application.GamePadButtonUpdate += new CCGamePadButtonDelegate(application_GamePadButtonUpdate);
//#endif
}

//#if XBOX || OUYA
// private void application_GamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, PlayerIndex player)
// {
// if (backButton == CCGamePadButtonStatus.Pressed)
// {
// ProcessBackClick();
// }
// }
//#endif

private void ProcessBackClick()
{
if (CCDirector.SharedDirector.IsCanPopScene)
{
CCDirector.SharedDirector.PopScene();
}
else
{
Exit();
}
}

protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
{
ProcessBackClick();
}

// TODO: Add your update logic here


base.Update(gameTime);
}
}
}

0 comments on commit 68e4202

Please sign in to comment.