Initial commit
This commit is contained in:
Родитель
96fad965c7
Коммит
cf622d32bb
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
|
@ -0,0 +1,40 @@
|
|||
# python-pykinect-pygame-cookiecutter
|
||||
|
||||
A [Cookiecutter](http://cookiecutter.readthedocs.io/) template for a
|
||||
[Python](https://www.python.org/) game that uses
|
||||
[pykinect](https://pypi.python.org/pypi/pykinect) and
|
||||
[pygame](https://pypi.python.org/pypi/Pygame).
|
||||
|
||||
This requires the original Kinect hardware (aka the Xbox 360 Kinect).
|
||||
|
||||
## Using this template
|
||||
|
||||
1. [Install Cookiecutter](http://cookiecutter.readthedocs.io/en/latest/installation.html)
|
||||
2. `cookiecutter gh:Microsoft/python-pykinect-pygame-cookiecutter`
|
||||
(or `cookiecutter https://github.com/Microsoft/python-pykinect-pygame-cookiecutter.git`
|
||||
if you prefer)
|
||||
3. Fill in the Cookiecutter items (see below as to what each item
|
||||
represents)
|
||||
4. Install the [Kinect for Windows SDK](https://www.microsoft.com/en-us/download/details.aspx?id=40278).
|
||||
5. Install the required packages listed in the generated requirements.txt.
|
||||
|
||||
|
||||
|
||||
### Cookiecutter items
|
||||
|
||||
- `app_name`: the name of the folder/project to create
|
||||
- `create_vs_project`: `y` to create a Visual Studio project file (.pyproj)
|
||||
|
||||
# Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
||||
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
||||
|
||||
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
||||
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
||||
provided by the bot. You will only need to do this once across all repos using our CLA.
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
||||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
||||
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"app_name": "kinect_game",
|
||||
"create_vs_project": "y",
|
||||
"_visual_studio" : {
|
||||
"app_name": {
|
||||
"value_source": "ProjectName",
|
||||
"visible": false
|
||||
},
|
||||
"create_vs_project": {
|
||||
"value_source": "IsNewProject",
|
||||
"visible": false
|
||||
}
|
||||
},
|
||||
"_visual_studio_post_cmds": [
|
||||
{
|
||||
"name": "File.OpenProject",
|
||||
"args": "{{cookiecutter._output_folder_path}}\\{{cookiecutter.app_name}}.pyproj"
|
||||
}
|
||||
]}
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
|
||||
def delete_file(filepath):
|
||||
os.remove(os.path.join(os.path.realpath(os.path.curdir), filepath))
|
||||
|
||||
if __name__ == '__main__':
|
||||
if '{{cookiecutter.create_vs_project}}'.lower() != 'y':
|
||||
delete_file('{{cookiecutter.app_name}}.pyproj')
|
|
@ -0,0 +1,47 @@
|
|||
"""
|
||||
A simple Kinect game using PyGame.
|
||||
"""
|
||||
|
||||
import pygame
|
||||
import pygame.color
|
||||
from pykinect import nui
|
||||
|
||||
KINECTEVENT = pygame.USEREVENT
|
||||
WINDOW_SIZE = 640, 480
|
||||
|
||||
def post_frame(frame):
|
||||
"""Get skeleton events from the Kinect device and post them into the PyGame
|
||||
event queue."""
|
||||
try:
|
||||
pygame.event.post(
|
||||
pygame.event.Event(KINECTEVENT, skeletons=frame.SkeletonData)
|
||||
)
|
||||
except:
|
||||
# event queue full
|
||||
pass
|
||||
|
||||
def main():
|
||||
"""Initialize and run the game."""
|
||||
pygame.init()
|
||||
|
||||
# Initialize PyGame
|
||||
screen = pygame.display.set_mode(WINDOW_SIZE, 0, 16)
|
||||
pygame.display.set_caption('Python Kinect Game')
|
||||
screen.fill(pygame.color.THECOLORS["black"])
|
||||
|
||||
with nui.Runtime() as kinect:
|
||||
kinect.skeleton_engine.enabled = True
|
||||
kinect.skeleton_frame_ready += post_frame
|
||||
|
||||
# Main game loop
|
||||
while True:
|
||||
event = pygame.event.wait()
|
||||
|
||||
if event.type == pygame.QUIT:
|
||||
break
|
||||
elif event.type == KINECTEVENT:
|
||||
# process e.skeletons here
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -0,0 +1,2 @@
|
|||
pygame
|
||||
pykinect
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectHome>.</ProjectHome>
|
||||
<StartupFile>kinect_game.py</StartupFile>
|
||||
<SearchPath>
|
||||
</SearchPath>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<InterpreterId>Global|PythonCore|2.7-32</InterpreterId>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="kinect_game.py" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="requirements.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterpreterReference Include="Global|PythonCore|2.7-32" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
|
||||
<!-- Uncomment the CoreCompile target to enable the Build command in
|
||||
Visual Studio and specify your pre- and post-build commands in
|
||||
the BeforeBuild and AfterBuild targets below. -->
|
||||
<!--<Target Name="CoreCompile" />-->
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче