Initial check-in of game code

master
Levi Pearson 2016-04-07 19:47:18 -06:00
commit bd342efae7
4 changed files with 1240 additions and 0 deletions

846
Cargo.lock generated Normal file
View File

@ -0,0 +1,846 @@
[root]
name = "getting-started-spinning-square"
version = "0.1.0"
dependencies = [
"piston_window 0.40.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "android_glue"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "arrayvec"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nodrop 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"odds 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bitflags"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cgl"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gleam 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cocoa"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "color_quant"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "core-foundation"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-graphics"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "deque"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dlib"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libloading 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "draw_state"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dwmapi-sys"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dylib"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "enum_primitive"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "euclid"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "flate2"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fs2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gcc"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "gdi32-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"draw_state 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx_core"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"draw_state 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx_device_gl"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_gl 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gfx_gl"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_common 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gif"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"color_quant 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lzw 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gl"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gl_common"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gl_generator"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gl_generator"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"xml-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gleam"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl_generator 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "glob"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "glutin"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"android_glue 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gl_generator 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"khronos_api 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_library 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"shell32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-kbd 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-window 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "image"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"enum_primitive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gif 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "inflate"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "interpolation"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "itertools"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "jpeg-decoder"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kernel32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "khronos_api"
version = "0.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "khronos_api"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libloading"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "linked-hash-map"
version = "0.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lzw"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memmap"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fs2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz-sys"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ndarray"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itertools 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nodrop"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"odds 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num_cpus"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "objc"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "odds"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "osmesa-sys"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_library 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"pistoncore-event_loop 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-input 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-window 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston-float"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "piston-gfx_texture"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-texture 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston-shaders_graphics2d"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "piston-texture"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "piston-viewport"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"piston-float 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston2d-gfx_graphics"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-gfx_texture 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-shaders_graphics2d 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston2d-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rusttype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shader_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston2d-graphics"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"interpolation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-texture 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-viewport 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"read_color 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vecmath 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "piston_window"
version = "0.40.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gfx 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx_device_gl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston2d-gfx_graphics 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston2d-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-glutin_window 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shader_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pistoncore-event_loop"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"piston-viewport 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-input 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-window 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pistoncore-glutin_window"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gl 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-input 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pistoncore-window 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shader_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pistoncore-input"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"piston-viewport 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pistoncore-window"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"pistoncore-input 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"shader_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "png"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"inflate 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "read_color"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-serialize"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rusttype"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"ndarray 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"stb_truetype 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "shader_version"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "shared_library"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "shell32-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "stb_truetype"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tempfile"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "time"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "user32-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "vecmath"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"piston-float 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-client"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-scanner 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-sys 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-kbd"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"dlib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-scanner"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"xml-rs 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-sys"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dlib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wayland-window"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "x11-dl"
version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dylib 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "xml-rs"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "xml-rs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

13
Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "getting-started-spinning-square"
version = "0.1.0"
authors = [
"Levi Pearson <levipearson@gmail.com>"
]
[[bin]]
name = "spinning-square"
[dependencies]
piston_window = "0.40.0"

339
src/game.rs Normal file
View File

@ -0,0 +1,339 @@
use piston_window::*;
use piston_window::math::*;
use piston_window::draw_state::Blend;
use std::f64::consts::*;
static TURN_RATE: Scalar = 4.0;
static THRUST_RATE: Scalar = 4.0;
struct Controls {
up_d: bool,
down_d: bool,
left_d: bool,
right_d: bool,
fire: bool
}
impl Controls {
fn new() -> Self {
Controls {
up_d: false, down_d: false, left_d: false, right_d: false,
fire: false
}
}
fn update(&mut self, inp: Input) {
match inp {
Input::Press(b) => {
match b {
Button::Keyboard(Key::Up) => { self.up_d = true; }
Button::Keyboard(Key::Down) => { self.down_d = true; }
Button::Keyboard(Key::Left) => { self.left_d = true; }
Button::Keyboard(Key::Right) => { self.right_d = true; }
_ => {}
}
}
Input::Release(b) => {
match b {
Button::Keyboard(Key::Up) => { self.up_d = false; }
Button::Keyboard(Key::Down) => { self.down_d = false; }
Button::Keyboard(Key::Left) => { self.left_d = false; }
Button::Keyboard(Key::Right) => { self.right_d = false; }
Button::Keyboard(Key::Space) => { self.fire = true; }
_ => {}
}
}
_ => {}
}
}
fn velocity_change(&self, rot: Scalar, dt: Scalar) -> Vec2d {
let thrust = if self.up_d {
THRUST_RATE * dt
} else if self.down_d {
-THRUST_RATE * dt
} else {
0.0
};
if thrust != 0.0 {
[rot.cos() * thrust, rot.sin() * thrust]
} else {
[0.0, 0.0]
}
}
fn rotation_change(&self, dt: Scalar) -> Scalar {
if self.left_d {
-TURN_RATE * dt
} else if self.right_d {
TURN_RATE * dt
} else {
0.0
}
}
fn fire_check(&self) -> bool {
self.fire
}
}
const BULLET_POLY: &'static [[Scalar; 2]] = &[
[-1.5, -1.5],
[-1.5, 1.5],
[1.5, 1.5],
[1.5, -1.5]
];
#[derive(Debug)]
pub struct Bullet {
position: Vec2d,
velocity: Vec2d,
ttl: Scalar,
geometry: &'static [[Scalar; 2]]
}
const SHIP_POLY: &'static [[Scalar; 2]] = &[
[-10.0, -8.0],
[10.0, 0.0],
[-10.0, 8.0]
];
impl Bullet {
pub fn new(loc: Vec2d, velocity: Vec2d, ttl: Scalar) -> Self {
Bullet {
position: loc,
velocity: velocity,
ttl: ttl,
geometry: BULLET_POLY
}
}
pub fn update(&mut self, dt: Scalar) -> Scalar {
self.position = add(self.position, self.velocity);
self.ttl -= dt;
self.ttl
}
}
pub struct Ship {
rotation: Scalar,
position: Vec2d,
velocity: Vec2d,
geometry: &'static [[Scalar; 2]]
}
impl Ship {
pub fn new(loc: Vec2d) -> Self {
Ship {
rotation: -FRAC_PI_2,
position: loc,
velocity: [0.0, 0.0],
geometry: SHIP_POLY
}
}
pub fn update(&mut self, dv: Vec2d, dr: Scalar, map: &Map) {
self.rotation += dr;
self.velocity = add(self.velocity, dv);
self.position = add(self.position, self.velocity);
if self.position[0] > map.width {
self.velocity[0] = 0.0;
self.position[0] = map.width;
}
if self.position[0] < 0.0 {
self.velocity[0] = 0.0;
self.position[0] = 0.0;
}
if self.position[1] > map.height {
self.velocity[1] = 0.0;
self.position[1] = map.height;
}
if self.position[1] < 0.0 {
self.velocity[1] = 0.0;
self.position[1] = 0.0;
}
}
pub fn trajectory(&self) -> (Vec2d, Vec2d, Vec2d) {
let nose = self.geometry[1];
let rot = rotate_radians(self.rotation);
let trans = translate(self.position);
let tmat = multiply(trans, rot);
(transform_pos(tmat, nose), transform_vec(rot, [1.0,0.0]), self.velocity)
}
}
pub struct Camera {
position: Vec2d,
height: Scalar,
width: Scalar
}
impl Camera {
pub fn new(pos: Vec2d, width: Scalar, height: Scalar) -> Self {
Camera {
position: pos,
width: width,
height: height
}
}
pub fn follow(&mut self, pos: Vec2d, map: &Map) {
let dp = sub(pos, self.position);
let xmargin = self.width / 4.0;
let ymargin = self.height / 4.0;
if dp[0] > xmargin {
self.position[0] += dp[0] - xmargin;
}
if dp[0] < -xmargin {
self.position[0] += dp[0] + xmargin;
}
if dp[1] > ymargin {
self.position[1] += dp[1] - ymargin;
}
if dp[1] < -ymargin {
self.position[1] += dp[1] + ymargin;
}
if self.position[0] + self.width / 2.0 > map.width {
self.position[0] = map.width - self.width / 2.0;
}
if self.position[0] - self.width / 2.0 < 0.0 {
self.position[0] = 0.0 + self.width / 2.0;
}
if self.position[1] + self.height / 2.0 > map.height {
self.position[1] = map.height - self.height / 2.0;
}
if self.position[1] - self.height / 2.0 < 0.0 {
self.position[1] = 0.0 + self.height / 2.0;
}
}
}
pub struct Map {
width: Scalar,
height: Scalar
}
impl Map {
pub fn new(width: Scalar, height: Scalar) -> Self {
Map { width: width, height: height }
}
pub fn center(&self) -> Vec2d {
[self.width / 2.0, self.height / 2.0]
}
pub fn draw_grid<G>(&self, cpos: Vec2d,
cw: Scalar, ch: Scalar,
draw_state: &DrawState,
transform: Matrix2d, g: &mut G)
where G: Graphics {
const GREEN: [f32; 4] = [0.0, 1.0, 0.0, 0.05];
let minx = cpos[0] - cw / 2.0;
let miny = cpos[1] - ch / 2.0;
let xcount = (cw / 100.0).ceil() as u32 + 2;
let ycount = (ch / 100.0).ceil() as u32 + 2;
let firstx = (minx / 100.0).trunc() * 100.0;
let firsty = (miny / 100.0).trunc() * 100.0;
for x in 0..xcount {
let sy = cpos[1] - ch;
let ey = cpos[1] + ch;
let lx = firstx + (100.0 * x as Scalar);
Line::new(GREEN, 1.0)
.draw([lx-cpos[0], sy-cpos[1], lx-cpos[0], ey-cpos[1]],
draw_state, transform, g);
}
for y in 0..ycount {
let sx = cpos[0] - cw;
let ex = cpos[0] + cw;
let ly = firsty + (100.0 * y as Scalar);
Line::new(GREEN, 1.0)
.draw([sx-cpos[0], ly-cpos[1], ex-cpos[0], ly-cpos[1]],
draw_state, transform, g);
}
}
}
pub struct Game {
player: Ship,
bullets: Vec<Bullet>,
map: Map,
camera: Camera,
controls: Controls
}
impl Game {
pub fn new(width: Scalar, height: Scalar) -> Self {
let new_map = Map::new(10000.0, 10000.0);
let center = new_map.center();
Game {
player: Ship::new(center),
bullets: Vec::new(),
map: new_map,
camera: Camera::new(center, width, height),
controls: Controls::new()
}
}
pub fn render(&mut self, args: RenderArgs, w: PistonWindow) {
const BLACK: [f32; 4] = [0.0, 0.0, 0.0, 1.0];
const WHITE: [f32; 4] = [1.0, 1.0, 1.0, 1.0];
const RED: [f32; 4] = [1.0, 0.0, 0.0, 1.0];
let rotation = self.player.rotation;
let cpos = sub(self.player.position, self.camera.position);
let (x, y) = ((args.width / 2) as Scalar + cpos[0],
(args.height / 2) as Scalar + cpos[1]);
w.draw_2d(|c, gl| {
let transform = c.transform
.trans(x, y)
.rot_rad(rotation);
let cp = self.camera.position;
let cw = self.camera.width;
let ch = self.camera.height;
let ct = c.transform.trans((args.width / 2) as Scalar,
(args.height / 2) as Scalar);
let ds = c.draw_state.blend(Blend::Alpha);
clear(BLACK, gl);
self.map.draw_grid(cp, cw, ch, &ds, ct, gl);
for bullet in self.bullets.iter() {
let bpos = sub(bullet.position, self.camera.position);
let (bx, by) = ((args.width / 2) as Scalar + bpos[0],
(args.height / 2) as Scalar + bpos[1]);
let btrans = c.transform.trans(bx, by);
Polygon::new(WHITE).draw(bullet.geometry, &ds, btrans, gl);
}
Polygon::new(RED).draw(self.player.geometry, &ds, transform, gl);
});
}
pub fn update(&mut self, args: UpdateArgs) {
let dv = self.controls.velocity_change(self.player.rotation, args.dt);
let dr = self.controls.rotation_change(args.dt);
let firing = self.controls.fire_check();
self.player.update(dv, dr, &self.map);
for bullet in self.bullets.iter_mut() { bullet.update(args.dt); }
self.bullets.retain(|&ref bullet| bullet.ttl > 0.0);
if firing {
let (nose, dir, vel) = self.player.trajectory();
let bul = Bullet::new(nose, add(vel,mul_scalar(dir, 3.0)), 2.0);
self.bullets.push(bul);
self.controls.fire = false;
}
self.camera.follow(self.player.position, &self.map);
}
pub fn input(&mut self, inp: Input) {
self.controls.update(inp);
}
}

42
src/main.rs Normal file
View File

@ -0,0 +1,42 @@
extern crate piston_window;
use piston_window::*;
use piston_window::math::{Scalar};
mod game;
use game::Game;
const XDIM: u32 = 600;
const YDIM: u32 = 600;
fn main() {
let window: PistonWindow = WindowSettings::new(
"spinning-square",
[XDIM, YDIM]
)
.exit_on_esc(true)
.samples(8)
.vsync(true)
.build()
.unwrap();
// Create a new game and run it.
let mut game = Game::new(XDIM as Scalar, YDIM as Scalar);
for e in window {
match e.event {
Some(Event::Update(upd)) => {
game.update(upd);
}
Some(Event::Render(ren)) => {
game.render(ren, e);
}
Some(Event::Input(inp)) => {
game.input(inp);
}
_ => {
}
}
}
}