dxruby64 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +14 -0
- data/README-ja.md +125 -0
- data/README.md +120 -0
- data/lib/31/dxruby.so +0 -0
- data/lib/32/dxruby.so +0 -0
- data/lib/33/dxruby.so +0 -0
- data/lib/34/dxruby.so +0 -0
- data/lib/dxruby.rb +2 -0
- data/sample/classic_sample/8_puzzle.rb +55 -0
- data/sample/classic_sample/block_destroy.rb +161 -0
- data/sample/classic_sample/block_fall.rb +194 -0
- data/sample/classic_sample/data.png +0 -0
- data/sample/classic_sample/dot.rb +80 -0
- data/sample/classic_sample/drawtile.rb +173 -0
- data/sample/classic_sample/flight.rb +75 -0
- data/sample/classic_sample/hitrangeview.rb +66 -0
- data/sample/classic_sample/mapedit.rb +270 -0
- data/sample/classic_sample/meiro.rb +106 -0
- data/sample/classic_sample/minsample.rb +14 -0
- data/sample/classic_sample/race.rb +119 -0
- data/sample/classic_sample/readme_sample.txt +42 -0
- data/sample/classic_sample/sample.rb +110 -0
- data/sample/classic_sample/soundeffect.rb +46 -0
- data/sample/new_sample/biyo.rb +25 -0
- data/sample/new_sample/image/enemy1.png +0 -0
- data/sample/new_sample/image/enemy1bomb.png +0 -0
- data/sample/new_sample/image/enemy2.png +0 -0
- data/sample/new_sample/image/enemy2bomb.png +0 -0
- data/sample/new_sample/image/enemyshot1.png +0 -0
- data/sample/new_sample/image/enemyshot2.png +0 -0
- data/sample/new_sample/image/maptile.png +0 -0
- data/sample/new_sample/image/myship.png +0 -0
- data/sample/new_sample/image/myshot.png +0 -0
- data/sample/new_sample/iraira.rb +49 -0
- data/sample/new_sample/laser2.rb +292 -0
- data/sample/new_sample/raycast.rb +249 -0
- data/sample/new_sample/readme_sample.txt +27 -0
- data/sample/new_sample/rubima.rb +597 -0
- data/sample/new_sample/ruby.png +0 -0
- data/sample/new_sample/slg.rb +82 -0
- data/sample/new_sample/sprite_animation.rb +133 -0
- data/sample/new_sample/sprite_collision1.rb +216 -0
- data/sample/new_sample/sprite_collision2.rb +93 -0
- data/sample/new_sample/sprite_simple.rb +65 -0
- data/sample/new_sample2/ImageFont.dat +0 -0
- data/sample/new_sample2/ImageFont.dat.png +0 -0
- data/sample/new_sample2/autocall.rb +24 -0
- data/sample/new_sample2/effecttest.rb +136 -0
- data/sample/new_sample2/fibersprite.rb +89 -0
- data/sample/new_sample2/hitrange.rb +133 -0
- data/sample/new_sample2/hlstest.rb +27 -0
- data/sample/new_sample2/mapedit_perlin.rb +291 -0
- data/sample/new_sample2/noise.rb +33 -0
- data/sample/new_sample2/particle.rb +220 -0
- data/sample/new_sample2/readme_sample.txt +29 -0
- data/sample/new_sample2/scenetest.rb +200 -0
- data/sample/new_sample2/scenetest2.rb +120 -0
- data/sample/scroll_sample/map.dat +32 -0
- data/sample/scroll_sample/map.rb +77 -0
- data/sample/scroll_sample/map_sub.dat +32 -0
- data/sample/scroll_sample/mapedit.rb +102 -0
- data/sample/scroll_sample/readme_sample.txt +24 -0
- data/sample/scroll_sample/scroll1.rb +108 -0
- data/sample/scroll_sample/scroll2.rb +149 -0
- data/sample/scroll_sample/scroll3.rb +148 -0
- data/sample/scroll_sample/simple.rb +13 -0
- data/sample/shader_sample/Shader/Flash.rb +93 -0
- data/sample/shader_sample/Shader/RasterScroll.rb +71 -0
- data/sample/shader_sample/Shader/RgssSprite.rb +143 -0
- data/sample/shader_sample/Shader/Transition.rb +108 -0
- data/sample/shader_sample/bgimage/BG00a1_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG10a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG13a_80.jpg +0 -0
- data/sample/shader_sample/bgimage/BG32a.jpg +0 -0
- data/sample/shader_sample/bgimage/BG42a.jpg +0 -0
- data/sample/shader_sample/bgimage/course.png +0 -0
- data/sample/shader_sample/bgimage/image1.png +0 -0
- data/sample/shader_sample/bgimage/world_map2.png +0 -0
- data/sample/shader_sample/fan.rb +53 -0
- data/sample/shader_sample/image/enemy1.png +0 -0
- data/sample/shader_sample/image/enemy2.png +0 -0
- data/sample/shader_sample/image/maptile.png +0 -0
- data/sample/shader_sample/readme_sample.txt +43 -0
- data/sample/shader_sample/rule//343/203/201/343/202/247/343/203/203/343/202/253/343/203/274.png +0 -0
- data/sample/shader_sample/rule//345/217/263/346/270/246/345/267/273/343/201/215.png +0 -0
- data/sample/shader_sample/rule//346/250/252/343/203/226/343/203/251/343/202/244/343/203/263/343/203/211.png +0 -0
- data/sample/shader_sample/sample_blur.rb +112 -0
- data/sample/shader_sample/sample_divide.rb +91 -0
- data/sample/shader_sample/sample_flash.rb +54 -0
- data/sample/shader_sample/sample_lens.rb +65 -0
- data/sample/shader_sample/sample_mapping.rb +50 -0
- data/sample/shader_sample/sample_rasterscroll.rb +48 -0
- data/sample/shader_sample/sample_rgsssprite.rb +41 -0
- data/sample/shader_sample/sample_spehari.rb +50 -0
- data/sample/shader_sample/sample_sphere.rb +66 -0
- data/sample/shader_sample/sample_transition.rb +62 -0
- data/sample/shader_sample/sample_vertexshader.rb +223 -0
- data/sample/shader_sample/sample_wingman.rb +47 -0
- data/sample/shader_sample/turn_transition.rb +74 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09456faf82b816e3acb5ab3134ac5062e9453e3f821c9f83835357ae334af644'
|
4
|
+
data.tar.gz: 18f08cc9f7139915b9f334e1ad12a44fef3f4db94b82c773dfe0d458cf123091
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c8a65bd3b7a8f3f7c6aca47b8098e897877614dee52ffeb76ec06e6c23522c7e8ad32fc950015097d61a1f5bedd02aec854f09e4ba975212ceea99143870712
|
7
|
+
data.tar.gz: af52610d33f31cdf2846dcffcff4e3b4e62e64fdefd66ff52a2c481cccddb14339ebdd34faeedd50f8d11d082bd42cf6764612f76699f52b1d34a6ceebb147b7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
The zlib/libpng License
|
2
|
+
Copyright (c) 2012 DXRuby Developers
|
3
|
+
Copyright (c) 2025 DXRuby64 Developers
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
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:
|
8
|
+
|
9
|
+
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.
|
10
|
+
|
11
|
+
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
12
|
+
|
13
|
+
3. This notice may not be removed or altered from any source distribution.
|
14
|
+
|
data/README-ja.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# DXRuby64
|
2
|
+
|
3
|
+
**DXRuby64** は 64ビット版の Ruby 3.1以降用にカスタムビルドされた **DXRuby** で、Universal C Runtime(UCRT)でビルドできるように[本家DXRuby](https://github.com/mirichi/dxruby)のソースにパッチを当てたものです。DXRuby64により、64ビット版の Rubyでも DirectX9をベースにした 2Dゲームを開発できるようになります。
|
4
|
+
|
5
|
+
**注意:** この gem は個人によって作成された非公式バージョンであり、オリジナルの DXRubyプロジェクトではメンテナンスされていません。
|
6
|
+
|
7
|
+
[English README here](README.md)
|
8
|
+
|
9
|
+
## インストール
|
10
|
+
|
11
|
+
gem をインストールするには、以下のコマンドを実行してください。
|
12
|
+
|
13
|
+
```bash
|
14
|
+
gem install dxruby64
|
15
|
+
```
|
16
|
+
|
17
|
+
## 使用方法
|
18
|
+
インストール後、従来どおり DXRubyの機能を使うことができます。
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'dxruby'
|
22
|
+
|
23
|
+
# 例:ウィンドウを作成し、単純な図形を表示
|
24
|
+
Window.width = 640
|
25
|
+
Window.height = 480
|
26
|
+
|
27
|
+
# 四角形を描画
|
28
|
+
Window.loop do
|
29
|
+
Window.draw(100, 100, Image.new(50, 50, C_WHITE))
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
#### 【サンプルファイルについて】
|
34
|
+
この gem には sample/ ディレクトリ内に簡単なサンプルコードが含まれています。
|
35
|
+
(本家 DXRubyで提供されていたものをそのまま転載)
|
36
|
+
|
37
|
+
gem のインストール先は Ruby の環境によって異なりますが、以下のコマンドでその場所を確認することができます。
|
38
|
+
|
39
|
+
```
|
40
|
+
gem contents dxruby64
|
41
|
+
```
|
42
|
+
|
43
|
+
## 必要条件
|
44
|
+
- **Ruby 3.1 以降 (64ビット版)** が Windows にインストールされていること。
|
45
|
+
|
46
|
+
- `d3dx9_40.dll` が必要です。これは DirectX 9 ランタイムの一部です。もしインストールされていない場合は、[Microsoft の公式サイト](https://www.microsoft.com/en-us/download/details.aspx?id=8109)からダウンロードできます。
|
47
|
+
|
48
|
+
#### 【`d3dx9_40.dll` の入手方法】
|
49
|
+
|
50
|
+
1. [DirectX End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109) をダウンロードします。
|
51
|
+
|
52
|
+
2. ダウンロードした `directx_Jun2010_redist.exe` をダブルクリックして、任意のディレクトリにファイルを展開します。
|
53
|
+
|
54
|
+
3. 展開したフォルダの中から `Nov2008_d3dx9_40_x64.cab` を探し、ダブルクリックします。
|
55
|
+
|
56
|
+
4. `Nov2008_d3dx9_40_x64.cab` の中にある `d3dx9_40.dll` を見つけ、Ruby のインストールフォルダ内の `bin` フォルダにコピー(または移動)します。(例:C:\Ruby34-x64\bin)
|
57
|
+
|
58
|
+
## ライセンス
|
59
|
+
この gem は zlib/libpngライセンスの下で提供されています。
|
60
|
+
|
61
|
+
## 免責事項
|
62
|
+
この gem は DXRubyの公式な後継ではなく、元の DXRubyプロジェクトによってメンテナンスされていません。これは、新しいバージョンの Ruby用に UCRT環境で動作することを目的としたカスタムビルドです。
|
63
|
+
|
64
|
+
## リポジトリ
|
65
|
+
ソースコードや詳細情報は、以下のリポジトリで確認できます。
|
66
|
+
https://github.com/spoolkitamura/dxruby64
|
67
|
+
|
68
|
+
<br>
|
69
|
+
<br>
|
70
|
+
<br>
|
71
|
+
|
72
|
+
## 開発者向けガイド
|
73
|
+
|
74
|
+
### `dxruby.so` のビルド手順
|
75
|
+
|
76
|
+
gemではビルド済みの .soファイルが提供されますが、開発者がソースから直接ビルドしたい場合は、以下の手順を参考にしてください。
|
77
|
+
|
78
|
+
#### 前提条件
|
79
|
+
|
80
|
+
- Ruby 3.1 以降 (64ビット版) がインストールされていること。
|
81
|
+
|
82
|
+
- `MSYS2` などの開発環境が用意されていること。
|
83
|
+
(Devkit付きの RubyInstallerを推奨)
|
84
|
+
|
85
|
+
#### 手順
|
86
|
+
|
87
|
+
1. リポジトリをクローンします。
|
88
|
+
|
89
|
+
```
|
90
|
+
git clone https://github.com/spoolkitamura/dxruby64.git
|
91
|
+
cd dxruby64
|
92
|
+
```
|
93
|
+
|
94
|
+
2. ext/dxruby64 フォルダに移動して、以下のコマンドで dxruby.so をビルドします。
|
95
|
+
|
96
|
+
```
|
97
|
+
cd ext/dxruby64
|
98
|
+
ridk enable
|
99
|
+
ruby extconf.rb # Makefileを生成
|
100
|
+
make clean
|
101
|
+
make # dxruby.soを生成
|
102
|
+
```
|
103
|
+
|
104
|
+
ビルドされた dxruby.so ファイルは、`make install` を実行することによって Rubyの拡張ライブラリ用ディレクトリ(例: C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/x64-ucrt/)にインストールされます。
|
105
|
+
なお、このディレクトリの場所は、`RbConfig::CONFIG["sitearchdir"]` で確認することができます。
|
106
|
+
|
107
|
+
### 備考
|
108
|
+
|
109
|
+
- 本家 DXRubyのソースは ext/orgに置かれています。
|
110
|
+
|
111
|
+
- この gemでは、Rubyの各バージョンごとにビルドした dxruby.soを以下のディレクトリ構成で配置しています。
|
112
|
+
|
113
|
+
```
|
114
|
+
lib/
|
115
|
+
dxruby.rb ← バージョン振り分け処理
|
116
|
+
31/
|
117
|
+
dxruby.so ← Ruby 3.1用
|
118
|
+
32/
|
119
|
+
dxruby.so ← Ruby 3.2用
|
120
|
+
33/
|
121
|
+
dxruby.so ← Ruby 3.3用
|
122
|
+
34/
|
123
|
+
dxruby.so ← Ruby 3.4用
|
124
|
+
```
|
125
|
+
|
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# DXRuby64
|
2
|
+
|
3
|
+
**DXRuby64** is a custom-built version of DXRuby for 64-bit Ruby 3.1 and later, created by patching the original DXRuby source to allow building with the Universal C Runtime (UCRT). With DXRuby64, you can develop 2D games using DirectX 9 even on 64-bit Ruby environments.
|
4
|
+
|
5
|
+
**Note:** This gem is an unofficial version created by an individual and is not maintained by the original DXRuby project.
|
6
|
+
|
7
|
+
[日本語の README はこちら](README-ja.md)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
To install the gem, simply run:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
gem install dxruby64
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
Once installed, you can use DXRuby features as usual:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'dxruby'
|
22
|
+
|
23
|
+
# Example code: Create a window and display a simple shape
|
24
|
+
Window.width = 640
|
25
|
+
Window.height = 480
|
26
|
+
|
27
|
+
# Draw a rectangle
|
28
|
+
Window.loop do
|
29
|
+
Window.draw(100, 100, Image.new(50, 50, C_WHITE))
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
#### About Sample Files
|
34
|
+
This gem includes simple sample code under the `sample/` directory.
|
35
|
+
(The files are direct copies of the original examples provided with DXRuby)
|
36
|
+
|
37
|
+
The gem installation path may vary depending on your Ruby environment, but you can check the location with the following command:
|
38
|
+
|
39
|
+
```
|
40
|
+
gem contents dxruby64
|
41
|
+
```
|
42
|
+
|
43
|
+
## Requirements
|
44
|
+
- **Ruby 3.1 or later (64-bit)** installed on Windows.
|
45
|
+
|
46
|
+
- `d3dx9_40.dll` is required. This is part of the DirectX 9 runtime. If it's not already installed, you can download it from [Microsoft's official site](https://www.microsoft.com/en-us/download/details.aspx?id=8109).
|
47
|
+
|
48
|
+
#### How to get `d3dx9_40.dll`
|
49
|
+
|
50
|
+
1. Download the [DirectX End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109).
|
51
|
+
|
52
|
+
2. Double-click the downloaded `directx_Jun2010_redist.exe` and extract the files to a directory of your choice.
|
53
|
+
|
54
|
+
3. In the extracted folder, locate `Nov2008_d3dx9_40_x64.cab` and double-click it.
|
55
|
+
|
56
|
+
4. Inside the `Nov2008_d3dx9_40_x64.cab` file, locate `d3dx9_40.dll` and copy (or move) it to the `bin` directory of your Ruby installation folder. (e.g. C:\Ruby34-x64\bin)
|
57
|
+
|
58
|
+
## License
|
59
|
+
This gem is licensed under the zlib/libpng license.
|
60
|
+
|
61
|
+
## Disclaimer
|
62
|
+
This gem is not an official successor of DXRuby, and it is not maintained by the original DXRuby project. It is a custom build intended to work in UCRT environments for newer versions of Ruby.
|
63
|
+
|
64
|
+
## Repository
|
65
|
+
For source code and further information, visit the repository:
|
66
|
+
https://github.com/spoolkitamura/dxruby64
|
67
|
+
|
68
|
+
<br>
|
69
|
+
<br>
|
70
|
+
<br>
|
71
|
+
|
72
|
+
## Developer Guide
|
73
|
+
### Building dxruby.so from Source
|
74
|
+
Although the gem includes precompiled .so files, developers who wish to build dxruby.so from source may refer to the steps below as a guide.
|
75
|
+
|
76
|
+
#### Prerequisites
|
77
|
+
- Ruby 3.1 or later (64-bit) must be installed.
|
78
|
+
|
79
|
+
- A development environment such as MSYS2 is required.
|
80
|
+
(RubyInstaller with Devkit is recommended)
|
81
|
+
|
82
|
+
#### Build Steps
|
83
|
+
Clone the repository:
|
84
|
+
|
85
|
+
```
|
86
|
+
git clone https://github.com/spoolkitamura/dxruby64.git
|
87
|
+
cd dxruby64
|
88
|
+
```
|
89
|
+
|
90
|
+
Move into the ext/dxruby64 folder and run the following commands to build dxruby.so:
|
91
|
+
|
92
|
+
```
|
93
|
+
cd ext/dxruby64
|
94
|
+
ridk enable
|
95
|
+
ruby extconf.rb # Generate Makefile
|
96
|
+
make clean
|
97
|
+
make # Build dxruby.so
|
98
|
+
```
|
99
|
+
|
100
|
+
The built dxruby.so file will be installed into Ruby's extension library directory (e.g., C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/x64-ucrt/) by executing `make install`.
|
101
|
+
You can check the exact path using `RbConfig::CONFIG["sitearchdir"]`.
|
102
|
+
|
103
|
+
### Notes
|
104
|
+
- The original DXRuby source code is located in ext/org.
|
105
|
+
|
106
|
+
- In this gem, prebuilt dxruby.so files for each supported Ruby version are organized in the following directory structure:
|
107
|
+
|
108
|
+
```
|
109
|
+
lib/
|
110
|
+
dxruby.rb - Dynamically loads the appropriate version-specific dxruby.so
|
111
|
+
31/
|
112
|
+
dxruby.so - For Ruby 3.1
|
113
|
+
32/
|
114
|
+
dxruby.so - For Ruby 3.2
|
115
|
+
33/
|
116
|
+
dxruby.so - For Ruby 3.3
|
117
|
+
34/
|
118
|
+
dxruby.so - For Ruby 3.4
|
119
|
+
```
|
120
|
+
|
data/lib/31/dxruby.so
ADDED
Binary file
|
data/lib/32/dxruby.so
ADDED
Binary file
|
data/lib/33/dxruby.so
ADDED
Binary file
|
data/lib/34/dxruby.so
ADDED
Binary file
|
data/lib/dxruby.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
# DXRuby �T���v�� �W�p�Y��
|
3
|
+
# ���N���b�N�Ńs�[�X���ړ��A�E�N���b�N�ŃV���b�t��
|
4
|
+
# �g�p�\�ȉ摜��jpg�Apng�Abmp�Ȃǒʏ�̃t�H�[�}�b�g�ł��B
|
5
|
+
require 'dxruby'
|
6
|
+
|
7
|
+
filename = Window.openFilename([["�����̧��(*.*)", "*.*"]], "�p�Y���p�̉摜��I��")
|
8
|
+
image = Image.loadToArray(filename, 3, 3)
|
9
|
+
|
10
|
+
# ���ݒ�
|
11
|
+
width = image[0].width
|
12
|
+
height = image[0].height
|
13
|
+
if width < 32 then
|
14
|
+
Window.scale = 48.0 / width
|
15
|
+
end
|
16
|
+
Window.width = image[0].width * 3
|
17
|
+
Window.height = image[0].height * 3
|
18
|
+
Window.caption = "�W�p�Y��"
|
19
|
+
|
20
|
+
# �p�Y���̏��
|
21
|
+
piece = [0,1,2,3,4,5,6,7,8]
|
22
|
+
|
23
|
+
# �N���b�N���̏����B�Ă�ʒu�̂ƂȂ肾���������ւ���B
|
24
|
+
def click(x, y, piece)
|
25
|
+
i = piece.index(8) # ��s�[�X����
|
26
|
+
if (((i % 3) - x).abs == 1 and (i / 3) == y) or (((i / 3) - y).abs == 1 and (i % 3) == x) then
|
27
|
+
piece[x + y * 3], piece[i] = piece[i], piece[x + y * 3] # ����ւ� a,b = b,a��swap�ł���
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# ���C�����[�v
|
32
|
+
Window.loop do
|
33
|
+
|
34
|
+
# �E�N���b�N�ŃV���b�t���i�����_����1000��قǃN���b�N���Ă�����Ă܂�^^;)
|
35
|
+
if Input.mousePush?(M_RBUTTON) then
|
36
|
+
1000.times do
|
37
|
+
click(rand(3), rand(3), piece)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# ���N���b�N����
|
42
|
+
if Input.mousePush?(M_LBUTTON) then
|
43
|
+
click((Input.mousePosX / Window.scale / image[0].width).to_i, (Input.mousePosY / Window.scale / image[0].height).to_i, piece)
|
44
|
+
end
|
45
|
+
|
46
|
+
# ��������ƕ`��
|
47
|
+
for i in 0..8
|
48
|
+
if piece[i] != 8 or piece == [0,1,2,3,4,5,6,7,8] then
|
49
|
+
Window.draw(i % 3 * image[0].width , i / 3 * image[0].height, image[piece[i]])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# �G�X�P�[�v�L�[�ŏI��
|
54
|
+
break if Input.keyPush?(K_ESCAPE)
|
55
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
# DXRuby �T���v�� �u���b�N�������h�L
|
3
|
+
# ���N���b�N�Ń{�[������т܂��B��̓}�E�X�őł��Ԃ��āB
|
4
|
+
require 'dxruby'
|
5
|
+
|
6
|
+
Window.caption = "�u���b�N�������h�L"
|
7
|
+
|
8
|
+
# �u���b�N�̍\����
|
9
|
+
Block = Struct.new(:x, :y, :image)
|
10
|
+
|
11
|
+
# ���f�[�^�쐬
|
12
|
+
v = 80 # �{�����[��
|
13
|
+
s1 = SoundEffect.new(50) do # 50mSec�̌��ʉ��B�u���b�N����1ms�̕ω�
|
14
|
+
v = v - 4 if v > 0 # �{�����[���_�E��
|
15
|
+
[220, v] # �u���b�N�̖߂�̔z���g���ƃ{�����[��
|
16
|
+
end
|
17
|
+
v = 80
|
18
|
+
s2 = SoundEffect.new(50) do
|
19
|
+
v = v - 4 if v > 0
|
20
|
+
[440, v]
|
21
|
+
end
|
22
|
+
v = 80
|
23
|
+
s3 = SoundEffect.new(50) do
|
24
|
+
v = v - 4 if v > 0
|
25
|
+
[880, v]
|
26
|
+
end
|
27
|
+
|
28
|
+
# �摜�f�[�^�쐬�B
|
29
|
+
# �p�b�h�̉摜
|
30
|
+
padimage = Image.new(100, 20)
|
31
|
+
padimage.boxFill(0, 0, 99, 19, [255, 255, 255])
|
32
|
+
|
33
|
+
# �u���b�N�̉摜�B��������Y��ɂ��悤�Ǝv�����炸���Ԃ��������
|
34
|
+
blockimage = [Image.new(60, 20, [255, 0, 0]),
|
35
|
+
Image.new(60, 20, [255, 255, 0]),
|
36
|
+
Image.new(60, 20, [0, 255, 0])]
|
37
|
+
blockimage[0].line(0, 0, 59, 0, [255, 150, 150])
|
38
|
+
blockimage[0].line(0, 0, 0, 19, [255, 150, 150])
|
39
|
+
blockimage[0].line(0, 19, 59, 19, [120, 0, 0])
|
40
|
+
blockimage[0].line(59, 0, 59, 19, [120, 0, 0])
|
41
|
+
blockimage[1].line(0, 0, 59, 0, [255, 255, 150])
|
42
|
+
blockimage[1].line(0, 0, 0, 19, [255, 255, 150])
|
43
|
+
blockimage[1].line(0, 19, 59, 19, [150, 150, 0])
|
44
|
+
blockimage[1].line(59, 0, 59, 19, [150, 150, 0])
|
45
|
+
blockimage[2].line(0, 0, 59, 0, [150, 255, 120])
|
46
|
+
blockimage[2].line(0, 0, 0, 19, [150, 255, 120])
|
47
|
+
blockimage[2].line(0, 19, 59, 19, [0, 150, 0])
|
48
|
+
blockimage[2].line(59, 0, 59, 19, [0, 150, 0])
|
49
|
+
|
50
|
+
# �e�̉摜
|
51
|
+
ballimage = Image.new(24, 24)
|
52
|
+
ballimage.circleFill(12, 12, 11, [255, 255, 255])
|
53
|
+
|
54
|
+
# �ʂ̏��
|
55
|
+
tx = 0
|
56
|
+
ty = 416
|
57
|
+
dtx = 0
|
58
|
+
dty = 0
|
59
|
+
|
60
|
+
# 0�͏������A1�͋ʂ����łȂ��B2�͔��ł�B
|
61
|
+
state = 0
|
62
|
+
|
63
|
+
block = []
|
64
|
+
|
65
|
+
# ���C�����[�v
|
66
|
+
Window.loop do
|
67
|
+
x = Input.mousePosX - 50
|
68
|
+
x = 0 if x < 0
|
69
|
+
x = 540 if x > 540
|
70
|
+
y = Input.mousePosY - 10
|
71
|
+
y = 220 if y < 220
|
72
|
+
y = 460 if y > 460
|
73
|
+
|
74
|
+
case state
|
75
|
+
when 0
|
76
|
+
# �u���b�N�z����
|
77
|
+
block.clear
|
78
|
+
# �u���b�N����
|
79
|
+
for i in 0..9
|
80
|
+
for j in 0..5
|
81
|
+
block.push(Block.new(i * 64 + 2, j * 24 + 50, blockimage[j / 2]))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
state = 1
|
85
|
+
|
86
|
+
when 1
|
87
|
+
# ���łȂ��Ƃ��̓p�b�h�ɂ������Ă���
|
88
|
+
if Input.mousePush?(M_LBUTTON) then # �}�E�X�̍��N���b�N�Ŕ��
|
89
|
+
state = 2
|
90
|
+
dtx = rand(2) * 16 - 8
|
91
|
+
dty = -8
|
92
|
+
else # �������Ă�Ƃ�
|
93
|
+
tx = x + 38
|
94
|
+
ty = y - 24
|
95
|
+
end
|
96
|
+
|
97
|
+
when 2
|
98
|
+
# �Q�[�����C������
|
99
|
+
# �u���b�N�Ƃ̔���
|
100
|
+
block.delete_if do |b|
|
101
|
+
flag = false
|
102
|
+
# ���Ƀu���b�N���������牡�ɂ͂˂�����
|
103
|
+
if tx + dtx + 24 > b.x and tx + dtx < b.x + 60 and
|
104
|
+
ty + 24 > b.y and ty < b.y + 20 then
|
105
|
+
dtx = -dtx
|
106
|
+
s3.play
|
107
|
+
# �i�i���ɂ������ꍇ�͏c�ɂ��͂˂�����
|
108
|
+
if tx + 24 > b.x and tx < b.x + 60 and
|
109
|
+
ty + dty + 24 > b.y and ty + dty < b.y + 20 then
|
110
|
+
dty = -dty
|
111
|
+
end
|
112
|
+
flag = true
|
113
|
+
|
114
|
+
# �c�Ƀu���b�N����������c�ɂ͂˂�����
|
115
|
+
elsif tx + 24 > b.x and tx < b.x + 60 and
|
116
|
+
ty + dty + 24 > b.y and ty + dty < b.y + 20 then
|
117
|
+
dty = -dty
|
118
|
+
s3.play
|
119
|
+
flag = true
|
120
|
+
end
|
121
|
+
flag
|
122
|
+
end
|
123
|
+
# �ړ�
|
124
|
+
tx = tx + dtx
|
125
|
+
ty = ty + dty
|
126
|
+
# �p�b�h�Ƃ̔���
|
127
|
+
if tx + 24 > x and tx < x + 100 and ty + 24 > y and ty < y + 20 and dty > 0 then
|
128
|
+
dty = -8
|
129
|
+
if tx < x + 38 - dtx * 2 then
|
130
|
+
dtx = -8
|
131
|
+
else
|
132
|
+
dtx = 8
|
133
|
+
end
|
134
|
+
s1.play
|
135
|
+
end
|
136
|
+
# ��ʊO�̔���
|
137
|
+
if tx > 607 then
|
138
|
+
dtx = -8
|
139
|
+
s2.play
|
140
|
+
end
|
141
|
+
if tx < 8 then
|
142
|
+
dtx = 8
|
143
|
+
s2.play
|
144
|
+
end
|
145
|
+
if ty <= 0 then
|
146
|
+
dty = 8
|
147
|
+
s2.play
|
148
|
+
end
|
149
|
+
state = 1 if ty > 479 # �{�[����������
|
150
|
+
state = 0 if block.size == 0 # �u���b�N���S��������
|
151
|
+
end
|
152
|
+
|
153
|
+
# �摜�`��
|
154
|
+
Window.draw(x, y, padimage)
|
155
|
+
Window.draw(tx, ty, ballimage)
|
156
|
+
block.each do |b|
|
157
|
+
Window.draw(b.x, b.y, b.image)
|
158
|
+
end
|
159
|
+
|
160
|
+
break if Input.keyDown?(K_ESCAPE)
|
161
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
#!ruby -Ks
|
2
|
+
# DXRuby �T���v�� �u���b�N���Ƃ�
|
3
|
+
# SPACE�ŊJ�n�A���E�ňړ��AZorX�ʼn�]�A���ŗ��Ƃ��B
|
4
|
+
require 'dxruby'
|
5
|
+
|
6
|
+
Window.caption = "�u���b�N���Ƃ����h�L"
|
7
|
+
|
8
|
+
# �u���b�N�f�[�^
|
9
|
+
blank = [0, 0, 0, 0]
|
10
|
+
BLOCK = [[],#�_�~�[
|
11
|
+
[blank,
|
12
|
+
[0, 1, 1, 0],# O
|
13
|
+
[0, 1, 1, 0],
|
14
|
+
blank],
|
15
|
+
[blank,
|
16
|
+
[2, 2, 2, 2],# I
|
17
|
+
[0, 0, 0, 0],
|
18
|
+
blank],
|
19
|
+
[blank,
|
20
|
+
[0, 0, 3, 3],# S
|
21
|
+
[0, 3, 3, 0],
|
22
|
+
blank],
|
23
|
+
[blank,
|
24
|
+
[0, 4, 4, 0],# Z
|
25
|
+
[0, 0, 4, 4],
|
26
|
+
blank],
|
27
|
+
[blank,
|
28
|
+
[0, 5, 5, 5],# L
|
29
|
+
[0, 5, 0, 0],
|
30
|
+
blank],
|
31
|
+
[blank,
|
32
|
+
[0, 6, 6, 6],# J
|
33
|
+
[0, 0, 0, 6],
|
34
|
+
blank],
|
35
|
+
[blank,
|
36
|
+
[0, 7, 7, 7],# T
|
37
|
+
[0, 0, 7, 0],
|
38
|
+
blank]
|
39
|
+
]
|
40
|
+
|
41
|
+
# �摜�f�[�^�̍쐬
|
42
|
+
blockimage = [[]]
|
43
|
+
(1..7). each do |i| # �u���b�N�̊G
|
44
|
+
# �u���b�N�̎�ނ������̂Ōv�Z�ŐF������Ă݂�
|
45
|
+
# ����Ȃ��Ƃ�����摜�t�@�C������ǂނق����I�X�X�����܂�
|
46
|
+
data = Image.new(16, 16, [(i / 4)*220, ((i % 4) / 2)*220, (i % 2)*220])
|
47
|
+
data.line(0, 0, 14, 0, [(i / 4)*128+127, ((i % 4) / 2)*128+127, (i % 2)*128+127])
|
48
|
+
data.line(0, 0, 0, 14, [(i / 4)*128+127, ((i % 4) / 2)*128+127, (i % 2)*128+127])
|
49
|
+
data.line(15, 1, 15, 15, [(i / 4)*128, ((i % 4) / 2)*128, (i % 2)*128])
|
50
|
+
data.line(1, 15, 15, 15, [(i / 4)*128, ((i % 4) / 2)*128, (i % 2)*128])
|
51
|
+
blockimage.push(data)
|
52
|
+
end
|
53
|
+
|
54
|
+
blockimage.push(Image.new(16, 16, [100,100,100])) # �ǂ̊G
|
55
|
+
|
56
|
+
# �t�B�[���h�f�[�^
|
57
|
+
$field = Array.new(20){[8] + [0]*10 + [8]*2}.push([8]*13).push([8]*13)
|
58
|
+
|
59
|
+
# 4*4�̔z����w������E��]
|
60
|
+
def rotation(kind, angle)
|
61
|
+
b = BLOCK[kind]
|
62
|
+
angle = angle + 4 if angle < 0 # angle��-1�ɂȂ邱�Ƃ�����
|
63
|
+
angle.times do
|
64
|
+
a = [[], [], [], []]
|
65
|
+
for y in 0..3 do
|
66
|
+
for x in 0..3 do
|
67
|
+
a[x].push(b[3 - y][x])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
b = a
|
71
|
+
end
|
72
|
+
return b
|
73
|
+
end
|
74
|
+
|
75
|
+
# �����蔻��
|
76
|
+
def check(b, x, y)
|
77
|
+
for i in 0..3 do
|
78
|
+
for j in 0..3 do
|
79
|
+
if b[i][j] != 0 and $field[(y+15) / 16 + i][x / 16 + j] != 0 then
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
87
|
+
x = 0
|
88
|
+
y = 0
|
89
|
+
kind = 0
|
90
|
+
angle = 0
|
91
|
+
state = 2
|
92
|
+
|
93
|
+
# �L�[�̃I�[�g���s�[�g�ݒ�
|
94
|
+
Input.setRepeat(10,2)
|
95
|
+
|
96
|
+
# �E�B���h�E�T�C�Y�ݒ�
|
97
|
+
Window.width = 192
|
98
|
+
Window.height = 336
|
99
|
+
|
100
|
+
# �t�H���g�쐬
|
101
|
+
font = Font.new(16)
|
102
|
+
fontback = Image.new(192, 32, [100,100,100])
|
103
|
+
|
104
|
+
# ���C�����[�v
|
105
|
+
Window.loop do
|
106
|
+
case state
|
107
|
+
when 0 # ������
|
108
|
+
x = 64 # ��
|
109
|
+
y = 0 # �c
|
110
|
+
kind = rand(7)+1 # �u���b�N�̎��
|
111
|
+
angle = 0 # �p�x
|
112
|
+
$field = Array.new(20){[8] + [0]*10 + [8]*2}.push([8]*13).push([8]*13)
|
113
|
+
state = 1
|
114
|
+
|
115
|
+
when 1
|
116
|
+
# ��]����
|
117
|
+
if Input.padPush?(P_BUTTON0) and check(rotation(kind, angle-1), x, y) == false then
|
118
|
+
if angle == 0 then
|
119
|
+
angle = 3
|
120
|
+
else
|
121
|
+
angle = angle - 1
|
122
|
+
end
|
123
|
+
end
|
124
|
+
if Input.padPush?(P_BUTTON1) and check(rotation(kind, angle+1), x, y) == false then
|
125
|
+
if angle == 3 then
|
126
|
+
angle = 0
|
127
|
+
else
|
128
|
+
angle = angle + 1
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
b = rotation(kind, angle) # ��]�����f�[�^���쐬
|
133
|
+
|
134
|
+
# �u���b�N�̈ړ�
|
135
|
+
x = x - 16 if Input.padPush?(P_LEFT) and check(b, x-16, y) == false
|
136
|
+
x = x + 16 if Input.padPush?(P_RIGHT) and check(b, x+16, y) == false
|
137
|
+
y = y + 1
|
138
|
+
y = y + 3 if Input.padDown?(P_DOWN)
|
139
|
+
|
140
|
+
# �����蔻��
|
141
|
+
if check(b, x, y) == true then # ������������
|
142
|
+
for i in 0..3 do
|
143
|
+
for j in 0..3 do # �t�B�[���h�z��ɐݒ�
|
144
|
+
$field[(y+15) / 16 + i - 1][x / 16 + j] += b[i][j]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
for i in 0..19 do # �������s���폜&��ɋ�s�lj�
|
149
|
+
if $field[i].index(0) == nil then
|
150
|
+
$field.delete_at(i)
|
151
|
+
$field.unshift([-1] + [0]*10 + [-1]*2)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# �ʒu�̏�����
|
156
|
+
x = 64
|
157
|
+
y = 0
|
158
|
+
kind = rand(7)+1
|
159
|
+
angle = 0
|
160
|
+
|
161
|
+
# �Q�[���I�[�o�[����
|
162
|
+
b = BLOCK[kind]
|
163
|
+
if check(b, x, y) == true then
|
164
|
+
state = 2
|
165
|
+
for i in 0..3 do
|
166
|
+
for j in 0..3 do # �t�B�[���h�z��ɐݒ�
|
167
|
+
$field[(y+15) / 16 + i][x / 16 + j] = b[i][j] if b[i][j] != 0
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
else # �������Ă��Ȃ�������
|
172
|
+
# �摜�`��
|
173
|
+
for i in 0..3 do
|
174
|
+
for j in 0..3 do
|
175
|
+
Window.draw(j * 16 + x, i * 16 + y, blockimage[kind]) if b[i][j] != 0
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
when 2 # �X�y�[�X���͑҂�
|
181
|
+
Window.draw(0, 92, fontback, 9)
|
182
|
+
Window.drawFont(64, 100, "push space", font, :color=>[255,255,255,255],:z=>10)
|
183
|
+
state = 0 if Input.keyPush?(K_SPACE)
|
184
|
+
end
|
185
|
+
|
186
|
+
# �t�B�[���h�`��
|
187
|
+
for i in 0..20 do
|
188
|
+
for j in 0..11 do
|
189
|
+
Window.draw(j * 16, i * 16, blockimage[$field[i][j]]) if $field[i][j] != 0
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
break if Input.keyDown?(K_ESCAPE)
|
194
|
+
end
|
Binary file
|