DXRuby0.0.4
@@ -73,8 +73,13 @@ | ||
73 | 73 | LPDIRECTINPUTDEVICE8 g_pDIDKeyBoard = NULL; /* DirectInputのキーボードデバイス */ |
74 | 74 | LPDIRECTINPUTDEVICE8 g_pDIDJoyPad[PADMAX]; /* DirectInputのパッドデバイス */ |
75 | 75 | BYTE g_diKeyState[256]; /* DirectInputでのキーボード入力用バッファ */ |
76 | +BYTE g_diKeyStateOld[256]; /* DirectInputでのキーボード入力用バッファ1フレーム前 */ | |
76 | 77 | int g_JoystickCount = 0; |
78 | +BYTE g_byMouseState_L, g_byMouseStateOld_L; | |
79 | +BYTE g_byMouseState_M, g_byMouseStateOld_M; | |
80 | +BYTE g_byMouseState_R, g_byMouseStateOld_R; | |
77 | 81 | |
82 | + | |
78 | 83 | IDirectMusicPerformance8 *g_pDMPerformance = NULL; /* DirectMusicPerformance8インターフェイス */ |
79 | 84 | IDirectMusicLoader8 *g_pDMLoader = NULL; /* ローダー */ |
80 | 85 | IDirectMusicAudioPath8 *g_pDMDefAudioPathBGM = NULL; /* デフォルト・オーディオパス BGM用 */ |
@@ -102,6 +107,7 @@ | ||
102 | 107 | int RefreshRate; /* リフレッシュレート */ |
103 | 108 | int enablemouse; /* マウスを表示するかどうか */ |
104 | 109 | int mousewheelpos; /* マウスホイールの位置 */ |
110 | + int fps; /* fps */ | |
105 | 111 | } g_WindowInfo; |
106 | 112 | |
107 | 113 | /* リンクリスト構造体 */ |
@@ -176,7 +182,7 @@ | ||
176 | 182 | struct DXRubyPadState { |
177 | 183 | char button[20]; |
178 | 184 | int PadConfig[20]; |
179 | -} g_PadState[PADMAX]; | |
185 | +} g_PadState[PADMAX], g_PadStateOld[PADMAX]; | |
180 | 186 | |
181 | 187 | |
182 | 188 | /* プロトタイプ宣言 */ |
@@ -368,7 +374,7 @@ | ||
368 | 374 | /* 描画 */ |
369 | 375 | Window_update(); |
370 | 376 | /* fps調整 */ |
371 | - Window_sync( 60 ); | |
377 | + Window_sync( g_WindowInfo.fps ); | |
372 | 378 | } |
373 | 379 | } |
374 | 380 |
@@ -1097,6 +1103,17 @@ | ||
1097 | 1103 | |
1098 | 1104 | |
1099 | 1105 | /*-------------------------------------------------------------------- |
1106 | + fps値を設定する | |
1107 | + ---------------------------------------------------------------------*/ | |
1108 | +static VALUE Window_setfps( VALUE obj, VALUE fps ) | |
1109 | +{ | |
1110 | + g_WindowInfo.fps = FIX2INT(fps); | |
1111 | + | |
1112 | + return fps; | |
1113 | +} | |
1114 | + | |
1115 | + | |
1116 | +/*-------------------------------------------------------------------- | |
1100 | 1117 | 終了時に実行する |
1101 | 1118 | ---------------------------------------------------------------------*/ |
1102 | 1119 | static VALUE Window_shutdown( VALUE obj ) |
@@ -1331,13 +1348,64 @@ | ||
1331 | 1348 | /*-------------------------------------------------------------------- |
1332 | 1349 | ImgaeクラスのInitialize |
1333 | 1350 | ---------------------------------------------------------------------*/ |
1334 | -static VALUE Image_initialize( int argc, VALUE *argv, VALUE obj ) | |
1351 | +static VALUE Image_initialize( VALUE obj, VALUE width, VALUE height ) | |
1335 | 1352 | { |
1336 | 1353 | struct DXRubyImage *image; |
1337 | 1354 | struct DXRubyTexture *texture; |
1355 | + HRESULT hr; | |
1356 | + | |
1357 | + /* デバイスオブジェクトの初期化チェック */ | |
1358 | + if( g_pD3DDevice == NULL ) | |
1359 | + { | |
1360 | + rb_raise( eDXRubyError, "DirectX Graphicsが初期化されていません" ); | |
1361 | + } | |
1362 | + | |
1363 | + Check_Type(width, T_FIXNUM); | |
1364 | + Check_Type(height, T_FIXNUM); | |
1365 | + | |
1366 | + /* テクスチャメモリ取得 */ | |
1367 | + texture = (struct DXRubyTexture *)malloc( sizeof( struct DXRubyTexture ) ); | |
1368 | + | |
1369 | + if( texture == NULL ) | |
1370 | + { | |
1371 | + rb_raise( eDXRubyError, "画像用メモリの取得に失敗しました - Image_initialize" ); | |
1372 | + } | |
1373 | + | |
1374 | + /* メモリファイルを読み込んでテクスチャオブジェクトを作成する */ | |
1375 | + hr = D3DXCreateTexture( g_pD3DDevice, FIX2INT( width ), FIX2INT( height ), | |
1376 | + 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, | |
1377 | + &texture->pD3DTexture); | |
1378 | + | |
1379 | + if( FAILED( hr ) ) | |
1380 | + { | |
1381 | + rb_raise( eDXRubyError, "テクスチャの作成に失敗しました - Image_initialize" ); | |
1382 | + } | |
1383 | + | |
1384 | + texture->refcount = 1; | |
1385 | + | |
1386 | + /* Imageオブジェクト設定 */ | |
1387 | + Data_Get_Struct( obj, struct DXRubyImage, image ); | |
1388 | + | |
1389 | + image->texture = texture; | |
1390 | + image->x = 0; | |
1391 | + image->y = 0; | |
1392 | + image->width = FIX2INT( width ); | |
1393 | + image->height = FIX2INT( height ); | |
1394 | + | |
1395 | + return obj; | |
1396 | +} | |
1397 | + | |
1398 | + | |
1399 | +/*-------------------------------------------------------------------- | |
1400 | + Imgaeクラスのload | |
1401 | + ---------------------------------------------------------------------*/ | |
1402 | +static VALUE Image_load( int argc, VALUE *argv, VALUE klass ) | |
1403 | +{ | |
1404 | + struct DXRubyImage *image; | |
1405 | + struct DXRubyTexture *texture; | |
1338 | 1406 | D3DXIMAGE_INFO srcinfo; |
1339 | 1407 | HRESULT hr; |
1340 | - VALUE filename, width, height; | |
1408 | + VALUE filename, width, height, obj; | |
1341 | 1409 | |
1342 | 1410 | /* デバイスオブジェクトの初期化チェック */ |
1343 | 1411 | if( g_pD3DDevice == NULL ) |
@@ -1362,7 +1430,7 @@ | ||
1362 | 1430 | texture->refcount = 1; |
1363 | 1431 | |
1364 | 1432 | /* Imageオブジェクト設定 */ |
1365 | - Data_Get_Struct( obj, struct DXRubyImage, image ); | |
1433 | + obj = Data_Make_Struct( cImage, struct DXRubyImage, 0, release_Image, image ); | |
1366 | 1434 | |
1367 | 1435 | image->texture = texture; |
1368 | 1436 | image->x = 0; |
@@ -1377,7 +1445,7 @@ | ||
1377 | 1445 | /*-------------------------------------------------------------------- |
1378 | 1446 | Imgaeオブジェクトの分割作成 |
1379 | 1447 | ---------------------------------------------------------------------*/ |
1380 | -static VALUE Image_load( VALUE klass, VALUE filename, VALUE x, VALUE y ) | |
1448 | +static VALUE Image_loadToArray( VALUE klass, VALUE filename, VALUE x, VALUE y ) | |
1381 | 1449 | { |
1382 | 1450 | struct DXRubyImage *image; |
1383 | 1451 | struct DXRubyTexture *texture; |
@@ -1793,6 +1861,129 @@ | ||
1793 | 1861 | |
1794 | 1862 | |
1795 | 1863 | /*-------------------------------------------------------------------- |
1864 | + イメージのデータ設定(circle用のline描画) | |
1865 | + ---------------------------------------------------------------------*/ | |
1866 | +static void Image_circle_line( int x1, int x2, int y, int col, D3DLOCKED_RECT *texrect, struct DXRubyImage *image ) | |
1867 | +{ | |
1868 | + int x; | |
1869 | + | |
1870 | + if( y < 0 || y > image->height - 1 ) | |
1871 | + { | |
1872 | + return; | |
1873 | + } | |
1874 | + | |
1875 | + /* クリップ */ | |
1876 | + if( x1 < 0 ) | |
1877 | + { | |
1878 | + x1 = 0; | |
1879 | + } | |
1880 | + if( x2 > image->width - 1 ) | |
1881 | + { | |
1882 | + x2 = image->width - 1; | |
1883 | + } | |
1884 | + | |
1885 | + for( x = x1; x <= x2; x++ ) | |
1886 | + { | |
1887 | + *((int*)((char *)texrect->pBits + | |
1888 | + ( x + (int)image->x ) * 4 + | |
1889 | + ( y + (int)image->y ) * texrect->Pitch)) = col; | |
1890 | + } | |
1891 | +} | |
1892 | + | |
1893 | + | |
1894 | +/*-------------------------------------------------------------------- | |
1895 | + イメージのデータ設定(circle描画塗りつぶす) | |
1896 | + ---------------------------------------------------------------------*/ | |
1897 | +static VALUE Image_circleFill( VALUE obj, VALUE vx0, VALUE vy0, VALUE vr, VALUE color ) | |
1898 | +{ | |
1899 | + struct DXRubyImage *image; | |
1900 | + D3DLOCKED_RECT texrect; | |
1901 | + int x0, y0, r, F, x, y; | |
1902 | + int col; | |
1903 | + | |
1904 | + Data_Get_Struct( obj, struct DXRubyImage, image ); | |
1905 | + | |
1906 | + x0 = FIX2INT( vx0 ); | |
1907 | + y0 = FIX2INT( vy0 ); | |
1908 | + r = FIX2INT( vr ); | |
1909 | + | |
1910 | + image->texture->pD3DTexture->lpVtbl->LockRect( image->texture->pD3DTexture, 0, &texrect, NULL, 0 ); | |
1911 | + | |
1912 | + col = FIX2INT(rb_ary_entry(color, 0))<<24 | FIX2INT(rb_ary_entry(color, 1))<<16 | | |
1913 | + FIX2INT(rb_ary_entry(color, 2))<<8 | FIX2INT(rb_ary_entry(color, 3)); | |
1914 | + | |
1915 | + x = r; | |
1916 | + y = 0; | |
1917 | + F = -2 * r + 3; | |
1918 | + | |
1919 | + while ( x >= y ) { | |
1920 | + Image_circle_line( x0 - x, x0 + x, y0 + y, col, &texrect, image ); | |
1921 | + Image_circle_line( x0 - x, x0 + x, y0 - y, col, &texrect, image ); | |
1922 | + Image_circle_line( x0 - y, x0 + y, y0 + x, col, &texrect, image ); | |
1923 | + Image_circle_line( x0 - y, x0 + y, y0 - x, col, &texrect, image ); | |
1924 | + if ( F >= 0 ) { | |
1925 | + x--; | |
1926 | + F -= 4 * x; | |
1927 | + } | |
1928 | + y++; | |
1929 | + F += 4 * y + 2; | |
1930 | + } | |
1931 | + | |
1932 | + image->texture->pD3DTexture->lpVtbl->UnlockRect( image->texture->pD3DTexture, 0 ); | |
1933 | + | |
1934 | + return obj; | |
1935 | +} | |
1936 | + | |
1937 | + | |
1938 | +/*-------------------------------------------------------------------- | |
1939 | + イメージのデータ設定(circle描画塗りつぶさない) | |
1940 | + ---------------------------------------------------------------------*/ | |
1941 | +static VALUE Image_circle( VALUE obj, VALUE vx0, VALUE vy0, VALUE vr, VALUE color ) | |
1942 | +{ | |
1943 | + struct DXRubyImage *image; | |
1944 | + D3DLOCKED_RECT texrect; | |
1945 | + int x0, y0, r, F, x, y; | |
1946 | + int col; | |
1947 | + | |
1948 | + Data_Get_Struct( obj, struct DXRubyImage, image ); | |
1949 | + | |
1950 | + x0 = FIX2INT( vx0 ); | |
1951 | + y0 = FIX2INT( vy0 ); | |
1952 | + r = FIX2INT( vr ); | |
1953 | + | |
1954 | + image->texture->pD3DTexture->lpVtbl->LockRect( image->texture->pD3DTexture, 0, &texrect, NULL, 0 ); | |
1955 | + | |
1956 | + col = FIX2INT(rb_ary_entry(color, 0))<<24 | FIX2INT(rb_ary_entry(color, 1))<<16 | | |
1957 | + FIX2INT(rb_ary_entry(color, 2))<<8 | FIX2INT(rb_ary_entry(color, 3)); | |
1958 | + | |
1959 | + x = r; | |
1960 | + y = 0; | |
1961 | + F = -2 * r + 3; | |
1962 | + | |
1963 | + while ( x >= y ) { | |
1964 | + *((int*)((char *)texrect.pBits + ( x0 + x + (int)image->x ) * 4 + ( y0 + y + (int)image->y ) * texrect.Pitch)) = col; | |
1965 | + *((int*)((char *)texrect.pBits + ( x0 - x + (int)image->x ) * 4 + ( y0 + y + (int)image->y ) * texrect.Pitch)) = col; | |
1966 | + *((int*)((char *)texrect.pBits + ( x0 + x + (int)image->x ) * 4 + ( y0 - y + (int)image->y ) * texrect.Pitch)) = col; | |
1967 | + *((int*)((char *)texrect.pBits + ( x0 - x + (int)image->x ) * 4 + ( y0 - y + (int)image->y ) * texrect.Pitch)) = col; | |
1968 | + *((int*)((char *)texrect.pBits + ( x0 + y + (int)image->x ) * 4 + ( y0 + x + (int)image->y ) * texrect.Pitch)) = col; | |
1969 | + *((int*)((char *)texrect.pBits + ( x0 - y + (int)image->x ) * 4 + ( y0 + x + (int)image->y ) * texrect.Pitch)) = col; | |
1970 | + *((int*)((char *)texrect.pBits + ( x0 + y + (int)image->x ) * 4 + ( y0 - x + (int)image->y ) * texrect.Pitch)) = col; | |
1971 | + *((int*)((char *)texrect.pBits + ( x0 - y + (int)image->x ) * 4 + ( y0 - x + (int)image->y ) * texrect.Pitch)) = col; | |
1972 | + if ( F >= 0 ) { | |
1973 | + x--; | |
1974 | + F -= 4 * x; | |
1975 | + } | |
1976 | + y++; | |
1977 | + F += 4 * y + 2; | |
1978 | + } | |
1979 | + | |
1980 | + image->texture->pD3DTexture->lpVtbl->UnlockRect( image->texture->pD3DTexture, 0 ); | |
1981 | + | |
1982 | + return obj; | |
1983 | +} | |
1984 | + | |
1985 | + | |
1986 | +/*-------------------------------------------------------------------- | |
1796 | 1987 | イメージのデータ設定(line描画) |
1797 | 1988 | ---------------------------------------------------------------------*/ |
1798 | 1989 | static VALUE Image_line( VALUE obj, VALUE vx1, VALUE vy1, VALUE vx2, VALUE vy2, VALUE color ) |
@@ -2217,7 +2408,8 @@ | ||
2217 | 2408 | } |
2218 | 2409 | |
2219 | 2410 | /* キーボードの直接データを取得する */ |
2220 | - g_pDIDKeyBoard->lpVtbl->GetDeviceState( g_pDIDKeyBoard, 256, g_diKeyState ); | |
2411 | + memcpy( g_diKeyStateOld, g_diKeyState, sizeof(g_diKeyState) ); | |
2412 | + g_pDIDKeyBoard->lpVtbl->GetDeviceState( g_pDIDKeyBoard, 256, g_diKeyState ); | |
2221 | 2413 | |
2222 | 2414 | /* ゲームパッドのデータを取得する */ |
2223 | 2415 | for( i = 0; i < g_JoystickCount; i++ ) |
@@ -2229,7 +2421,8 @@ | ||
2229 | 2421 | |
2230 | 2422 | for( j = 0; j < 20; j++ ) |
2231 | 2423 | { |
2232 | - g_PadState[i].button[j] = 0; | |
2424 | + g_PadStateOld[i].button[j] = g_PadState[i].button[j]; | |
2425 | + g_PadState[i].button[j] = 0; | |
2233 | 2426 | } |
2234 | 2427 | |
2235 | 2428 | /* 左 */ |
@@ -2260,6 +2453,15 @@ | ||
2260 | 2453 | g_PadState[i].button[j + 4] = paddata.rgbButtons[j] >> 7; |
2261 | 2454 | } |
2262 | 2455 | } |
2456 | + | |
2457 | + /* マウスボタンの状態 */ | |
2458 | + g_byMouseStateOld_L = g_byMouseState_L; | |
2459 | + g_byMouseStateOld_M = g_byMouseState_M; | |
2460 | + g_byMouseStateOld_R = g_byMouseState_R; | |
2461 | + g_byMouseState_L = GetKeyState( VK_LBUTTON ); | |
2462 | + g_byMouseState_M = GetKeyState( VK_MBUTTON ); | |
2463 | + g_byMouseState_R = GetKeyState( VK_RBUTTON ); | |
2464 | + | |
2263 | 2465 | } |
2264 | 2466 | |
2265 | 2467 |
@@ -2371,11 +2573,74 @@ | ||
2371 | 2573 | /*-------------------------------------------------------------------- |
2372 | 2574 | Inputモジュールのデータ取得 |
2373 | 2575 | |
2576 | + 押した瞬間だけtrueになる。引数はボタン番号。 | |
2577 | + ---------------------------------------------------------------------*/ | |
2578 | +static VALUE Input_buttonPush( int argc, VALUE *argv, VALUE obj ) | |
2579 | +{ | |
2580 | + int number, button; | |
2581 | + | |
2582 | + rb_scan_args( argc, argv, "11", &button, &number); | |
2583 | + | |
2584 | + if( number == Qnil ) | |
2585 | + { | |
2586 | + number = 0; | |
2587 | + } | |
2588 | + | |
2589 | + if( FIX2INT( number ) < 0 || FIX2INT( button ) < 0 || FIX2INT( number ) >= PADMAX || FIX2INT( button ) >= 20 ) | |
2590 | + { | |
2591 | + rb_raise( eDXRubyError, "値が範囲外です。 - Input_button" ); | |
2592 | + } | |
2593 | + | |
2594 | + if( (g_diKeyState[g_PadState[FIX2INT(number)].PadConfig[FIX2INT(button)]] & 0x80 || | |
2595 | + g_PadState[FIX2INT(number)].button[FIX2INT(button)] == 1 ) && | |
2596 | + (!(g_diKeyStateOld[g_PadState[FIX2INT(number)].PadConfig[FIX2INT(button)]] & 0x80) && | |
2597 | + g_PadStateOld[FIX2INT(number)].button[FIX2INT(button)] != 1 ) ) | |
2598 | + { | |
2599 | + return Qtrue; | |
2600 | + } | |
2601 | + | |
2602 | + return Qfalse; | |
2603 | +} | |
2604 | + | |
2605 | + | |
2606 | +/*-------------------------------------------------------------------- | |
2607 | + Inputモジュールのデータ取得 | |
2608 | + | |
2609 | + 押した瞬間だけtrueになる。引数はキーコード。 | |
2610 | + ---------------------------------------------------------------------*/ | |
2611 | +static VALUE Input_keyPush( VALUE obj , VALUE key ) | |
2612 | +{ | |
2613 | + if( FIX2INT( key ) < 0 || FIX2INT( key ) >= 256 ) | |
2614 | + { | |
2615 | + rb_raise( eDXRubyError, "値が範囲外です。 - Input_key" ); | |
2616 | + } | |
2617 | + | |
2618 | + if( (g_diKeyState[FIX2INT(key)] & 0x80) && !(g_diKeyStateOld[FIX2INT(key)] & 0x80)) | |
2619 | + { | |
2620 | + return Qtrue; | |
2621 | + } | |
2622 | + | |
2623 | + return Qfalse; | |
2624 | +} | |
2625 | + | |
2626 | + | |
2627 | +/*-------------------------------------------------------------------- | |
2628 | + Inputモジュールのデータ取得 | |
2629 | + | |
2374 | 2630 | 押されていたらtrueになる。引数はボタン番号。 |
2375 | 2631 | ---------------------------------------------------------------------*/ |
2376 | -static VALUE Input_button( VALUE obj , VALUE number, VALUE button ) | |
2632 | +static VALUE Input_button( int argc, VALUE *argv, VALUE obj ) | |
2377 | 2633 | { |
2378 | - if( FIX2INT( number ) < 0 || FIX2INT( button ) < 0 || FIX2INT( number ) >= PADMAX || FIX2INT( button ) >= 20 ) | |
2634 | + int number, button; | |
2635 | + | |
2636 | + rb_scan_args( argc, argv, "11", &button, &number); | |
2637 | + | |
2638 | + if( number == Qnil ) | |
2639 | + { | |
2640 | + number = 0; | |
2641 | + } | |
2642 | + | |
2643 | + if( FIX2INT( number ) < 0 || FIX2INT( button ) < 0 || FIX2INT( number ) >= PADMAX || FIX2INT( button ) >= 20 ) | |
2379 | 2644 | { |
2380 | 2645 | rb_raise( eDXRubyError, "値が範囲外です。 - Input_button" ); |
2381 | 2646 | } |
@@ -2398,9 +2663,18 @@ | ||
2398 | 2663 | g_PadState[number].PadConfig[pad] = key; |
2399 | 2664 | } |
2400 | 2665 | |
2401 | -static VALUE Input_setconfig( VALUE obj ,VALUE number, VALUE pad, VALUE key ) | |
2666 | +static VALUE Input_setconfig( int argc, VALUE *argv, VALUE obj ) | |
2402 | 2667 | { |
2403 | - if( FIX2INT( number ) < 0 || FIX2INT( pad ) < 0 || FIX2INT( key ) < 0 || FIX2INT( number ) >= PADMAX || FIX2INT( pad ) >= 20 || FIX2INT( key ) >= 256 ) | |
2668 | + int number, pad, key; | |
2669 | + | |
2670 | + rb_scan_args( argc, argv, "21", &pad, &key, &number); | |
2671 | + | |
2672 | + if( number == Qnil ) | |
2673 | + { | |
2674 | + number = 0; | |
2675 | + } | |
2676 | + | |
2677 | + if( FIX2INT( number ) < 0 || FIX2INT( pad ) < 0 || FIX2INT( key ) < 0 || FIX2INT( number ) >= PADMAX || FIX2INT( pad ) >= 20 || FIX2INT( key ) >= 256 ) | |
2404 | 2678 | { |
2405 | 2679 | rb_raise( eDXRubyError, "値が範囲外です。 - Input_setconfig" ); |
2406 | 2680 | } |
@@ -2429,7 +2703,7 @@ | ||
2429 | 2703 | switch( FIX2INT( button ) ) |
2430 | 2704 | { |
2431 | 2705 | case M_LBUTTON: |
2432 | - if( GetKeyState( VK_LBUTTON ) & 0x80 ) | |
2706 | + if( g_byMouseState_L & 0x80 ) | |
2433 | 2707 | { |
2434 | 2708 | return Qtrue; |
2435 | 2709 | } |
@@ -2439,7 +2713,7 @@ | ||
2439 | 2713 | } |
2440 | 2714 | |
2441 | 2715 | case M_RBUTTON: |
2442 | - if( GetKeyState( VK_RBUTTON ) & 0x80 ) | |
2716 | + if( g_byMouseState_R & 0x80 ) | |
2443 | 2717 | { |
2444 | 2718 | return Qtrue; |
2445 | 2719 | } |
@@ -2449,7 +2723,7 @@ | ||
2449 | 2723 | } |
2450 | 2724 | |
2451 | 2725 | case M_MBUTTON: |
2452 | - if( GetKeyState( VK_MBUTTON ) & 0x80 ) | |
2726 | + if( g_byMouseState_M & 0x80 ) | |
2453 | 2727 | { |
2454 | 2728 | return Qtrue; |
2455 | 2729 | } |
@@ -2464,6 +2738,49 @@ | ||
2464 | 2738 | |
2465 | 2739 | |
2466 | 2740 | /*-------------------------------------------------------------------- |
2741 | + マウスのボタン状態を返す | |
2742 | + ---------------------------------------------------------------------*/ | |
2743 | +static VALUE Input_mousePush( VALUE obj, VALUE button ) | |
2744 | +{ | |
2745 | + | |
2746 | + switch( FIX2INT( button ) ) | |
2747 | + { | |
2748 | + case M_LBUTTON: | |
2749 | + if( (g_byMouseState_L & 0x80) && !(g_byMouseStateOld_L & 0x80) ) | |
2750 | + { | |
2751 | + return Qtrue; | |
2752 | + } | |
2753 | + else | |
2754 | + { | |
2755 | + return Qfalse; | |
2756 | + } | |
2757 | + | |
2758 | + case M_RBUTTON: | |
2759 | + if( g_byMouseState_R & 0x80 && !(g_byMouseStateOld_R & 0x80) ) | |
2760 | + { | |
2761 | + return Qtrue; | |
2762 | + } | |
2763 | + else | |
2764 | + { | |
2765 | + return Qfalse; | |
2766 | + } | |
2767 | + | |
2768 | + case M_MBUTTON: | |
2769 | + if( g_byMouseState_M & 0x80 && !(g_byMouseStateOld_M & 0x80) ) | |
2770 | + { | |
2771 | + return Qtrue; | |
2772 | + } | |
2773 | + else | |
2774 | + { | |
2775 | + return Qfalse; | |
2776 | + } | |
2777 | + } | |
2778 | + | |
2779 | + return Qnil; | |
2780 | +} | |
2781 | + | |
2782 | + | |
2783 | +/*-------------------------------------------------------------------- | |
2467 | 2784 | マウスカーソルの位置を返す |
2468 | 2785 | ---------------------------------------------------------------------*/ |
2469 | 2786 | static VALUE Input_getmouseposx( VALUE obj ) |
@@ -2708,6 +3025,7 @@ | ||
2708 | 3025 | rb_define_singleton_method( mWindow, "scale=" , Window_setScale , 1 ); |
2709 | 3026 | rb_define_singleton_method( mWindow, "windowed=", Window_setwindowed, 1 ); |
2710 | 3027 | rb_define_singleton_method( mWindow, "getScreenShot", Window_getScreenShot, -1 ); |
3028 | + rb_define_singleton_method( mWindow, "fps=" , Window_setfps , 1 ); | |
2711 | 3029 | |
2712 | 3030 | |
2713 | 3031 | /* Imageクラス定義 */ |
@@ -2714,11 +3032,12 @@ | ||
2714 | 3032 | cImage = rb_define_class( "Image", rb_cObject ); |
2715 | 3033 | |
2716 | 3034 | /* Imageクラスにクラスメソッド登録*/ |
2717 | - rb_define_singleton_method(cImage, "load", Image_load, 3); | |
3035 | + rb_define_singleton_method(cImage, "load", Image_load, -1); | |
3036 | + rb_define_singleton_method(cImage, "loadToArray", Image_loadToArray, 3); | |
2718 | 3037 | rb_define_singleton_method(cImage, "createFromArray", Image_createFromArray, 3); |
2719 | 3038 | |
2720 | 3039 | /* Imageクラスにメソッド登録*/ |
2721 | - rb_define_method( cImage, "initialize", Image_initialize, -1 ); | |
3040 | + rb_define_method( cImage, "initialize", Image_initialize, 2 ); | |
2722 | 3041 | rb_define_method( cImage, "width" , Image_getWidth , 0 ); |
2723 | 3042 | rb_define_method( cImage, "height" , Image_getHeight , 0 ); |
2724 | 3043 | rb_define_method( cImage, "set" , Image_setPixel , 3 ); |
@@ -2725,6 +3044,8 @@ | ||
2725 | 3044 | rb_define_method( cImage, "get" , Image_getPixel , 2 ); |
2726 | 3045 | rb_define_method( cImage, "box" , Image_box , 5 ); |
2727 | 3046 | rb_define_method( cImage, "line" , Image_line , 5 ); |
3047 | + rb_define_method( cImage, "circle" , Image_circle , 4 ); | |
3048 | + rb_define_method( cImage, "circleFill", Image_circleFill, 4 ); | |
2728 | 3049 | rb_define_method( cImage, "x" , Image_getX , 0 ); |
2729 | 3050 | rb_define_method( cImage, "y" , Image_getY , 0 ); |
2730 | 3051 | rb_define_method( cImage, "width=" , Image_setWidth , 1 ); |
@@ -2740,17 +3061,21 @@ | ||
2740 | 3061 | mInput = rb_define_module( "Input" ); |
2741 | 3062 | |
2742 | 3063 | /* Inputモジュールにメソッド登録 */ |
2743 | - rb_define_singleton_method( mInput, "button" , Input_button , 2 ); | |
2744 | 3064 | rb_define_singleton_method( mInput, "x" , Input_x , -1 ); |
2745 | 3065 | rb_define_singleton_method( mInput, "y" , Input_y , -1 ); |
2746 | - rb_define_singleton_method( mInput, "key" , Input_key , 1 ); | |
2747 | - rb_define_singleton_method( mInput, "setConfig" , Input_setconfig , 3 ); | |
2748 | 3066 | rb_define_singleton_method( mInput, "mousePosX" , Input_getmouseposx , 0 ); |
2749 | 3067 | rb_define_singleton_method( mInput, "mousePosY" , Input_getmouseposy , 0 ); |
3068 | + rb_define_singleton_method( mInput, "keyDown?" , Input_key , 1 ); | |
3069 | + rb_define_singleton_method( mInput, "keyPush?" , Input_keyPush , 1 ); | |
3070 | + rb_define_singleton_method( mInput, "padDown?" , Input_button , -1 ); | |
3071 | + rb_define_singleton_method( mInput, "padPush?" , Input_buttonPush , -1 ); | |
3072 | + rb_define_singleton_method( mInput, "mouseDown?" , Input_getmousebutton , 1 ); | |
3073 | + rb_define_singleton_method( mInput, "mousePush?" , Input_mousePush , 1 ); | |
2750 | 3074 | rb_define_singleton_method( mInput, "mouseEnable=" , Input_enablemouse , 1 ); |
2751 | 3075 | rb_define_singleton_method( mInput, "mouseWheelPos" , Input_getmousewheelpos, 0 ); |
2752 | - rb_define_singleton_method( mInput, "mouseButton" , Input_getmousebutton , 1 ); | |
3076 | + rb_define_singleton_method( mInput, "setConfig" , Input_setconfig , -1 ); | |
2753 | 3077 | |
3078 | + | |
2754 | 3079 | /* Fontクラス登録 */ |
2755 | 3080 | cFont = rb_define_class( "Font", rb_cObject ); |
2756 | 3081 |
@@ -2760,7 +3085,8 @@ | ||
2760 | 3085 | /* Fontオブジェクトを生成した時にinitializeの前に呼ばれるメモリ割り当て関数登録 */ |
2761 | 3086 | rb_define_alloc_func( cFont, Font_allocate ); |
2762 | 3087 | |
2763 | - /* Soundクラス定義 */ | |
3088 | + | |
3089 | + /* Soundクラス定義 */ | |
2764 | 3090 | cSound= rb_define_class( "Sound", rb_cObject ); |
2765 | 3091 | |
2766 | 3092 | /* Soundクラスにメソッド登録*/ |
@@ -2771,7 +3097,8 @@ | ||
2771 | 3097 | /* Soundオブジェクトを生成した時にinitializeの前に呼ばれるメモリ割り当て関数登録 */ |
2772 | 3098 | rb_define_alloc_func( cSound, Sound_allocate ); |
2773 | 3099 | |
2774 | - /* キーボードのスキャンコード定数設定 */ | |
3100 | + | |
3101 | + /* キーボードのスキャンコード定数設定 */ | |
2775 | 3102 | rb_define_const( rb_cObject, "K_ESCAPE" , INT2FIX(DIK_ESCAPE) ); |
2776 | 3103 | rb_define_const( rb_cObject, "K_TAB" , INT2FIX(DIK_TAB) ); |
2777 | 3104 | rb_define_const( rb_cObject, "K_RETURN" , INT2FIX(DIK_RETURN) ); |
@@ -2865,6 +3192,7 @@ | ||
2865 | 3192 | g_WindowInfo.scale = 1; |
2866 | 3193 | g_WindowInfo.enablemouse = Qtrue; |
2867 | 3194 | g_WindowInfo.mousewheelpos = 0; |
3195 | + g_WindowInfo.fps = 60; | |
2868 | 3196 | |
2869 | 3197 | ShowCursor( TRUE ); |
2870 | 3198 |