├── .gitattributes
├── .gitignore
├── Build
└── .keep
├── Content
├── AudioTest
│ ├── City01.g2m
│ ├── City01Hell.g2m
│ ├── Coin.wav
│ ├── Explosion.wav
│ ├── Jump.wav
│ ├── Laser.wav
│ ├── LiberationSans-Regular.ttf
│ ├── Powerup.wav
│ ├── Readme.txt
│ ├── ShortLoop.ogg
│ ├── UFO.wav
│ └── virt-robo.ogg
├── Flash
│ ├── animations-monoclelogo.xml
│ ├── animations-monocleman.xml
│ ├── animations-test.xml
│ ├── guy.png
│ ├── monoclelogo
│ │ ├── Hat.png
│ │ ├── LeftStache.png
│ │ ├── MainText.png
│ │ ├── Monocle.png
│ │ ├── RightStache.png
│ │ └── SmallText.png
│ ├── monocleman
│ │ ├── eye_l.png
│ │ ├── eye_r.png
│ │ ├── eyebrow.png
│ │ ├── hand_l.png
│ │ ├── hand_r.png
│ │ ├── hat.png
│ │ ├── lowerarm_l.png
│ │ ├── lowerarm_r.png
│ │ ├── lowerleg_l.png
│ │ ├── lowerleg_r.png
│ │ ├── monocle.png
│ │ ├── mustache.png
│ │ ├── nose.png
│ │ ├── torso.png
│ │ ├── tortilla.png
│ │ ├── upperarm_l.png
│ │ ├── upperarm_r.png
│ │ ├── upperleg_l.png
│ │ └── upperleg_r.png
│ ├── sheets-monoclelogo.xml
│ └── sheets-monocleman.xml
├── Jumper
│ └── Graphics
│ │ └── Player.png
├── LevelEditorTest
│ ├── graphics
│ │ ├── bg-rock-0001.png
│ │ ├── bg-rock-0002.png
│ │ ├── fish-0001.png
│ │ ├── player.png
│ │ └── starfish-0001.png
│ ├── level.xml
│ └── project.xml
├── Ogmo
│ ├── coin.png
│ ├── level01.xml
│ ├── player.png
│ ├── project.xml
│ ├── spike.png
│ └── tiles.png
├── Pong
│ ├── LiberationSans-Regular.ttf
│ └── Readme.txt
├── PuppetTest
│ ├── graphics
│ │ ├── logo.png
│ │ └── monocleman.png
│ └── puppet.xml
└── Scripted
│ └── main.lua
├── Core
├── Asset.cpp
├── Asset.h
├── Assets.cpp
├── Assets.h
├── Audio
│ ├── Audio.cpp
│ ├── Audio.h
│ ├── AudioAsset.cpp
│ ├── AudioAsset.h
│ ├── AudioAssetReader.cpp
│ ├── AudioAssetReader.h
│ ├── AudioCrypt.cpp
│ ├── AudioCrypt.h
│ ├── AudioDeck.cpp
│ ├── AudioDeck.h
│ ├── AudioDecoder.cpp
│ ├── AudioDecoder.h
│ ├── AudioVis.cpp
│ ├── AudioVis.h
│ ├── ChannelStream.cpp
│ ├── ChannelStream.h
│ ├── Decoders
│ │ ├── OggDecoder.cpp
│ │ ├── OggDecoder.h
│ │ ├── WaveDecoder.cpp
│ │ └── WaveDecoder.h
│ ├── VisCache2.cpp
│ ├── VisCache2.h
│ ├── fft.cpp
│ └── fft.h
├── CMakeLists.txt
├── Camera.cpp
├── Camera.h
├── Cocoa
│ ├── CocoaEvents.h
│ ├── CocoaEvents.mm
│ ├── CocoaKeys.h
│ ├── CocoaKeys.mm
│ ├── CocoaOpenGL.h
│ ├── CocoaOpenGL.mm
│ ├── CocoaPlatform.h
│ ├── CocoaPlatform.mm
│ ├── CocoaWindowListener.h
│ └── CocoaWindowListener.mm
├── Colliders
│ ├── CircleCollider.cpp
│ ├── CircleCollider.h
│ ├── Collider.cpp
│ ├── Collider.h
│ ├── PathCollider.cpp
│ ├── PathCollider.h
│ ├── PolygonCollider.cpp
│ ├── PolygonCollider.h
│ ├── RectangleCollider.cpp
│ └── RectangleCollider.h
├── Collision.cpp
├── Collision.h
├── CollisionData.cpp
├── CollisionData.h
├── Color.cpp
├── Color.h
├── ConfigValues.cpp
├── ConfigValues.h
├── Debug.cpp
├── Debug.h
├── Editor.cpp
├── Editor.h
├── Entity.cpp
├── Entity.h
├── FileNode.cpp
├── FileNode.h
├── FontAsset.h
├── GUI.cpp
├── GUI.h
├── Game.cpp
├── Game.h
├── Graphics.h
├── Graphics
│ ├── Sprite.cpp
│ ├── Sprite.h
│ ├── SpriteAnimation.cpp
│ ├── SpriteAnimation.h
│ ├── Tilemap.cpp
│ └── Tilemap.h
├── Input.cpp
├── Input.h
├── Level.cpp
├── Level.h
├── LevelEditor
│ ├── FringeTile.cpp
│ ├── FringeTile.h
│ ├── ImageBrowser.cpp
│ ├── ImageBrowser.h
│ ├── LevelEditor.cpp
│ ├── LevelEditor.h
│ ├── Node.cpp
│ ├── Node.h
│ ├── PathMesh.cpp
│ └── PathMesh.h
├── Linux
│ ├── LinuxPlatform.cpp
│ └── LinuxPlatform.h
├── Macros.h
├── Monocle.cpp
├── Monocle.h
├── MonocleToolkit.cpp
├── MonocleToolkit.h
├── OpenGL
│ ├── OpenGLGraphics.cpp
│ ├── OpenGLTTFFontAsset.cpp
│ └── OpenGLTextureAsset.cpp
├── Platform.h
├── Puppet
│ ├── Puppet.cpp
│ ├── Puppet.h
│ ├── PuppetEditor.cpp
│ └── PuppetEditor.h
├── Random.cpp
├── Random.h
├── Rect.cpp
├── Rect.h
├── Scene.cpp
├── Scene.h
├── TTFFontAsset.h
├── TextureAsset.h
├── TextureAtlas.cpp
├── TextureAtlas.h
├── Tileset.cpp
├── Tileset.h
├── Transform.cpp
├── Transform.h
├── Tween.cpp
├── Tween.h
├── Vector2.cpp
├── Vector2.h
├── Vector3.cpp
├── Vector3.h
├── Windows
│ ├── WindowsPlatform.cpp
│ └── WindowsPlatform.h
├── XML
│ ├── XMLFileNode.cpp
│ └── XMLFileNode.h
└── premake4-monocle.lua
├── Libraries
├── AL
│ ├── EFX-Util.h
│ ├── al.h
│ ├── alc.h
│ ├── efx-creative.h
│ ├── efx.h
│ └── xram.h
├── Compiled
│ ├── MacOSX
│ │ ├── adjust.sh
│ │ ├── libGLEW.a
│ │ ├── libogg.a
│ │ ├── libvorbis.a
│ │ ├── libvorbisenc.a
│ │ └── libvorbisfile.a
│ └── Win32
│ │ ├── EFX-Util_MT
│ │ └── EFX-Util.lib
│ │ ├── EFX-Util_MTDLL
│ │ └── EFX-Util.lib
│ │ ├── OpenAL32.lib
│ │ ├── glew32s.lib
│ │ ├── libogg_static.lib
│ │ ├── libvorbis_static.lib
│ │ └── libvorbisfile_static.lib
├── GL
│ ├── glew.c
│ ├── glew.h
│ ├── glxew.h
│ └── wglew.h
├── TinyXML
│ ├── tinyxml.cpp
│ ├── tinyxml.h
│ ├── tinyxmlerror.cpp
│ └── tinyxmlparser.cpp
├── ogg
│ ├── ogg.h
│ └── os_types.h
├── stb
│ ├── stb_image.c
│ ├── stb_image_write.h
│ └── stb_truetype.h
└── vorbis
│ ├── codec.h
│ ├── vorbisenc.h
│ └── vorbisfile.h
├── Project
└── Xcode4
│ └── MonocleTest
│ ├── Monocle.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── josh.xcuserdatad
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── xcdebugger
│ │ │ └── Expressions.xcexplist
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── Monocle.xcscheme
│ └── xcuserdata
│ │ └── josh.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
│ ├── Monocle
│ ├── Monocle-Info.plist
│ ├── Monocle-Prefix.pch
│ └── en.lproj
│ │ └── InfoPlist.strings
│ └── MonocleTests
│ ├── MonocleTests.xcodeproj
│ ├── project.pbxproj
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── Monocle Tests.xcscheme
│ └── xcuserdata
│ │ └── josh.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
│ └── MonocleTests
│ ├── MonocleTests-Info.plist
│ ├── MonocleTests-Prefix.pch
│ └── en.lproj
│ └── InfoPlist.strings
├── README
├── Samples
├── All
│ └── premake4-All.lua
├── AudioTest
│ ├── AudioTest.cpp
│ ├── AudioTest.h
│ ├── CMakeLists.txt
│ └── Main.cpp
├── Flash
│ ├── CMakeLists.txt
│ ├── Flash.cpp
│ ├── Flash.h
│ └── Main.cpp
├── Jumper
│ ├── CMakeLists.txt
│ ├── Jumper.cpp
│ ├── Jumper.h
│ └── Main.cpp
├── LevelEditor
│ ├── CMakeLists.txt
│ ├── LevelEditorTest.cpp
│ ├── LevelEditorTest.h
│ └── Main.cpp
├── Ogmo
│ ├── CMakeLists.txt
│ ├── Main.cpp
│ ├── Ogmo.cpp
│ └── Ogmo.h
├── Pong
│ ├── CMakeLists.txt
│ ├── Main.cpp
│ ├── Pong.cpp
│ └── Pong.h
├── PuppetTest
│ ├── CMakeLists.txt
│ ├── Main.cpp
│ ├── PuppetTest.cpp
│ └── PuppetTest.h
├── RenderTests
│ └── TextRenderTest.cpp
├── Scripted
│ └── Main.cpp
├── TestSelector
│ ├── Main.cpp
│ └── premake4-TestSelector.lua
└── premake4-test-generic.lua
├── Tests
├── InputHandlerTest
│ ├── InputHandlerTest.h
│ └── Main.cpp
├── Libraries
│ └── cpptest
│ │ ├── cpptest-assert.h
│ │ ├── cpptest-collectoroutput.h
│ │ ├── cpptest-compileroutput.h
│ │ ├── cpptest-htmloutput.h
│ │ ├── cpptest-output.h
│ │ ├── cpptest-source.h
│ │ ├── cpptest-suite.h
│ │ ├── cpptest-textoutput.h
│ │ ├── cpptest-time.h
│ │ └── cpptest.h
├── Main.cpp
├── Tests.h
└── Unit
│ ├── AssetTest.cpp
│ ├── AssetTest.h
│ ├── AssetsTest.cpp
│ ├── AssetsTest.h
│ ├── CameraTest.cpp
│ ├── CameraTest.h
│ ├── FontAssetTest.cpp
│ ├── FontAssetTest.h
│ ├── VectorTest.cpp
│ └── VectorTest.h
├── linux-build-basic.sh
├── premake4-helper.lua
└── premake4.lua
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.sh eol=lf
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Build
2 | CMakeCache.txt
3 | CMakeFiles
4 | Makefile
5 | *.cmake
6 |
7 | #Qt creator project files
8 | monocle.files
9 | monocle.includes
10 | monocle.config
11 | monocle.creator.*
12 |
13 | # OSX
14 | .DS_Store
15 |
16 | # Build artifacts
17 | *.obj
18 |
19 | # VS2010
20 | *.sdf
21 | *.opensdf
22 | *.suo
23 | *.tlog
24 | *.lastbuildstate
25 | *.unsuccessfulbuild
26 | *.manifest
27 | *.idb
28 | *.pdb
29 | *.ipch
30 | *.vcxproj.user
31 | [Dd]ebug
32 | [Rr]elease
33 |
34 | # XCode
35 | *.mode1
36 | *.mode1v3
37 | *.mode2v3
38 | *.perspective
39 | *.perspectivev3
40 | *.pbxuser
41 | *.xcuserstate
42 |
--------------------------------------------------------------------------------
/Build/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Build/.keep
--------------------------------------------------------------------------------
/Content/AudioTest/City01.g2m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/City01.g2m
--------------------------------------------------------------------------------
/Content/AudioTest/City01Hell.g2m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/City01Hell.g2m
--------------------------------------------------------------------------------
/Content/AudioTest/Coin.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/Coin.wav
--------------------------------------------------------------------------------
/Content/AudioTest/Explosion.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/Explosion.wav
--------------------------------------------------------------------------------
/Content/AudioTest/Jump.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/Jump.wav
--------------------------------------------------------------------------------
/Content/AudioTest/Laser.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/Laser.wav
--------------------------------------------------------------------------------
/Content/AudioTest/LiberationSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/LiberationSans-Regular.ttf
--------------------------------------------------------------------------------
/Content/AudioTest/Powerup.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/Powerup.wav
--------------------------------------------------------------------------------
/Content/AudioTest/Readme.txt:
--------------------------------------------------------------------------------
1 | Information on Liberation Fonts:
2 | http://en.wikipedia.org/wiki/Liberation_fonts
--------------------------------------------------------------------------------
/Content/AudioTest/ShortLoop.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/ShortLoop.ogg
--------------------------------------------------------------------------------
/Content/AudioTest/UFO.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/UFO.wav
--------------------------------------------------------------------------------
/Content/AudioTest/virt-robo.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/AudioTest/virt-robo.ogg
--------------------------------------------------------------------------------
/Content/Flash/animations-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Content/Flash/guy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/guy.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/Hat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/Hat.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/LeftStache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/LeftStache.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/MainText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/MainText.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/Monocle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/Monocle.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/RightStache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/RightStache.png
--------------------------------------------------------------------------------
/Content/Flash/monoclelogo/SmallText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monoclelogo/SmallText.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/eye_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/eye_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/eye_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/eye_r.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/eyebrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/eyebrow.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/hand_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/hand_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/hand_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/hand_r.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/hat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/hat.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/lowerarm_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/lowerarm_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/lowerarm_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/lowerarm_r.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/lowerleg_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/lowerleg_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/lowerleg_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/lowerleg_r.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/monocle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/monocle.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/mustache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/mustache.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/nose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/nose.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/torso.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/torso.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/tortilla.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/tortilla.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/upperarm_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/upperarm_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/upperarm_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/upperarm_r.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/upperleg_l.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/upperleg_l.png
--------------------------------------------------------------------------------
/Content/Flash/monocleman/upperleg_r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Flash/monocleman/upperleg_r.png
--------------------------------------------------------------------------------
/Content/Flash/sheets-monoclelogo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Content/Flash/sheets-monocleman.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Content/Jumper/Graphics/Player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Jumper/Graphics/Player.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/graphics/bg-rock-0001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/LevelEditorTest/graphics/bg-rock-0001.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/graphics/bg-rock-0002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/LevelEditorTest/graphics/bg-rock-0002.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/graphics/fish-0001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/LevelEditorTest/graphics/fish-0001.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/graphics/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/LevelEditorTest/graphics/player.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/graphics/starfish-0001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/LevelEditorTest/graphics/starfish-0001.png
--------------------------------------------------------------------------------
/Content/LevelEditorTest/level.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Content/LevelEditorTest/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Content/Ogmo/coin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Ogmo/coin.png
--------------------------------------------------------------------------------
/Content/Ogmo/player.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Ogmo/player.png
--------------------------------------------------------------------------------
/Content/Ogmo/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Content/Ogmo/spike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Ogmo/spike.png
--------------------------------------------------------------------------------
/Content/Ogmo/tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Ogmo/tiles.png
--------------------------------------------------------------------------------
/Content/Pong/LiberationSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/Pong/LiberationSans-Regular.ttf
--------------------------------------------------------------------------------
/Content/Pong/Readme.txt:
--------------------------------------------------------------------------------
1 | Information on Liberation Fonts:
2 | http://en.wikipedia.org/wiki/Liberation_fonts
--------------------------------------------------------------------------------
/Content/PuppetTest/graphics/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/PuppetTest/graphics/logo.png
--------------------------------------------------------------------------------
/Content/PuppetTest/graphics/monocleman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaphire/Monocle-Engine/a4558b5436681ab0ec95aec388cbb791b26f0b81/Content/PuppetTest/graphics/monocleman.png
--------------------------------------------------------------------------------
/Content/PuppetTest/puppet.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 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Content/Scripted/main.lua:
--------------------------------------------------------------------------------
1 | io.write "Something\n"
2 |
3 | Point = {}
4 |
5 | Point.new = function(x, y)
6 | local self = {}
7 | x = x or 0
8 | x = y or 0
9 |
10 | self.getx = function() return x end
11 | self.gety = function() return y end
12 | self.write = function() io.write(string.format("(%d, %d)\n", x, y)) end
13 |
14 | return self
15 | end
16 |
17 | p = Point.new(2,5)
18 | p.write()
19 |
20 | function HelloWorld()
21 | io.write "Hello, World!\n"
22 | local test = true
23 | if test == true then
24 | io.write "it's true!\n"
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/Core/Asset.cpp:
--------------------------------------------------------------------------------
1 | #include "Asset.h"
2 | #include "Debug.h"
3 | #include "Assets.h"
4 |
5 | namespace Monocle
6 | {
7 | Asset::Asset(AssetType type)
8 | : type(type)
9 | {
10 | isCached = false;
11 | referenceCount = 0;
12 | }
13 |
14 | void Asset::AddReference()
15 | {
16 | referenceCount++;
17 |
18 | //Debug::Log("referenceCount increased for: " + filename);
19 | //Debug::Log(referenceCount);
20 | }
21 |
22 | void Asset::RemoveReference()
23 | {
24 | referenceCount--;
25 |
26 | Debug::Log("referenceCount decreased for: " + filename);
27 | Debug::Log(referenceCount);
28 |
29 | if (referenceCount == 0)
30 | {
31 | if (!isCached)
32 | {
33 | Unload();
34 | Assets::RemoveAsset(this);
35 | }
36 | }
37 | }
38 |
39 | std::string Asset::GetName()
40 | {
41 | //Will this stop working correctly if the content path is changed?
42 | int size = Assets::GetContentPath().size();
43 | return filename.substr(size, filename.size() - size);
44 | }
45 |
46 | std::string Asset::GetExtension()
47 | {
48 | std::string fn = GetName();
49 | return fn.substr(fn.find_last_of(".") + 1);
50 | }
51 |
52 | /*
53 | void Asset::Load(const char *filename)
54 | {
55 |
56 | }
57 |
58 | void Asset::Unload()
59 | {
60 |
61 | }
62 | */
63 | }
64 |
--------------------------------------------------------------------------------
/Core/Asset.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | namespace Monocle
6 | {
7 | enum AssetType
8 | {
9 | ASSET_UNDEFINED,
10 | ASSET_TEXTURE,
11 | ASSET_AUDIO,
12 | ASSET_FONT,
13 | ASSET_MAX,
14 | };
15 |
16 | //! Filter type for TextureAssets.
17 | enum FilterType
18 | {
19 | FILTER_NONE,
20 | FILTER_LINEAR
21 | };
22 |
23 | //! \brief Base class for Asset types.
24 | //!
25 | //! Provides functions to manages filename and extensions, and reference counting for all derived AssetTypes.
26 | //! Derived classes must override void Reload(), void Unload(), and it is expected that they will have a
27 | //! void Load(const std::string &filename, ...) where ... is any additional necessary parameters.
28 | class Asset
29 | {
30 | public:
31 | //! Creates an Asset of the given type and initilizes the reference count to 0. Intended to be called by
32 | //! constructors of derived classes.
33 | Asset(AssetType type);
34 | virtual ~Asset() {}
35 |
36 | //! The filename associated with this asset.
37 | std::string filename;
38 |
39 | //! The type of this asset
40 | AssetType type;
41 |
42 | //! The number of references to this asset currently in use throughout the program.
43 | //! This number is incremented when this asset is requested through Assets::RequestTYPE()
44 | int referenceCount; // <- how many things use this
45 |
46 | //!
47 | bool isCached; // <- should we free ourselves?
48 |
49 | //! Increments the reference count of this asset.
50 | void AddReference();
51 | //! Decrements the reference count of this asset.
52 | void RemoveReference();
53 | //! Reloads this asset. This function is to be overridden by derived classes.
54 | //! Typically takes the form { Unload(); Load(); }
55 | virtual void Reload()=0;
56 |
57 | //! Returns the file path relative to the content path.
58 | std::string GetName();
59 | //! Returns the file extension.
60 | std::string GetExtension(); // after the . : "booty.ogg" would return "ogg"
61 |
62 | protected:
63 | friend class Assets;
64 | // allow derived classes to add whatever params they want to load
65 | //virtual void Load(const std::string &filename)=0;
66 | //! Unloads the asset. Must be overriden by derived classes.
67 | virtual void Unload() = 0;
68 | };
69 | }
70 |
--------------------------------------------------------------------------------
/Core/Audio/AudioAsset.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // AudioAsset.cpp
3 | // MonocleTest
4 | //
5 | // Created by Josh Whelchel on 4/19/11.
6 | //
7 |
8 | #include "Audio.h"
9 | #include "AudioAsset.h"
10 | #include "../MonocleToolkit.h"
11 | #include "../Debug.h"
12 |
13 | #include
14 | #include // required for free and malloc (GCC)
15 |
16 | namespace Monocle
17 | {
18 | AudioAsset::AudioAsset() : Asset(ASSET_AUDIO)
19 | {
20 | size = 0;
21 | streamFromDisk = false;
22 | dataBuffer = 0;
23 | decodeString = "";
24 | }
25 |
26 | /// Alec: Removed destructor.
27 | /// These objects get deleted when you call RemoveReference() (if the references run out)
28 |
29 | void AudioAsset::Load(const std::string &filename, bool streamFromDisk)
30 | {
31 | this->filename = filename;
32 |
33 | this->streamFromDisk = streamFromDisk;
34 |
35 | FILE *f;
36 | f = fopen(this->filename.c_str(),"rb");
37 |
38 | if (!f){
39 | Debug::Log("Asset " + filename + " was not found and cannot be loaded."); // ERROR
40 | return;
41 | }
42 |
43 | fseek(f,0,SEEK_END);
44 | size = ftell(f);
45 | fseek(f,0,SEEK_SET);
46 |
47 | if (!streamFromDisk){
48 | // Load to memory!
49 | dataBuffer = malloc(size);
50 | fread(dataBuffer,size,1,f);
51 |
52 | Debug::Log("Commited " + StringOf(size) + " bytes to memory for " + GetName());
53 | }
54 |
55 | fclose(f);
56 | }
57 |
58 | void AudioAsset::Reload()
59 | {
60 | Unload();
61 | Load(this->filename,streamFromDisk);
62 | }
63 |
64 | void AudioAsset::Unload()
65 | {
66 | Debug::Log("Freeing audio memory for: " + this->filename);
67 |
68 | if (dataBuffer)
69 | {
70 | free(dataBuffer);
71 | dataBuffer = NULL;
72 | }
73 | }
74 |
75 | bool AudioAsset::IsStreaming()
76 | {
77 | return streamFromDisk;
78 | }
79 |
80 | void *AudioAsset::GetDataBuffer()
81 | {
82 | return dataBuffer;
83 | }
84 |
85 | long AudioAsset::GetDataSize()
86 | {
87 | return size;
88 | }
89 |
90 | void AudioAsset::SetDecodeString(std::string decodeString)
91 | {
92 | this->decodeString = decodeString;
93 | }
94 |
95 | std::string AudioAsset::GetDecodeString()
96 | {
97 | return this->decodeString;
98 | }
99 |
100 | void AudioAsset::Play( int loops, float volume, float pan, float pitch )
101 | {
102 | Audio::PlaySound(this,loops,volume,pan,pitch);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/Core/Audio/AudioAsset.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "../Asset.h"
4 | #include "AudioDecoder.h"
5 |
6 | namespace Monocle
7 | {
8 | class AudioAsset : public Asset
9 | {
10 | public:
11 | AudioAsset();
12 |
13 | /**
14 | Prepares the asset for decoding.
15 |
16 | @param streamFromDisk true if the asset should be streamed from disk or false if the asset should be loaded into memory.
17 | */
18 | void Load( const std::string &filename, bool streamFromDisk );
19 | void Reload();
20 | void Unload();
21 |
22 | /**
23 | @return true if the asset is to be streamed from disk
24 | */
25 | bool IsStreaming();
26 |
27 | /**
28 | If the asset isn't streaming from disk, this will return the pointer to the data buffer.
29 |
30 | @see GetDataSize()
31 | @return Pointer to the data.
32 | */
33 | void *GetDataBuffer();
34 |
35 | /**
36 | This returns the size in bytes of the asset, regardless of whether or not it is streaming from disk.
37 |
38 | @return the size in bytes of the asset, regardless of whether or not it is streaming from disk.
39 | */
40 | long GetDataSize();
41 |
42 | /**
43 | Sets the decode string for use by AudioCrypt. If the asset is not encoded, send ""
44 | */
45 | void SetDecodeString( std::string decodeString );
46 |
47 | std::string GetDecodeString();
48 |
49 | /**
50 | Plays an audio file. The deck it plays on will be freed automatically when the sound is complete.
51 |
52 | @param loops Number of times to loop
53 | @param volume Volume, between 0.0 and 1.0
54 | @param pan Panning, between -1.0(L) and 1.0(R), 0.0 for center
55 | @param pitch Pitch, 0.5 - 2.0
56 |
57 | @see Audio::PlaySound
58 | */
59 | void Play( int loops = 1, float volume = 1.0, float pan = 0.0, float pitch = 1.0 );
60 |
61 | private:
62 |
63 | long size;
64 | bool streamFromDisk;
65 | void *dataBuffer;
66 |
67 | std::string decodeString;
68 |
69 | };
70 | }
--------------------------------------------------------------------------------
/Core/Audio/AudioAssetReader.h:
--------------------------------------------------------------------------------
1 | //
2 | // AudioAssetReader.h
3 | //
4 | // Created by Josh Whelchel on 4/27/11.
5 | //
6 |
7 | #pragma once
8 |
9 | #include "AudioAsset.h"
10 | #include "AudioCrypt.h"
11 |
12 | namespace Monocle {
13 |
14 | /*
15 | * AudioAssetReader is designed to include a file/memory pointer for reading from audio assets either on disk or in memory
16 | */
17 | class AudioAssetReader
18 | {
19 | public:
20 |
21 | AudioAssetReader( AudioAsset *asset, std::string key = "" );
22 | ~AudioAssetReader();
23 |
24 | size_t SpaceUntilEOF();
25 | size_t Read( void *dst, size_t size );
26 | void Seek( size_t offset, int whence );
27 | size_t Tell(); // Gets the position we're at (dataRead)
28 |
29 | private:
30 |
31 | // When Reading from Buffer
32 | char* dataPtr; // Pointer to the data in memory
33 | long dataSize; // Sizeo fo the data
34 |
35 | long dataRead; // How much data we have read so far
36 |
37 | // When Streaming
38 | FILE *file;
39 |
40 | AudioAsset *asset;
41 | AudioCryptKey *cryptKey;
42 |
43 | };
44 |
45 | }
--------------------------------------------------------------------------------
/Core/Audio/AudioCrypt.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | namespace Monocle
6 | {
7 |
8 | /**
9 | Encrypts and decrypts a data stream
10 | */
11 | class AudioCryptKey
12 | {
13 | public:
14 |
15 | /**
16 | @param keyStr Decode string
17 | */
18 | AudioCryptKey( std::string keyStr );
19 | ~AudioCryptKey(void);
20 |
21 | /**
22 | Encodes an entire stream of data based on the key string.
23 |
24 | @param pData Data buffer
25 | @param nLength Length of data
26 | */
27 | void EncodeStream( unsigned char *pData, unsigned long nLength );
28 |
29 | /**
30 | Decodes an entire stream of data based on the key string. You cannot provide a stream that begins at an offset other than 5,
31 | and if the data is less than five bytes worth it will be assumed to be the END of the full stream of data. If this is not the case,
32 | use DecodeSlice5b().
33 |
34 | @param pData Data buffer
35 | @param nLength Length of data
36 | */
37 | void DecodeStream( unsigned char *pData, unsigned long nLength );
38 |
39 | /**
40 | Decodes a slice of data in 5 byte chunks. This needs an entire 5 bytes plus more to look ahead and look behind (in order to align it
41 | to 5 byte slices in relation to the full stream of data. To achieve this, nLength specifies the length of the data you wish to
42 | alter, with nOffset providing how many bytes away from being a multiple of 5 origData points to.
43 |
44 | For instance, if origData begins on the 3rd byte, you should provide 3 for nOffset. If it is byte 7, you will provide 7%5 (= 2).
45 |
46 | lookAhead is responsible for notifying how many bytes of data are available to seek past the end of origData (you should provide
47 | the entire length remaining after nLength if possible, otherwise it simply needs to align to a full chunk of 5. When in doubt, read
48 | 5 bytes OR the space until EOF if less).
49 |
50 | @param origData Pointer to the original data to read. Will read also before this pointer nOffset bytes and beyond it up to 5 (or lookAhead if less).
51 | @param newData Pointer to a buffer of nLength size to fill with decoded data.
52 | @param lookAhead How many bytes exist after nLength in origData pointer that can be read. Will read up to 5, but should be less if EOF is sooner.
53 | @param nOffset How many bytes away from a multiple 5 origData starts at in the entirety of the datastream. This is usually just Tell()%5.
54 | */
55 | void DecodeSlice5b(unsigned char *origData, unsigned char *newData, unsigned long nLength, unsigned long nOffset, unsigned long lookAhead=0);
56 |
57 | void ResetUses();
58 |
59 | unsigned long m_lUses[4];
60 |
61 | private:
62 |
63 | unsigned long m_nPart1;
64 | unsigned long m_nPart2;
65 | unsigned long m_nPart3;
66 | unsigned long m_nPart4;
67 |
68 | unsigned long m_bLookup1[ 256 ];
69 | unsigned long m_bLookup2[ 256 ];
70 | unsigned long m_bLookup3[ 256 ];
71 | unsigned long m_bLookup4[ 256 ];
72 |
73 | static void KeyStringToFourParts(char *cKeyStr, unsigned long *nPart1, unsigned long *nPart2, unsigned long *nPart3, unsigned long *nPart4);
74 |
75 | void DecodeSegment( unsigned char *newByte, unsigned char *oldByte );
76 | void EncodeSegment( unsigned char *newByte, unsigned char *oldByte );
77 |
78 | };
79 |
80 | }
--------------------------------------------------------------------------------
/Core/Audio/AudioDecoder.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "Audio.h"
3 | #include "AudioDecoder.h"
4 |
5 | #include
6 | #include
7 |
8 | namespace Monocle
9 | {
10 |
11 | void AudioDecoder::Init( int samplerate, int bit, int ch )
12 | {
13 | this->samplerate = samplerate;
14 | this->bit = bit;
15 | this->ch = ch;
16 |
17 | this->loopsRemaining = 0;
18 | this->outOfData = false;
19 | this->seekOffset = -1;
20 | this->total = 0;
21 | }
22 |
23 | AudioDecoder::~AudioDecoder()
24 | {
25 |
26 | }
27 |
28 | AudioDecoder::AudioDecoder( )
29 | {
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/Core/Audio/AudioVis.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //
3 | // AudioVis.h
4 | //
5 | // Created by Josh Whelchel on 4/26/11.
6 | //
7 |
8 | #ifndef WINAPI
9 | #define WINAPI void
10 | #endif
11 |
12 | #include "VisCache2.h"
13 |
14 | namespace Monocle {
15 | // Contains visualization data (:
16 |
17 | class AudioVisData;
18 |
19 | class AudioVis
20 | {
21 | public:
22 |
23 | AudioVis();
24 | ~AudioVis();
25 |
26 | void PrepData();
27 |
28 | // Vis Data
29 | float imm[2][16];
30 | float avg[2][16];
31 | float med_avg[2][16];
32 | float long_avg[2][16];
33 |
34 | unsigned char cWaveformR[576];
35 | unsigned char cWaveformL[576];
36 | float fWaveform[2][576];
37 | float fSpectrum[2][512];
38 |
39 | bool bClear; // True when vis should be clear.
40 | int bIsBeat; // 0 when not a beat, 1 on a beat (detected :3)
41 |
42 | long engineerData[4]; // Current data from the cache
43 |
44 | unsigned long updateCount;
45 |
46 | bool bDisabled; // This is set when the freuqnecy is changed.
47 |
48 | AudioVisData *data;
49 |
50 | void AnalyzeNewSound(long rsize);
51 | void BeatDetect();
52 |
53 | int _usedCount;
54 | };
55 | }
--------------------------------------------------------------------------------
/Core/Audio/Decoders/OggDecoder.h:
--------------------------------------------------------------------------------
1 | #ifdef MONOCLE_AUDIO_OGG
2 | //
3 | // OggDecoder.h
4 | // MonocleTest
5 | //
6 | // Created by Josh Whelchel on 4/19/11.
7 | //
8 |
9 | #pragma once
10 |
11 | #include "../AudioDecoder.h"
12 |
13 | namespace Monocle
14 | {
15 | class OggDecoder : public AudioDecoder
16 | {
17 | public:
18 |
19 | OggDecoder( AudioAsset *asset );
20 | ~OggDecoder();
21 |
22 | virtual unsigned long Render( unsigned long size, void *outputBuffer );
23 |
24 | void *oggData;
25 |
26 | AudioAsset *audAsset;
27 | };
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/Core/Audio/Decoders/WaveDecoder.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // WaveDecoder.cpp
3 | //
4 | // Created by Josh Whelchel on 4/28/11.
5 | //
6 |
7 | #include "WaveDecoder.h"
8 |
9 | namespace Monocle
10 | {
11 | /***
12 | THIS CODE is responsible for registering this decoder with the file extension.
13 | See more info in Audio::Init.
14 | ***/
15 | AudioDecoder *makeWaveFunc( AudioAsset *asset )
16 | {
17 | return new WaveDecoder(asset);
18 | }
19 |
20 | static short WAVE_FORMAT_PCM = 0x0001;
21 |
22 | void WaveDecoder::WaveOpen()
23 | {
24 | char csID[10];
25 | int fsize;
26 | int wfxsize;
27 | int datasize;
28 | WAVEFORMATEX *wfx = &format;
29 |
30 | csID[4] = 0;
31 | reader->Read(csID,4);
32 | if (std::string (csID) != "RIFF"){
33 | return;
34 | }
35 |
36 | reader->Read ((char*)&fsize, 4);
37 | reader->Read (csID, 4);
38 | if (std::string (csID) != "WAVE"){
39 | std::string s (" is not a valid WAVE form-type.");
40 | throw s;
41 | }
42 |
43 | reader->Read (csID, 4);
44 | if (std::string (csID) != "fmt "){
45 | std::string s (" does not have a valid wave-form chunk ID.");
46 | throw s;
47 | }
48 |
49 | reader->Read ((char*)&wfxsize, 4);
50 | reader->Read ((char*)wfx, wfxsize);
51 | if (wfx->wFormatTag != WAVE_FORMAT_PCM){
52 | std::string s (" is not of type PCM wave format.");
53 | throw s;
54 | }
55 |
56 | reader->Read (csID, 4);
57 | if (std::string (csID) != "data"){
58 | std::string s (" does not have a valid data chunk ID.");
59 | throw s;
60 | }
61 |
62 | reader->Read ((char*)&datasize, 4);
63 |
64 | // Should be at data...
65 | }
66 |
67 | WaveDecoder::WaveDecoder( AudioAsset *asset )
68 | {
69 | this->audAsset = asset;
70 | reader = new AudioAssetReader(audAsset,audAsset->GetDecodeString());
71 |
72 | WaveOpen();
73 |
74 | Init(format.nSamplesPerSec,format.wBitsPerSample,format.nChannels);
75 | }
76 |
77 | unsigned long WaveDecoder::Render( unsigned long size, void *buf )
78 | {
79 | size_t ret = reader->Read(buf, size);
80 | if (!ret)
81 | outOfData = true;
82 |
83 | return ret;
84 | }
85 |
86 | WaveDecoder::~WaveDecoder()
87 | {
88 | delete reader;
89 | }
90 | }
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/Core/Audio/Decoders/WaveDecoder.h:
--------------------------------------------------------------------------------
1 | //
2 | // OggDecoder.h
3 | // MonocleTest
4 | //
5 | // Created by Josh Whelchel on 4/19/11.
6 | //
7 |
8 | #pragma once
9 |
10 | #include "../AudioDecoder.h"
11 | #include "../AudioAssetReader.h"
12 |
13 | typedef struct {
14 | short wFormatTag;
15 | short nChannels;
16 | int nSamplesPerSec;
17 | int nAvgBytesPerSec;
18 | short nBlockAlign;
19 | short wBitsPerSample;
20 | short cbSize;
21 | } WAVEFORMATEX;
22 |
23 | namespace Monocle
24 | {
25 | class WaveDecoder : public AudioDecoder
26 | {
27 | public:
28 |
29 | WaveDecoder( AudioAsset *asset );
30 | ~WaveDecoder();
31 |
32 | virtual unsigned long Render( unsigned long size, void *outputBuffer );
33 |
34 | AudioAsset *audAsset;
35 |
36 | WAVEFORMATEX format;
37 | AudioAssetReader *reader;
38 |
39 | private:
40 |
41 | void WaveOpen();
42 | };
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/Core/Audio/VisCache2.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace Monocle {
4 |
5 | typedef struct vc2_entry_s
6 | {
7 | // 576 8bit Stereo Samples
8 | unsigned char cWaveLeft[576];
9 | unsigned char cWaveRight[576];
10 |
11 | // With a recorded time
12 | unsigned long nPos;
13 |
14 | // Engineer Data (4 longs should be plenty)
15 | // (eg, want to store information on the current order of a module, etc)
16 | long engineerData[4];
17 |
18 | bool isSet;
19 | } vc2_entry;
20 |
21 | /**
22 | A cache mechanism for syncing written audio data with when it is actually played through the speakers.
23 | */
24 | class VisCache2
25 | {
26 | public:
27 | VisCache2(void);
28 | public:
29 | ~VisCache2(void);
30 |
31 | public:
32 |
33 | // Init with max latency in MS, Sample rate in Samples per Second
34 | void Init( long maxLatency, long srate );
35 | void Clean();
36 | void Reset();
37 |
38 | // Sets data to be retrieved later at position "pos" in MS
39 | void SetWrittenTime( unsigned long pos );
40 |
41 | void PutWaveLeft( unsigned char * data );
42 | void PutWaveRight( unsigned char * data );
43 |
44 | void SetEngineerData( long data1, long data2, long data3, long data4 );
45 |
46 | void EndEntry();
47 |
48 | // Gets the latent data at play position "pos" in MS
49 | // This will return 0 if it's nothing new
50 | int GetLatentData( unsigned long pos );
51 |
52 | void GetWaveLeft(unsigned char *out);
53 | void GetWaveRight(unsigned char *out);
54 |
55 | void GetEngineerData( long *data1, long *data2, long *data3, long *data4 );
56 |
57 | void Destroy();
58 |
59 | private:
60 |
61 | long m_nBufLen;
62 | vc2_entry *m_buf;
63 |
64 | long m_lastIndex;
65 | long m_curIndex;
66 | long m_readIndex;
67 | };
68 | }
69 |
--------------------------------------------------------------------------------
/Core/Audio/fft.h:
--------------------------------------------------------------------------------
1 | /*
2 | LICENSE
3 | -------
4 | Copyright (C) 1999-2002 Nullsoft, Inc.
5 |
6 | This source code is provided 'as-is', without any express or implied
7 | warranty. In no event will the authors be held liable for any damages
8 | arising from the use of this source code or the software it produces.
9 |
10 | Permission is granted to anyone to use this source code for any purpose,
11 | including commercial applications, and to alter it and redistribute it
12 | freely, subject to the following restrictions:
13 |
14 | 1. The origin of this source code must not be misrepresented; you must not
15 | claim that you wrote the original source code. If you use this source code
16 | in a product, an acknowledgment in the product documentation would be
17 | appreciated but is not required.
18 | 2. Altered source versions must be plainly marked as such, and must not be
19 | misrepresented as being the original source code.
20 | 3. This notice may not be removed or altered from any source distribution.
21 | */
22 |
23 | #ifndef __NULLSOFT_DX8_PLUGIN_SHELL_FFT_H__
24 | #define __NULLSOFT_DX8_PLUGIN_SHELL_FFT_H__ 1
25 |
26 |
27 | class FFT
28 | {
29 | public:
30 | FFT();
31 | ~FFT();
32 | void Init(int samples_in, int samples_out, int bEqualize=1, float envelope_power=1.0f);
33 | void time_to_frequency_domain(float *in_wavedata, float *out_spectraldata);
34 | int GetNumFreq() { return NFREQ; };
35 | void CleanUp();
36 | private:
37 | int m_ready;
38 | int m_samples_in;
39 | int NFREQ;
40 |
41 | void InitEnvelopeTable(float power);
42 | void InitEqualizeTable();
43 | void InitBitRevTable();
44 | void InitCosSinTable();
45 |
46 | int *bitrevtable;
47 | float *envelope;
48 | float *equalize;
49 | float *temp1;
50 | float *temp2;
51 | float (*cossintable)[2];
52 | };
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | #endif
--------------------------------------------------------------------------------
/Core/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | file(GLOB CORE_SRCS *.cpp)
2 | file(GLOB COLLIDERS_SRCS Colliders/*.cpp)
3 | file(GLOB GRAPHICS_SRCS Graphics/*.cpp)
4 | file(GLOB LEVELEDITOR_SRCS LevelEditor/*.cpp)
5 | file(GLOB OGMOSIS_SRCS Ogmosis/*.cpp)
6 | file(GLOB XML_SRCS XML/*.cpp)
7 | file(GLOB AUDIO_SRCS Audio/*.cpp)
8 | file(GLOB AUDIO_DECODER_SRCS Audio/Decoders/*.cpp)
9 | file(GLOB PUPPET_SRCS Puppet/*.cpp)
10 |
11 | set(CORE_SRCS ${CORE_SRCS}
12 | ${COLLIDERS_SRCS}
13 | ${GRAPHICS_SRCS}
14 | ${LEVELEDITOR_SRCS}
15 | ${OGMOSIS_SRCS}
16 | ${AUDIO_SRCS}
17 | ${AUDIO_DECODER_SRCS}
18 | ${PUPPET_SRCS}
19 | )
20 |
21 | if(WINDOWS)
22 | file(GLOB WINDOWS_SRCS Windows/*.cpp)
23 | set(PLATFORM_SRCS ${PLATFORM_SRCS} ${WINDOWS_SRCS})
24 | endif(WINDOWS)
25 |
26 | if(LINUX)
27 | include_directories(${X11_INCLUDE_DIR})
28 | set(CORE_LINK ${CORE_LINK} ${X11_LIBRARIES})
29 | file(GLOB LINUX_SRCS Linux/*.cpp)
30 | set(PLATFORM_SRCS ${PLATFORM_SRCS} ${LINUX_SRCS})
31 | endif(LINUX)
32 |
33 | if(WITH_OPENGL)
34 | include_directories(${OPENGL_INCLUDE_DIR})
35 | file(GLOB OPENGL_SRCS
36 | OpenGL/*.cpp
37 | OpenGL/*.c
38 | OpenGL/GL/*.c
39 | )
40 | set(CORE_LINK ${CORE_LINK} ${OPENGL_LIBRARIES})
41 | set(CORE_SRCS ${CORE_SRCS} ${OPENGL_SRCS})
42 | endif(WITH_OPENGL)
43 |
44 | if(WITH_OPENAL)
45 | include_directories(${OPENAL_INCLUDE_DIR})
46 | file(GLOB OPENAL_SRCS OpenAL/*.cpp)
47 | set(CORE_LINK ${CORE_LINK} ${OPENAL_LIBRARY})
48 | set(CORE_SRCS ${CORE_SRCS} ${OPENAL_SRCS})
49 | endif(WITH_OPENAL)
50 |
51 | if(WITH_AUDIOWAVE)
52 | file(GLOB WAVE_SRCS Audio/wave/*.cpp)
53 | set(CORE_SRCS ${CORE_SRCS} ${WAVE_SRCS})
54 | endif(WITH_AUDIOWAVE)
55 |
56 | if(WITH_AUDIOOGG)
57 | include_directories(${OGGVORBIS_INCLUDE_DIR})
58 | set(CORE_LINK ${CORE_LINK} ${OGGVORBIS_LIBRARIES})
59 | endif(WITH_AUDIOOGG)
60 |
61 | add_library(MonocleCore
62 | ${CORE_SRCS}
63 | ${PLATFORM_SRCS}
64 | )
65 | add_library(TinyXML ${XML_SRCS})
66 |
67 | target_link_libraries(MonocleCore TinyXML ${CORE_LINK})
68 |
69 | if(BUILD_TESTS)
70 | add_subdirectory(Tests)
71 | endif(BUILD_TESTS)
72 |
--------------------------------------------------------------------------------
/Core/Camera.cpp:
--------------------------------------------------------------------------------
1 | #include "Camera.h"
2 | #include "Graphics.h"
3 |
4 | namespace Monocle
5 | {
6 | Camera::Camera(const Camera& camera)
7 | : Transform(camera), isVisible(camera.isVisible), frontLayer(camera.frontLayer), backLayer(camera.backLayer)
8 | {
9 |
10 | }
11 |
12 | Camera::Camera()
13 | : Transform(), isVisible(true), frontLayer(-100), backLayer(100)
14 | {
15 | position = Graphics::GetScreenCenter();
16 | }
17 |
18 | void Camera::ApplyMatrix()
19 | {
20 | //Graphics::IdentityMatrix();
21 | Graphics::DefaultMatrix();
22 | Graphics::Scale(scale);
23 | Graphics::Translate(position * -1.0f);
24 | Graphics::Rotate(rotation, 0, 0, 1);
25 | }
26 |
27 | void Camera::SetLayers(int backLayer, int frontLayer)
28 | {
29 | this->frontLayer = frontLayer;
30 | this->backLayer = backLayer;
31 | }
32 |
33 | int Camera::GetBackLayer()
34 | {
35 | return backLayer;
36 | }
37 |
38 | int Camera::GetFrontLayer()
39 | {
40 | return frontLayer;
41 | }
42 | }
--------------------------------------------------------------------------------
/Core/Camera.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Transform.h"
4 |
5 | namespace Monocle
6 | {
7 | //! \brief Manages the details of a view through which items in a scene are rendered.
8 | //! Cameras are the eyes of the engine, their position, rotation, and depth of vision determine what is rendered
9 | //! onto the screen.
10 | class Camera : public Transform
11 | {
12 | public:
13 | Camera();
14 | Camera(const Camera& camera);
15 |
16 | //! Applies the position translation, scale, and rotation of this camera to the graphics context.
17 | void ApplyMatrix();
18 |
19 | //! Sets the layers that this camera can see.
20 | //! \param backLayer The deepest layer in this camera's vision
21 | //! \param frontLayer The shallowest layer in this camera's vision
22 | void SetLayers(int backLayer, int frontLayer);
23 | //! Returns the deepest layer the camera can see
24 | int GetBackLayer();
25 | //! Returns the shallowest layer the camera can see
26 | int GetFrontLayer();
27 |
28 | //! Whether or not the camera is to be rendered
29 | bool isVisible;
30 |
31 | private:
32 | int backLayer, frontLayer;
33 | };
34 | }
35 |
--------------------------------------------------------------------------------
/Core/Cocoa/CocoaEvents.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | extern void Cocoa_RegisterApp(void);
4 | extern void Cocoa_PumpEvents();
5 |
6 |
--------------------------------------------------------------------------------
/Core/Cocoa/CocoaKeys.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | void Cocoa_HandleKeyEvent(NSEvent *event);
4 |
5 |
--------------------------------------------------------------------------------
/Core/Cocoa/CocoaOpenGL.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | extern NSOpenGLContext* Cocoa_GL_CreateContext();
6 | extern int Cocoa_GL_MakeCurrent(NSWindow* window, NSOpenGLContext* context);
7 | extern void Cocoa_GL_SwapWindow();
8 | extern void Cocoa_GL_DeleteContext(NSOpenGLContext* context);
9 | extern int Cocoa_GL_SetSwapInterval(int interval);
10 | extern int Cocoa_GL_GetSwapInterval();
11 |
12 | /* vi: set ts=4 sw=4 noexpandtab: */
13 |
14 |
--------------------------------------------------------------------------------
/Core/Cocoa/CocoaPlatform.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "../Platform.h"
4 | #include "CocoaWindowListener.h"
5 |
6 | #include
7 |
8 | namespace Monocle
9 | {
10 | class CocoaPlatform
11 | {
12 | public:
13 | static CocoaPlatform* instance;
14 | static Platform* platform;
15 |
16 | ~CocoaPlatform();
17 |
18 | void Init(const std::string &name, int w, int h, int bits, bool fullscreen);
19 |
20 | NSWindow* window;
21 | WindowData* windowData;
22 |
23 | std::string bundleResourcesPath;
24 | };
25 | }
26 |
27 | /* vi: set ts=4 sw=4 noexpandtab: */
28 |
29 |
--------------------------------------------------------------------------------
/Core/Cocoa/CocoaWindowListener.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #import
4 |
5 | typedef struct WindowData WindowData;
6 |
7 | #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
8 | @interface CocoaWindowListener : NSResponder {
9 | #else
10 | @interface CocoaWindowListener : NSResponder {
11 | #endif
12 | WindowData* _data;
13 | }
14 |
15 | -(void) listen:(WindowData *) data;
16 | -(void) close;
17 |
18 | /* Window delegate functionality */
19 | -(BOOL) windowShouldClose:(id) sender;
20 | -(void) windowDidResize:(NSNotification *) aNotification;
21 |
22 | /* Window event handling */
23 | -(void) mouseDown:(NSEvent *) theEvent;
24 | -(void) rightMouseDown:(NSEvent *) theEvent;
25 | -(void) otherMouseDown:(NSEvent *) theEvent;
26 | -(void) mouseUp:(NSEvent *) theEvent;
27 | -(void) rightMouseUp:(NSEvent *) theEvent;
28 | -(void) otherMouseUp:(NSEvent *) theEvent;
29 | -(void) mouseEntered:(NSEvent *)theEvent;
30 | -(void) mouseExited:(NSEvent *)theEvent;
31 | -(void) mouseMoved:(NSEvent *) theEvent;
32 | -(void) mouseDragged:(NSEvent *) theEvent;
33 | -(void) rightMouseDragged:(NSEvent *) theEvent;
34 | -(void) otherMouseDragged:(NSEvent *) theEvent;
35 | -(void) scrollWheel:(NSEvent *) theEvent;
36 |
37 | /* Touch event handling */
38 | typedef enum {
39 | COCOA_TOUCH_DOWN,
40 | COCOA_TOUCH_UP,
41 | COCOA_TOUCH_MOVE,
42 | COCOA_TOUCH_CANCELLED
43 | } cocoaTouchType;
44 | -(void) handleTouches:(cocoaTouchType)type withEvent:(NSEvent*) event;
45 |
46 | @end
47 |
48 | struct WindowData
49 | {
50 | bool created;
51 | NSWindow *nswindow;
52 | CocoaWindowListener *listener;
53 | };
54 |
55 | void Cocoa_DestroyWindow(WindowData* data);
56 |
57 |
--------------------------------------------------------------------------------
/Core/Colliders/CircleCollider.cpp:
--------------------------------------------------------------------------------
1 | #include "CircleCollider.h"
2 | #include "../CollisionData.h"
3 | #include
4 |
5 | namespace Monocle
6 | {
7 | CircleCollider::CircleCollider(float radius, Vector2 offset)
8 | : Collider()
9 | {
10 | this->offset = offset;
11 | this->radius = radius;
12 | }
13 |
14 | ColliderType CircleCollider::GetColliderType()
15 | {
16 | return CT_CIRCLE;
17 | }
18 |
19 | bool CircleCollider::IntersectsPoint(const Vector2& point, CollisionData *collisionData)
20 | {
21 | Vector2 ePos = GetEntityPosition();
22 |
23 | Vector2 diff = point - (ePos + offset);
24 | return (diff.IsInRange(radius));
25 | }
26 |
27 | bool CircleCollider::IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius, CollisionData *collisionData)
28 | {
29 | //Algorithm stolen from: http://www.gamedev.net/topic/304578-finite-line-circle-intersection/page__view__findpost__p__2938618
30 |
31 | Vector2 ePos = GetEntityPosition();
32 |
33 | Vector2 dir = end - start;
34 | Vector2 diff = (ePos + offset) - start;
35 | float t = diff.Dot(dir) / dir.GetSquaredMagnitude();
36 | if (t < 0.0f)
37 | t = 0.0f;
38 | if (t > 1.0f)
39 | t = 1.0f;
40 | Vector2 closest = (t * dir) + start;
41 | Vector2 d = (ePos + offset) - closest;
42 |
43 | bool didCollide = d.GetSquaredMagnitude() <= (radius + lineRadius) * (radius + lineRadius);
44 |
45 | if (didCollide && collisionData)
46 | {
47 | Vector2 diff = start - ePos;
48 | diff.Clamp(radius);
49 | collisionData->hitPoint = ePos + diff;
50 | collisionData->penetration = fabs(d.GetMagnitude() - (radius + lineRadius));
51 | collisionData->normal = (ePos - closest).GetNormalized();
52 | collisionData->collider = this;
53 | }
54 |
55 | return didCollide;
56 | }
57 |
58 | float CircleCollider::GetCenterX(bool relativeToEntity)
59 | {
60 | if (relativeToEntity)
61 | return offset.x;
62 | else
63 | return GetEntityPosition().x + offset.x;
64 | }
65 |
66 | float CircleCollider::GetCenterY(bool relativeToEntity)
67 | {
68 | if (relativeToEntity)
69 | return offset.y;
70 | else
71 | return GetEntityPosition().y + offset.y;
72 | }
73 |
74 | Vector2 CircleCollider::GetCenter(bool relativeToEntity)
75 | {
76 | return Vector2(GetCenterX(relativeToEntity), GetCenterY(relativeToEntity));
77 | }
78 | }
--------------------------------------------------------------------------------
/Core/Colliders/CircleCollider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Collider.h"
4 | #include "../Vector2.h"
5 | #include "../Entity.h"
6 |
7 | namespace Monocle
8 | {
9 | class CircleCollider : public Collider
10 | {
11 | public:
12 | float radius;
13 | CircleCollider(float radius, Vector2 offset=Vector2::zero);
14 | ColliderType GetColliderType();
15 | bool IntersectsPoint(const Vector2& point, CollisionData *collisionData = NULL);
16 | bool IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius = 1.0f, CollisionData *collisionData = NULL);
17 |
18 | float GetCenterX(bool relativeToEntity = false);
19 | float GetCenterY(bool relativeToEntity = false);
20 | Vector2 GetCenter(bool relativeToEntity = false);
21 | };
22 | }
--------------------------------------------------------------------------------
/Core/Colliders/Collider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "../Vector2.h"
4 | // for NULL
5 | #include
6 |
7 | namespace Monocle
8 | {
9 | enum ColliderType
10 | {
11 | CT_RECT=0,
12 | CT_CIRCLE,
13 | CT_POLYGON,
14 | CT_PATH
15 | };
16 |
17 | class RectangleCollider;
18 | class CircleCollider;
19 | class PolygonCollider;
20 | class LineSegmentCollider;
21 | class PathCollider;
22 | class Entity;
23 | class CollisionData;
24 |
25 | class Collider
26 | {
27 | public:
28 | Collider();
29 |
30 | void SetEntity(Entity* entity);
31 | Entity* GetEntity();
32 | Vector2 GetEntityPosition();
33 |
34 | Vector2 offset;
35 |
36 | virtual ColliderType GetColliderType() = 0;
37 | virtual bool IntersectsPoint(const Vector2& point, CollisionData *collisionData=NULL)=0;
38 | virtual bool IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius = 0.0f, CollisionData *collisionData=NULL)=0;
39 |
40 | static bool Collide(Collider* a, Collider* b, CollisionData *collisionData = NULL);
41 | static bool LinesIntersect(const Vector2& aStart, const Vector2& aEnd, const Vector2& bStart, const Vector2& bEnd, CollisionData *collisionData=NULL);
42 |
43 | private:
44 | Entity *entity;
45 | static bool CollideRectRect(RectangleCollider* a, RectangleCollider* b, CollisionData *collisionData);
46 | static bool CollideCircleCircle(CircleCollider* a, CircleCollider* b, CollisionData *collisionData);
47 | static bool CollidePolygonPolygon(PolygonCollider* a, PolygonCollider* b, CollisionData *collisionData);
48 |
49 | static bool CollideRectCircle(RectangleCollider* a, CircleCollider* b, CollisionData *collisionData);
50 | static bool CollideRectPolygon(RectangleCollider* a, PolygonCollider* b, CollisionData *collisionData);
51 | static bool CollideCirclePolygon(CircleCollider* a, PolygonCollider* b, CollisionData *collisionData);
52 |
53 | static bool CollideCirclePath(CircleCollider *a, PathCollider *b, CollisionData *collisionData);
54 | };
55 | }
--------------------------------------------------------------------------------
/Core/Colliders/PathCollider.cpp:
--------------------------------------------------------------------------------
1 | #include "PathCollider.h"
2 | #include "CollisionData.h"
3 |
4 | namespace Monocle
5 | {
6 | PathCollider::PathCollider()
7 | : Collider(), startNode(NULL), radius(0.0f)
8 | {
9 | }
10 |
11 | PathCollider::PathCollider(Node *node, float radius)
12 | : Collider(), startNode(node), radius(radius)
13 | {
14 | }
15 |
16 | ColliderType PathCollider::GetColliderType()
17 | {
18 | return CT_PATH;
19 | }
20 |
21 | bool PathCollider::IntersectsPoint(const Vector2& point, CollisionData *collisionData)
22 | {
23 | return false;
24 | }
25 |
26 | // ignores radius for now
27 | bool PathCollider::IntersectsLine(const Vector2& start, const Vector2& end, float radius, CollisionData *collisionData)
28 | {
29 | Node *node = startNode;
30 | while(node)
31 | {
32 | Node *next = node->GetNext();
33 | if (next)
34 | {
35 | if (node->variant != -1)
36 | {
37 | if (LinesIntersect(node->GetWorldPosition(), next->GetWorldPosition(), start, end, collisionData))
38 | {
39 | collisionData->collider = this;
40 | return true;
41 | }
42 | }
43 | }
44 | node = next;
45 | }
46 | return false;
47 | }
48 | }
--------------------------------------------------------------------------------
/Core/Colliders/PathCollider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Collider.h"
4 | #include "../LevelEditor/Node.h"
5 |
6 | namespace Monocle
7 | {
8 | class PathCollider : public Collider
9 | {
10 | public:
11 | PathCollider();
12 | PathCollider(Node *node, float radius);
13 | ColliderType GetColliderType();
14 | bool IntersectsPoint(const Vector2& point, CollisionData *collisionData = NULL);
15 | bool IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius = 1.0f, CollisionData *collisionData = NULL);
16 |
17 | Node *startNode;
18 |
19 | float radius;
20 | };
21 | }
--------------------------------------------------------------------------------
/Core/Colliders/PolygonCollider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Collider.h"
4 | #include "../Vector2.h"
5 | #include "../Entity.h"
6 | #include
7 |
8 | namespace Monocle
9 | {
10 | // Arbitrary, possibly concave polygon
11 | class PolygonCollider : public Collider
12 | {
13 | public:
14 | std::vector points;
15 | PolygonCollider(Vector2 offset=Vector2::zero);
16 | ColliderType GetColliderType();
17 | bool IntersectsPoint(const Vector2& point);
18 | bool IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius = 1.0f);
19 |
20 | bool IsEmpty();
21 | void AddPoint(Vector2 point);
22 | int GetPointCount();
23 | Vector2 GetPoint(int index, bool relativeToEntity = false);
24 |
25 | float GetLeftmost(bool relativeToEntity = false);
26 | float GetRightmost(bool relativeToEntity = false);
27 | float GetTopmost(bool relativeToEntity = false);
28 | float GetBottommost(bool relativeToEntity = false);
29 |
30 | private:
31 | float leftmost;
32 | float rightmost;
33 | float topmost;
34 | float bottommost;
35 | };
36 | }
--------------------------------------------------------------------------------
/Core/Colliders/RectangleCollider.cpp:
--------------------------------------------------------------------------------
1 | #include "RectangleCollider.h"
2 |
3 | namespace Monocle
4 | {
5 | //Note: collision is centered
6 | // so 0,0 is the center of the sprite
7 | // unless you set an offset (position)
8 |
9 | RectangleCollider::RectangleCollider(float width, float height, Vector2 offset)
10 | : Collider()
11 | {
12 | this->offset = offset;
13 | this->width = width;
14 | this->height = height;
15 | }
16 |
17 | ColliderType RectangleCollider::GetColliderType()
18 | {
19 | return CT_RECT;
20 | }
21 |
22 | bool RectangleCollider::IntersectsPoint(const Vector2& point, CollisionData *collisionData)
23 | {
24 | //Vector2 ePos = GetEntityPosition();
25 |
26 | return (point.x > GetLeft() && point.y > GetTop() && point.x < GetRight() && point.y < GetBottom());
27 | }
28 |
29 | bool RectangleCollider::IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius, CollisionData *collisionData)
30 | {
31 | //TODO: Support line width!
32 |
33 | if (!collisionData)
34 | {
35 | if (IntersectsPoint(start) || IntersectsPoint(end))
36 | return true;
37 | }
38 |
39 | Vector2 pA = GetTopLeft();
40 | Vector2 pB = GetTopRight();
41 | Vector2 pC = GetBottomRight();
42 | Vector2 pD = GetBottomLeft();
43 |
44 | return (LinesIntersect(start, end, pA, pB, collisionData) || LinesIntersect(start, end, pB, pC, collisionData) || LinesIntersect(start, end, pC, pD, collisionData) || LinesIntersect(start, end, pD, pA, collisionData));
45 | }
46 |
47 | float RectangleCollider::GetRight(bool relativeToEntity)
48 | {
49 | if (relativeToEntity)
50 | return offset.x + width*0.5;
51 | else
52 | return GetEntityPosition().x + offset.x + width*0.5;
53 | }
54 |
55 | float RectangleCollider::GetLeft(bool relativeToEntity)
56 | {
57 | if (relativeToEntity)
58 | return offset.x - width*0.5f;
59 | else
60 | return GetEntityPosition().x + offset.x - width*0.5;
61 | }
62 |
63 | float RectangleCollider::GetTop(bool relativeToEntity)
64 | {
65 | if (relativeToEntity)
66 | return offset.y - height*0.5f;
67 | else
68 | return GetEntityPosition().y + offset.y - height*0.5f;
69 | }
70 |
71 | float RectangleCollider::GetBottom(bool relativeToEntity)
72 | {
73 | if (relativeToEntity)
74 | return offset.y + height*0.5f;
75 | else
76 | return GetEntityPosition().y + offset.y + height*0.5f;
77 | }
78 |
79 | Vector2 RectangleCollider::GetTopLeft(bool relativeToEntity)
80 | {
81 | return Vector2(GetLeft(relativeToEntity), GetTop(relativeToEntity));
82 | }
83 |
84 | Vector2 RectangleCollider::GetTopRight(bool relativeToEntity)
85 | {
86 | return Vector2(GetRight(relativeToEntity), GetTop(relativeToEntity));
87 | }
88 |
89 | Vector2 RectangleCollider::GetBottomLeft(bool relativeToEntity)
90 | {
91 | return Vector2(GetLeft(relativeToEntity), GetBottom(relativeToEntity));
92 | }
93 |
94 | Vector2 RectangleCollider::GetBottomRight(bool relativeToEntity)
95 | {
96 | return Vector2(GetRight(relativeToEntity), GetBottom(relativeToEntity));
97 | }
98 | }
--------------------------------------------------------------------------------
/Core/Colliders/RectangleCollider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Collider.h"
4 | #include "../Vector2.h"
5 | #include "../Entity.h"
6 |
7 | namespace Monocle
8 | {
9 | // Axis-Aligned Bounding Box
10 | class RectangleCollider : public Collider
11 | {
12 | public:
13 | float width;
14 | float height;
15 | RectangleCollider(float width, float height, Vector2 offset=Vector2::zero);
16 | ColliderType GetColliderType();
17 | bool IntersectsPoint(const Vector2& point, CollisionData *collisionData = NULL);
18 | bool IntersectsLine(const Vector2& start, const Vector2& end, float lineRadius = 0.0f, CollisionData *collisionData=NULL);
19 |
20 | float GetRight(bool relativeToEntity = false);
21 | float GetLeft(bool relativeToEntity = false);
22 | float GetTop(bool relativeToEntity = false);
23 | float GetBottom(bool relativeToEntity = false);
24 |
25 | Vector2 GetTopLeft(bool relativeToEntity = false);
26 | Vector2 GetTopRight(bool relativeToEntity = false);
27 | Vector2 GetBottomLeft(bool relativeToEntity = false);
28 | Vector2 GetBottomRight(bool relativeToEntity = false);
29 | };
30 | }
--------------------------------------------------------------------------------
/Core/Collision.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Colliders/Collider.h"
4 | #include "Colliders/RectangleCollider.h"
5 | #include "Colliders/CircleCollider.h"
6 |
7 | #include "CollisionData.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | namespace Monocle
14 | {
15 | class Entity;
16 |
17 | //!
18 | //! \brief Manages collision for Monocle. In most cases there is no need to reference this class, use the Entity::Collide function instead.
19 | //!
20 | //! Collision tracks Collider instances, and uses their Entity pointers to check for which entities fit the tag description passed to Collision::Collide.
21 | //!
22 | class Collision
23 | {
24 | public:
25 | //! Returns the first Collider with the specified tag that intersects with the line.
26 | //! \param start The beginning vector of the line to cast.
27 | //! \param end The end vector of the line to cast.
28 | //! \param radius The radius of the line to cast.
29 | //! \param tag The tag of the Colliders to be checked for intersection
30 | //! \param collisionData [out] The data resulting from the collision
31 | static Collider* LineCast(const Vector2 &start, const Vector2 &end, float radius, const std::string &tag, CollisionData *collisionData = NULL);
32 |
33 | private:
34 | friend class Entity;
35 | friend class Game;
36 |
37 | Collision();
38 | void Init();
39 |
40 | static void RegisterColliderWithEntity(Collider *collider, Entity *entity);
41 | static void RemoveCollider(Collider *collider);
42 | static Collider* Collide(Entity *entity, const std::string &tag, CollisionData *collisionData=NULL);
43 | static Collider* Collide(Collider *collider, const std::string &tag, CollisionData *collisionData=NULL);
44 |
45 | private:
46 | static Collision *instance;
47 | std::list colliders;
48 | };
49 | }
50 |
--------------------------------------------------------------------------------
/Core/CollisionData.cpp:
--------------------------------------------------------------------------------
1 | #include "CollisionData.h"
2 |
3 | namespace Monocle
4 | {
5 | CollisionData::CollisionData()
6 | : penetration(0.0f), collider(NULL)
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/Core/CollisionData.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Vector2.h"
4 | #include "Colliders/Collider.h"
5 |
6 | namespace Monocle
7 | {
8 | //! Describes the result of a collision. Used to resolve collisions.
9 | class CollisionData
10 | {
11 | public:
12 | CollisionData();
13 |
14 | //! Position where the collision occurred
15 | Vector2 hitPoint;
16 | //! Normal of the collision
17 | Vector2 normal;
18 | //! How far into the collider we've moved
19 | float penetration;
20 | //! Pointer to the collider that was hit
21 | Collider *collider;
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/Core/Color.cpp:
--------------------------------------------------------------------------------
1 | #include "Color.h"
2 | #include
3 |
4 | namespace Monocle
5 | {
6 | Color Color::white = Color(1,1,1,1);
7 | Color Color::grey = Color(0.5f, 0.5f, 0.5f, 1.0f);
8 |
9 | Color Color::black = Color(0,0,0,1);
10 | Color Color::red = Color(1,0,0,1);
11 | Color Color::green = Color(0,1,0,1);
12 | Color Color::blue = Color(0,0,1,1);
13 | Color Color::yellow = Color(1,1,0,1);
14 | Color Color::orange = Color(1.0f,0.5f,0.0f,1.0f);
15 | Color Color::purple = Color(0.5f, 0.0f, 1.0f, 1.0f);
16 |
17 | Color::Color(const Color &color)
18 | : r(color.r), g(color.g), b(color.b), a(color.a)
19 | {
20 | }
21 |
22 | Color::Color()
23 | : r(1), g(1), b(1), a(1)
24 | {
25 |
26 | }
27 |
28 | Color::Color(float r, float g, float b, float a)
29 | : r(r), g(g), b(b), a(a)
30 | {
31 |
32 | }
33 |
34 | Color::Color(const std::string &hexString)
35 | {
36 | std::istringstream is(hexString);
37 |
38 | unsigned int hexcolor;
39 | is >> std::hex >> hexcolor;
40 |
41 | r = ( hexcolor >> 16 ) & 0xFF;
42 | g = ( hexcolor >> 8 ) & 0xFF;
43 | b = hexcolor & 0xFF;
44 | r /= 255.0f;
45 | g /= 255.0f;
46 | b /= 255.0f;
47 | a = 1.0f;
48 | }
49 |
50 | bool Color::operator==(const Color& rhs)
51 | {
52 | return ((r == rhs.r) && (g == rhs.g) && (b == rhs.b) && (a == rhs.a));
53 | }
54 |
55 | bool Color::operator!=(const Color& rhs)
56 | {
57 | return ((r != rhs.r) || (g != rhs.g) || (b != rhs.b) || (a != rhs.a));
58 | }
59 |
60 | void Color::Clamp()
61 | {
62 | for (unsigned int i = 0; i < 4; i++)
63 | {
64 | if ((*this)[i] > 1.0f)
65 | (*this)[i] = 1.0f;
66 | if ((*this)[i] < 0.0f)
67 | (*this)[i] = 0.0f;
68 | }
69 | }
70 |
71 | float& Color::operator[] (unsigned int i)
72 | {
73 | switch(i)
74 | {
75 | case 0: return r;
76 | case 1: return g;
77 | case 2: return b;
78 | default: return a;
79 | }
80 | }
81 |
82 | Color operator+(const Color& lhs, const Color& rhs)
83 | {
84 | return Color(lhs.r + rhs.r, lhs.g + rhs.g, lhs.b + rhs.b, lhs.a + rhs.a);
85 | }
86 |
87 | Color operator-(const Color& lhs, const Color& rhs)
88 | {
89 | return Color(lhs.r - rhs.r, lhs.g - rhs.g, lhs.b - rhs.b, lhs.a - rhs.a);
90 | }
91 |
92 | Color operator*(float lhs, const Color& rhs) // left scalar multiplication
93 | {
94 | return Color(lhs * rhs.r, lhs * rhs.g, lhs * rhs.b, lhs * rhs.a);
95 | }
96 |
97 | Color operator*(const Color& lhs, float rhs) // right scalar multiplication
98 | {
99 | return Color(lhs.r * rhs, lhs.g * rhs, lhs.b * rhs, lhs.a * rhs);
100 | }
101 |
102 | Color operator/(const Color& lhs, float rhs)
103 | {
104 | return Color(lhs.r / rhs, lhs.g / rhs, lhs.b / rhs, lhs.a / rhs);
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Core/Color.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | namespace Monocle
6 | {
7 | //! Describes a color using 4 floats in 0.0 - 1.0 range.
8 | class Color
9 | {
10 | public:
11 | Color(const Color &color);
12 | Color();
13 | Color(float r, float g, float b, float a);
14 | Color(const std::string &hexString);
15 |
16 | //! Clamps the rgba values to between 0 and 1.0, inclusive.
17 | void Clamp();
18 |
19 | //! Indirect accessor for rgba values. Color[0] = r, [1] = g, [2] = b, [3] = a, [4+] = undefined
20 | float& operator[] (unsigned int i);
21 | bool operator==(const Color& rhs);
22 | bool operator!=(const Color& rhs);
23 |
24 | //! Red, green, blue, alpha (translucency)
25 | float r, g, b, a;
26 |
27 | static Color white;
28 | static Color grey;
29 | static Color black;
30 | static Color red;
31 | static Color green;
32 | static Color blue;
33 | static Color yellow;
34 | static Color orange;
35 | static Color purple;
36 | };
37 |
38 | Color operator+(const Color& lhs, const Color& rhs);
39 | Color operator-(const Color& lhs, const Color& rhs);
40 | Color operator*(float lhs, const Color& rhs); // left scalar multiplication
41 | Color operator*(const Color& lhs, float rhs); // right scalar multiplication
42 | Color operator/(const Color& lhs, float rhs);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/Core/ConfigValues.cpp:
--------------------------------------------------------------------------------
1 | #include "ConfigValues.h"
2 |
3 | namespace Monocle
4 | {
5 | ConfigValues *ConfigValues::instance = NULL;
6 |
7 | ConfigValues::ConfigValues()
8 | {
9 | instance = this;
10 | }
11 |
12 | void ConfigValues::Load(const std::string &filename)
13 | {
14 | TiXmlDocument doc;
15 | doc.LoadFile(Assets::GetContentPath() + filename);
16 | TiXmlElement *xmlValues = doc.FirstChildElement("config");
17 | if (xmlValues)
18 | {
19 | TiXmlElement *xmlValue = xmlValues->FirstChildElement("value");
20 | while (xmlValue)
21 | {
22 | std::string name = XMLReadString(xmlValue, "name");
23 |
24 | if (xmlValue->Attribute("float"))
25 | instance->floats[name] = XMLReadFloat(xmlValue, "float");
26 |
27 | if (xmlValue->Attribute("string"))
28 | instance->strings[name] = XMLReadString(xmlValue, "string");
29 |
30 | if (xmlValue->Attribute("int"))
31 | instance->ints[name] = XMLReadInt(xmlValue, "int");
32 |
33 | if (xmlValue->Attribute("bool"))
34 | instance->bools[name] = XMLReadBool(xmlValue, "bool");
35 |
36 | if (xmlValue->Attribute("vector2"))
37 | instance->vector2s[name] = XMLReadVector2(xmlValue, "vector2");
38 |
39 | xmlValue = xmlValue->NextSiblingElement("value");
40 | }
41 | }
42 | }
43 |
44 | std::string ConfigValues::GetString(const std::string &valueName)
45 | {
46 | return instance->strings[valueName];
47 | }
48 |
49 | int ConfigValues::GetInt(const std::string &valueName)
50 | {
51 | return instance->ints[valueName];
52 | }
53 |
54 | float ConfigValues::GetFloat(const std::string &valueName)
55 | {
56 | return instance->floats[valueName];
57 | }
58 |
59 | bool ConfigValues::GetBool(const std::string &valueName)
60 | {
61 | return instance->bools[valueName];
62 | }
63 |
64 | Vector2 ConfigValues::GetVector2(const std::string &valueName)
65 | {
66 | return instance->vector2s[valueName];
67 | }
68 | }
--------------------------------------------------------------------------------
/Core/ConfigValues.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include