できれば、以下のソースを生かして、なめらかにスクロールさせる方法を教えてください。
C言語・プログラミングともに初心者です。
#include "DxLib.h" int playerX , playerY ; int moveY ; int playerGraph ; int houkou=0; int jump_flag=0; int gamenX, gamenY; const mapX=20; const mapY=45; int mapMove = 0; int hantei[mapY][mapX] = { //省略 }; int can_or_cannot(int x,int y,int houkou){//進めるかを判定する if(houkou=0) //右に進んでいるとき if(hantei[((y+63)/32)][x/32]==1) return 1; if(houkou=1) //左に進んでいるとき if (hantei[((y+63)/32)][(x+31)/32]==1) return 1; return 0;//正常 } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { int Key ; SetGraphMode( 640 , 480 , 16 ) ; if( DxLib_Init() == -1 ) // DXライブラリ初期化処理 { return -1; // エラーが起きたら直ちに終了 } // 描画先画面を裏画面にセット SetDrawScreen( DX_SCREEN_BACK ) ; // グラフィックのロード playerGraph = LoadGraph( "player.bmp" ) ; // キャラクターの初期データをセット playerX = 320 ; playerY = 40*32 ; moveY = 0 ; gamenY=15; //表示画面の左上のY座標 // ループ while( ProcessMessage() == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 ) { // キー入力取得 Key = GetJoypadInputState( DX_INPUT_KEY_PAD1 ) ; //左右の壁にぶつかったら、方向反転 if (playerX < 32) houkou=0 ; if (playerX > 604-32) houkou=1; if (houkou == 0) playerX += 3 ; // 右に進む if (houkou == 1) playerX -=3; //左に進む // ジャンプボタンを押していて、地面についていたらジャンプ if( (Key & PAD_INPUT_M) && jump_flag==0){ moveY = 20 ; jump_flag =1; } // 落下加速度を加える moveY =moveY - 1 ; //ブロックをすり抜けないように。 if (moveY <-31) moveY=-31; // 落下処理 playerY = playerY-moveY ; //落下中のマップとの当たり判定 if (moveY < 0) if (can_or_cannot(playerX,playerY,houkou)==1){ playerY = ((playerY)/32)*32; jump_flag = 0; moveY=0; } if(playerY-gamenY*32<15/2*32){ gamenY=gamenY-1; } if(playerY-gamenY*32>15/2*32){ gamenY++; } // 画面を初期化する ClearDrawScreen() ; //マップを描画する for(int x=0;x<20;x++) for(int y = gamenY; y < gamenY+15; y++)//画面左上の座標からスタート if(hantei[y][x]==1) //■を描画 DrawBox( x*32, ((y-gamenY)*32)+mapMove, x*32+31, ((y-gamenY)*32+31)+mapMove, GetColor( 255,255,255 ), TRUE ) ; // プレイヤーを描画する DrawGraph( playerX , playerY-gamenY*32 , playerGraph , TRUE ) ; // 裏画面の内容を表画面に反映させる ScreenFlip() ; } DxLib_End() ; // DXライブラリ使用の終了処理 return 0 ; // ソフトの終了 }