ライセンス表記とサンプルのアップデート
@@ -16,7 +16,7 @@ | ||
16 | 16 | ・・・砂が降ってくるデモです。マウスでいじってください。 |
17 | 17 | |
18 | 18 | drawtile |
19 | - ・・・Window.drawTileとWindow.setViewportのデモ。マップの2レイヤ描画をしています。 | |
19 | + ・・・Window.drawTileとRenderTargetクラスのデモ。マップの2レイヤ描画をしています。 | |
20 | 20 | |
21 | 21 | flight |
22 | 22 | ・・・空を飛んでるっぽい疑似3D表現のサンプルです。カーソルキーで動きます。 |
@@ -45,3 +45,6 @@ | ||
45 | 45 | dxrubyex_sample2 |
46 | 46 | ・・・同梱のDXRubyExtensionのサンプルその2です。 |
47 | 47 | |
48 | +laser | |
49 | + ・・・DXRubyExtensionを使ってレーザーを実装してみたサンプルです。 | |
50 | + |
@@ -1,4 +1,5 @@ | ||
1 | 1 | # マップデータから背景描画サンプル |
2 | +# RenderTargetクラスの使い方のサンプルになっています。 | |
2 | 3 | require 'dxruby' |
3 | 4 | |
4 | 5 | # マップデータ |
@@ -37,7 +38,7 @@ | ||
37 | 38 | [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] |
38 | 39 | ] |
39 | 40 | |
40 | -# 手前に描画する用のマップデータ(4は木のあたま。nilにすると描画しない) | |
41 | +# 手前に描画する用の上層マップデータ(4は木のあたま。nilにすると描画しない) | |
41 | 42 | map2 = [ |
42 | 43 | [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 4, nil, nil, nil], |
43 | 44 | [nil, 4, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 4, nil, nil, nil, nil, nil], |
@@ -108,10 +109,12 @@ | ||
108 | 109 | # 移動カウント |
109 | 110 | count = 0 |
110 | 111 | |
111 | -# ビューポート設定 | |
112 | -Window.setViewport(32, 32, 640-64, 480-64) | |
112 | +# RenderTarget作成 | |
113 | +rt_main = RenderTarget.new(640-64, 480-64) | |
114 | +rt_sub = RenderTarget.new(640-64, 480-64) | |
113 | 115 | |
114 | 116 | Window.loop do |
117 | + | |
115 | 118 | # 移動中はカウントアップするだけ |
116 | 119 | if state == 1 then |
117 | 120 | count = count + 4 # カウントアップ |
@@ -146,18 +149,25 @@ | ||
146 | 149 | end |
147 | 150 | end |
148 | 151 | |
149 | - # 優先順位を変えて2回描画することで、キャラより手前にマップチップを描画することもできます。 | |
150 | - # ベースマップ描画 | |
151 | - Window.drawTile(32, 32, map1, mapimage, (x - 8.5) * 32 + count * dx, (y - 6) * 32 + count * dy, 18, 13, 0) # 優先順位0 | |
152 | + # ベースマップをrt_mainに描画 | |
153 | + rt_main.drawTile(0, 0, map1, mapimage, (x - 8.5) * 32 + count * dx, (y - 6) * 32 + count * dy, 18, 13) | |
154 | + rt_main.update | |
152 | 155 | |
153 | - # 人より手前に描画するマップ | |
154 | - Window.drawTile(32, 32, map2, mapimage, (x - 8.5) * 32 + count * dx, (y - 6) * 32 + count * dy, 18, 13, 2) # 優先順位2 | |
156 | + # 上層マップをrt_subに描画 | |
157 | + rt_sub.drawTile(0, 0, map2, mapimage, (x - 8.5) * 32 + count * dx, (y - 6) * 32 + count * dy, 18, 13) | |
158 | + rt_sub.update | |
155 | 159 | |
160 | + # ベースマップを画面に描画 | |
161 | + Window.draw(32, 32, rt_main) | |
162 | + | |
156 | 163 | # 人描画 |
157 | - Window.draw(9.5 * 32, 7 * 32 - 16, image, 1) # 人は優先順位をマップの間にしておく | |
164 | + Window.draw(9.5 * 32, 7 * 32 - 16, image) | |
158 | 165 | |
166 | + # 上層マップを画面に描画 | |
167 | + Window.draw(32, 32, rt_sub) | |
168 | + | |
159 | 169 | # エスケープキーで終了 |
160 | 170 | break if Input.keyPush?(K_ESCAPE) |
161 | - Window.drawFont(32,32,Window.fps.to_s + " fps", font, :z=>3) | |
162 | - Window.drawFont(32,64,Window.getLoad.to_i.to_s + " %", font, :z=>3) | |
171 | + Window.drawFont(32,32,Window.fps.to_s + " fps", font) | |
172 | + Window.drawFont(32,64,Window.getLoad.to_i.to_s + " %", font) | |
163 | 173 | end |
@@ -1,21 +1,13 @@ | ||
1 | -The MIT License | |
1 | +The zlib/libpng License | |
2 | +Copyright (c) <2011> <mirichi> | |
2 | 3 | |
3 | -Copyright (c) 2009 mirichi | |
4 | +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. | |
4 | 5 | |
5 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | -of this software and associated documentation files (the "Software"), to deal | |
7 | -in the Software without restriction, including without limitation the rights | |
8 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | -copies of the Software, and to permit persons to whom the Software is | |
10 | -furnished to do so, subject to the following conditions: | |
6 | +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: | |
11 | 7 | |
12 | -The above copyright notice and this permission notice shall be included in | |
13 | -all copies or substantial portions of the Software. | |
8 | +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. | |
14 | 9 | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
21 | -THE SOFTWARE. | |
10 | +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | |
11 | + | |
12 | +3. This notice may not be removed or altered from any source distribution. | |
13 | + |
@@ -1,21 +1,13 @@ | ||
1 | -The MIT License | |
1 | +The zlib/libpng License | |
2 | +Copyright (c) <2011> <mirichi> | |
2 | 3 | |
3 | -Copyright (c) 2009 mirichi | |
4 | +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. | |
4 | 5 | |
5 | -Permission is hereby granted, free of charge, to any person obtaining a copy | |
6 | -of this software and associated documentation files (the "Software"), to deal | |
7 | -in the Software without restriction, including without limitation the rights | |
8 | -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
9 | -copies of the Software, and to permit persons to whom the Software is | |
10 | -furnished to do so, subject to the following conditions: | |
6 | +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: | |
11 | 7 | |
12 | -The above copyright notice and this permission notice shall be included in | |
13 | -all copies or substantial portions of the Software. | |
8 | +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. | |
14 | 9 | |
15 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
18 | -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
19 | -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 | -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
21 | -THE SOFTWARE. | |
10 | +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | |
11 | + | |
12 | +3. This notice may not be removed or altered from any source distribution. | |
13 | + |