ズブの初心者がゲーム作れるまで勉強するスレ
レス数が900を超えています。1000を超えると表示できなくなるよ。
0001名無しさん@お腹いっぱい。
01/11/07 20:26ID:PFtlmWD9ズブの初心者以外お断りです。
なおアドバイス等はプロのかたでも結構です。
初心者は聞く耳を持ちプロもわかりやすく教えてやってください。
0897名前は開発中のものです。
2006/03/23(木) 10:01:54ID:5WNqQ2iY#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;
0898名前は開発中のものです。
2006/03/23(木) 10:02:25ID:5WNqQ2iYLPSTR 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;
}
0899名前は開発中のものです。
2006/03/23(木) 10:03:24ID:5WNqQ2iY{
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));
}
0900名前は開発中のものです。
2006/03/23(木) 10:04:13ID:5WNqQ2iYndir=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;
0901名前は開発中のものです。
2006/03/23(木) 10:04:46ID:5WNqQ2iY}
//敵が接地したか
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;
0902名前は開発中のものです。
2006/03/23(木) 13:33:20ID:5WNqQ2iYfor (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() ;
0903名前は開発中のものです。
2006/03/23(木) 13:33:50ID:5WNqQ2iYif (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 ; // ソフトの終了
}
0904名前は開発中のものです。
2006/03/23(木) 13:34:21ID:5WNqQ2iYvoid 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;
0905名前は開発中のものです。
2006/03/23(木) 13:34:52ID:5WNqQ2iYinvasion = 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;
}
0906名前は開発中のものです。
2006/03/23(木) 13:35:36ID:5WNqQ2iYvoid 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座標
0907名前は開発中のものです。
2006/03/23(木) 14:22:32ID:sWF0/S5O乙。未実装の敵弾以外は普通に動いたよ。
とりあえず、敵のフラグと座標は構造体にしてみては?
0908名前は開発中のものです。
2006/03/24(金) 03:47:56ID:r2mkgPf1for ( cnt=0 ; cnt<EBULLET_MAX ; cnt++)
{
if (bl[cnt][0] == 0) {
bl[cnt][0] = 1;
bl[cnt][2] = tl[teki_num][2]+16;
bl[cnt][3] = tl[teki_num][3];
break;
}
}
return;
}
レス数が900を超えています。1000を超えると表示できなくなるよ。