summaryrefslogtreecommitdiffhomepage
path: root/samples/99_genre_3d
diff options
context:
space:
mode:
authorAmir Rajan <[email protected]>2020-09-11 02:02:01 -0500
committerAmir Rajan <[email protected]>2020-09-11 02:02:57 -0500
commit33ec37b141e896b47ed642923fd33b0c658ae9fb (patch)
treea40d3e5d41beeb06508200078f6f26b0ee57d6a4 /samples/99_genre_3d
parent958cf43779d2bf528869e80511c4c4f2a433b2db (diff)
downloaddragonruby-game-toolkit-contrib-33ec37b141e896b47ed642923fd33b0c658ae9fb.tar.gz
dragonruby-game-toolkit-contrib-33ec37b141e896b47ed642923fd33b0c658ae9fb.zip
synced samples
Diffstat (limited to 'samples/99_genre_3d')
-rw-r--r--samples/99_genre_3d/3d_cube/app/main.rb50
-rw-r--r--samples/99_genre_3d/3d_cube/sprites/square-blue.pngbin0 -> 283 bytes
2 files changed, 50 insertions, 0 deletions
diff --git a/samples/99_genre_3d/3d_cube/app/main.rb b/samples/99_genre_3d/3d_cube/app/main.rb
new file mode 100644
index 0000000..fc95291
--- /dev/null
+++ b/samples/99_genre_3d/3d_cube/app/main.rb
@@ -0,0 +1,50 @@
+STARTX = 0.0
+STARTY = 0.0
+ENDY = 20.0
+ENDX = 20.0
+SPINPOINT = 10
+SPINDURATION = 400
+POINTSIZE = 8
+BOXDEPTH = 40
+YAW = 1
+DISTANCE = 10
+
+def tick args
+ args.outputs.background_color = [0, 0, 0]
+ a = Math.sin(args.state.tick_count / SPINDURATION) * Math.tan(args.state.tick_count / SPINDURATION)
+ s = Math.sin(a)
+ c = Math.cos(a)
+ x = STARTX
+ y = STARTY
+ offset_x = (1280 - (ENDX - STARTX)) / 2
+ offset_y = (360 - (ENDY - STARTY)) / 2
+
+ srand(1)
+ while y < ENDY do
+ while x < ENDX do
+ if (y == STARTY ||
+ y == (ENDY / 0.5) * 2 ||
+ y == (ENDY / 0.5) * 2 + 0.5 ||
+ y == ENDY - 0.5 ||
+ x == STARTX ||
+ x == ENDX - 0.5)
+ z = rand(BOXDEPTH)
+ z *= Math.sin(a / 2)
+ x -= SPINPOINT
+ u = (x * c) - (z * s)
+ v = (x * s) + (z * c)
+ k = DISTANCE.fdiv(100) + (v / 500 * YAW)
+ u = u / k
+ v = y / k
+ w = POINTSIZE / 10 / k
+ args.outputs.sprites << { x: offset_x + u - w, y: offset_y + v - w, w: w, h: w, path: 'sprites/square-blue.png'}
+ x += SPINPOINT
+ end
+ x += 0.5
+ end
+ y += 0.5
+ x = STARTX
+ end
+end
+
+$gtk.reset
diff --git a/samples/99_genre_3d/3d_cube/sprites/square-blue.png b/samples/99_genre_3d/3d_cube/sprites/square-blue.png
new file mode 100644
index 0000000..b840849
--- /dev/null
+++ b/samples/99_genre_3d/3d_cube/sprites/square-blue.png
Binary files differ