NimotsuKun for MS-DOS

ゲームプログラマになる前に覚えておきたい技術

http://www.shuwasystem.co.jp/support/7980html/2118.html

サンプルプログラムの荷物君をTurbo C++ 1.0.1でビルドしてMS-DOSで動かしてみます。

>msdos tcc nimotsu.cpp
>msdos nimotsu.exe
########
# .. p #
# oo   #
#      #
########
a:left s:right w:up z:down. command?
a

main.cppをnimotsu.cppにリネームして改修しました。

nimotsu.cpp

#include <iostream.h>
// using namespace std;
typedef int bool;
#define true 1
#define false 0

//#壁 _空間 .ゴール oブロック p人
const char gStageData[] = "\
########\n\
# .. p #\n\
# oo   #\n\
#      #\n\
########";


enum Object{
	OBJ_SPACE,
	OBJ_WALL,
	OBJ_GOAL,
	OBJ_BLOCK,
	OBJ_BLOCK_ON_GOAL,
	OBJ_MAN,
	OBJ_MAN_ON_GOAL,

	OBJ_UNKNOWN,
};
const int gStageWidth = 8;
const int gStageHeight = 5;

//関数プロトタイプ
void initialize( Object* state, int w, int h, const char* stageData );
void draw( const Object* state, int w, int h );
void update( Object* state, char input, int w, int h );
bool checkClear( const Object* state, int w, int h );

int main(){
	//一次元配列である理由は本文参照
	Object* state = new Object[ gStageWidth * gStageHeight ]; //状態配列確保

(省略)

	//後始末
//	delete[] state;
	delete[ gStageWidth * gStageHeight ] state;
	state = 0;

	//Visual Studioから実行する人のために無限ループ。コマンドラインからはCtrl-Cで終えてください。
//	while( true ){
//		;
//	} 
	return 0;
}