トップページgamedev
990コメント416KB

ズブの初心者がゲーム作れるまで勉強するスレ

レス数が900を超えています。1000を超えると表示できなくなるよ。
0001名無しさん@お腹いっぱい。01/11/07 20:26ID:PFtlmWD9
【参加資格】
ズブの初心者以外お断りです。

なおアドバイス等はプロのかたでも結構です。
初心者は聞く耳を持ちプロもわかりやすく教えてやってください。
0921名前は開発中のものです。2006/03/25(土) 08:26:50ID:xoont0lh
#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);

//変数宣言
struct stEnemy
{
    int enable;
    int x;
    int y;
};
stEnemy Enemies[MAX];
/*
0922名前は開発中のものです。2006/03/25(土) 08:27:31ID:xoont0lh
*/
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;

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                 LPSTR lpCmdLine, int nCmdShow )
{
    if( DxLib_Init() == -1 )    // DXライブラリ初期化処理
    {
         return -1;                // エラーが起きたら直ちに終了
    }
/*
0923名前は開発中のものです。2006/03/25(土) 08:28:25ID:xoont0lh
*/
    //初期化
    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;
        }
/*
0924名前は開発中のものです。2006/03/25(土) 08:29:18ID:xoont0lh
*/
        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));
        }
/*
0925名前は開発中のものです。2006/03/25(土) 08:31:10ID:xoont0lh
*/
        //敵機
        ndir=dir;
        for (int cnt=0 ; cnt<MAX ; cnt++)
        {
            if (Enemies[cnt].enable == 1)
            {
                DrawGraph( Enemies[cnt].x, Enemies[cnt].y, HGTeki , FALSE ) ;

                Enemies[cnt].x = Enemies[cnt].x+dir;
                if (Enemies[cnt].x <= 0) ndir = tspeed;
                if (Enemies[cnt].x >= 602) ndir = -tspeed;

                //あたり判定
                if (benable && (Enemies[cnt].x < bx) && ((Enemies[cnt].x + 32) > bx) && (Enemies[cnt].y < by) && ((Enemies[cnt].y+32) > by) )
                {
                    Enemies[cnt].enable = 0;
                    Score = Score + 10;
                    Teki_Rest = Teki_Rest - 1;
/*
0926名前は開発中のものです。2006/03/25(土) 10:25:51ID:3v7Ny4hZ
>>912
 GamDevPukiWiki( http://gamdev.org/w/?FrontPage )に1ページ作ってそこにソースを書
いてみては? そしてここでは変更部分だけとか議論したいところだけ書き出すと。
0927名前は開発中のものです。2006/03/25(土) 11:26:18ID:nEkDgcKS
ここまで空気読めないと笑うしかないなwwww
0928名前は開発中のものです。2006/03/25(土) 12:22:40ID:Xo5AkaJL
( ^∀^)ゲラゲラ
0929名前は開発中のものです。2006/03/25(土) 15:57:33ID:xoont0lh
C++/DXライブラリ 構造体を利用
http://blog.goo.ne.jp/gamedevhsp/e/e1508c7e7747bb3bfa3118d2be75f58a

ソースをうpできる場所を確保してきました
長いものはこちらにうpします
0930名前は開発中のものです。2006/03/25(土) 16:20:00ID:dp6Fd2gl
HSPって

gcopyやると

チラチラして目が痛いンmだけど対策おしえてくれ!
あと、指定した色透明とかないの?
0931名前は開発中のものです。2006/03/25(土) 16:26:34ID:Xo5AkaJL
>>930
リファレンスと公式のチュートリアルも読めないのか池沼
0932名前は開発中のものです。2006/03/25(土) 20:58:41ID:xoont0lh
中途半端なのでうpしてしまいますね
*/
                    Enemy_Fire(cnt);
                }

                //敵が接地したか
                if (Enemies[cnt].y > 448) invasion = 1;
            }
        }

        if (dir != ndir) {
            for (int cnt=0 ; cnt<MAX ; cnt++)
            {
                Enemies[cnt].y = Enemies[cnt].y + 4;
            }
        }
        dir = ndir;
/*
0933名前は開発中のものです。2006/03/25(土) 20:59:11ID:xoont0lh
        //敵弾
        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() ;
0934名前は開発中のものです。2006/03/25(土) 21:31:46ID:dp6Fd2gl

rddraw 0

redraw 1

に挟んだらちらつきなくなりました〜ヤッホー!
第一段階クリアかな。

今、透明探してる。
0935名前は開発中のものです。2006/03/25(土) 23:56:51ID:bTVU6xMs
F1押して出てくるヘルプに
gcopy って打ち込めば関連ありそうなの表示されるよ
0936名前は開発中のものです。2006/03/26(日) 11:29:59ID:erP5z/In
うちのHSPにはrddrawがないよ(´・ω・`)ショボーン
0937名前は開発中のものです。2006/03/26(日) 11:35:24ID:erP5z/In
>>933にコメント入れ忘れたorz

*/
        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 ;                    // ソフトの終了
}
/*
0938名前は開発中のものです。2006/03/26(日) 11:36:55ID:erP5z/In
*/
//ステージ初期化
void Stage_Initialize()
{
    Stage_Num = Stage_Num + 1;

    ZeroMemory(Enemies, sizeof(Enemies)); //敵
    ZeroMemory(bl, sizeof(bl)); //敵の弾
    
    for (int cnt=0 ; cnt<MAX ; cnt++)
    {
        Enemies[cnt].enable = 1;    //利用中(0=否)
        Enemies[cnt].x = ( cnt * 64 ) % 640;    //X座標
        Enemies[cnt].y = ( cnt * 64 ) / 640 * 64;    //Y座標
    }
    cx=320;
    cy=440;

    benable=0;
    tspeed=1;

    Teki_Rest=MAX;
    invasion = 0;
    Dead = 0;

/*
0939名前は開発中のものです。2006/03/26(日) 11:37:30ID:erP5z/In
*/
    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;
}

/*
0940名前は開発中のものです。2006/03/26(日) 12:18:50ID:erP5z/In
*/
//敵が弾を発射
void Enemy_Fire(int cnt)
{
    int teki_num=cnt;

    for ( cnt=0 ; cnt<EBULLET_MAX ; cnt++)
    {
        if (bl[cnt][0] == 0) {
            bl[cnt][0] = 1;
            bl[cnt][2] = Enemies[teki_num].x+16;
            bl[cnt][3] = Enemies[teki_num].y;
            break;
        }
    }

    return;
}

/*
ここで終了です

開発環境
VC++
DXライブラリ
*/
レス数が900を超えています。1000を超えると表示できなくなるよ。