├── .gitignore ├── ChipmunkSharp.nuspec ├── ChipmunkSharp.sln ├── ChipmunkSharp ├── ChipmunkSharp.csproj ├── Common │ ├── cp.cs │ ├── cpColor.cs │ └── cpDebugDraw.cs ├── Constraints │ ├── cpConstraint.cs │ ├── cpDampedRotarySpring.cs │ ├── cpDampedSpring.cs │ ├── cpGearJoint.cs │ ├── cpGrooveJoint.cs │ ├── cpPinJoint.cs │ ├── cpPivotJoint.cs │ ├── cpRatchetJoint.cs │ ├── cpRotaryLimitJoint.cs │ ├── cpSimpleMotor.cs │ └── cpSlideJoint.cs ├── Helpers │ └── RandomHelper.cs ├── IDrawDelegate.cs ├── Rectangle.cs ├── Shapes │ ├── cpPolyShape.cs │ ├── cpQueryInfo.cs │ └── cpShape.cs ├── cpArbiter.cs ├── cpBB.cs ├── cpBBTree.cs ├── cpBody.cs ├── cpCollision.cs ├── cpContact.cs ├── cpSpace.cs ├── cpSpaceComponent.cs ├── cpSpaceQuery.cs ├── cpSpaceStep.cs ├── cpTransform.cs └── cpVect.cs ├── LICENSE ├── README.md ├── default.build ├── logo └── logo.png ├── nuget.exe ├── old ├── PCL │ ├── ChipmunkSharp.PCL.sln │ └── ChipmunkSharpPCLShared │ │ ├── Box2DAPI.cs │ │ ├── ChipmunkSharp.PCL.Shared.csproj │ │ ├── CocosSharpAPI.cs │ │ ├── MonoGame.FrameworkAPI.cs │ │ └── Properties │ │ └── AssemblyInfo.cs ├── examples │ └── ChipmunkExample │ │ ├── .vs │ │ └── ChipmunkExampleMac │ │ │ └── xs │ │ │ ├── UserPrefs.xml │ │ │ └── sqlite3 │ │ │ ├── db.lock │ │ │ └── storage.ide │ │ ├── ChipmunkExampleMac.sln │ │ ├── ChipmunkExampleW8.sln │ │ ├── Chipmunkv7Example.sln │ │ ├── Chipmunkv7ExampleWP8.sln │ │ ├── Common │ │ ├── ChipmunkDemoLayer.cs │ │ ├── Extensions │ │ │ ├── CCChipmunkDebugDraw.cs │ │ │ ├── CCMouse.cs │ │ │ ├── CCPhysicsDebugNode .cs │ │ │ ├── CCPhysicsSprite.cs │ │ │ ├── LogoNode.cs │ │ │ ├── PhysicsSprite.cs │ │ │ ├── PlayerIndex.cs │ │ │ └── cpExtension.cs │ │ ├── Helpers │ │ │ └── Extensions.cs │ │ └── Layers │ │ │ ├── ballLayer.cs │ │ │ ├── benchLayer.cs │ │ │ ├── buoyancyLayer.cs │ │ │ ├── chainsLayer.cs │ │ │ ├── contactGraphLayer.cs │ │ │ ├── contactPointsLayer.cs │ │ │ ├── convexLayer.cs │ │ │ ├── craneLayer.cs │ │ │ ├── gjkLayer.cs │ │ │ ├── grossiniDanceLayer.cs │ │ │ ├── jointsLayer.cs │ │ │ ├── logoSmashLayer.cs │ │ │ ├── oneWayLayer.cs │ │ │ ├── planetLayer.cs │ │ │ ├── playerLayer.cs │ │ │ ├── plinkLayer.cs │ │ │ ├── pumpLayer.cs │ │ │ ├── pyramidLayer.cs │ │ │ ├── pyramidToppleLayer.cs │ │ │ ├── queryLayer.cs │ │ │ ├── shatterLayer.cs │ │ │ ├── sliceLayer.cs │ │ │ ├── smoothLayer.cs │ │ │ ├── springiesLayer.cs │ │ │ ├── stickyLayer.cs │ │ │ ├── tankLayer.cs │ │ │ ├── theoJansenLayer.cs │ │ │ ├── tumbleLayer.cs │ │ │ └── unicycleLayer.cs │ │ ├── ContentPipeline │ │ ├── ContentPipeline │ │ │ ├── ContentPipeline.csproj │ │ │ ├── Game.ico │ │ │ ├── Game1.cs │ │ │ ├── GameThumbnail.png │ │ │ ├── Program.cs │ │ │ └── Properties │ │ │ │ └── AssemblyInfo.cs │ │ └── ContentPipelineContent │ │ │ ├── ContentPipelineContent.contentproj │ │ │ ├── weblysleeku-22.spritefont │ │ │ └── weblysleekuisb-22.spritefont │ │ ├── Resources │ │ ├── fonts │ │ │ ├── MarkerFelt-22.xnb │ │ │ ├── weblysleeku-22.xnb │ │ │ └── weblysleekuisb-22.xnb │ │ ├── png │ │ │ ├── Background-alone.png │ │ │ ├── Background.png │ │ │ ├── arrow-left-press.png │ │ │ ├── arrow-left.png │ │ │ ├── arrow-right-press.png │ │ │ ├── arrow-right.png │ │ │ ├── btn-clear-press.png │ │ │ ├── btn-clear.png │ │ │ ├── btn-reset-press.png │ │ │ ├── btn-reset.png │ │ │ ├── fps_images.png │ │ │ ├── grossini_dance_atlas.png │ │ │ ├── xamarin-img-raster.png │ │ │ └── xamarin-logo-no-shadow.png │ │ └── xnb │ │ │ ├── Background-alone.xnb │ │ │ ├── Background.xnb │ │ │ ├── arrow-left-press.xnb │ │ │ ├── arrow-left.xnb │ │ │ ├── arrow-right-press.xnb │ │ │ ├── arrow-right.xnb │ │ │ ├── btn-clear-press.xnb │ │ │ ├── btn-clear.xnb │ │ │ ├── btn-reset-press.xnb │ │ │ ├── btn-reset.xnb │ │ │ ├── fps_images.xnb │ │ │ ├── grossini_dance_atlas.xnb │ │ │ ├── xamarin-img-raster.xnb │ │ │ └── xamarin-logo-no-shadow.xnb │ │ ├── UpgradeLog.htm │ │ ├── macosx │ │ ├── ChipmunkExampleMac.csproj │ │ ├── Info.plist │ │ └── Program.cs │ │ ├── win32 │ │ ├── AppDelegate.cs │ │ ├── Chipmunkv7Example.csproj │ │ ├── Game.ico │ │ ├── Program.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── win8 │ │ ├── AppDelegate.cs │ │ ├── Assets │ │ │ ├── Logo.png │ │ │ ├── SmallLogo.png │ │ │ ├── SplashScreen.png │ │ │ └── StoreLogo.png │ │ ├── ChipmunkJSExampleW8.csproj │ │ ├── Content │ │ │ └── fonts │ │ │ │ └── MarkerFelt-22.xnb │ │ ├── Package.appxmanifest │ │ ├── Program.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── Spine.Store_TemporaryKey.pfx │ │ └── wp8 │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── AppDelegate.cs │ │ ├── Assets │ │ ├── AlignmentGrid.png │ │ ├── ApplicationIcon.png │ │ └── Tiles │ │ │ ├── FlipCycleTileLarge.png │ │ │ ├── FlipCycleTileMedium.png │ │ │ ├── FlipCycleTileSmall.png │ │ │ ├── IconicTileMediumLarge.png │ │ │ └── IconicTileSmall.png │ │ ├── Chipmunkv7ExampleW8.csproj │ │ ├── Content │ │ ├── Background-alone.xnb │ │ ├── Background.xnb │ │ ├── Default.xnb │ │ ├── arrow-left-press.xnb │ │ ├── arrow-left.xnb │ │ ├── arrow-right-press.xnb │ │ ├── arrow-right.xnb │ │ ├── btn-clear-press.xnb │ │ ├── btn-clear.xnb │ │ ├── btn-reset-press.xnb │ │ ├── btn-reset.xnb │ │ ├── fonts │ │ │ ├── MarkerFelt-22.xnb │ │ │ ├── weblysleeku-22.xnb │ │ │ └── weblysleekuisb-22.xnb │ │ ├── fps_images.xnb │ │ ├── grossini_dance_atlas.xnb │ │ ├── xamarin-img-raster.xnb │ │ └── xamarin-logo-no-shadow.xnb │ │ ├── GamePage.xaml │ │ ├── GamePage.xaml.cs │ │ ├── IntroLayer.cs │ │ ├── LocalizedStrings.cs │ │ ├── Properties │ │ ├── AppManifest.xml │ │ ├── AssemblyInfo.cs │ │ └── WMAppManifest.xml │ │ └── Resources │ │ ├── AppResources.Designer.cs │ │ └── AppResources.resx └── original.sources │ ├── cplus │ └── src │ │ ├── CMakeLists.txt │ │ ├── chipmunk.c │ │ ├── chipmunk.h │ │ ├── chipmunk_ffi.h │ │ ├── chipmunk_private.h │ │ ├── chipmunk_types.h │ │ ├── chipmunk_unsafe.h │ │ ├── constraints │ │ ├── cpConstraint.c │ │ ├── cpConstraint.h │ │ ├── cpDampedRotarySpring.c │ │ ├── cpDampedRotarySpring.h │ │ ├── cpDampedSpring.c │ │ ├── cpDampedSpring.h │ │ ├── cpGearJoint.c │ │ ├── cpGearJoint.h │ │ ├── cpGrooveJoint.c │ │ ├── cpGrooveJoint.h │ │ ├── cpPinJoint.c │ │ ├── cpPinJoint.h │ │ ├── cpPivotJoint.c │ │ ├── cpPivotJoint.h │ │ ├── cpRatchetJoint.c │ │ ├── cpRatchetJoint.h │ │ ├── cpRotaryLimitJoint.c │ │ ├── cpRotaryLimitJoint.h │ │ ├── cpSimpleMotor.c │ │ ├── cpSimpleMotor.h │ │ ├── cpSlideJoint.c │ │ ├── cpSlideJoint.h │ │ └── util.h │ │ ├── cpArbiter.c │ │ ├── cpArbiter.h │ │ ├── cpArray.c │ │ ├── cpBB.c │ │ ├── cpBB.h │ │ ├── cpBBTree.c │ │ ├── cpBody.c │ │ ├── cpBody.h │ │ ├── cpCollision.c │ │ ├── cpHashSet.c │ │ ├── cpPolyShape.c │ │ ├── cpPolyShape.h │ │ ├── cpShape.c │ │ ├── cpShape.h │ │ ├── cpSpace.c │ │ ├── cpSpace.h │ │ ├── cpSpaceComponent.c │ │ ├── cpSpaceHash.c │ │ ├── cpSpaceQuery.c │ │ ├── cpSpaceStep.c │ │ ├── cpSpatialIndex.c │ │ ├── cpSpatialIndex.h │ │ ├── cpSweep1D.c │ │ ├── cpVect.c │ │ ├── cpVect.h │ │ └── prime.h │ └── javascript │ ├── .gitignore │ ├── Makefile │ ├── README.md │ ├── benchmark │ ├── bench.html │ ├── bench.js │ └── mersenne.js │ ├── cp.extra.js │ ├── cp.js │ ├── cp.min.js │ ├── demo │ ├── Convex.html │ ├── Convex.js │ ├── Joints.html │ ├── Joints.js │ ├── LogoSmash.js │ ├── PyramidStack.html │ ├── PyramidStack.js │ ├── PyramidTopple.html │ ├── PyramidTopple.js │ ├── Query.html │ ├── Query.js │ ├── ball.html │ ├── ball.js │ ├── buoyancy.html │ ├── buoyancy.js │ ├── demo.js │ ├── grossiniDanceLayer.html │ ├── grossiniDanceLayer.js │ └── index.html │ ├── lib │ ├── chipmunk.js │ ├── constraints │ │ ├── cpConstraint.js │ │ ├── cpDampedRotarySpring.js │ │ ├── cpDampedSpring.js │ │ ├── cpGearJoint.js │ │ ├── cpGrooveJoint.js │ │ ├── cpPinJoint.js │ │ ├── cpPivotJoint.js │ │ ├── cpRatchetJoint.js │ │ ├── cpRotaryLimitJoint.js │ │ ├── cpSimpleMotor.js │ │ ├── cpSlideJoint.js │ │ └── util.js │ ├── cpArbiter.js │ ├── cpBB.js │ ├── cpBBTree.js │ ├── cpBody.js │ ├── cpCollision.js │ ├── cpPolyShape.js │ ├── cpShape.js │ ├── cpSpace.js │ ├── cpSpaceComponent.js │ ├── cpSpaceQuery.js │ ├── cpSpaceStep.js │ ├── cpSpatialIndex.js │ └── cpVect.js │ └── package.json └── samples ├── ChipmunkSharp.Example.Cocoa ├── AppDelegate.cs ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── AppIcon-128.png │ │ ├── AppIcon-128@2x.png │ │ ├── AppIcon-16.png │ │ ├── AppIcon-16@2x.png │ │ ├── AppIcon-256.png │ │ ├── AppIcon-256@2x.png │ │ ├── AppIcon-32.png │ │ ├── AppIcon-32@2x.png │ │ ├── AppIcon-512.png │ │ ├── AppIcon-512@2x.png │ │ └── Contents.json │ └── Contents.json ├── ChipmunkSharp.Example.Cocoa.csproj ├── CocoaDrawDelegate.cs ├── CocoaHelpers.cs ├── Entitlements.plist ├── Games │ ├── Game1.cs │ ├── GameBase.cs │ ├── GameObject.cs │ └── PhysicObject.cs ├── Info.plist ├── Main.cs ├── PhysicsDrawView.cs └── Resources │ ├── basketball.png │ ├── beachball.png │ └── football.png ├── ChipmunkSharp.Example.MonoGame ├── ChipmunkSharp.Example.MonoGame.csproj ├── Content │ ├── Content.mgcb │ ├── rose.png │ └── square.png ├── Game1.cs ├── GameObject.cs ├── Icon.bmp ├── Icon.ico ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── app.manifest └── ChipmunkSharp.Example.iOS ├── AppDelegate.cs ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── ChipmunkSharp.Example.iOS.csproj ├── Entitlements.plist ├── Games ├── Game1.cs ├── GameBase.cs ├── GameObject.cs └── PhysicObject.cs ├── Info.plist ├── LaunchScreen.storyboard ├── Main.cs ├── Main.storyboard ├── Resources ├── basketball.png ├── beachball.png └── football.png ├── ViewController.cs └── ViewController.designer.cs /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | *.cachefile 44 | *.pidb 45 | *.userprefs 46 | 47 | # Build results 48 | [Dd]ebug/ 49 | [Rr]elease/ 50 | *_i.c 51 | *_p.c 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.vspscc 66 | .builds 67 | *.dotCover 68 | 69 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 70 | #packages/ 71 | 72 | # Visual C++ cache files 73 | ipch/ 74 | *.aps 75 | *.ncb 76 | *.opensdf 77 | *.sdf 78 | 79 | # Visual Studio profiler 80 | *.psess 81 | *.vsp 82 | 83 | # ReSharper is a .NET coding add-in 84 | _ReSharper* 85 | 86 | # Installshield output folder 87 | [Ee]xpress 88 | 89 | # DocProject is a documentation generator add-in 90 | DocProject/buildhelp/ 91 | DocProject/Help/*.HxT 92 | DocProject/Help/*.HxC 93 | DocProject/Help/*.hhc 94 | DocProject/Help/*.hhk 95 | DocProject/Help/*.hhp 96 | DocProject/Help/Html2 97 | DocProject/Help/html 98 | 99 | # Click-Once directory 100 | publish 101 | 102 | # Others 103 | [Bb]in 104 | [Oo]bj 105 | sql 106 | TestResults 107 | *.Cache 108 | ClientBin 109 | stylecop.* 110 | ~$* 111 | *.dbmdl 112 | Generated_Code #added for RIA/Silverlight projects 113 | 114 | # Backup & report files from converting an old project file to a newer 115 | # Visual Studio version. Backup files are not needed, because we have git ;-) 116 | _UpgradeReport_Files/ 117 | Backup*/ 118 | UpgradeLog*.XML 119 | 120 | 121 | 122 | ############ 123 | ## Windows 124 | ############ 125 | 126 | # Windows image file caches 127 | Thumbs.db 128 | 129 | # Folder config file 130 | Desktop.ini 131 | 132 | 133 | ############# 134 | ## Python 135 | ############# 136 | 137 | *.py[co] 138 | 139 | # Packages 140 | *.egg 141 | *.egg-info 142 | dist 143 | build 144 | eggs 145 | parts 146 | bin 147 | var 148 | sdist 149 | develop-eggs 150 | .installed.cfg 151 | 152 | # Installer logs 153 | pip-log.txt 154 | 155 | # Unit test / coverage reports 156 | .coverage 157 | .tox 158 | 159 | #Translations 160 | *.mo 161 | 162 | #Mr Developer 163 | .mr.developer.cfg 164 | 165 | # Mac crap 166 | .DS_Store 167 | /ProjectTemplates/NuGet/output 168 | packages 169 | /chipmunk.png 170 | /chipmunk.ico 171 | 172 | /example/MonoGameChipmunkExample 173 | /example/Cocos2dChipmunkExample 174 | -------------------------------------------------------------------------------- /ChipmunkSharp.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ChipmunkSharp 5 | 7.0.1 6 | ChipmunkSharp v7 7 | Jose Medrano 8 | Jose Medrano 9 | MIT 10 | https://github.com/netonjm/ChipmunkSharp 11 | https://raw.githubusercontent.com/netonjm/ChipmunkSharp/v7.0.0.Leaf/logo/logo.png 12 | false 13 | ChipmunkSharp is a lightweight physic engine completely written in C# targeting .NET Standart v1.0 14 | netonjm 15 | chipmunk netcore visualization enginedirectx desktop windows 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ChipmunkSharp/ChipmunkSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard1.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ChipmunkSharp/Constraints/cpSimpleMotor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // cpSimpleMotor.cs 3 | // 4 | // Author: 5 | // Jose Medrano 6 | // 7 | // Copyright (c) 2015 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | 27 | using System; 28 | namespace ChipmunkSharp 29 | { 30 | 31 | public class cpSimpleMotor : cpConstraint 32 | { 33 | 34 | internal float rate; 35 | internal float iSum; 36 | internal float jAcc; 37 | 38 | public override void PreStep(float dt) 39 | { 40 | 41 | cpBody a = this.a; 42 | cpBody b = this.b; 43 | 44 | // calculate moment of inertia coefficient. 45 | this.iSum = 1.0f / (a.i_inv + b.i_inv); 46 | } 47 | 48 | public override void ApplyCachedImpulse(float dt_coef) 49 | { 50 | cpBody a = this.a; 51 | cpBody b = this.b; 52 | 53 | float j = this.jAcc * dt_coef; 54 | a.w -= j * a.i_inv; 55 | b.w += j * b.i_inv; 56 | } 57 | 58 | 59 | public override void ApplyImpulse(float dt) 60 | { 61 | 62 | cpBody a = this.a; 63 | cpBody b = this.b; 64 | 65 | // compute relative rotational velocity 66 | float wr = b.w - a.w + this.rate; 67 | 68 | float jMax = this.maxForce * dt; 69 | 70 | // compute normal impulse 71 | float j = -wr * this.iSum; 72 | float jOld = this.jAcc; 73 | this.jAcc = cp.cpfclamp(jOld + j, -jMax, jMax); 74 | j = this.jAcc - jOld; 75 | 76 | // apply impulse 77 | a.w -= j * a.i_inv; 78 | b.w += j * b.i_inv; 79 | 80 | } 81 | 82 | public override float GetImpulse() 83 | { 84 | return cp.cpfabs(jAcc); 85 | } 86 | 87 | 88 | 89 | 90 | public cpSimpleMotor(cpBody a, cpBody b, float rate) 91 | : base(a, b) 92 | { 93 | 94 | this.rate = rate; 95 | 96 | this.jAcc = 0.0f; 97 | 98 | } 99 | 100 | 101 | 102 | public override void SetRate(float rate) 103 | { 104 | ActivateBodies(); 105 | this.rate = rate; 106 | } 107 | 108 | 109 | public override float GetRate() 110 | { 111 | return rate; 112 | } 113 | 114 | 115 | 116 | } 117 | 118 | 119 | } -------------------------------------------------------------------------------- /ChipmunkSharp/Helpers/RandomHelper.cs: -------------------------------------------------------------------------------- 1 | // 2 | // RandomHelper.cs 3 | // 4 | // Author: 5 | // Jose Medrano 6 | // 7 | // Copyright (c) 2015 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | 32 | namespace ChipmunkSharp 33 | { 34 | public class RandomHelper 35 | { 36 | public static Random random = new Random(DateTime.Now.Millisecond); 37 | 38 | public static int RAND_MAX = 0x7fff; 39 | 40 | public static float next(float min, float max) 41 | { 42 | return (float)((max - min) * random.NextDouble() + min); 43 | } 44 | 45 | public static int rand() 46 | { 47 | return random.Next(); 48 | } 49 | 50 | public static float randBell(float scale) 51 | { 52 | return (float)((scale) * (-(frand(.5f) + frand(.5f) + frand(.5f)))); 53 | } 54 | 55 | 56 | public static float frand() //HACK 57 | { 58 | //float tmp = ((rand.Nextfloat() * f) / ((float) (/*(uint)~0*/ 0xFFFFFFFF /*or is it -1 :P */))); 59 | //return tmp < 0 ? (-tmp) : tmp; 60 | return (float)(random.NextDouble()); 61 | } 62 | 63 | /// 64 | /// This is bit spooky conversion of C -> C#... 65 | /// 66 | public static float frand(float f) //HACK 67 | { 68 | //float tmp = ((rand.Nextfloat() * f) / ((float) (/*(uint)~0*/ 0xFFFFFFFF /*or is it -1 :P */))); 69 | //return tmp < 0 ? (-tmp) : tmp; 70 | return frand() * f; 71 | } 72 | 73 | public static float FastDistance2D(float x, float y) 74 | { 75 | // this function computes the distance from 0,0 to x,y with ~3.5% error 76 | float mn; 77 | // first compute the absolute value of x,y 78 | x = (x < 0.0f) ? -x : x; 79 | y = (y < 0.0f) ? -y : y; 80 | 81 | // compute the minimum of x,y 82 | mn = x < y ? x : y; 83 | 84 | // return the distance 85 | //return(x+y-(mn*0.5f)-(mn*0.25f)+(mn*0.0625f)); 86 | return x + y - mn * .6875f; 87 | 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /ChipmunkSharp/IDrawDelegate.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | 4 | namespace ChipmunkSharp 5 | { 6 | [Flags] 7 | public enum PhysicsDrawFlags 8 | { 9 | 10 | None = 1 << 0, 11 | /// 12 | /// Draw shapes. 13 | /// 14 | Shapes = 1 << 1, 15 | 16 | /// 17 | /// Draw joint connections. 18 | /// 19 | Joints = 1 << 2, 20 | 21 | /// 22 | /// Draw contact points. 23 | /// 24 | ContactPoints = 1 << 3, 25 | 26 | /// 27 | /// Draw polygon BB. 28 | /// 29 | BB = 1 << 4, 30 | 31 | /// 32 | /// Draw All connections. 33 | /// 34 | All = 1 << 10, 35 | } 36 | 37 | public interface IDrawDelegate 38 | { 39 | void DrawCircle (cpVect center, float radius, cpColor color); 40 | void DrawSolidCircle (cpVect center, float radius, cpColor color); 41 | void DrawCircle (cpVect center, float radius, float angle, int segments, cpColor color); 42 | void DrawDot (cpVect pos, float radius, cpColor color); 43 | void DrawPolygon (cpVect[] verts, int count, cpColor fillColor, float borderWidth, cpColor borderColor); 44 | void DrawRect (Rectangle rect, cpColor color); 45 | void DrawSegment (cpVect from, cpVect to, float radius, cpColor color); 46 | void Draw (cpPolyShape poly, cpColor color); 47 | void Draw (cpBB bb); 48 | void Draw (cpBB bb, cpColor color); 49 | void Draw (cpContact contact); 50 | void Draw (cpCircleShape circle, cpColor color); 51 | void Draw (cpSegmentShape seg, cpColor color); 52 | void DrawFatSegment (cpVect ta, cpVect tb, float r, cpColor color); 53 | void Draw (cpVect point); 54 | void Draw (cpVect point, cpColor color); 55 | void Draw (cpVect point, float radius); 56 | void Draw (cpVect point, float radius, cpColor color); 57 | 58 | //DRAW CONSTRAINT 59 | void Draw (cpDampedRotarySpring constraint); 60 | void Draw (cpDampedSpring constraint); 61 | void Draw (cpSimpleMotor cpSimpleMotor); 62 | void Draw (cpGrooveJoint constraint); 63 | void Draw (cpPivotJoint constraint); 64 | void Draw (cpSlideJoint constraint); 65 | void Draw (cpPinJoint constraint); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /ChipmunkSharp/Rectangle.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace ChipmunkSharp 3 | { 4 | public class Rectangle 5 | { 6 | public int X { get; set; } 7 | public int Y { get; set; } 8 | public int Width { get; set; } 9 | public int Height { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ChipmunkSharp/cpContact.cs: -------------------------------------------------------------------------------- 1 | // 2 | // cpContact.cs 3 | // 4 | // Author: 5 | // Jose Medrano 6 | // 7 | // Copyright (c) 2015 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | 27 | namespace ChipmunkSharp 28 | { 29 | public class cpContact 30 | { 31 | //public cpVect p, n; 32 | //public float dist; 33 | 34 | public cpVect r1, r2; 35 | public float nMass, tMass, bounce; 36 | 37 | public float jnAcc, jtAcc, jBias; 38 | public float bias; 39 | 40 | public ulong hash; 41 | 42 | public override string ToString() 43 | { 44 | return string.Format("{0}: p({1}),n({2})", hash, r1, r2); 45 | } 46 | 47 | public cpContact(cpVect r1, cpVect r2, ulong hash) 48 | { 49 | Init(r1, r2, hash); 50 | } 51 | 52 | //public cpContact Clone() 53 | //{ 54 | // cpContact tmp = new cpContact(p, n, dist, hash); 55 | // return tmp; 56 | //} 57 | 58 | public void Init(cpVect r1, cpVect r2, ulong hash) 59 | { 60 | this.r1 = r1; 61 | this.r2 = r2; 62 | //this.dist = dist; 63 | 64 | // this.r1 = this.r2 = cpVect.Zero; 65 | this.nMass = this.tMass = this.bounce = this.bias = 0; 66 | 67 | this.jnAcc = this.jtAcc = this.jBias = 0; 68 | this.hash = hash; 69 | cp.numContacts++; 70 | } 71 | 72 | //public void Draw(cpDebugDraw m_debugDraw) 73 | //{ 74 | // m_debugDraw.DrawPoint(r1, 1, cpColor.Red); 75 | // m_debugDraw.DrawPoint(r2, 1, cpColor.Red); 76 | //} 77 | 78 | }; 79 | } 80 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Develop Studios 4 | Copyright 2014 Jose Medrano (@netonjm) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![alt tag](http://files.slembcke.net/chipmunk/logo/logo1_med.png) 2 | 3 | NOTE! 4 | 5 | The master branch is the in progress ChipmunkSharp 7.0 based on Chipmunk2D 7.0. The documentation on ChipmunkSharp website may not completely match. While the code should be pretty stable (there are some unit tests), the API is still evolving. You can check out the 6.x branch if you want the last released version. 6 | 7 | ABOUT: 8 | 9 | ChipmunkSharp is a simple, lightweight, fast and portable 2D rigid body physics library written in C# based on Scott Lembcke Chipmunk2D Engine. It's licensed under the unrestrictive MIT license. 10 | 11 | FEATURES: 12 | 13 | * Designed specifically for 2D video games. 14 | * Circle, convex polygon, and beveled line segment collision primitives. 15 | * Multiple collision primitives can be attached to a single rigid body. 16 | * Fast broad phase collision detection by using a bounding box tree with great temporal coherence or a spatial hash. 17 | * Extremely fast impulse solving by utilizing Erin Catto's contact persistence algorithm. 18 | * Supports sleeping objects that have come to rest to reduce the CPU load. 19 | * Support for collision event callbacks based on user definable object types types. 20 | * Flexible collision filtering system with layers, exclusion groups and callbacks. 21 | ** Can be used to create all sorts of effects like one way platforms or buoyancy areas. (Examples included) 22 | * Supports nearest point, segment (raycasting), shape and bounding box queries to the collision detection system. 23 | * Collision impulses amounts can be retrieved for gameplay effects, sound effects, etc. 24 | * Large variety of joints - easily make vehicles, ragdolls, and more. 25 | * Joint callbacks. 26 | ** Can be used to easily implement breakable or animated joints. (Examples included) 27 | * Maintains a contact graph of all colliding objects. 28 | * Lightweight C99 implementation with no external dependencies outside of the Std. C library. 29 | * "Many language bindings available":http://chipmunk2d.net/bindingsAndPorts.php. 30 | * Simple, read the "documentation":http://chipmunk2d.net/documentation.php and see! 31 | * Unrestrictive MIT license 32 | 33 | 34 | BUILDING: 35 | 36 | TODO 37 | 38 | 39 | GET UP TO DATE: 40 | 41 | If you got the source from a point release download, you might want to consider getting the latest source from GitHub. Bugs are fixed and new features are added regularly. Big changes are done in branches and tested before merging them in it's rare for the point release downloads to be better or more bug free than the latest code. 42 | 43 | 44 | GETTING STARTED: 45 | 46 | A good starting point is to take a look at the included Demo application. The demos all just set up a Chipmunk simulation space and the demo app draws the graphics directly out of that. This makes it easy to see how the Chipmunk API works without worrying about the graphics code. You are free to use the demo drawing routines in your own projects, though it is certainly not the recommended way of drawing Chipmunk objects as it pokes around at the undocumented/private APIs of Chipmunk. 47 | 48 | 49 | SUPPORT: 50 | 51 | The best way to get support is to visit the "Chipmunk Forums https://chipmunksharp.codeplex.com/discussions 52 | or visit the original Chipmunk2D forum 53 | -------------------------------------------------------------------------------- /logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/logo/logo.png -------------------------------------------------------------------------------- /nuget.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/nuget.exe -------------------------------------------------------------------------------- /old/PCL/ChipmunkSharp.PCL.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChipmunkSharp.PCL.Shared", "ChipmunkSharpPCLShared\ChipmunkSharp.PCL.Shared.csproj", "{6EC840D4-8CE9-4176-9F47-CFFF93CB6172}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Distribution|Any CPU = Distribution|Any CPU 12 | Per|Any CPU = Per|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Distribution|Any CPU.ActiveCfg = Debug|Any CPU 19 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Distribution|Any CPU.Build.0 = Debug|Any CPU 20 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Per|Any CPU.ActiveCfg = Debug|Any CPU 21 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Per|Any CPU.Build.0 = Debug|Any CPU 22 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(MonoDevelopProperties) = preSolution 29 | StartupItem = CocosSharpPCLShared\CocosSharp.PCL.Shared.csproj 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /old/PCL/ChipmunkSharpPCLShared/ChipmunkSharp.PCL.Shared.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {6EC840D4-8CE9-4176-9F47-CFFF93CB6172} 9 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Library 11 | ChipmunkSharp 12 | ChipmunkSharp 13 | Profile136 14 | v4.0 15 | CocosSharp PCL 16 | 10.0 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug 23 | DEBUG; 24 | prompt 25 | 4 26 | false 27 | 28 | 29 | full 30 | true 31 | bin\Release 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /old/PCL/ChipmunkSharpPCLShared/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | [assembly: AssemblyTitle("ChipmunkSharp.PCL.Shared")] 7 | [assembly: AssemblyDescription ("")] 8 | [assembly: AssemblyConfiguration ("")] 9 | [assembly: AssemblyProduct ("")] 10 | [assembly: AssemblyCompany("Open Source Software Provided As-Is")] 11 | [assembly: AssemblyCopyright("Copyright © netonjm")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | [assembly: AssemblyVersion("2.2.4.0")] 15 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/.vs/ChipmunkExampleMac/xs/UserPrefs.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/.vs/ChipmunkExampleMac/xs/sqlite3/db.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/.vs/ChipmunkExampleMac/xs/sqlite3/db.lock -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/.vs/ChipmunkExampleMac/xs/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/.vs/ChipmunkExampleMac/xs/sqlite3/storage.ide -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ChipmunkExampleMac.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChipmunkExampleMac", "macosx\ChipmunkExampleMac.csproj", "{C976AEE3-940E-4658-BCDD-80A581E4C696}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | AppStore|Any CPU = AppStore|Any CPU 11 | Distribution|Any CPU = Distribution|Any CPU 12 | Debug|iPhoneSimulator = Debug|iPhoneSimulator 13 | Release|iPhoneSimulator = Release|iPhoneSimulator 14 | Debug|iPhone = Debug|iPhone 15 | Release|iPhone = Release|iPhone 16 | Ad-Hoc|iPhone = Ad-Hoc|iPhone 17 | AppStore|iPhone = AppStore|iPhone 18 | Debug|x86 = Debug|x86 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU 23 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU 24 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.AppStore|Any CPU.ActiveCfg = AppStore|Any CPU 25 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.AppStore|Any CPU.Build.0 = AppStore|Any CPU 26 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.AppStore|iPhone.ActiveCfg = AppStore|Any CPU 27 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.AppStore|iPhone.Build.0 = AppStore|Any CPU 28 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|iPhone.ActiveCfg = Debug|Any CPU 31 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|iPhone.Build.0 = Debug|Any CPU 32 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU 33 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU 34 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|x86.ActiveCfg = Debug|Any CPU 35 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Debug|x86.Build.0 = Debug|Any CPU 36 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Distribution|Any CPU.ActiveCfg = Debug|Any CPU 37 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Distribution|Any CPU.Build.0 = Debug|Any CPU 38 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|iPhone.ActiveCfg = Release|Any CPU 41 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|iPhone.Build.0 = Release|Any CPU 42 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU 43 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|iPhoneSimulator.Build.0 = Release|Any CPU 44 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|x86.ActiveCfg = Release|Any CPU 45 | {C976AEE3-940E-4658-BCDD-80A581E4C696}.Release|x86.Build.0 = Release|Any CPU 46 | EndGlobalSection 47 | GlobalSection(MonoDevelopProperties) = preSolution 48 | StartupItem = macosx\ChipmunkExampleMac.csproj 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Chipmunkv7ExampleWP8.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chipmunkv7ExampleW8", "wp8\Chipmunkv7ExampleW8.csproj", "{72778D87-238A-4F25-AD7F-10098E8377EB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|Mixed Platforms = Debug|Mixed Platforms 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|Mixed Platforms = Release|Mixed Platforms 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|ARM.Build.0 = Debug|ARM 20 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 22 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|Mixed Platforms.Build.0 = Debug|x86 23 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|Mixed Platforms.Deploy.0 = Debug|x86 24 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|x86.ActiveCfg = Debug|x86 25 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|x86.Build.0 = Debug|x86 26 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Debug|x86.Deploy.0 = Debug|x86 27 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|ARM.ActiveCfg = Release|ARM 28 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|ARM.Build.0 = Release|ARM 29 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|ARM.Deploy.0 = Release|ARM 30 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|Mixed Platforms.ActiveCfg = Release|x86 31 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|Mixed Platforms.Build.0 = Release|x86 32 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|Mixed Platforms.Deploy.0 = Release|x86 33 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|x86.ActiveCfg = Release|x86 34 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|x86.Build.0 = Release|x86 35 | {72778D87-238A-4F25-AD7F-10098E8377EB}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Extensions/LogoNode.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace ChipmunkExample 8 | { 9 | public class LogoNode : CCNode 10 | { 11 | public CCParticleMeteor ParticleStay; 12 | //public CCParticleMeteor ParticleSelected; 13 | 14 | CCSprite xamarinLogo; 15 | 16 | CCParticleMeteor CreateMeteor(CCPoint position) 17 | { 18 | CCParticleMeteor dev = new CCParticleMeteor(position) 19 | { 20 | Angle = 90, 21 | AngleVar = 360, 22 | BlendFunc = new CCBlendFunc(1, 772), 23 | EmissionRate = 50, 24 | Gravity = new CCPoint(0, 200), 25 | Life = 1f, 26 | Speed = 15, 27 | SpeedVar = 5, 28 | StartSize = 100 29 | }; 30 | return dev; 31 | } 32 | 33 | CCParticleMeteor CreateGalaxy(CCPoint position) 34 | { 35 | CCParticleMeteor dev = new CCParticleMeteor(position) 36 | { 37 | Angle = 90, 38 | AngleVar = 360, 39 | BlendFunc = new CCBlendFunc(772, 772), 40 | EmissionRate = 50, 41 | Life = 0.5f, 42 | Speed = 60, 43 | SpeedVar = 10, 44 | StartSize = 100, 45 | TangentialAccel = 80 46 | }; 47 | return dev; 48 | } 49 | 50 | public LogoNode() 51 | { 52 | 53 | xamarinLogo = new CCSprite("xamarin-logo-no-shadow.png"); 54 | xamarinLogo.Scale = .4f; 55 | AddChild(xamarinLogo, 2); 56 | 57 | ContentSize = xamarinLogo.ContentSize; 58 | 59 | xamarinLogo.Position = new CCPoint( 60 | ContentSize.Width * xamarinLogo.ScaleX * ScaleX * .5f, 61 | ContentSize.Height * xamarinLogo.ScaleY * ScaleY * .5f); 62 | 63 | ParticleStay = CreateMeteor(new CCPoint(100, 100)); 64 | ParticleStay.Scale = .55f; 65 | AddChild(ParticleStay, 1); 66 | 67 | ParticleStay.Position = xamarinLogo.Position; 68 | 69 | } 70 | 71 | private bool _isHover; 72 | 73 | public bool IsHover 74 | { 75 | get { return _isHover; } 76 | set 77 | { 78 | 79 | if (!_isHover && value) 80 | ExecAnimationMouseIn(); 81 | 82 | if (_isHover && !value) 83 | ExecAnimationMouseOut(); 84 | 85 | _isHover = value; 86 | 87 | } 88 | } 89 | 90 | public void ExecAnimationMouseIn() 91 | { 92 | ParticleStay.Gravity = new CCPoint(0, 0); 93 | ParticleStay.Life = 3f; 94 | } 95 | 96 | public void ExecAnimationMouseOut() 97 | { 98 | ParticleStay.Gravity = new CCPoint(0, 200); 99 | ParticleStay.Life = 1f; 100 | } 101 | 102 | 103 | public CCPoint InitialPosition { get; set; } 104 | 105 | public CCPoint MoveOffset = CCPoint.Zero; 106 | 107 | 108 | public bool IsMoving { get; set; } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Extensions/PhysicsSprite.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | 8 | namespace CocosSharp 9 | { 10 | class PhysicsSprite : CCPhysicsSprite 11 | { 12 | public PhysicsSprite(CCTexture2D texture, CCRect rect) 13 | : base(texture, rect) 14 | { 15 | 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Extensions/PlayerIndex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ChipmunkExample 7 | { 8 | public class PlayerIndex 9 | { 10 | 11 | public int Count = 0; 12 | 13 | public int Index = 0; 14 | 15 | public PlayerIndex() 16 | { 17 | 18 | } 19 | 20 | public PlayerIndex(int count) 21 | { 22 | Count = count; 23 | } 24 | 25 | public bool Next() 26 | { 27 | if (Index >= Count - 1) 28 | { 29 | Index = 0; 30 | return true; 31 | } 32 | else 33 | { 34 | Index++; 35 | return false; 36 | } 37 | } 38 | 39 | public bool Prev() 40 | { 41 | 42 | if (Index <= 0) 43 | { 44 | Index = Count - 1; 45 | return true; 46 | } 47 | else 48 | { 49 | Index--; 50 | return false; 51 | 52 | } 53 | } 54 | 55 | 56 | 57 | internal void Reset() 58 | { 59 | Index = 0; 60 | //Count = 0; 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Extensions/cpExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text; 3 | using System; 4 | using CocosSharp; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace ChipmunkSharp 8 | { 9 | public static class cpExtension 10 | { 11 | 12 | public static cpVect ToCpVect(this CCPoint vec) 13 | { 14 | 15 | 16 | return new cpVect(vec.X, vec.Y); 17 | } 18 | 19 | public static CCPoint ToCCPoint(this cpVect vec) 20 | { 21 | return new CCPoint((float)vec.x, (float)vec.y); 22 | } 23 | 24 | 25 | 26 | public static CCColor4F ToCCColor4F(this cpColor color) 27 | { 28 | return new CCColor4F(color.r / 255, color.g / 255, color.b / 255, color.a / 255); 29 | } 30 | 31 | public static CCColor4B ToCCColor4B(this cpColor color) 32 | { 33 | return new CCColor4B(color.r / 255, color.g / 255, color.b / 255, color.a / 255); 34 | } 35 | 36 | //public static Vector2 ToVector(this CCPoint sender) 37 | //{ 38 | // return new Vector2(sender.X, sender.Y); 39 | //} 40 | //public static Vector2 ToVector(this cpVect sender) 41 | //{ 42 | // return new Vector2((float)sender.x, (float)sender.y); 43 | //} 44 | 45 | //public static CCPoint ToCCPoint(this Vector2 sender) 46 | //{ 47 | // return new CCPoint(sender.X, sender.Y); 48 | //} 49 | 50 | public static CCVector2 ToCCVector2(this cpVect vec) 51 | { 52 | return new CCVector2((float)vec.x, (float)vec.y); 53 | } 54 | 55 | public static Vector2 ToVector(this CCPoint sender) 56 | { 57 | return new Vector2(sender.X, sender.Y); 58 | } 59 | 60 | public static CCPoint ToCCPoint(this Vector2 sender) 61 | { 62 | return new CCPoint(sender.X, sender.Y); 63 | } 64 | 65 | } 66 | 67 | 68 | } -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Helpers/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace CocosSharp 8 | { 9 | 10 | 11 | public static class Extensions 12 | { 13 | 14 | public static Vector2 ToVector(this CCPoint sender) 15 | { 16 | return new Vector2(sender.X, sender.Y); 17 | } 18 | 19 | 20 | public static CCPoint ToCCPoint(this Vector2 sender) 21 | { 22 | return new CCPoint(sender.X, sender.Y); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/ballLayer.cs: -------------------------------------------------------------------------------- 1 | using ChipmunkSharp; 2 | using CocosSharp; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace ChipmunkExample 9 | { 10 | class ballLayer : ChipmunkDemoLayer 11 | { 12 | protected override void AddedToScene() 13 | { 14 | base.AddedToScene(); 15 | 16 | //PositionX += (windowSize.Width - 640) * .5d; //new CCPoint(150, 150); 17 | space.SetIterations(60); 18 | space.SetGravity(new cpVect(0, -500)); 19 | space.SetSleepTimeThreshold(0.5f); 20 | space.SetCollisionSlop(0.5f); 21 | space.SetSleepTimeThreshold(0.5f); 22 | 23 | this.addFloor(); 24 | this.addWalls(); 25 | float width = 50; 26 | float height = 60; 27 | float mass = width * height * 1f / 1000f; 28 | 29 | var rock = space.AddBody(new cpBody(mass, cp.MomentForBox(mass, width, height))); 30 | rock.SetPosition(new cpVect(200, 0)); 31 | rock.SetAngle(1); 32 | 33 | cpPolyShape shape = space.AddShape(cpPolyShape.BoxShape(rock, width, height, 0.0f)) as cpPolyShape; 34 | shape.SetFriction(0.3f); 35 | shape.SetElasticity(0.3f); 36 | //shape.SetFilter(NOT_GRABBABLE_FILTER); //The box cannot be dragg 37 | 38 | for (var i = 1; i <= 6; i++) 39 | { 40 | float radius = 20f; 41 | mass = 3; 42 | var body = space.AddBody(new cpBody(mass, cp.MomentForCircle(mass, 0f, radius, cpVect.Zero))); 43 | body.SetPosition(new cpVect(i, (2 * radius + 5) * 1)); 44 | 45 | cpCircleShape circle = space.AddShape(new cpCircleShape(body, radius, cpVect.Zero)) as cpCircleShape; 46 | circle.SetElasticity(0.8f); 47 | circle.SetFriction(1); 48 | } 49 | 50 | var ramp = space.AddShape(new cpSegmentShape(space.GetStaticBody(), new cpVect(0, 0), new cpVect(300, 200), 10)); 51 | ramp.SetElasticity(1f); 52 | ramp.SetFriction(1f); 53 | ramp.SetFilter(NOT_GRABBABLE_FILTER); 54 | 55 | Schedule(); 56 | } 57 | 58 | public override void Update(float dt) 59 | { 60 | base.Update(dt); 61 | space.Step(dt); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/gjkLayer.cs: -------------------------------------------------------------------------------- 1 | using ChipmunkSharp; 2 | using CocosSharp; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace ChipmunkExample 9 | { 10 | class gjkLayer : ChipmunkDemoLayer 11 | { 12 | 13 | cpShape shape1, shape2; 14 | 15 | public override void OnEnter() 16 | { 17 | base.OnEnter(); 18 | 19 | 20 | space.SetIterations(5); 21 | space.SetDamping(0.1f); 22 | 23 | float mass = 1.0f; 24 | 25 | { 26 | float size = 100.0f; 27 | 28 | cpBody body = space.AddBody(new cpBody(mass, cp.MomentForBox(mass, size, size))); 29 | body.SetPosition(new cpVect(100.0f, 50.0f)); 30 | 31 | shape1 = space.AddShape(cpPolyShape.BoxShape(body, size, size, 0.0f)); 32 | //shape1.SetGroup(1); 33 | } 34 | { 35 | float size = 100.0f; 36 | 37 | cpBody body = space.AddBody(new cpBody(mass, cp.MomentForBox(mass, size, size))); 38 | body.SetPosition(new cpVect(120.0f, -40.0f)); 39 | body.SetAngle(1e-2f); 40 | 41 | shape2 = space.AddShape(cpPolyShape.BoxShape(body, size, size, 0.0f)); 42 | //shape2.SetGroup(1); 43 | } 44 | 45 | 46 | Schedule(); 47 | 48 | } 49 | 50 | 51 | 52 | protected override void Draw() 53 | { 54 | base.Draw(); 55 | 56 | //ChipmunkDemoDefaultDrawImpl(space); 57 | //ContactPoint[] arr = new ContactPoint[cpArbiter.CP_MAX_CONTACTS_PER_ARBITER]; 58 | // cpCollideShapes(shape1, shape2, (cpCollisionID[]){0}, arr); 59 | //cpCollisionInfo info = cpCollideShapes(shape2, shape1, 0x00000000, arr); 60 | List contacts = new List(); 61 | cpCollision.cpCollide(shape1, shape2, 0, ref contacts); 62 | int collisions = contacts.Count; 63 | string description = ""; 64 | 65 | 66 | for (int i = 0; i < collisions; i++) 67 | { 68 | description += contacts[0].ToString(); 69 | } 70 | 71 | 72 | 73 | SetSubTitle(string.Format("{0} collitions: ({1})", collisions, description)); 74 | } 75 | 76 | public override void Update(float dt) 77 | { 78 | base.Update(dt); 79 | 80 | space.Step(dt); 81 | } 82 | 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/pyramidLayer.cs: -------------------------------------------------------------------------------- 1 | using ChipmunkSharp; 2 | using CocosSharp; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace ChipmunkExample 9 | { 10 | class pyramidLayer : ChipmunkDemoLayer 11 | { 12 | 13 | public override void OnEnter() 14 | { 15 | base.OnEnter(); 16 | 17 | space.SetIterations(30); 18 | space.SetGravity(new cpVect(0, -100)); 19 | space.SetSleepTimeThreshold(0.5f); 20 | space.SetCollisionSlop(0.5f); 21 | 22 | cpBody body, staticBody = space.GetStaticBody(); 23 | cpShape shape; 24 | 25 | // Create segments around the edge of the screen. 26 | shape = space.AddShape(new cpSegmentShape(staticBody, new cpVect(-320, -240), new cpVect(-320, 240), 0.0f)); 27 | shape.SetElasticity(1.0f); 28 | shape.SetFriction(1.0f); 29 | shape.SetFilter(NOT_GRABBABLE_FILTER); 30 | 31 | shape = space.AddShape(new cpSegmentShape(staticBody, new cpVect(320, -240), new cpVect(320, 240), 0.0f)); 32 | shape.SetElasticity(1.0f); 33 | shape.SetFriction(1.0f); 34 | shape.SetFilter(NOT_GRABBABLE_FILTER); 35 | 36 | shape = space.AddShape(new cpSegmentShape(staticBody, new cpVect(-320, -240), new cpVect(320, -240), 0.0f)); 37 | shape.SetElasticity(1.0f); 38 | shape.SetFriction(1.0f); 39 | shape.SetFilter(NOT_GRABBABLE_FILTER); 40 | 41 | // Add lots of boxes. 42 | for (var i = 0; i < 10; i++) 43 | { 44 | for (var j = 0; j <= i; j++) 45 | { 46 | body = space.AddBody(new cpBody(1, cp.MomentForBox(1, 30, 30))); 47 | body.SetPosition(new cpVect(j * 32 - i * 16 + 0, 300 - i * 32)); 48 | 49 | shape = space.AddShape(cpPolyShape.BoxShape(body, 30, 30, 0.5f)); 50 | shape.SetElasticity(0); 51 | shape.SetFriction(0.8f); 52 | } 53 | } 54 | 55 | // Add a ball to make things more interesting 56 | float radius = 15f; 57 | body = space.AddBody(new cpBody(10, cp.MomentForCircle(10f, 0, radius, cpVect.Zero))); 58 | body.SetPosition(new cpVect(0, -240 + radius + 5)); 59 | 60 | shape = space.AddShape(new cpCircleShape(body, radius, cpVect.Zero)); 61 | shape.SetElasticity(0.0f); 62 | shape.SetFriction(0.9f); 63 | 64 | Schedule(); 65 | 66 | } 67 | 68 | 69 | public override void Update(float dt) 70 | { 71 | base.Update(dt); 72 | 73 | this.space.Step(dt); 74 | } 75 | 76 | 77 | 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/pyramidToppleLayer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using CocosSharp; 6 | using ChipmunkSharp; 7 | 8 | namespace ChipmunkExample 9 | { 10 | class pyramidToppleLayer : ChipmunkDemoLayer 11 | { 12 | 13 | int WIDTH = 4; 14 | int HEIGHT = 20; 15 | 16 | public override void OnEnter() 17 | { 18 | base.OnEnter(); 19 | 20 | space.SetIterations(30); 21 | space.SetGravity(new cpVect(0, -300)); 22 | space.SetSleepTimeThreshold(0.5f); 23 | space.SetCollisionSlop(0.5f); 24 | 25 | 26 | cpShape shape = space.AddShape(new cpSegmentShape(space.GetStaticBody(), new cpVect(-600, -240), new cpVect(600, -240), 0.0f)); 27 | shape.SetElasticity(1.0f); 28 | shape.SetFriction(1.0f); 29 | shape.SetFilter(NOT_GRABBABLE_FILTER); 30 | 31 | 32 | // Add the dominoes. 33 | var n = 7; 34 | for (var i = 0; i < n; i++) 35 | { 36 | for (var j = 0; j < (n - i); j++) 37 | { 38 | var offset = new cpVect((j - (n - 1 - i) * 0.5f) * 1.5f * HEIGHT, (i + 0.5f) * (HEIGHT + 2 * WIDTH) - WIDTH - 240); 39 | add_domino(offset, false); 40 | add_domino(cpVect.cpvadd(offset, new cpVect(0, (HEIGHT + WIDTH) / 2)), true); 41 | 42 | if (j == 0) 43 | { 44 | add_domino(cpVect.cpvadd(offset, new cpVect(0.5f * (WIDTH - HEIGHT), HEIGHT + WIDTH)), false); 45 | } 46 | 47 | if (j != n - i - 1) 48 | { 49 | add_domino(cpVect.cpvadd(offset, new cpVect(HEIGHT * 0.75f, (HEIGHT + 3 * WIDTH) / 2)), true); 50 | } 51 | else 52 | { 53 | add_domino(cpVect.cpvadd(offset, new cpVect(0.5f * (HEIGHT - WIDTH), HEIGHT + WIDTH)), false); 54 | } 55 | } 56 | } 57 | 58 | Schedule(); 59 | 60 | 61 | } 62 | 63 | 64 | public override void Update(float dt) 65 | { 66 | base.Update(dt); 67 | 68 | this.space.Step(dt); 69 | } 70 | 71 | 72 | public void add_domino(cpVect pos, bool flipped) 73 | { 74 | 75 | 76 | float mass = 1f; 77 | float radius = 0.5f; 78 | float moment = cp.MomentForBox(mass, WIDTH, HEIGHT); 79 | 80 | var body = space.AddBody(new cpBody(mass, moment)); 81 | body.SetPosition(pos); 82 | 83 | var shape = (flipped ? cpPolyShape.BoxShape(body, HEIGHT, WIDTH, 0.0f) : cpPolyShape.BoxShape(body, WIDTH - radius * 2.0f, HEIGHT, radius)); 84 | space.AddShape(shape); 85 | shape.SetElasticity(0f); 86 | shape.SetFriction(0.6f); 87 | 88 | } 89 | 90 | 91 | 92 | 93 | 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/smoothLayer.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace ChipmunkExample 8 | { 9 | class smoothLayer : ChipmunkDemoLayer 10 | { 11 | 12 | 13 | 14 | 15 | protected override void AddedToScene() 16 | { 17 | base.AddedToScene(); 18 | 19 | 20 | 21 | Schedule(); 22 | } 23 | 24 | public override void Update(float dt) 25 | { 26 | base.Update(dt); 27 | 28 | } 29 | 30 | 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/springiesLayer.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace ChipmunkExample 8 | { 9 | class springiesLayer : ChipmunkDemoLayer 10 | { 11 | 12 | 13 | 14 | 15 | protected override void AddedToScene() 16 | { 17 | base.AddedToScene(); 18 | 19 | 20 | Schedule(); 21 | } 22 | 23 | public override void Update(float dt) 24 | { 25 | base.Update(dt); 26 | 27 | } 28 | 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Common/Layers/tumbleLayer.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace ChipmunkExample 8 | { 9 | class tumbleLayer : ChipmunkDemoLayer 10 | { 11 | 12 | 13 | public tumbleLayer() 14 | { 15 | 16 | 17 | Schedule(); 18 | } 19 | 20 | public override void Update(float dt) 21 | { 22 | base.Update(dt); 23 | 24 | space.Step(dt); 25 | } 26 | 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/Game.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/Game.ico -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/Game1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Microsoft.Xna.Framework; 5 | using Microsoft.Xna.Framework.Audio; 6 | using Microsoft.Xna.Framework.Content; 7 | using Microsoft.Xna.Framework.GamerServices; 8 | using Microsoft.Xna.Framework.Graphics; 9 | using Microsoft.Xna.Framework.Input; 10 | using Microsoft.Xna.Framework.Media; 11 | 12 | namespace ContentPipeline 13 | { 14 | /// 15 | /// This is the main type for your game 16 | /// 17 | public class Game1 : Microsoft.Xna.Framework.Game 18 | { 19 | GraphicsDeviceManager graphics; 20 | SpriteBatch spriteBatch; 21 | 22 | public Game1() 23 | { 24 | graphics = new GraphicsDeviceManager(this); 25 | Content.RootDirectory = "Content"; 26 | } 27 | 28 | /// 29 | /// Allows the game to perform any initialization it needs to before starting to run. 30 | /// This is where it can query for any required services and load any non-graphic 31 | /// related content. Calling base.Initialize will enumerate through any components 32 | /// and initialize them as well. 33 | /// 34 | protected override void Initialize() 35 | { 36 | // TODO: Add your initialization logic here 37 | 38 | base.Initialize(); 39 | } 40 | 41 | /// 42 | /// LoadContent will be called once per game and is the place to load 43 | /// all of your content. 44 | /// 45 | protected override void LoadContent() 46 | { 47 | // Create a new SpriteBatch, which can be used to draw textures. 48 | spriteBatch = new SpriteBatch(GraphicsDevice); 49 | 50 | // TODO: use this.Content to load your game content here 51 | } 52 | 53 | /// 54 | /// UnloadContent will be called once per game and is the place to unload 55 | /// all content. 56 | /// 57 | protected override void UnloadContent() 58 | { 59 | // TODO: Unload any non ContentManager content here 60 | } 61 | 62 | /// 63 | /// Allows the game to run logic such as updating the world, 64 | /// checking for collisions, gathering input, and playing audio. 65 | /// 66 | /// Provides a snapshot of timing values. 67 | protected override void Update(GameTime gameTime) 68 | { 69 | // Allows the game to exit 70 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) 71 | this.Exit(); 72 | 73 | // TODO: Add your update logic here 74 | 75 | base.Update(gameTime); 76 | } 77 | 78 | /// 79 | /// This is called when the game should draw itself. 80 | /// 81 | /// Provides a snapshot of timing values. 82 | protected override void Draw(GameTime gameTime) 83 | { 84 | GraphicsDevice.Clear(Color.CornflowerBlue); 85 | 86 | // TODO: Add your drawing code here 87 | 88 | base.Draw(gameTime); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/GameThumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/GameThumbnail.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ContentPipeline 4 | { 5 | #if WINDOWS || XBOX 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | static void Main(string[] args) 12 | { 13 | using (Game1 game = new Game1()) 14 | { 15 | game.Run(); 16 | } 17 | } 18 | } 19 | #endif 20 | } 21 | 22 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipeline/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ContentPipeline")] 9 | [assembly: AssemblyProduct("ContentPipeline")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. Only Windows 19 | // assemblies support COM. 20 | [assembly: ComVisible(false)] 21 | 22 | // On Windows, the following GUID is for the ID of the typelib if this 23 | // project is exposed to COM. On other platforms, it unique identifies the 24 | // title storage container when deploying this assembly to the device. 25 | [assembly: Guid("6491e3c3-03d0-49fd-bee9-81ab3184710f")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipelineContent/weblysleeku-22.spritefont: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | WeblySleek UI Light 15 | 16 | 20 | 22 21 | 22 | 26 | 0 27 | 28 | 32 | true 33 | 34 | 38 | 39 | 40 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | ~ 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/ContentPipeline/ContentPipelineContent/weblysleekuisb-22.spritefont: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 14 | WeblySleek UI Semibold 15 | 16 | 20 | 22 21 | 22 | 26 | 0 27 | 28 | 32 | true 33 | 34 | 38 | 39 | 40 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | ~ 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/fonts/MarkerFelt-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/fonts/MarkerFelt-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/fonts/weblysleeku-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/fonts/weblysleeku-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/fonts/weblysleekuisb-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/fonts/weblysleekuisb-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/Background-alone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/Background-alone.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/Background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/Background.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/arrow-left-press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/arrow-left-press.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/arrow-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/arrow-left.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/arrow-right-press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/arrow-right-press.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/arrow-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/arrow-right.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/btn-clear-press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/btn-clear-press.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/btn-clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/btn-clear.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/btn-reset-press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/btn-reset-press.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/btn-reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/btn-reset.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/fps_images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/fps_images.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/grossini_dance_atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/grossini_dance_atlas.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/xamarin-img-raster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/xamarin-img-raster.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/png/xamarin-logo-no-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/png/xamarin-logo-no-shadow.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/Background-alone.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/Background-alone.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/Background.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/Background.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/arrow-left-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/arrow-left-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/arrow-left.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/arrow-left.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/arrow-right-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/arrow-right-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/arrow-right.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/arrow-right.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/btn-clear-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/btn-clear-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/btn-clear.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/btn-clear.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/btn-reset-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/btn-reset-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/btn-reset.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/btn-reset.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/fps_images.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/fps_images.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/grossini_dance_atlas.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/grossini_dance_atlas.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/xamarin-img-raster.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/xamarin-img-raster.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/Resources/xnb/xamarin-logo-no-shadow.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/Resources/xnb/xamarin-logo-no-shadow.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/UpgradeLog.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/UpgradeLog.htm -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/macosx/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.xamarin.CocosSharp.Spine 7 | CFBundleName 8 | CocosSharpSpine 9 | CFBundleVersion 10 | 1 11 | LSMinimumSystemVersion 12 | 10.6 13 | NSPrincipalClass 14 | NSApplication 15 | LSApplicationCategoryType 16 | public.app-category.games 17 | CFBundleDisplayName 18 | CocosSharp.Spine 19 | 20 | 21 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/macosx/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MonoMac; 3 | using MonoMac.AppKit; 4 | using MonoMac.Foundation; 5 | using CocosSharp; 6 | 7 | namespace ChipmunkExample 8 | { 9 | class Program : NSApplicationDelegate 10 | { 11 | //Game1 game; 12 | 13 | static void Main (string[] args) 14 | { 15 | NSApplication.Init (); 16 | 17 | using (var p = new NSAutoreleasePool()) 18 | { 19 | NSApplication.SharedApplication.Delegate = new Program(); 20 | NSApplication.Main(args); 21 | } 22 | 23 | } 24 | 25 | public override void FinishedLaunching (NSObject notification) 26 | { 27 | var application = new CCApplication(); 28 | application.ApplicationDelegate = new AppDelegate(); 29 | application.StartGame(); 30 | } 31 | 32 | public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender) 33 | { 34 | return true; 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win32/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Microsoft.Xna.Framework; 3 | using CocosDenshion; 4 | using CocosSharp; 5 | 6 | namespace ChipmunkExample 7 | { 8 | public class AppDelegate : CCApplicationDelegate 9 | { 10 | float preferredWidth; 11 | float preferredHeight; 12 | 13 | static CCWindow sharedWindow; 14 | public static CCSize DefaultResolution; 15 | 16 | public static CCWindow SharedWindow 17 | { 18 | get { return sharedWindow; } 19 | } 20 | 21 | public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) 22 | { 23 | sharedWindow = mainWindow; 24 | preferredWidth = application.MainWindow.WindowSizeInPixels.Width; 25 | preferredHeight = application.MainWindow.WindowSizeInPixels.Height; 26 | 27 | DefaultResolution = new CCSize(preferredWidth, preferredHeight); 28 | application.ContentRootDirectory = "Content"; 29 | application.ContentSearchPaths.Add("SD"); 30 | 31 | CCScene scene = ChipmunkDemoLayer.ActualScene; 32 | mainWindow.RunWithScene(scene); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win32/Game.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win32/Game.ico -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win32/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using CocosSharp; 4 | //using Microsoft.Xna.Framework; 5 | 6 | namespace ChipmunkExample 7 | { 8 | 9 | static class Program 10 | { 11 | [STAThread] 12 | static void Main(string[] args) 13 | { 14 | CCApplication application = new CCApplication(false, new CCSize(1024f, 768f)); 15 | application.ApplicationDelegate = new AppDelegate(); 16 | application.StartGame(); 17 | } 18 | } 19 | 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win32/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ChipmunkExample")] 9 | [assembly: AssemblyProduct("ChipmunkExample")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("400cbf0e-6fc4-40d2-aab5-ceb578fe01a3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using Microsoft.Xna.Framework.Graphics; 4 | using CocosSharp; 5 | 6 | 7 | namespace ChipmunkExample 8 | { 9 | public class AppDelegate : CCApplicationDelegate 10 | { 11 | static CCDirector sharedDirector; 12 | static CCWindow sharedWindow; 13 | static CCViewport sharedViewport; 14 | static CCCamera sharedCamera; 15 | 16 | public static CCDirector SharedDirector 17 | { 18 | get { return sharedDirector; } 19 | } 20 | 21 | public static CCWindow SharedWindow 22 | { 23 | get { return sharedWindow; } 24 | } 25 | 26 | public static CCViewport SharedViewport 27 | { 28 | get { return sharedViewport; } 29 | } 30 | 31 | public static CCCamera SharedCamera 32 | { 33 | get { return sharedCamera; } 34 | } 35 | 36 | public override void ApplicationDidFinishLaunching(CCApplication application) 37 | { 38 | //application.SupportedOrientations = CCDisplayOrientation.LandscapeRight | CCDisplayOrientation.LandscapeLeft; 39 | //application.AllowUserResizing = true; 40 | //application.PreferMultiSampling = false; 41 | application.ContentRootDirectory = "Content"; 42 | 43 | 44 | //CCRect boundsRect = new CCRect(0.0f, 0.0f, 960, 640); 45 | 46 | //sharedViewport = new CCViewport(new CCRect(0.0f, 0.0f, 1.0f, 1.0f)); 47 | //sharedWindow = application.MainWindow; 48 | //sharedCamera = new CCCamera(boundsRect.Size, new CCPoint3(boundsRect.Center, 100.0f), new CCPoint3(boundsRect.Center, 0.0f)); 49 | 50 | #if WINDOWS || WINDOWSGL || WINDOWSDX 51 | //application.PreferredBackBufferWidth = 1024; 52 | //application.PreferredBackBufferHeight = 768; 53 | #elif MACOS 54 | //application.PreferredBackBufferWidth = 960; 55 | //application.PreferredBackBufferHeight = 640; 56 | #endif 57 | 58 | #if WINDOWS_PHONE8 59 | application.HandleMediaStateAutomatically = false; // Bug in MonoGame - https://github.com/Cocos2DXNA/cocos2d-xna/issues/325 60 | #endif 61 | 62 | //sharedDirector = new CCDirector(); 63 | //director.DisplayStats = true; 64 | //director.AnimationInterval = 1.0 / 60; 65 | 66 | 67 | // if (sharedWindow.WindowSizeInPixels.Height > 320) 68 | // { 69 | // application.ContentSearchPaths.Insert(0,"HD"); 70 | // } 71 | 72 | sharedWindow.AddSceneDirector(sharedDirector); 73 | 74 | //CCScene scene = new CCScene(sharedWindow, sharedViewport, sharedDirector); 75 | //CCLayer layer = 76 | //layer.Camera = sharedCamera; 77 | 78 | //scene.AddChild(layer); 79 | sharedDirector.RunWithScene(ChipmunkDemoLayer.ActualScene); 80 | } 81 | 82 | public override void ApplicationDidEnterBackground(CCApplication application) 83 | { 84 | application.PauseGame(); 85 | } 86 | 87 | public override void ApplicationWillEnterForeground(CCApplication application) 88 | { 89 | application.ResumeGame(); 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Assets/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Assets/Logo.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Assets/SmallLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Assets/SmallLogo.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Assets/SplashScreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Assets/SplashScreen.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Assets/StoreLogo.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Content/fonts/MarkerFelt-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Content/fonts/MarkerFelt-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | Spine.Store 10 | Cocos2D-XNA 11 | Assets\StoreLogo.png 12 | 13 | 14 | 15 | 6.2.1 16 | 6.2.1 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Program.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | 4 | namespace ChipmunkJSExample 5 | { 6 | /// 7 | /// The main class. 8 | /// 9 | public static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | static void Main() 15 | { 16 | CCApplication application = new CCApplication(true); 17 | application.ApplicationDelegate = new AppDelegate(); 18 | 19 | application.StartGame(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ChipmunkJSExample")] 9 | [assembly: AssemblyProduct("ChipmunkJSExample")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by using the '*' as shown below: 31 | // [assembly: AssemblyVersion("1.0.*")] 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/win8/Spine.Store_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/win8/Spine.Store_TemporaryKey.pfx -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using CocosSharp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Chipmunkv7Example 9 | { 10 | public class AppDelegate : CCApplicationDelegate 11 | { 12 | static CCWindow sharedWindow; 13 | 14 | public static CCWindow SharedWindow 15 | { 16 | get { return sharedWindow; } 17 | } 18 | 19 | public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow) 20 | { 21 | //application.SupportedOrientations = CCDisplayOrientation.LandscapeRight | CCDisplayOrientation.LandscapeLeft; 22 | //application.AllowUserResizing = true; 23 | //application.PreferMultiSampling = false; 24 | application.ContentRootDirectory = "Content"; 25 | 26 | sharedWindow = mainWindow; 27 | 28 | mainWindow.SetDesignResolutionSize(960, 640, CCSceneResolutionPolicy.ShowAll); 29 | 30 | #if WINDOWS || WINDOWSGL || WINDOWSDX 31 | //application.PreferredBackBufferWidth = 1024; 32 | //application.PreferredBackBufferHeight = 768; 33 | #elif MACOS 34 | //application.PreferredBackBufferWidth = 960; 35 | //application.PreferredBackBufferHeight = 640; 36 | #endif 37 | 38 | #if WINDOWS_PHONE8 39 | application.HandleMediaStateAutomatically = false; // Bug in MonoGame - https://github.com/Cocos2DXNA/cocos2d-xna/issues/325 40 | #endif 41 | 42 | CCSpriteFontCache.FontScale = 0.6f; 43 | CCSpriteFontCache.RegisterFont("arial", 12, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 38, 50, 64); 44 | CCSpriteFontCache.RegisterFont("MarkerFelt", 16, 18, 22, 32); 45 | CCSpriteFontCache.RegisterFont("MarkerFelt-Thin", 12, 18); 46 | CCSpriteFontCache.RegisterFont("Paint Boy", 26); 47 | CCSpriteFontCache.RegisterFont("Schwarzwald Regular", 26); 48 | CCSpriteFontCache.RegisterFont("Scissor Cuts", 26); 49 | CCSpriteFontCache.RegisterFont("A Damn Mess", 26); 50 | CCSpriteFontCache.RegisterFont("Abberancy", 26); 51 | CCSpriteFontCache.RegisterFont("Abduction", 26); 52 | 53 | //sharedDirector = new CCDirector(); 54 | //director.DisplayStats = true; 55 | //director.AnimationInterval = 1.0 / 60; 56 | 57 | 58 | // if (sharedWindow.WindowSizeInPixels.Height > 320) 59 | // { 60 | // application.ContentSearchPaths.Insert(0,"HD"); 61 | // } 62 | 63 | //sharedWindow.AddSceneDirector(sharedDirector); 64 | 65 | CCScene scene = new CCScene(sharedWindow); 66 | CCLayer layer = new IntroLayer(); 67 | 68 | scene.AddChild(layer); 69 | sharedWindow.RunWithScene(scene); 70 | } 71 | 72 | public override void ApplicationDidEnterBackground(CCApplication application) 73 | { 74 | application.Paused = true; 75 | } 76 | 77 | public override void ApplicationWillEnterForeground(CCApplication application) 78 | { 79 | application.Paused = false; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/AlignmentGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/AlignmentGrid.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/ApplicationIcon.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileLarge.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileMedium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileMedium.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/Tiles/FlipCycleTileSmall.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/Tiles/IconicTileMediumLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/Tiles/IconicTileMediumLarge.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Assets/Tiles/IconicTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Assets/Tiles/IconicTileSmall.png -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/Background-alone.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/Background-alone.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/Background.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/Background.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/Default.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/Default.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/arrow-left-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/arrow-left-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/arrow-left.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/arrow-left.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/arrow-right-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/arrow-right-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/arrow-right.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/arrow-right.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/btn-clear-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/btn-clear-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/btn-clear.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/btn-clear.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/btn-reset-press.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/btn-reset-press.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/btn-reset.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/btn-reset.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/fonts/MarkerFelt-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/fonts/MarkerFelt-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/fonts/weblysleeku-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/fonts/weblysleeku-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/fonts/weblysleekuisb-22.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/fonts/weblysleekuisb-22.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/fps_images.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/fps_images.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/grossini_dance_atlas.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/grossini_dance_atlas.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/xamarin-img-raster.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/xamarin-img-raster.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Content/xamarin-logo-no-shadow.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/old/examples/ChipmunkExample/wp8/Content/xamarin-logo-no-shadow.xnb -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/GamePage.xaml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/GamePage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Navigation; 8 | using Microsoft.Phone.Controls; 9 | using Microsoft.Phone.Shell; 10 | using Microsoft.Xna.Framework; 11 | using MonoGame.Framework.WindowsPhone; 12 | 13 | namespace Chipmunkv7Example 14 | { 15 | public partial class GamePage : PhoneApplicationPage 16 | { 17 | 18 | // Constructor 19 | public GamePage() 20 | { 21 | InitializeComponent(); 22 | 23 | CocosSharp.CCApplication.Create(new AppDelegate(), "", this); 24 | 25 | // Sample code to localize the ApplicationBar 26 | //BuildLocalizedApplicationBar(); 27 | } 28 | 29 | // Sample code for building a localized ApplicationBar 30 | //private void BuildLocalizedApplicationBar() 31 | //{ 32 | // // Set the page's ApplicationBar to a new instance of ApplicationBar. 33 | // ApplicationBar = new ApplicationBar(); 34 | 35 | // // Create a new button and set the text value to the localized string from AppResources. 36 | // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); 37 | // appBarButton.Text = AppResources.AppBarButtonText; 38 | // ApplicationBar.Buttons.Add(appBarButton); 39 | 40 | // // Create a new menu item with the localized string from AppResources. 41 | // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); 42 | // ApplicationBar.MenuItems.Add(appBarMenuItem); 43 | //} 44 | } 45 | } -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/IntroLayer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Xna.Framework; 3 | using CocosSharp; 4 | 5 | namespace Chipmunkv7Example 6 | { 7 | public class IntroLayer : CCLayerColor 8 | { 9 | public IntroLayer() 10 | { 11 | 12 | // create and initialize a Label 13 | //var label = new CCLabelTtf("Hello Cocos2D-XNA", "MarkerFelt", 22); 14 | 15 | // position the label on the center of the screen 16 | //label.Position = Window.WindowSizeInPixels.Center; 17 | 18 | // add the label as a child to this Layer 19 | //AddChild(label); 20 | 21 | // setup our color for the background 22 | Color = CCColor3B.Blue; 23 | Opacity = 255; 24 | 25 | } 26 | 27 | 28 | 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/LocalizedStrings.cs: -------------------------------------------------------------------------------- 1 | using Chipmunkv7Example.Resources; 2 | 3 | namespace Chipmunkv7Example 4 | { 5 | /// 6 | /// Provides access to string resources. 7 | /// 8 | public class LocalizedStrings 9 | { 10 | private static AppResources _localizedResources = new AppResources(); 11 | 12 | public AppResources LocalizedResources { get { return _localizedResources; } } 13 | } 14 | } -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Properties/AppManifest.xml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Chipmunkv7Example")] 9 | [assembly: AssemblyProduct("Chipmunkv7Example")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyCopyright("Copyright © 2013")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. Only Windows 19 | // assemblies support COM. 20 | [assembly: ComVisible(false)] 21 | 22 | // On Windows, the following GUID is for the ID of the typelib if this 23 | // project is exposed to COM. On other platforms, it unique identifies the 24 | // title storage container when deploying this assembly to the device. 25 | [assembly: Guid("4175e910-993b-4585-b010-3a4d31b0cc0f")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | [assembly: AssemblyVersion("1.0.0.0")] -------------------------------------------------------------------------------- /old/examples/ChipmunkExample/wp8/Properties/WMAppManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Assets\ApplicationIcon.png 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Assets\Tiles\FlipCycleTileSmall.png 21 | 0 22 | Assets\Tiles\FlipCycleTileMedium.png 23 | Chipmunkv7Example 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_STATIC 1) 2 | 3 | file(GLOB chipmunk_source_files "*.c" "constraints/*.c") 4 | file(GLOB chipmunk_public_header "${chipmunk_SOURCE_DIR}/include/chipmunk/*.h") 5 | file(GLOB chipmunk_constraint_header "${chipmunk_SOURCE_DIR}/include/chipmunk/constraints/*.h") 6 | 7 | include_directories(${chipmunk_SOURCE_DIR}/include/chipmunk) 8 | 9 | if(BUILD_SHARED) 10 | add_library(chipmunk SHARED 11 | ${chipmunk_source_files} 12 | ) 13 | # Tell MSVC to compile the code as C++. 14 | if(MSVC) 15 | set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) 16 | set_target_properties(chipmunk PROPERTIES LINKER_LANGUAGE CXX) 17 | endif(MSVC) 18 | # set the lib's version number 19 | # But avoid on Android because symlinks to version numbered .so's don't work with Android's Java-side loadLibrary. 20 | if(NOT ANDROID) 21 | set_target_properties(chipmunk PROPERTIES VERSION 6.2.1) 22 | endif(NOT ANDROID) 23 | if(ANDROID) 24 | # need to explicitly link to the math library because the CMake/Android toolchains may not do it automatically 25 | target_link_libraries(chipmunk m) 26 | endif(ANDROID) 27 | install(TARGETS chipmunk RUNTIME DESTINATION lib LIBRARY DESTINATION lib) 28 | endif(BUILD_SHARED) 29 | 30 | if(BUILD_STATIC) 31 | add_library(chipmunk_static STATIC 32 | ${chipmunk_source_files} 33 | ) 34 | # Tell MSVC to compile the code as C++. 35 | if(MSVC) 36 | set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) 37 | set_target_properties(chipmunk_static PROPERTIES LINKER_LANGUAGE CXX) 38 | endif(MSVC) 39 | # Sets chipmunk_static to output "libchipmunk.a" not "libchipmunk_static.a" 40 | set_target_properties(chipmunk_static PROPERTIES OUTPUT_NAME chipmunk) 41 | if(INSTALL_STATIC) 42 | install(TARGETS chipmunk_static ARCHIVE DESTINATION lib) 43 | endif(INSTALL_STATIC) 44 | endif(BUILD_STATIC) 45 | 46 | if(BUILD_SHARED OR INSTALL_STATIC) 47 | # FIXME: change to PUBLIC_HEADER to allow building frameworks 48 | install(FILES ${chipmunk_public_header} DESTINATION include/chipmunk) 49 | install(FILES ${chipmunk_constraint_header} DESTINATION include/chipmunk/constraints) 50 | endif(BUILD_SHARED OR INSTALL_STATIC) 51 | 52 | set_target_properties(chipmunk_static 53 | PROPERTIES 54 | ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" 55 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" 56 | ) 57 | 58 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/chipmunk_unsafe.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /* This header defines a number of "unsafe" operations on Chipmunk objects. 23 | * In this case "unsafe" is referring to operations which may reduce the 24 | * physical accuracy or numerical stability of the simulation, but will not 25 | * cause crashes. 26 | * 27 | * The prime example is mutating collision shapes. Chipmunk does not support 28 | * this directly. Mutating shapes using this API will caused objects in contact 29 | * to be pushed apart using Chipmunk's overlap solver, but not using real 30 | * persistent velocities. Probably not what you meant, but perhaps close enough. 31 | */ 32 | 33 | /// @defgroup unsafe Chipmunk Unsafe Shape Operations 34 | /// These functions are used for mutating collision shapes. 35 | /// Chipmunk does not have any way to get velocity information on changing shapes, 36 | /// so the results will be unrealistic. You must explicity include the chipmunk_unsafe.h header to use them. 37 | /// @{ 38 | 39 | #ifndef CHIPMUNK_UNSAFE_HEADER 40 | #define CHIPMUNK_UNSAFE_HEADER 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /// Set the radius of a circle shape. 47 | void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius); 48 | /// Set the offset of a circle shape. 49 | void cpCircleShapeSetOffset(cpShape *shape, cpVect offset); 50 | 51 | /// Set the endpoints of a segment shape. 52 | void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b); 53 | /// Set the radius of a segment shape. 54 | void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius); 55 | 56 | /// Set the vertexes of a poly shape. 57 | void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset); 58 | /// Set the radius of a poly shape. 59 | void cpPolyShapeSetRadius(cpShape *shape, cpFloat radius); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #endif 65 | /// @} 66 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpConstraint.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "chipmunk_private.h" 23 | #include "constraints/util.h" 24 | 25 | // TODO: Comment me! 26 | 27 | void cpConstraintDestroy(cpConstraint *constraint){} 28 | 29 | void 30 | cpConstraintFree(cpConstraint *constraint) 31 | { 32 | if(constraint){ 33 | cpConstraintDestroy(constraint); 34 | cpfree(constraint); 35 | } 36 | } 37 | 38 | // *** declared in util.h TODO move declaration to chipmunk_private.h 39 | 40 | void 41 | cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, cpBody *a, cpBody *b) 42 | { 43 | constraint->klass = klass; 44 | 45 | constraint->a = a; 46 | constraint->b = b; 47 | constraint->space = NULL; 48 | 49 | constraint->next_a = NULL; 50 | constraint->next_b = NULL; 51 | 52 | constraint->maxForce = (cpFloat)INFINITY; 53 | constraint->errorBias = cpfpow(1.0f - 0.1f, 60.0f); 54 | constraint->maxBias = (cpFloat)INFINITY; 55 | 56 | constraint->preSolve = NULL; 57 | constraint->postSolve = NULL; 58 | } 59 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpDampedRotarySpring.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpDampedRotarySpring cpDampedRotarySpring 23 | /// @{ 24 | 25 | typedef cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, cpFloat relativeAngle); 26 | 27 | const cpConstraintClass *cpDampedRotarySpringGetClass(void); 28 | 29 | /// @private 30 | typedef struct cpDampedRotarySpring { 31 | cpConstraint constraint; 32 | cpFloat restAngle; 33 | cpFloat stiffness; 34 | cpFloat damping; 35 | cpDampedRotarySpringTorqueFunc springTorqueFunc; 36 | 37 | cpFloat target_wrn; 38 | cpFloat w_coef; 39 | 40 | cpFloat iSum; 41 | cpFloat jAcc; 42 | } cpDampedRotarySpring; 43 | 44 | /// Allocate a damped rotary spring. 45 | cpDampedRotarySpring* cpDampedRotarySpringAlloc(void); 46 | /// Initialize a damped rotary spring. 47 | cpDampedRotarySpring* cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); 48 | /// Allocate and initialize a damped rotary spring. 49 | cpConstraint* cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); 50 | 51 | CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, restAngle, RestAngle) 52 | CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, stiffness, Stiffness) 53 | CP_DefineConstraintProperty(cpDampedRotarySpring, cpFloat, damping, Damping) 54 | CP_DefineConstraintProperty(cpDampedRotarySpring, cpDampedRotarySpringTorqueFunc, springTorqueFunc, SpringTorqueFunc) 55 | 56 | /// @} 57 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpDampedSpring.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpDampedSpring cpDampedSpring 23 | /// @{ 24 | 25 | typedef struct cpDampedSpring cpDampedSpring; 26 | 27 | typedef cpFloat (*cpDampedSpringForceFunc)(cpConstraint *spring, cpFloat dist); 28 | 29 | const cpConstraintClass *cpDampedSpringGetClass(void); 30 | 31 | /// @private 32 | struct cpDampedSpring { 33 | cpConstraint constraint; 34 | cpVect anchr1, anchr2; 35 | cpFloat restLength; 36 | cpFloat stiffness; 37 | cpFloat damping; 38 | cpDampedSpringForceFunc springForceFunc; 39 | 40 | cpFloat target_vrn; 41 | cpFloat v_coef; 42 | 43 | cpVect r1, r2; 44 | cpFloat nMass; 45 | cpVect n; 46 | 47 | cpFloat jAcc; 48 | }; 49 | 50 | /// Allocate a damped spring. 51 | cpDampedSpring* cpDampedSpringAlloc(void); 52 | /// Initialize a damped spring. 53 | cpDampedSpring* cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); 54 | /// Allocate and initialize a damped spring. 55 | cpConstraint* cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping); 56 | 57 | CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr1, Anchr1) 58 | CP_DefineConstraintProperty(cpDampedSpring, cpVect, anchr2, Anchr2) 59 | CP_DefineConstraintProperty(cpDampedSpring, cpFloat, restLength, RestLength) 60 | CP_DefineConstraintProperty(cpDampedSpring, cpFloat, stiffness, Stiffness) 61 | CP_DefineConstraintProperty(cpDampedSpring, cpFloat, damping, Damping) 62 | CP_DefineConstraintProperty(cpDampedSpring, cpDampedSpringForceFunc, springForceFunc, SpringForceFunc) 63 | 64 | /// @} 65 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpGearJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpGearJoint cpGearJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpGearJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpGearJoint { 29 | cpConstraint constraint; 30 | cpFloat phase, ratio; 31 | cpFloat ratio_inv; 32 | 33 | cpFloat iSum; 34 | 35 | cpFloat bias; 36 | cpFloat jAcc; 37 | } cpGearJoint; 38 | 39 | /// Allocate a gear joint. 40 | cpGearJoint* cpGearJointAlloc(void); 41 | /// Initialize a gear joint. 42 | cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); 43 | /// Allocate and initialize a gear joint. 44 | cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); 45 | 46 | CP_DefineConstraintProperty(cpGearJoint, cpFloat, phase, Phase) 47 | CP_DefineConstraintGetter(cpGearJoint, cpFloat, ratio, Ratio) 48 | /// Set the ratio of a gear joint. 49 | void cpGearJointSetRatio(cpConstraint *constraint, cpFloat value); 50 | 51 | /// @} 52 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpGrooveJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpGrooveJoint cpGrooveJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpGrooveJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpGrooveJoint { 29 | cpConstraint constraint; 30 | cpVect grv_n, grv_a, grv_b; 31 | cpVect anchr2; 32 | 33 | cpVect grv_tn; 34 | cpFloat clamp; 35 | cpVect r1, r2; 36 | cpMat2x2 k; 37 | 38 | cpVect jAcc; 39 | cpVect bias; 40 | } cpGrooveJoint; 41 | 42 | /// Allocate a groove joint. 43 | cpGrooveJoint* cpGrooveJointAlloc(void); 44 | /// Initialize a groove joint. 45 | cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); 46 | /// Allocate and initialize a groove joint. 47 | cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2); 48 | 49 | CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_a, GrooveA) 50 | /// Set endpoint a of a groove joint's groove 51 | void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value); 52 | CP_DefineConstraintGetter(cpGrooveJoint, cpVect, grv_b, GrooveB) 53 | /// Set endpoint b of a groove joint's groove 54 | void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value); 55 | CP_DefineConstraintProperty(cpGrooveJoint, cpVect, anchr2, Anchr2) 56 | 57 | /// @} 58 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpPinJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpPinJoint cpPinJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpPinJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpPinJoint { 29 | cpConstraint constraint; 30 | cpVect anchr1, anchr2; 31 | cpFloat dist; 32 | 33 | cpVect r1, r2; 34 | cpVect n; 35 | cpFloat nMass; 36 | 37 | cpFloat jnAcc; 38 | cpFloat bias; 39 | } cpPinJoint; 40 | 41 | /// Allocate a pin joint. 42 | cpPinJoint* cpPinJointAlloc(void); 43 | /// Initialize a pin joint. 44 | cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); 45 | /// Allocate and initialize a pin joint. 46 | cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); 47 | 48 | CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr1, Anchr1) 49 | CP_DefineConstraintProperty(cpPinJoint, cpVect, anchr2, Anchr2) 50 | CP_DefineConstraintProperty(cpPinJoint, cpFloat, dist, Dist) 51 | 52 | ///@} 53 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpPivotJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpPivotJoint cpPivotJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpPivotJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpPivotJoint { 29 | cpConstraint constraint; 30 | cpVect anchr1, anchr2; 31 | 32 | cpVect r1, r2; 33 | cpMat2x2 k; 34 | 35 | cpVect jAcc; 36 | cpVect bias; 37 | } cpPivotJoint; 38 | 39 | /// Allocate a pivot joint 40 | cpPivotJoint* cpPivotJointAlloc(void); 41 | /// Initialize a pivot joint. 42 | cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); 43 | /// Allocate and initialize a pivot joint. 44 | cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); 45 | /// Allocate and initialize a pivot joint with specific anchors. 46 | cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2); 47 | 48 | CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr1, Anchr1) 49 | CP_DefineConstraintProperty(cpPivotJoint, cpVect, anchr2, Anchr2) 50 | 51 | /// @} 52 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpRatchetJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpRatchetJoint cpRatchetJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpRatchetJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpRatchetJoint { 29 | cpConstraint constraint; 30 | cpFloat angle, phase, ratchet; 31 | 32 | cpFloat iSum; 33 | 34 | cpFloat bias; 35 | cpFloat jAcc; 36 | } cpRatchetJoint; 37 | 38 | /// Allocate a ratchet joint. 39 | cpRatchetJoint* cpRatchetJointAlloc(void); 40 | /// Initialize a ratched joint. 41 | cpRatchetJoint* cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); 42 | /// Allocate and initialize a ratchet joint. 43 | cpConstraint* cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); 44 | 45 | CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, angle, Angle) 46 | CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, phase, Phase) 47 | CP_DefineConstraintProperty(cpRatchetJoint, cpFloat, ratchet, Ratchet) 48 | 49 | /// @} 50 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpRotaryLimitJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpRotaryLimitJoint cpRotaryLimitJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpRotaryLimitJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpRotaryLimitJoint { 29 | cpConstraint constraint; 30 | cpFloat min, max; 31 | 32 | cpFloat iSum; 33 | 34 | cpFloat bias; 35 | cpFloat jAcc; 36 | } cpRotaryLimitJoint; 37 | 38 | /// Allocate a damped rotary limit joint. 39 | cpRotaryLimitJoint* cpRotaryLimitJointAlloc(void); 40 | /// Initialize a damped rotary limit joint. 41 | cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); 42 | /// Allocate and initialize a damped rotary limit joint. 43 | cpConstraint* cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); 44 | 45 | CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, min, Min) 46 | CP_DefineConstraintProperty(cpRotaryLimitJoint, cpFloat, max, Max) 47 | 48 | /// @} 49 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpSimpleMotor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpSimpleMotor cpSimpleMotor 23 | /// @{ 24 | 25 | const cpConstraintClass *cpSimpleMotorGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpSimpleMotor { 29 | cpConstraint constraint; 30 | cpFloat rate; 31 | 32 | cpFloat iSum; 33 | 34 | cpFloat jAcc; 35 | } cpSimpleMotor; 36 | 37 | /// Allocate a simple motor. 38 | cpSimpleMotor* cpSimpleMotorAlloc(void); 39 | /// initialize a simple motor. 40 | cpSimpleMotor* cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); 41 | /// Allocate and initialize a simple motor. 42 | cpConstraint* cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); 43 | 44 | CP_DefineConstraintProperty(cpSimpleMotor, cpFloat, rate, Rate) 45 | 46 | /// @} 47 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/constraints/cpSlideJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpSlideJoint cpSlideJoint 23 | /// @{ 24 | 25 | const cpConstraintClass *cpSlideJointGetClass(void); 26 | 27 | /// @private 28 | typedef struct cpSlideJoint { 29 | cpConstraint constraint; 30 | cpVect anchr1, anchr2; 31 | cpFloat min, max; 32 | 33 | cpVect r1, r2; 34 | cpVect n; 35 | cpFloat nMass; 36 | 37 | cpFloat jnAcc; 38 | cpFloat bias; 39 | } cpSlideJoint; 40 | 41 | /// Allocate a slide joint. 42 | cpSlideJoint* cpSlideJointAlloc(void); 43 | /// Initialize a slide joint. 44 | cpSlideJoint* cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); 45 | /// Allocate and initialize a slide joint. 46 | cpConstraint* cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max); 47 | 48 | CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr1, Anchr1) 49 | CP_DefineConstraintProperty(cpSlideJoint, cpVect, anchr2, Anchr2) 50 | CP_DefineConstraintProperty(cpSlideJoint, cpFloat, min, Min) 51 | CP_DefineConstraintProperty(cpSlideJoint, cpFloat, max, Max) 52 | 53 | /// @} 54 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/cpBB.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "chipmunk_private.h" 23 | 24 | cpVect 25 | cpBBWrapVect(const cpBB bb, const cpVect v) 26 | { 27 | cpFloat ix = cpfabs(bb.r - bb.l); 28 | cpFloat modx = cpfmod(v.x - bb.l, ix); 29 | cpFloat x = (modx > 0.0f) ? modx : modx + ix; 30 | 31 | cpFloat iy = cpfabs(bb.t - bb.b); 32 | cpFloat mody = cpfmod(v.y - bb.b, iy); 33 | cpFloat y = (mody > 0.0f) ? mody : mody + iy; 34 | 35 | return cpv(x + bb.l, y + bb.b); 36 | } 37 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/cpSpatialIndex.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "chipmunk_private.h" 23 | 24 | void 25 | cpSpatialIndexFree(cpSpatialIndex *index) 26 | { 27 | if(index){ 28 | cpSpatialIndexDestroy(index); 29 | cpfree(index); 30 | } 31 | } 32 | 33 | cpSpatialIndex * 34 | cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) 35 | { 36 | index->klass = klass; 37 | index->bbfunc = bbfunc; 38 | index->staticIndex = staticIndex; 39 | 40 | if(staticIndex){ 41 | cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index."); 42 | staticIndex->dynamicIndex = index; 43 | } 44 | 45 | return index; 46 | } 47 | 48 | typedef struct dynamicToStaticContext { 49 | cpSpatialIndexBBFunc bbfunc; 50 | cpSpatialIndex *staticIndex; 51 | cpSpatialIndexQueryFunc queryFunc; 52 | void *data; 53 | } dynamicToStaticContext; 54 | 55 | static void 56 | dynamicToStaticIter(void *obj, dynamicToStaticContext *context) 57 | { 58 | cpSpatialIndexQuery(context->staticIndex, obj, context->bbfunc(obj), context->queryFunc, context->data); 59 | } 60 | 61 | void 62 | cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data) 63 | { 64 | if(staticIndex && cpSpatialIndexCount(staticIndex) > 0){ 65 | dynamicToStaticContext context = {dynamicIndex->bbfunc, staticIndex, func, data}; 66 | cpSpatialIndexEach(dynamicIndex, (cpSpatialIndexIteratorFunc)dynamicToStaticIter, &context); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/cpVect.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "chipmunk_private.h" 25 | 26 | cpVect 27 | cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t) 28 | { 29 | cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); 30 | cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); 31 | 32 | if(omega < 1e-3){ 33 | // If the angle between two vectors is very small, lerp instead to avoid precision issues. 34 | return cpvlerp(v1, v2, t); 35 | } else { 36 | cpFloat denom = 1.0f/cpfsin(omega); 37 | return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom)); 38 | } 39 | } 40 | 41 | cpVect 42 | cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a) 43 | { 44 | cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); 45 | cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); 46 | 47 | return cpvslerp(v1, v2, cpfmin(a, omega)/omega); 48 | } 49 | 50 | char* 51 | cpvstr(const cpVect v) 52 | { 53 | static char str[256]; 54 | sprintf(str, "(% .3f, % .3f)", v.x, v.y); 55 | return str; 56 | } 57 | -------------------------------------------------------------------------------- /old/original.sources/cplus/src/prime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | // Used for resizing hash tables. 23 | // Values approximately double. 24 | // http://planetmath.org/encyclopedia/GoodHashTablePrimes.html 25 | static int primes[] = { 26 | 5, 27 | 13, 28 | 23, 29 | 47, 30 | 97, 31 | 193, 32 | 389, 33 | 769, 34 | 1543, 35 | 3079, 36 | 6151, 37 | 12289, 38 | 24593, 39 | 49157, 40 | 98317, 41 | 196613, 42 | 393241, 43 | 786433, 44 | 1572869, 45 | 3145739, 46 | 6291469, 47 | 12582917, 48 | 25165843, 49 | 50331653, 50 | 100663319, 51 | 201326611, 52 | 402653189, 53 | 805306457, 54 | 1610612741, 55 | 0, 56 | }; 57 | 58 | static inline int 59 | next_prime(int n) 60 | { 61 | int i = 0; 62 | while(n > primes[i]){ 63 | i++; 64 | cpAssertHard(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen 65 | } 66 | 67 | return primes[i]; 68 | } 69 | -------------------------------------------------------------------------------- /old/original.sources/javascript/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /old/original.sources/javascript/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean, all 2 | 3 | all: cp.min.js cp.extra.min.js bench.js demos.js 4 | 5 | js = chipmunk.js \ 6 | cpVect.js \ 7 | cpBB.js \ 8 | cpShape.js \ 9 | cpPolyShape.js \ 10 | cpBody.js \ 11 | cpSpatialIndex.js \ 12 | cpBBTree.js \ 13 | cpArbiter.js \ 14 | cpCollision.js \ 15 | cpSpace.js \ 16 | cpSpaceComponent.js \ 17 | cpSpaceQuery.js \ 18 | cpSpaceStep.js 19 | 20 | constraints = \ 21 | util.js \ 22 | cpConstraint.js \ 23 | cpPinJoint.js \ 24 | cpSlideJoint.js \ 25 | cpPivotJoint.js \ 26 | cpGrooveJoint.js \ 27 | cpDampedSpring.js \ 28 | cpDampedRotarySpring.js \ 29 | cpRotaryLimitJoint.js \ 30 | cpRatchetJoint.js \ 31 | cpGearJoint.js \ 32 | cpSimpleMotor.js 33 | 34 | demos = demo.js \ 35 | ball.js \ 36 | PyramidStack.js \ 37 | PyramidTopple.js 38 | 39 | jsfiles = $(addprefix lib/, $(js)) 40 | constraintfiles = $(addprefix lib/constraints/, $(constraints)) 41 | demofiles = $(addprefix demo/, $(demos)) 42 | 43 | cp.js: $(jsfiles) $(constraintfiles) 44 | echo '(function(){' > $@ 45 | cat $+ >> $@ 46 | echo "})();" >> $@ 47 | 48 | %.min.js: %.js 49 | uglifyjs $+ -m -c > $@ 50 | 51 | bench.js: $(jsfiles) $(constraintfiles) benchmark/mersenne.js benchmark/bench.js 52 | cat $+ > $@ 53 | 54 | demos.js: $(demofiles) 55 | cat $+ > $@ 56 | 57 | clean: 58 | rm -f cp.js cp.min.js cp.extra.min.js bench.js demos.js 59 | -------------------------------------------------------------------------------- /old/original.sources/javascript/benchmark/bench.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/Convex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/Convex.js: -------------------------------------------------------------------------------- 1 | 2 | var DENSITY = 1/10000; 3 | 4 | 5 | var Convex = function() { 6 | Demo.call(this); 7 | 8 | this.message = "Right click and drag to change the block's shape."; 9 | 10 | var space = this.space; 11 | space.iterations = 30; 12 | space.gravity = v(0, -500); 13 | space.sleepTimeThreshold = 0.5; 14 | space.collisionSlop = 0.5; 15 | 16 | var body, staticBody = space.staticBody; 17 | 18 | // Create segments around the edge of the screen. 19 | this.addFloor(); 20 | 21 | var width = 50; 22 | var height = 70; 23 | var mass = width*height*DENSITY; 24 | var moment = cp.momentForBox(mass, width, height); 25 | 26 | body = space.addBody(new cp.Body(mass, moment)); 27 | body.setPos(v(320, height / 2)); 28 | 29 | this.shape = space.addShape(new cp.BoxShape(body, width, height)); 30 | this.shape.setFriction(0.6); 31 | }; 32 | 33 | Convex.prototype = Object.create(Demo.prototype); 34 | 35 | Convex.prototype.update = function(dt) { 36 | var tolerance = 2; 37 | 38 | info = this.shape.nearestPointQuery(this.mouse); 39 | if(this.rightClick && info.d > tolerance){ 40 | var shape = this.shape; 41 | var body = shape.getBody(); 42 | var count = shape.getNumVerts(); 43 | 44 | // Allocate the space for the new vertexes on the stack. 45 | var verts = new Array((count + 1)*2); 46 | 47 | for(var i=0; i 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/PyramidStack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/PyramidStack.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | var PyramidStack = function() { 23 | Demo.call(this); 24 | 25 | var space = this.space; 26 | //space.iterations = 30; 27 | space.gravity = v(0, -100); 28 | space.sleepTimeThreshold = 0.5; 29 | space.collisionSlop = 0.5; 30 | 31 | var body, staticBody = space.staticBody; 32 | var shape; 33 | 34 | this.addFloor(); 35 | this.addWalls(); 36 | 37 | // Add lots of boxes. 38 | for(var i=0; i<14; i++){ 39 | for(var j=0; j<=i; j++){ 40 | body = space.addBody(new cp.Body(1, cp.momentForBox(1, 30, 30))); 41 | body.setPos(v(j*32 - i*16 + 320, 540 - i*32)); 42 | 43 | shape = space.addShape(new cp.BoxShape(body, 30, 30)); 44 | shape.setElasticity(0); 45 | shape.setFriction(0.8); 46 | } 47 | } 48 | 49 | // Add a ball to make things more interesting 50 | var radius = 15; 51 | body = space.addBody(new cp.Body(10, cp.momentForCircle(10, 0, radius, v(0,0)))); 52 | body.setPos(v(320, radius+5)); 53 | 54 | shape = space.addShape(new cp.CircleShape(body, radius, v(0,0))); 55 | shape.setElasticity(0); 56 | shape.setFriction(0.9); 57 | }; 58 | 59 | PyramidStack.prototype = Object.create(Demo.prototype); 60 | 61 | PyramidStack.prototype.update = function(dt) 62 | { 63 | var steps = 3; 64 | dt /= steps; 65 | for (var i = 0; i < 3; i++){ 66 | this.space.step(dt); 67 | } 68 | }; 69 | 70 | addDemo('Pyramid Stack', PyramidStack); 71 | 72 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/PyramidTopple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/Query.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/ball.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/ball.js: -------------------------------------------------------------------------------- 1 | var Balls = function() { 2 | Demo.call(this); 3 | 4 | var space = this.space; 5 | space.iterations = 60; 6 | space.gravity = v(0, -500); 7 | space.sleepTimeThreshold = 0.5; 8 | space.collisionSlop = 0.5; 9 | space.sleepTimeThreshold = 0.5; 10 | 11 | this.addFloor(); 12 | this.addWalls(); 13 | 14 | var width = 50; 15 | var height = 60; 16 | var mass = width * height * 1/1000; 17 | var rock = space.addBody(new cp.Body(mass, cp.momentForBox(mass, width, height))); 18 | rock.setPos(v(500, 100)); 19 | rock.setAngle(1); 20 | shape = space.addShape(new cp.BoxShape(rock, width, height)); 21 | shape.setFriction(0.3); 22 | shape.setElasticity(0.3); 23 | 24 | for (var i = 1; i <= 10; i++) { 25 | var radius = 20; 26 | mass = 3; 27 | var body = space.addBody(new cp.Body(mass, cp.momentForCircle(mass, 0, radius, v(0, 0)))); 28 | body.setPos(v(200 + i, (2 * radius + 5) * i)); 29 | var circle = space.addShape(new cp.CircleShape(body, radius, v(0, 0))); 30 | circle.setElasticity(0.8); 31 | circle.setFriction(1); 32 | } 33 | 34 | 35 | /* 36 | * atom.canvas.onmousedown = function(e) { 37 | radius = 10; 38 | mass = 3; 39 | body = space.addBody(new cp.Body(mass, cp.momentForCircle(mass, 0, radius, v(0, 0)))); 40 | body.setPos(v(e.clientX, e.clientY)); 41 | circle = space.addShape(new cp.CircleShape(body, radius, v(0, 0))); 42 | circle.setElasticity(0.5); 43 | return circle.setFriction(1); 44 | }; 45 | */ 46 | 47 | this.ctx.strokeStyle = "black"; 48 | 49 | var ramp = space.addShape(new cp.SegmentShape(space.staticBody, v(100, 100), v(300, 200), 10)); 50 | ramp.setElasticity(1); 51 | ramp.setFriction(1); 52 | ramp.setLayers(NOT_GRABABLE_MASK); 53 | 54 | }; 55 | 56 | Balls.prototype = Object.create(Demo.prototype); 57 | 58 | addDemo('Balls', Balls); 59 | 60 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/buoyancy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/grossiniDanceLayer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/grossiniDanceLayer.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | var Dance = function() { 23 | 24 | Demo.call(this); 25 | 26 | var space = this.space; 27 | 28 | space.gravity = v(0, -300); 29 | 30 | this.addFloor(); 31 | this.addWalls(); 32 | 33 | var width = 50; 34 | var height = 60; 35 | var mass = width * height * 1/1000; 36 | var rock = space.addBody(new cp.Body(mass, cp.momentForBox(mass, width, height))); 37 | rock.setPos(v(500, 100)); 38 | rock.setAngle(1); 39 | shape = space.addShape(new cp.BoxShape(rock, width, height)); 40 | shape.setFriction(0.3); 41 | shape.setElasticity(0.3); 42 | 43 | }; 44 | 45 | Dance.prototype = Object.create(Demo.prototype); 46 | 47 | Dance.prototype.update = function(dt) 48 | { 49 | var steps = 3; 50 | dt /= steps; 51 | for (var i = 0; i < 3; i++){ 52 | this.space.step(dt); 53 | } 54 | } 55 | 56 | 57 | addDemo('Dance', Dance); 58 | 59 | -------------------------------------------------------------------------------- /old/original.sources/javascript/demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 87 | -------------------------------------------------------------------------------- /old/original.sources/javascript/lib/constraints/cpConstraint.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | // TODO: Comment me! 23 | 24 | // a and b are bodies that the constraint applies to. 25 | var Constraint = cp.Constraint = function(a, b) 26 | { 27 | /// The first body connected to this constraint. 28 | this.a = a; 29 | /// The second body connected to this constraint. 30 | this.b = b; 31 | 32 | this.space = null; 33 | 34 | this.next_a = null; 35 | this.next_b = null; 36 | 37 | /// The maximum force that this constraint is allowed to use. 38 | this.maxForce = Infinity; 39 | /// The rate at which joint error is corrected. 40 | /// Defaults to pow(1 - 0.1, 60) meaning that it will 41 | /// correct 10% of the error every 1/60th of a second. 42 | this.errorBias = Math.pow(1 - 0.1, 60); 43 | /// The maximum rate at which joint error is corrected. 44 | this.maxBias = Infinity; 45 | }; 46 | 47 | Constraint.prototype.activateBodies = function() 48 | { 49 | if(this.a) this.a.activate(); 50 | if(this.b) this.b.activate(); 51 | }; 52 | 53 | /// These methods are overridden by the constraint itself. 54 | Constraint.prototype.preStep = function(dt) {}; 55 | Constraint.prototype.applyCachedImpulse = function(dt_coef) {}; 56 | Constraint.prototype.applyImpulse = function() {}; 57 | Constraint.prototype.getImpulse = function() { return 0; }; 58 | 59 | /// Function called before the solver runs. This can be overridden by the user 60 | /// to customize the constraint. 61 | /// Animate your joint anchors, update your motor torque, etc. 62 | Constraint.prototype.preSolve = function(space) {}; 63 | 64 | /// Function called after the solver runs. This can be overridden by the user 65 | /// to customize the constraint. 66 | /// Use the applied impulse to perform effects like breakable joints. 67 | Constraint.prototype.postSolve = function(space) {}; 68 | 69 | Constraint.prototype.next = function(body) 70 | { 71 | return (this.a === body ? this.next_a : this.next_b); 72 | }; 73 | 74 | -------------------------------------------------------------------------------- /old/original.sources/javascript/lib/constraints/cpDampedRotarySpring.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | var defaultSpringTorque = function(spring, relativeAngle){ 23 | return (relativeAngle - spring.restAngle)*spring.stiffness; 24 | } 25 | 26 | var DampedRotarySpring = cp.DampedRotarySpring = function(a, b, restAngle, stiffness, damping) 27 | { 28 | Constraint.call(this, a, b); 29 | 30 | this.restAngle = restAngle; 31 | this.stiffness = stiffness; 32 | this.damping = damping; 33 | this.springTorqueFunc = defaultSpringTorque; 34 | 35 | this.target_wrn = 0; 36 | this.w_coef = 0; 37 | this.iSum = 0; 38 | }; 39 | 40 | DampedRotarySpring.prototype = Object.create(Constraint.prototype); 41 | 42 | DampedRotarySpring.prototype.preStep = function(dt) 43 | { 44 | var a = this.a; 45 | var b = this.b; 46 | 47 | var moment = a.i_inv + b.i_inv; 48 | assertSoft(moment !== 0, "Unsolvable spring."); 49 | this.iSum = 1/moment; 50 | 51 | this.w_coef = 1 - Math.exp(-this.damping*dt*moment); 52 | this.target_wrn = 0; 53 | 54 | // apply this torque 55 | var j_spring = this.springTorqueFunc(this, a.a - b.a)*dt; 56 | a.w -= j_spring*a.i_inv; 57 | b.w += j_spring*b.i_inv; 58 | }; 59 | 60 | // DampedRotarySpring.prototype.applyCachedImpulse = function(dt_coef){}; 61 | 62 | DampedRotarySpring.prototype.applyImpulse = function() 63 | { 64 | var a = this.a; 65 | var b = this.b; 66 | 67 | // compute relative velocity 68 | var wrn = a.w - b.w;//normal_relative_velocity(a, b, r1, r2, n) - this.target_vrn; 69 | 70 | // compute velocity loss from drag 71 | // not 100% certain spring is derived correctly, though it makes sense 72 | var w_damp = (this.target_wrn - wrn)*this.w_coef; 73 | this.target_wrn = wrn + w_damp; 74 | 75 | //apply_impulses(a, b, this.r1, this.r2, vmult(this.n, v_damp*this.nMass)); 76 | var j_damp = w_damp*this.iSum; 77 | a.w += j_damp*a.i_inv; 78 | b.w -= j_damp*b.i_inv; 79 | }; 80 | 81 | // DampedRotarySpring.prototype.getImpulse = function(){ return 0; }; 82 | 83 | -------------------------------------------------------------------------------- /old/original.sources/javascript/lib/constraints/cpGearJoint.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | var GearJoint = cp.GearJoint = function(a, b, phase, ratio) 23 | { 24 | Constraint.call(this, a, b); 25 | 26 | this.phase = phase; 27 | this.ratio = ratio; 28 | this.ratio_inv = 1/ratio; 29 | 30 | this.jAcc = 0; 31 | 32 | this.iSum = this.bias = this.jMax = 0; 33 | }; 34 | 35 | GearJoint.prototype = Object.create(Constraint.prototype); 36 | 37 | GearJoint.prototype.preStep = function(dt) 38 | { 39 | var a = this.a; 40 | var b = this.b; 41 | 42 | // calculate moment of inertia coefficient. 43 | this.iSum = 1/(a.i_inv*this.ratio_inv + this.ratio*b.i_inv); 44 | 45 | // calculate bias velocity 46 | var maxBias = this.maxBias; 47 | this.bias = clamp(-bias_coef(this.errorBias, dt)*(b.a*this.ratio - a.a - this.phase)/dt, -maxBias, maxBias); 48 | 49 | // compute max impulse 50 | this.jMax = this.maxForce * dt; 51 | }; 52 | 53 | GearJoint.prototype.applyCachedImpulse = function(dt_coef) 54 | { 55 | var a = this.a; 56 | var b = this.b; 57 | 58 | var j = this.jAcc*dt_coef; 59 | a.w -= j*a.i_inv*this.ratio_inv; 60 | b.w += j*b.i_inv; 61 | }; 62 | 63 | GearJoint.prototype.applyImpulse = function() 64 | { 65 | var a = this.a; 66 | var b = this.b; 67 | 68 | // compute relative rotational velocity 69 | var wr = b.w*this.ratio - a.w; 70 | 71 | // compute normal impulse 72 | var j = (this.bias - wr)*this.iSum; 73 | var jOld = this.jAcc; 74 | this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); 75 | j = this.jAcc - jOld; 76 | 77 | // apply impulse 78 | a.w -= j*a.i_inv*this.ratio_inv; 79 | b.w += j*b.i_inv; 80 | }; 81 | 82 | GearJoint.prototype.getImpulse = function() 83 | { 84 | return Math.abs(this.jAcc); 85 | }; 86 | 87 | GearJoint.prototype.setRatio = function(value) 88 | { 89 | this.ratio = value; 90 | this.ratio_inv = 1/value; 91 | this.activateBodies(); 92 | }; 93 | 94 | -------------------------------------------------------------------------------- /old/original.sources/javascript/lib/constraints/cpSimpleMotor.js: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Scott Lembcke 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | var SimpleMotor = cp.SimpleMotor = function(a, b, rate) 23 | { 24 | Constraint.call(this, a, b); 25 | 26 | this.rate = rate; 27 | 28 | this.jAcc = 0; 29 | 30 | this.iSum = this.jMax = 0; 31 | }; 32 | 33 | SimpleMotor.prototype = Object.create(Constraint.prototype); 34 | 35 | SimpleMotor.prototype.preStep = function(dt) 36 | { 37 | // calculate moment of inertia coefficient. 38 | this.iSum = 1/(this.a.i_inv + this.b.i_inv); 39 | 40 | // compute max impulse 41 | this.jMax = this.maxForce * dt; 42 | }; 43 | 44 | SimpleMotor.prototype.applyCachedImpulse = function(dt_coef) 45 | { 46 | var a = this.a; 47 | var b = this.b; 48 | 49 | var j = this.jAcc*dt_coef; 50 | a.w -= j*a.i_inv; 51 | b.w += j*b.i_inv; 52 | }; 53 | 54 | SimpleMotor.prototype.applyImpulse = function() 55 | { 56 | var a = this.a; 57 | var b = this.b; 58 | 59 | // compute relative rotational velocity 60 | var wr = b.w - a.w + this.rate; 61 | 62 | // compute normal impulse 63 | var j = -wr*this.iSum; 64 | var jOld = this.jAcc; 65 | this.jAcc = clamp(jOld + j, -this.jMax, this.jMax); 66 | j = this.jAcc - jOld; 67 | 68 | // apply impulse 69 | a.w -= j*a.i_inv; 70 | b.w += j*b.i_inv; 71 | }; 72 | 73 | SimpleMotor.prototype.getImpulse = function() 74 | { 75 | return Math.abs(this.jAcc); 76 | }; 77 | 78 | -------------------------------------------------------------------------------- /old/original.sources/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Joseph Gentle (josephg.com)", 3 | "name": "chipmunk", 4 | "description": "Chipmunk 2d physics engine, in Javascript", 5 | "version": "6.1.1", 6 | "homepage": "https://github.com/josephg/chipmunk-js", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/josephg/Chipmunk-js.git" 10 | }, 11 | "main": "cp.js", 12 | "engines": { 13 | "node": "~0.6.5" 14 | }, 15 | "keywords": ["physics", "engine", "chipmunk"], 16 | "dependencies": {}, 17 | "devDependencies": {} 18 | } 19 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using AppKit; 2 | using Foundation; 3 | 4 | namespace ChipmunkSharp.Example.Cocoa 5 | { 6 | [Register ("AppDelegate")] 7 | public class AppDelegate : NSApplicationDelegate 8 | { 9 | public AppDelegate () 10 | { 11 | } 12 | 13 | public override void DidFinishLaunching (NSNotification notification) 14 | { 15 | // Insert code here to initialize your application 16 | } 17 | 18 | public override void WillTerminate (NSNotification notification) 19 | { 20 | // Insert code here to tear down your application 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "filename": "AppIcon-16.png", 5 | "size": "16x16", 6 | "scale": "1x", 7 | "idiom": "mac" 8 | }, 9 | { 10 | "filename": "AppIcon-16@2x.png", 11 | "size": "16x16", 12 | "scale": "2x", 13 | "idiom": "mac" 14 | }, 15 | { 16 | "filename": "AppIcon-32.png", 17 | "size": "32x32", 18 | "scale": "1x", 19 | "idiom": "mac" 20 | }, 21 | { 22 | "filename": "AppIcon-32@2x.png", 23 | "size": "32x32", 24 | "scale": "2x", 25 | "idiom": "mac" 26 | }, 27 | { 28 | "filename": "AppIcon-128.png", 29 | "size": "128x128", 30 | "scale": "1x", 31 | "idiom": "mac" 32 | }, 33 | { 34 | "filename": "AppIcon-128@2x.png", 35 | "size": "128x128", 36 | "scale": "2x", 37 | "idiom": "mac" 38 | }, 39 | { 40 | "filename": "AppIcon-256.png", 41 | "size": "256x256", 42 | "scale": "1x", 43 | "idiom": "mac" 44 | }, 45 | { 46 | "filename": "AppIcon-256@2x.png", 47 | "size": "256x256", 48 | "scale": "2x", 49 | "idiom": "mac" 50 | }, 51 | { 52 | "filename": "AppIcon-512.png", 53 | "size": "512x512", 54 | "scale": "1x", 55 | "idiom": "mac" 56 | }, 57 | { 58 | "filename": "AppIcon-512@2x.png", 59 | "size": "512x512", 60 | "scale": "2x", 61 | "idiom": "mac" 62 | } 63 | ], 64 | "info": { 65 | "version": 1, 66 | "author": "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/CocoaHelpers.cs: -------------------------------------------------------------------------------- 1 | using CoreGraphics; 2 | 3 | namespace ChipmunkSharp 4 | { 5 | public static class CocoaHelpers 6 | { 7 | public static CGPoint cpVert2Point (cpVect vert) 8 | { 9 | return new CGPoint (vert.x, vert.y); 10 | } 11 | 12 | public static CGPoint[] cpVertArray2ccpArrayN (cpVect[] cpVertArray, int count) 13 | { 14 | if (count == 0) 15 | return null; 16 | CGPoint[] pPoints = new CGPoint[count]; 17 | 18 | for (int i = 0; i < count; ++i) { 19 | pPoints[i].X = cpVertArray[i].x; 20 | pPoints[i].Y = cpVertArray[i].y; 21 | } 22 | return pPoints; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Games/Game1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AppKit; 3 | using CoreGraphics; 4 | 5 | namespace ChipmunkSharp.Example 6 | { 7 | class Game1 : GameBase 8 | { 9 | PhysicObject square; 10 | PhysicObject ground; 11 | cpSpace spc; 12 | 13 | public Game1 (cpSpace space) 14 | { 15 | spc = space; 16 | spc.SetGravity (new cpVect (0, 1f)); 17 | spc.AddDefaultCollisionHandler ().preSolveFunc = new Func ((arg1, arg2, arg3) => { Console.WriteLine ("ij"); return true; }); 18 | spc.AddDefaultCollisionHandler ().beginFunc = new Func ((arg1, arg2, arg3) => { Console.WriteLine ("ij"); return true; }); 19 | } 20 | 21 | protected override void OnUpdate (long tick) 22 | { 23 | spc.Step (1 / 60); 24 | square.Update (tick); 25 | ground.Update (tick); 26 | } 27 | 28 | public void Initialize (NSView contentView) 29 | { 30 | var roseImage = NSImage.ImageNamed ("basketball.png"); 31 | var squareImage = NSImage.ImageNamed ("football.png"); 32 | square = new PhysicObject (squareImage, 20, spc, false); 33 | ground = new PhysicObject (roseImage, 20, spc, false); 34 | square.SetPosition (300, 0); 35 | ground.SetPosition (330, 0); 36 | 37 | contentView.AddSubview (square); 38 | contentView.AddSubview (ground); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Games/GameBase.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace ChipmunkSharp.Example 4 | { 5 | abstract class GameBase 6 | { 7 | const int DefaultLoopTime = 10; 8 | bool stopping; 9 | 10 | public bool Loop { get; private set; } 11 | 12 | public int DelayTime { get; private set; } = DefaultLoopTime; 13 | 14 | public void Start (int delayTime = DefaultLoopTime, bool loop = false) 15 | { 16 | stopping = false; 17 | Loop = loop; 18 | DelayTime = delayTime; 19 | 20 | //Loop 21 | while (!stopping) { 22 | OnUpdate (0); 23 | Task.Delay (delayTime).Wait (); 24 | } 25 | } 26 | 27 | protected abstract void OnUpdate (long tick); 28 | 29 | public async Task StartAsync (int delayTime = DefaultLoopTime, bool loop = false) 30 | { 31 | await Task.Run (() => Start (delayTime, loop)); 32 | } 33 | 34 | public void Stop () 35 | { 36 | stopping = true; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Games/GameObject.cs: -------------------------------------------------------------------------------- 1 | using AppKit; 2 | using CoreGraphics; 3 | 4 | namespace ChipmunkSharp.Example 5 | { 6 | class GameObject : NSImageView 7 | { 8 | protected float angle = 0; 9 | 10 | public override bool IsFlipped => true; 11 | 12 | protected void SetPosition (cpVect vector) 13 | { 14 | Frame = new CGRect (vector.x, vector.y, Frame.Width, Frame.Height); 15 | } 16 | 17 | public GameObject (NSImage firstText) 18 | { 19 | Image = firstText; 20 | } 21 | 22 | public virtual void Update (long gametime) 23 | { 24 | 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Games/PhysicObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AppKit; 3 | 4 | namespace ChipmunkSharp.Example 5 | { 6 | class PhysicObject : GameObject 7 | { 8 | static Random rnd = new Random (DateTime.Now.Millisecond); 9 | 10 | static int collCount = 0; 11 | readonly cpBody physic; 12 | readonly cpSpace space; 13 | cpCircleShape shp; 14 | cpTransform trsf; 15 | 16 | public cpBody Physic { 17 | get { return physic; } 18 | } 19 | 20 | public cpShape Shape { 21 | get { return shp; } 22 | } 23 | 24 | public PhysicObject (NSImage firstText, int radius, cpSpace space, bool isKinematic = false) : base (firstText) 25 | { 26 | trsf = new cpTransform (); 27 | collCount++; 28 | physic = new cpBody (rnd.Next (500,1000), cp.PHYSICS_INFINITY); 29 | 30 | if (isKinematic) 31 | physic.SetBodyType (cpBodyType.KINEMATIC); 32 | shp = new cpCircleShape (physic, radius, cpVect.Zero); 33 | shp.Active (); 34 | shp.SetSensor (true); 35 | shp.SetCollisionType (1); 36 | physic.SetPosition (new cpVect ((float)Frame.Location.X, (float)Frame.Location.Y)); 37 | if (space != null) { 38 | space.AddBody (physic); 39 | space.AddShape (shp); 40 | this.space = space; 41 | } 42 | } 43 | 44 | public void SetPosition (float x, float y) 45 | { 46 | Frame = new CoreGraphics.CGRect (x, y, shp.r, shp.r); 47 | physic.SetPosition (new cpVect (x, y)); 48 | } 49 | 50 | public override void Update (long gametime) 51 | { 52 | physic.UpdateVelocity (space.GetGravity (), 1, 0.01f); 53 | physic.UpdatePosition (1); 54 | shp.Update (trsf); 55 | cpVect position = physic.GetPosition (); 56 | 57 | InvokeOnMainThread (() => { 58 | SetPosition (position); 59 | }); 60 | 61 | angle = (physic.GetAngle () % 360) / 57.2958f; 62 | if (position.y > 200) { 63 | physic.ApplyImpulse (new cpVect (1, -150), new cpVect (0.1f, 0.1f)); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | ChipmunkSharp.Example.Cocoa 7 | CFBundleIdentifier 8 | com.companyname.ChipmunkSharp-Example-Cocoa 9 | CFBundleShortVersionString 10 | 1.0 11 | CFBundleVersion 12 | 1 13 | LSMinimumSystemVersion 14 | 10.14 15 | CFBundleDevelopmentRegion 16 | en 17 | CFBundleInfoDictionaryVersion 18 | 6.0 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | NSHumanReadableCopyright 24 | 25 | NSPrincipalClass 26 | NSApplication 27 | XSAppIconAssets 28 | Assets.xcassets/AppIcon.appiconset 29 | 30 | 31 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Main.cs: -------------------------------------------------------------------------------- 1 | using AppKit; 2 | using CoreGraphics; 3 | 4 | namespace ChipmunkSharp.Example.Cocoa 5 | { 6 | static class MainClass 7 | { 8 | class SpaceView : NSView 9 | { 10 | public override bool IsFlipped => true; 11 | } 12 | 13 | static void Main (string[] args) 14 | { 15 | NSApplication.Init (); 16 | NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular; 17 | 18 | var xPos = NSScreen.MainScreen.Frame.Width / 2;// NSWidth([[window screen] frame])/ 2 - NSWidth([window frame])/ 2; 19 | var yPos = NSScreen.MainScreen.Frame.Height / 2; // NSHeight([[window screen] frame])/ 2 - NSHeight([window frame])/ 2; 20 | var mainWindow = new NSWindow (new CGRect (xPos, yPos, 600, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false) { 21 | ContentView = new SpaceView () 22 | }; 23 | 24 | var space = new cpSpace { 25 | CollisionEnabled = true 26 | }; 27 | 28 | #region Scene 29 | 30 | var example = new Game1 (space); 31 | example.Initialize (mainWindow.ContentView); 32 | example.StartAsync (loop: true); 33 | 34 | #endregion 35 | 36 | mainWindow.Title = "Example Debug Xamarin.Mac"; 37 | 38 | //mainWindow.MakeKeyWindow(); 39 | mainWindow.MakeKeyAndOrderFront (null); 40 | NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); 41 | NSApplication.SharedApplication.Run (); 42 | //mainWindow.Dispose(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/PhysicsDrawView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using AppKit; 3 | using CoreGraphics; 4 | 5 | namespace ChipmunkSharp 6 | { 7 | class PhysicsDrawView : NSView 8 | { 9 | public PhysicsDrawFlags Flags = PhysicsDrawFlags.None; 10 | 11 | cpSpace _space; 12 | cpBody _body; 13 | 14 | readonly IDrawDelegate drawDelegate; 15 | 16 | public PhysicsDrawView (IDrawDelegate drawDelegate, cpSpace space) 17 | { 18 | this.drawDelegate = drawDelegate; 19 | } 20 | 21 | public cpBody Body { 22 | get { return _body; } 23 | set { _body = value; } 24 | } 25 | 26 | public CGPoint Position { 27 | get { return CocoaHelpers.cpVert2Point (_body.GetPosition ()); } 28 | set { _body.SetPosition (new cpVect ((float) value.X, (float)value.Y)); } 29 | } 30 | 31 | public void DebugDraw () 32 | { 33 | //TODO: EEE 34 | 35 | } 36 | 37 | /// 38 | /// Append flags to the current flags. 39 | /// 40 | public void AppendFlags (params PhysicsDrawFlags[] flags) 41 | { 42 | foreach (var item in flags) 43 | Flags |= item; 44 | } 45 | 46 | /// 47 | /// Clear flags from the current flags. 48 | /// 49 | public void ClearFlags (params PhysicsDrawFlags[] flags) 50 | { 51 | foreach (var item in flags) 52 | Flags &= ~item; 53 | } 54 | 55 | 56 | public void DrawShape (cpShape shape) 57 | { 58 | cpBody body = shape.body; 59 | cpColor color = cp.GetShapeColor (shape); // ColorForBody(body); 60 | 61 | switch (shape.shapeType) { 62 | case cpShapeType.Circle: { 63 | cpCircleShape circle = (cpCircleShape)shape; 64 | 65 | if (Flags.HasFlag (PhysicsDrawFlags.BB) || Flags.HasFlag (PhysicsDrawFlags.All)) 66 | drawDelegate.Draw (circle.bb); 67 | 68 | if (Flags.HasFlag (PhysicsDrawFlags.Shapes) || Flags.HasFlag (PhysicsDrawFlags.All)) 69 | drawDelegate.Draw (circle, color); 70 | } 71 | break; 72 | case cpShapeType.Segment: { 73 | cpSegmentShape seg = (cpSegmentShape)shape; 74 | if (Flags.HasFlag (PhysicsDrawFlags.BB) || Flags.HasFlag (PhysicsDrawFlags.All)) 75 | drawDelegate.Draw (seg.bb); 76 | 77 | if (Flags.HasFlag (PhysicsDrawFlags.Shapes) || Flags.HasFlag (PhysicsDrawFlags.All)) 78 | drawDelegate.Draw (seg, color); 79 | } 80 | break; 81 | case cpShapeType.Polygon: { 82 | cpPolyShape poly = (cpPolyShape)shape; 83 | if (Flags.HasFlag (PhysicsDrawFlags.BB) || Flags.HasFlag (PhysicsDrawFlags.All)) 84 | drawDelegate.Draw (poly.bb); 85 | 86 | if (Flags.HasFlag (PhysicsDrawFlags.Shapes) || Flags.HasFlag (PhysicsDrawFlags.All)) { 87 | drawDelegate.Draw (poly, color); 88 | } 89 | } 90 | break; 91 | default: 92 | cp.AssertHard (false, "Bad assertion in DrawShape()"); 93 | break; 94 | } 95 | } 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Resources/basketball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Resources/basketball.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Resources/beachball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Resources/beachball.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.Cocoa/Resources/football.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.Cocoa/Resources/football.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/$(Platform) 5 | /intermediateDir:obj/$(Platform) 6 | /platform:DesktopGL 7 | /config: 8 | /profile:Reach 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin rose.png 17 | /importer:TextureImporter 18 | /processor:TextureProcessor 19 | /processorParam:ColorKeyColor=255,0,255,255 20 | /processorParam:ColorKeyEnabled=True 21 | /processorParam:GenerateMipmaps=False 22 | /processorParam:PremultiplyAlpha=True 23 | /processorParam:ResizeToPowerOfTwo=False 24 | /processorParam:MakeSquare=False 25 | /processorParam:TextureFormat=Color 26 | /build:rose.png 27 | 28 | #begin square.png 29 | /importer:TextureImporter 30 | /processor:TextureProcessor 31 | /processorParam:ColorKeyColor=255,0,255,255 32 | /processorParam:ColorKeyEnabled=True 33 | /processorParam:GenerateMipmaps=False 34 | /processorParam:PremultiplyAlpha=True 35 | /processorParam:ResizeToPowerOfTwo=False 36 | /processorParam:MakeSquare=False 37 | /processorParam:TextureFormat=Color 38 | /build:square.png 39 | 40 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Content/rose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.MonoGame/Content/rose.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Content/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.MonoGame/Content/square.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/GameObject.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace ChipmunkSharp.Example.Desktop 5 | { 6 | class PhysicObject : GameObject 7 | { 8 | static int collCount = 0; 9 | ChipmunkSharp.cpBody physic; 10 | ChipmunkSharp.cpSpace space; 11 | ChipmunkSharp.cpShape shp; 12 | ChipmunkSharp.cpTransform trsf; 13 | 14 | public ChipmunkSharp.cpBody Physic { 15 | get { return physic; } 16 | } 17 | 18 | public ChipmunkSharp.cpShape Shape { 19 | get { return shp; } 20 | } 21 | 22 | public PhysicObject (Texture2D firstText, Vector2 startingPos, ChipmunkSharp.cpSpace space, bool isKinematic = false) : base (firstText, startingPos) 23 | { 24 | trsf = new cpTransform (); 25 | collCount++; 26 | physic = new cpBody (1000, cp.PHYSICS_INFINITY); 27 | 28 | if (isKinematic) 29 | physic.SetBodyType (cpBodyType.KINEMATIC); 30 | shp = new ChipmunkSharp.cpCircleShape (physic, 100, ChipmunkSharp.cpVect.Zero); 31 | shp.Active (); 32 | shp.SetSensor (true); 33 | shp.SetCollisionType (1); 34 | physic.SetPosition (new ChipmunkSharp.cpVect (Position.X, Position.Y)); 35 | if (space != null) { 36 | space.AddBody (physic); 37 | space.AddShape (shp); 38 | this.space = space; 39 | } 40 | } 41 | 42 | public override void Update (GameTime gametime) 43 | { 44 | base.Update (gametime); 45 | physic.UpdateVelocity (space.GetGravity (), 1, 0.01f); 46 | physic.UpdatePosition (1); 47 | shp.Update (trsf); 48 | ChipmunkSharp.cpVect vec = physic.GetPosition (); 49 | Position = new Vector2 (vec.x, vec.y); 50 | angle = (physic.GetAngle () % 360) / 57.2958f; 51 | if (Position.Y > 200) { 52 | physic.ApplyImpulse (new ChipmunkSharp.cpVect (1, -100), new ChipmunkSharp.cpVect (0.1f, 0.1f)); 53 | } 54 | } 55 | } 56 | 57 | class GameObject 58 | { 59 | public Vector2 Position { 60 | get { return pos; } 61 | set { pos = value; } 62 | } 63 | protected Vector2 pos; 64 | protected Texture2D text; 65 | protected float angle = 0; 66 | 67 | public GameObject (Texture2D firstText, Vector2 startingPos) 68 | { 69 | text = firstText; 70 | pos = startingPos; 71 | } 72 | 73 | public virtual void Draw (SpriteBatch spriteBatch) 74 | { 75 | spriteBatch.Draw (text, pos, null, Color.White, angle, Vector2.Zero, 0.25f, SpriteEffects.None, 0f); 76 | } 77 | 78 | public virtual void Draw (SpriteBatch spriteBatch, float rotation) 79 | { 80 | spriteBatch.Draw (text, pos, null, Color.White, rotation, Vector2.Zero, 0.25f, SpriteEffects.None, 0f); 81 | } 82 | 83 | public virtual void Update (GameTime gametime) 84 | { 85 | 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.MonoGame/Icon.bmp -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.MonoGame/Icon.ico -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ChipmunkSharp.Example.Desktop 4 | { 5 | /// 6 | /// The main class. 7 | /// 8 | public static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main () 15 | { 16 | using (var game = new Game1 ()) 17 | game.Run (); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle ("ChipmunkSharp.Example.Desktop")] 9 | [assembly: AssemblyProduct ("ChipmunkSharp.Example.Desktop")] 10 | [assembly: AssemblyConfiguration ("")] 11 | [assembly: AssemblyDescription ("")] 12 | [assembly: AssemblyCompany ("")] 13 | [assembly: AssemblyCopyright ("Copyright © 2017")] 14 | [assembly: AssemblyTrademark ("")] 15 | [assembly: AssemblyCulture ("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible (false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid ("7a791e2e-d318-4695-bd8d-4187ef29d8ba")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion ("1.0.0.0")] 36 | [assembly: AssemblyFileVersion ("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.MonoGame/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | true/pm 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | using UIKit; 3 | 4 | namespace ChipmunkSharp.Example.iOS 5 | { 6 | // The UIApplicationDelegate for the application. This class is responsible for launching the 7 | // User Interface of the application, as well as listening (and optionally responding) to application events from iOS. 8 | [Register ("AppDelegate")] 9 | public class AppDelegate : UIApplicationDelegate 10 | { 11 | // class-level declarations 12 | 13 | public override UIWindow Window { 14 | get; 15 | set; 16 | } 17 | 18 | public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) 19 | { 20 | // Override point for customization after application launch. 21 | // If not required for your application you can safely delete this method 22 | 23 | return true; 24 | } 25 | 26 | public override void OnResignActivation (UIApplication application) 27 | { 28 | // Invoked when the application is about to move from active to inactive state. 29 | // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) 30 | // or when the user quits the application and it begins the transition to the background state. 31 | // Games should use this method to pause the game. 32 | } 33 | 34 | public override void DidEnterBackground (UIApplication application) 35 | { 36 | // Use this method to release shared resources, save user data, invalidate timers and store the application state. 37 | // If your application supports background exection this method is called instead of WillTerminate when the user quits. 38 | } 39 | 40 | public override void WillEnterForeground (UIApplication application) 41 | { 42 | // Called as part of the transiton from background to active state. 43 | // Here you can undo many of the changes made on entering the background. 44 | } 45 | 46 | public override void OnActivated (UIApplication application) 47 | { 48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. 49 | // If the application was previously in the background, optionally refresh the user interface. 50 | } 51 | 52 | public override void WillTerminate (UIApplication application) 53 | { 54 | // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground. 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Games/Game1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UIKit; 3 | using CoreGraphics; 4 | 5 | namespace ChipmunkSharp.Example 6 | { 7 | class Game1 : GameBase 8 | { 9 | PhysicObject square; 10 | PhysicObject ground; 11 | cpSpace spc; 12 | 13 | public Game1 (cpSpace space) 14 | { 15 | spc = space; 16 | spc.SetGravity (new cpVect (0, 1f)); 17 | spc.AddDefaultCollisionHandler ().preSolveFunc = new Func ((arg1, arg2, arg3) => { Console.WriteLine ("ij"); return true; }); 18 | spc.AddDefaultCollisionHandler ().beginFunc = new Func ((arg1, arg2, arg3) => { Console.WriteLine ("ij"); return true; }); 19 | } 20 | 21 | protected override void OnUpdate (long tick) 22 | { 23 | spc.Step (1 / 60); 24 | square.Update (tick); 25 | ground.Update (tick); 26 | } 27 | 28 | public void Initialize (UIView contentView) 29 | { 30 | var roseImage = new UIImage ("basketball.png"); 31 | var squareImage = new UIImage ("football.png"); 32 | square = new PhysicObject (squareImage, 20, spc, false); 33 | ground = new PhysicObject (roseImage, 20, spc, false); 34 | square.SetPosition (150, 0); 35 | ground.SetPosition (150, 0); 36 | 37 | contentView.AddSubview (square); 38 | contentView.AddSubview (ground); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Games/GameBase.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace ChipmunkSharp.Example 4 | { 5 | abstract class GameBase 6 | { 7 | const int DefaultLoopTime = 10; 8 | bool stopping; 9 | 10 | public bool Loop { get; private set; } 11 | 12 | public int DelayTime { get; private set; } = DefaultLoopTime; 13 | 14 | public void Start (int delayTime = DefaultLoopTime, bool loop = false) 15 | { 16 | stopping = false; 17 | Loop = loop; 18 | DelayTime = delayTime; 19 | 20 | //Loop 21 | while (!stopping) { 22 | OnUpdate (0); 23 | Task.Delay (delayTime).Wait (); 24 | } 25 | } 26 | 27 | protected abstract void OnUpdate (long tick); 28 | 29 | public async Task StartAsync (int delayTime = DefaultLoopTime, bool loop = false) 30 | { 31 | await Task.Run (() => Start (delayTime, loop)); 32 | } 33 | 34 | public void Stop () 35 | { 36 | stopping = true; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Games/GameObject.cs: -------------------------------------------------------------------------------- 1 | using CoreGraphics; 2 | using UIKit; 3 | namespace ChipmunkSharp.Example 4 | { 5 | class GameObject : UIImageView 6 | { 7 | protected float angle = 0; 8 | 9 | protected void SetPosition (cpVect vector) 10 | { 11 | Frame = new CGRect (vector.x, vector.y, Frame.Width, Frame.Height); 12 | } 13 | 14 | public GameObject (UIImage firstText) 15 | { 16 | Image = firstText; 17 | } 18 | 19 | public virtual void Update (long gametime) 20 | { 21 | 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Games/PhysicObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UIKit; 3 | 4 | namespace ChipmunkSharp.Example 5 | { 6 | class PhysicObject : GameObject 7 | { 8 | static Random rnd = new Random (DateTime.Now.Millisecond); 9 | 10 | static int collCount = 0; 11 | readonly cpBody physic; 12 | readonly cpSpace space; 13 | cpCircleShape shp; 14 | cpTransform trsf; 15 | 16 | public cpBody Physic { 17 | get { return physic; } 18 | } 19 | 20 | public cpShape Shape { 21 | get { return shp; } 22 | } 23 | 24 | public PhysicObject (UIImage firstText, int radius, cpSpace space, bool isKinematic = false) : base (firstText) 25 | { 26 | trsf = new cpTransform (); 27 | collCount++; 28 | physic = new cpBody (rnd.Next (500,1000), cp.PHYSICS_INFINITY); 29 | 30 | if (isKinematic) 31 | physic.SetBodyType (cpBodyType.KINEMATIC); 32 | shp = new cpCircleShape (physic, radius, cpVect.Zero); 33 | shp.Active (); 34 | shp.SetSensor (true); 35 | shp.SetCollisionType (1); 36 | physic.SetPosition (new cpVect ((float)Frame.Location.X, (float)Frame.Location.Y)); 37 | if (space != null) { 38 | space.AddBody (physic); 39 | space.AddShape (shp); 40 | this.space = space; 41 | } 42 | } 43 | 44 | public void SetPosition (float x, float y) 45 | { 46 | Frame = new CoreGraphics.CGRect (x, y, shp.r, shp.r); 47 | physic.SetPosition (new cpVect (x, y)); 48 | } 49 | 50 | public override void Update (long gametime) 51 | { 52 | physic.UpdateVelocity (space.GetGravity (), 1, 0.01f); 53 | physic.UpdatePosition (1); 54 | shp.Update (trsf); 55 | cpVect position = physic.GetPosition (); 56 | 57 | InvokeOnMainThread (() => { 58 | SetPosition (position); 59 | }); 60 | 61 | angle = (physic.GetAngle () % 360) / 57.2958f; 62 | if (position.y > 500) { 63 | physic.ApplyImpulse (new cpVect (1, -150), new cpVect (0.1f, 0.1f)); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Info.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | CFBundleName 6 | ChipmunkSharp.Example.iOS 7 | CFBundleIdentifier 8 | com.companyname.ChipmunkSharp-Example-iOS 9 | CFBundleShortVersionString 10 | 1.0 11 | CFBundleVersion 12 | 1.0 13 | LSRequiresIPhoneOS 14 | 15 | MinimumOSVersion 16 | 12.1 17 | UIDeviceFamily 18 | 19 | 1 20 | 2 21 | 22 | UILaunchStoryboardName 23 | LaunchScreen 24 | UIMainStoryboardFile 25 | Main 26 | UIRequiredDeviceCapabilities 27 | 28 | armv7 29 | 30 | UISupportedInterfaceOrientations 31 | 32 | UIInterfaceOrientationPortrait 33 | UIInterfaceOrientationPortraitUpsideDown 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | XSAppIconAssets 38 | Assets.xcassets/AppIcon.appiconset 39 | 40 | 41 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace ChipmunkSharp.Example.iOS 4 | { 5 | public class Application 6 | { 7 | // This is the main entry point of the application. 8 | static void Main (string[] args) 9 | { 10 | // if you want to use a different Application Delegate class from "AppDelegate" 11 | // you can specify it here. 12 | UIApplication.Main (args, null, "AppDelegate"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Main.storyboard: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Resources/basketball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.iOS/Resources/basketball.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Resources/beachball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.iOS/Resources/beachball.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/Resources/football.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netonjm/ChipmunkSharp/20208bce4432ef8a9e62a47cc93e377d22957da6/samples/ChipmunkSharp.Example.iOS/Resources/football.png -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/ViewController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using UIKit; 4 | 5 | namespace ChipmunkSharp.Example.iOS 6 | { 7 | public partial class ViewController : UIViewController 8 | { 9 | protected ViewController (IntPtr handle) : base (handle) 10 | { 11 | // Note: this .ctor should not contain any initialization logic. 12 | } 13 | 14 | public override void ViewDidLoad () 15 | { 16 | base.ViewDidLoad (); 17 | // Perform any additional setup after loading the view, typically from a nib. 18 | 19 | var space = new cpSpace { 20 | CollisionEnabled = true 21 | }; 22 | 23 | #region Scene 24 | 25 | var example = new Game1 (space); 26 | example.Initialize (View); 27 | example.StartAsync (loop: true); 28 | 29 | #endregion 30 | 31 | } 32 | 33 | public override void DidReceiveMemoryWarning () 34 | { 35 | base.DidReceiveMemoryWarning (); 36 | // Release any cached data, images, etc that aren't in use. 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /samples/ChipmunkSharp.Example.iOS/ViewController.designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // This file has been generated automatically by MonoDevelop to store outlets and 3 | // actions made in the Xcode designer. If it is removed, they will be lost. 4 | // Manual changes to this file may not be handled correctly. 5 | // 6 | using Foundation; 7 | 8 | namespace ChipmunkSharp.Example.iOS 9 | { 10 | [Register ("ViewController")] 11 | partial class ViewController 12 | { 13 | void ReleaseDesignerOutlets () 14 | { 15 | } 16 | } 17 | } 18 | --------------------------------------------------------------------------------