summaryrefslogtreecommitdiffhomepage
path: root/samples/02_input_basics/01_moving_a_sprite
diff options
context:
space:
mode:
author_Tradam <[email protected]>2021-12-16 19:22:26 -0500
committerGitHub <[email protected]>2021-12-16 19:22:26 -0500
commit5954b9beb4d4a3b4f248d72d1851195f030558a8 (patch)
treefecd8aa840a25afdb502915b0fdb4d03b7ed339a /samples/02_input_basics/01_moving_a_sprite
parent2f845281f133849256b57bb08fd3e9ae57600784 (diff)
parenteaa29e72939f5edf61735ccbb73c36ee89369f65 (diff)
downloaddragonruby-game-toolkit-contrib-master.tar.gz
dragonruby-game-toolkit-contrib-master.zip
Merge branch 'DragonRuby:master' into masterHEADmaster
Diffstat (limited to 'samples/02_input_basics/01_moving_a_sprite')
-rw-r--r--samples/02_input_basics/01_moving_a_sprite/app/main.rb30
-rw-r--r--samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt9
-rw-r--r--samples/02_input_basics/01_moving_a_sprite/replay.txt73
-rw-r--r--samples/02_input_basics/01_moving_a_sprite/sprites/square/green.pngbin0 -> 283 bytes
4 files changed, 112 insertions, 0 deletions
diff --git a/samples/02_input_basics/01_moving_a_sprite/app/main.rb b/samples/02_input_basics/01_moving_a_sprite/app/main.rb
new file mode 100644
index 0000000..da699a0
--- /dev/null
+++ b/samples/02_input_basics/01_moving_a_sprite/app/main.rb
@@ -0,0 +1,30 @@
+def tick args
+ # create a player and set default values
+ # for the player's x, y, w (width), and h (height)
+ args.state.player.x ||= 100
+ args.state.player.y ||= 100
+ args.state.player.w ||= 50
+ args.state.player.h ||= 50
+
+ # render the player to the screen
+ args.outputs.sprites << { x: args.state.player.x,
+ y: args.state.player.y,
+ w: args.state.player.w,
+ h: args.state.player.h,
+ path: 'sprites/square/green.png' }
+
+ # move the player around using the keyboard
+ if args.inputs.up
+ args.state.player.y += 10
+ elsif args.inputs.down
+ args.state.player.y -= 10
+ end
+
+ if args.inputs.left
+ args.state.player.x -= 10
+ elsif args.inputs.right
+ args.state.player.x += 10
+ end
+end
+
+$gtk.reset
diff --git a/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt b/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt
new file mode 100644
index 0000000..100dcec
--- /dev/null
+++ b/samples/02_input_basics/01_moving_a_sprite/license-for-sample.txt
@@ -0,0 +1,9 @@
+Copyright 2019 DragonRuby LLC
+
+MIT License
+
+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.
diff --git a/samples/02_input_basics/01_moving_a_sprite/replay.txt b/samples/02_input_basics/01_moving_a_sprite/replay.txt
new file mode 100644
index 0000000..1ec5f3a
--- /dev/null
+++ b/samples/02_input_basics/01_moving_a_sprite/replay.txt
@@ -0,0 +1,73 @@
+replay_version 2.0
+stopped_at 442
+seed 100
+recorded_at 2021-11-20 11:06:58 -0600
+[:mouse_button_up, 1, 0, 1, 1, 5]
+[:key_down_raw, 1073741903, 0, 2, 2, 147]
+[:key_down_raw, 1073741903, 0, 2, 3, 162]
+[:key_down_raw, 1073741903, 0, 2, 4, 164]
+[:key_down_raw, 1073741903, 0, 2, 5, 166]
+[:key_down_raw, 1073741903, 0, 2, 6, 168]
+[:key_down_raw, 1073741903, 0, 2, 7, 170]
+[:key_down_raw, 1073741903, 0, 2, 8, 172]
+[:key_down_raw, 1073741906, 0, 2, 9, 172]
+[:key_down_raw, 1073741905, 0, 2, 10, 182]
+[:key_up_raw, 1073741903, 0, 2, 11, 185]
+[:key_up_raw, 1073741906, 0, 2, 12, 188]
+[:key_down_raw, 1073741904, 0, 2, 13, 195]
+[:key_up_raw, 1073741905, 0, 2, 14, 202]
+[:key_up_raw, 1073741904, 0, 2, 15, 208]
+[:key_down_raw, 1073741903, 0, 2, 16, 210]
+[:key_down_raw, 1073741903, 0, 2, 17, 225]
+[:key_down_raw, 1073741903, 0, 2, 18, 227]
+[:key_down_raw, 1073741903, 0, 2, 19, 229]
+[:key_down_raw, 1073741903, 0, 2, 20, 231]
+[:key_down_raw, 1073741903, 0, 2, 21, 233]
+[:key_down_raw, 1073741903, 0, 2, 22, 235]
+[:key_down_raw, 1073741903, 0, 2, 23, 237]
+[:key_down_raw, 1073741903, 0, 2, 24, 239]
+[:key_down_raw, 1073741903, 0, 2, 25, 241]
+[:key_down_raw, 1073741903, 0, 2, 26, 243]
+[:key_down_raw, 1073741903, 0, 2, 27, 245]
+[:key_down_raw, 1073741903, 0, 2, 28, 247]
+[:key_down_raw, 1073741903, 0, 2, 29, 249]
+[:key_down_raw, 1073741903, 0, 2, 30, 251]
+[:key_down_raw, 1073741903, 0, 2, 31, 253]
+[:key_down_raw, 1073741903, 0, 2, 32, 255]
+[:key_down_raw, 1073741903, 0, 2, 33, 257]
+[:key_down_raw, 1073741903, 0, 2, 34, 259]
+[:key_down_raw, 1073741903, 0, 2, 35, 261]
+[:key_down_raw, 1073741903, 0, 2, 36, 263]
+[:key_down_raw, 1073741903, 0, 2, 37, 265]
+[:key_down_raw, 1073741903, 0, 2, 38, 267]
+[:key_down_raw, 1073741903, 0, 2, 39, 269]
+[:key_down_raw, 1073741903, 0, 2, 40, 271]
+[:key_down_raw, 1073741906, 0, 2, 41, 271]
+[:key_up_raw, 1073741903, 0, 2, 42, 282]
+[:key_down_raw, 1073741906, 0, 2, 43, 286]
+[:key_down_raw, 1073741906, 0, 2, 44, 288]
+[:key_down_raw, 1073741906, 0, 2, 45, 290]
+[:key_down_raw, 1073741906, 0, 2, 46, 292]
+[:key_down_raw, 1073741906, 0, 2, 47, 294]
+[:key_down_raw, 1073741906, 0, 2, 48, 296]
+[:key_down_raw, 1073741906, 0, 2, 49, 298]
+[:key_down_raw, 1073741906, 0, 2, 50, 301]
+[:key_down_raw, 1073741905, 0, 2, 51, 302]
+[:key_up_raw, 1073741906, 0, 2, 52, 313]
+[:key_down_raw, 1073741904, 0, 2, 53, 315]
+[:key_up_raw, 1073741905, 0, 2, 54, 322]
+[:key_down_raw, 1073741904, 0, 2, 55, 330]
+[:key_down_raw, 1073741904, 0, 2, 56, 332]
+[:key_down_raw, 1073741904, 0, 2, 57, 334]
+[:key_down_raw, 1073741904, 0, 2, 58, 336]
+[:key_down_raw, 1073741904, 0, 2, 59, 338]
+[:key_down_raw, 1073741904, 0, 2, 60, 340]
+[:key_down_raw, 1073741904, 0, 2, 61, 342]
+[:key_down_raw, 1073741904, 0, 2, 62, 344]
+[:key_down_raw, 1073741904, 0, 2, 63, 346]
+[:key_down_raw, 1073741904, 0, 2, 64, 348]
+[:key_down_raw, 1073741904, 0, 2, 65, 350]
+[:key_up_raw, 1073741904, 0, 2, 66, 351]
+[:key_down_raw, 96, 0, 2, 67, 359]
+[:key_up_raw, 96, 0, 2, 68, 364]
+[:key_down_raw, 13, 0, 2, 69, 442]
diff --git a/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png b/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png
new file mode 100644
index 0000000..5ef7f75
--- /dev/null
+++ b/samples/02_input_basics/01_moving_a_sprite/sprites/square/green.png
Binary files differ