「画像を分割読み込み」の編集履歴(バックアップ)一覧はこちら
「画像を分割読み込み」(2008/11/11 (火) 02:57:41) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
//C++
#include "DxLib.h"
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define WINDOW_TEXT "RozenMaidenDuoDectet"
#define IMG_BACK "image\\Back.bmp"
#define IMG_TABLE "image\\gtable.bmp"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
SetMainWindowText(WINDOW_TEXT); //ウィンドウの文字列設定
SetWindowIconID(101); //Resouce.rcでID定義してます。
ChangeWindowMode(TRUE); //ウィンドウモードに
SetGraphMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32); //解像度、カラーモードを設定
//DXライブラリの初期化
if(DxLib_Init() == -1)
return false;
//バックバッファの設定
SetDrawScreen(DX_SCREEN_BACK);
//グラフィックデータのロード
int gh_Background = LoadGraph(IMG_BACK);
//グラフィックの分割読み込み
int gh_Table[100];
LoadDivGraph(IMG_TABLE,100, //格納している画像の個数
10, 10, //横に何枚 縦に何枚
150, 200, //画像チップのサイズ
gh_Table); //画像を格納する配列のアドレス
int x = 0, y = 0;
int ghi = 0;
while(1)
{
if( CheckHitKey( KEY_INPUT_LEFT ) == 1) x -= 8 ;
if( CheckHitKey( KEY_INPUT_RIGHT) == 1) x += 8 ;
if( CheckHitKey( KEY_INPUT_UP ) == 1) ghi += 1 ;
if( CheckHitKey( KEY_INPUT_DOWN ) == 1) ghi -= 1 ;
if(ghi >= 100) ghi = 0;
if(ghi < 0 ) ghi = 100;
DrawGraph(0, 0, gh_Background,FALSE);
DrawGraph(x, y, gh_Table[ghi], FALSE);
ScreenFlip(); // バッファをフリップ
WaitTimer(20);
if(ProcessMessage() == -1) break;
if(CheckHitKey( KEY_INPUT_ESCAPE) == 1) break;
}
//DXライブラリの終了
DxLib_End();
return 0 ; // ソフトの終了
}