[過去ログ] ズブの初心者がゲーム作れるまで勉強するスレ (990レス)
上下前次1-新
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
897(1): 名前は開発中のものです。 [] 2006/03/23(木) 10:01:54 ID:5WNqQ2iY(1/10) AAS
#define _CRT_SECURE_NO_DEPRECATE
#define MAX 50 //敵の数最大
#define cspeed 8 //自機移動速度
#define EBULLET_MAX 50 //敵弾数最大
#include "DxLib.h"
//プロトタイプ宣言
void Boot_Initialize();
void Play_Initialize();
void Stage_Initialize();
void Enemy_Fire(int cnt);
//変数宣言
int tl[MAX][4]; //敵
int bl[EBULLET_MAX][4]; //敵の弾
int cx=0, cy=0;
int bx=0, by=0, benable=0;
int ndir=0, dir=0;
int tspeed=0, Teki_Rest=0;
int Score=0, HighScore=0;
int Dead=0, invasion=0;
int Stage_Num=0;
int HGJiki=0;
int HGTeki=0;
898: 名前は開発中のものです。 [] 2006/03/23(木) 10:02:25 ID:5WNqQ2iY(2/10) AAS
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
if( DxLib_Init() == -1 ) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
//初期化
Boot_Initialize();
Play_Initialize();
//裏画面
SetDrawScreen( DX_SCREEN_BACK ) ;
//*Start
while (1)
{
ClsDrawScreen() ;
WaitTimer( 1 ) ;
//自機
if( CheckHitKey( KEY_INPUT_LEFT ) == 1 )
{
cx=cx-cspeed;
if (cx<0) cx=0;
}
899: 名前は開発中のものです。 [] 2006/03/23(木) 10:03:24 ID:5WNqQ2iY(3/10) AAS
if( CheckHitKey( KEY_INPUT_RIGHT ) == 1 )
{
cx=cx+cspeed;
if (cx>639-32) cx=639-32;
}
if( CheckHitKey( KEY_INPUT_LCONTROL ) == 1 )
{
if (benable == 0) {
benable=1;
bx=cx+16;
by=cy;
}
}
DrawGraph( cx , cy , HGJiki , FALSE ) ;
//自機弾
if (benable == 1) {
by=by-8;
if (by<0) benable=0;
DrawLine(bx, by, bx, by-16, GetColor(255,255,255));
}
900: 名前は開発中のものです。 [] 2006/03/23(木) 10:04:13 ID:5WNqQ2iY(4/10) AAS
//敵機
ndir=dir;
for (int cnt=0 ; cnt<MAX ; cnt++)
{
if (tl[cnt][0] == 1)
{
DrawGraph( tl[cnt][2], tl[cnt][3], HGTeki , FALSE ) ;
tl[cnt][2] = tl[cnt][2]+dir;
if (tl[cnt][2] <= 0) ndir = tspeed;
if (tl[cnt][2] >= 602) ndir = -tspeed;
//あたり判定
if (benable && (tl[cnt][2] < bx) && ((tl[cnt][2] + 32) > bx) && (tl[cnt][3] < by) && ((tl[cnt][3]+32) > by) )
{
tl[cnt][0] = 0;
Score = Score + 10;
Teki_Rest = Teki_Rest - 1;
901: 名前は開発中のものです。 [] 2006/03/23(木) 10:04:46 ID:5WNqQ2iY(5/10) AAS
Enemy_Fire(cnt);
}
//敵が接地したか
if (tl[cnt][3] > 448) invasion = 1;
}
}
if (dir != ndir) {
for (int cnt=0 ; cnt<MAX ; cnt++)
{
tl[cnt][3] = tl[cnt][3] + 4;
}
}
dir = ndir;
902: 名前は開発中のものです。 [] 2006/03/23(木) 13:33:20 ID:5WNqQ2iY(6/10) AAS
//敵弾
for (int cnt=0 ; cnt<EBULLET_MAX ; cnt++)
{
if (bl[cnt][0] == 1)
{
bl[cnt][3] = bl[cnt][3] + 8; //移動
DrawLine(bl[cnt][2], bl[cnt][3], bl[cnt][2], bl[cnt][3] + 16, GetColor(255,255,255)); //描画
if (bl[cnt][3] > 480) bl[cnt][0] = 0; //画面外なら使用終了
if ((bl[cnt][2] > cx) && (bl[cnt][2] < cx + 32) && (bl[cnt][3] > cy) && (bl[cnt][3] < cy+32)) Dead = 1; //自機との当たり判定
}
}
DrawFormatString( 200, 0, GetColor(255,255,255), "Score : %d", Score);
if (Score > HighScore) HighScore = Score;
DrawFormatString( 0, 0, GetColor(255,255,255), "High-Score : %d", HighScore);
// 裏画面の内容を表画面に反映させる
ScreenFlip() ;
903: 名前は開発中のものです。 [] 2006/03/23(木) 13:33:50 ID:5WNqQ2iY(7/10) AAS
if (Teki_Rest <= 10) tspeed=2;
if (Teki_Rest <= 1) tspeed=4;
if (Teki_Rest == 0) Stage_Initialize();
if ( (invasion == 1) || (Dead == 1) ) Play_Initialize();
// Windows システムからくる情報を処理する
if( ProcessMessage() == -1 ) break ;
// ESCキーが押されたらループから抜ける
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 ) break ;
}
DxLib_End() ; // DXライブラリ使用の終了処理
return 0 ; // ソフトの終了
}
904: 名前は開発中のものです。 [] 2006/03/23(木) 13:34:21 ID:5WNqQ2iY(8/10) AAS
//ステージ初期化
void Stage_Initialize()
{
Stage_Num = Stage_Num + 1;
ZeroMemory(tl, sizeof(tl)); //Dim tl, MAX, 3 //敵
ZeroMemory(bl, sizeof(bl)); //Dim bl, EBULLET_MAX, 3 //敵の弾
for (int cnt=0 ; cnt<MAX ; cnt++)
{
tl[cnt][0] = 1; //利用中(0=否)
tl[cnt][1] = 0; //呼び出すサブルーチン(未使用)
tl[cnt][2] = ( cnt * 64 ) % 640; //X座標
tl[cnt][3] = ( cnt * 64 ) / 640 * 64; //Y座標
}
cx=320;
cy=440;
benable=0;
tspeed=1;
905: 名前は開発中のものです。 [] 2006/03/23(木) 13:34:52 ID:5WNqQ2iY(9/10) AAS
Teki_Rest=MAX;
invasion = 0;
Dead = 0;
ClsDrawScreen();
DrawFormatString( 280, 240, GetColor(255,255,255), "Stage : %d", Stage_Num);
ScreenFlip() ;
WaitTimer( 1000 ) ;
return;
}
//プレイ初期化
void Play_Initialize()
{
Stage_Num=0;
Score=0;
Stage_Initialize();
return;
}
906: 名前は開発中のものです。 [] 2006/03/23(木) 13:35:36 ID:5WNqQ2iY(10/10) AAS
//起動時の初期化
void Boot_Initialize()
{
HighScore=74;
Score=0;
HGJiki = LoadGraph( "jiki.bmp" ) ;
HGTeki = LoadGraph( "teki.bmp" ) ;
ClsDrawScreen();
return;
}
//敵が弾を発射
void Enemy_Fire(int cnt)
{
// bl.cnt.0 //使用中かどうか
// bl.cnt.1 //弾道サブルーチン(未使用)
// bl.cnt.2 //X座標
// bl.cnt.3 //Y座標
上下前次1-新書関写板覧索設栞歴
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.037s