C++【观察系列】混乱的“蜜蜂”

#include <ctime>
#include <iostream>
#include "windows.h"
using namespace std;

class Game {
   
	public:
		void Move ( );
		void MoveGo ( );
		void SetConsole ( int ic_x, int ic_y );
		int Random ( int ic_numberA, int ic_numberB );
		Game ( int ic_window_width, int ic_window_heigth, int ic_speed );
		~Game ( );
	private:
		int i_window_width,
			i_window_height,
			i_window_right,
			i_window_down,
			i_random_x,
			i_random_y,
			i_formerly_x,
			i_formerly_y,
			i_direction_id,
			i_speed;
};

int main ( ) {
   
	system ( "mode con cols=100 lines=30" );
	srand ( time ( NULL ) );
	
	Game game ( 100, 30, 10 );
	game.MoveGo ( );
	
	return 0;
}


Game::Game ( int ic_window_width, int ic_window_height, int ic_speed ) {
   
	i_window_width	= ic_window_width;
	i_window_height	= ic_window_height;
	i_window_right	= i_window_width - 1;
	i_window_down	= i_window_height - 1;
	i_random_x 		= Random ( 0, i_window_right );
	i_random_y 		= Random ( 0, i_window_down );
	i_direction_id 	= Random ( 1, 4 );
	i_speed 		= ic_speed;
}

Game::~Game ( ) {
   
}
int Game::Random ( int ic_numberA, int ic_numberB ) {
   
	return ic_numberA + rand
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值