⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singlemode.cpp

📁 自制的双子球游戏
💻 CPP
字号:
// SingleMode.cpp: implementation of the CSingleMode class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "DBallGame.h"
#include "SingleMode.h"

#include "MyDef.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSingleMode::CSingleMode()
{

}

CSingleMode::~CSingleMode()
{

}



bool CSingleMode::MoveEx()
{
	bool i;
	if(Pos.y >=y_Above+6&&Pos.y<=y_Above+6+delta_x )//小球步长为2
	{
		i=y_dir;
		if(Analyse(BAR_ABOVE))y_dir=0;
		
		if(i!=y_dir)
		{
			PlaySound("sound",AfxGetResourceHandle(),SND_RESOURCE|SND_ASYNC|SND_NODEFAULT  );
			m_score ++;
			CString str;
			str.Format ("战绩: %d  记录: %d",m_score,m_hiscore); 
			m_news->SetWindowText (str);
		}
		return 0;
	}
	if(Pos.y <=y_Below-6&&Pos.y>=y_Below-6-delta_x )
	{
		i=y_dir;
		if(Analyse(BAR_BELOW))y_dir=1;
		if(i!=y_dir)
		{
			PlaySound("sound",AfxGetResourceHandle(),SND_RESOURCE|SND_ASYNC|SND_NODEFAULT  );
			m_score ++;
			CString str;
			str.Format ("战绩: %d  记录: %d",m_score,m_hiscore); 
			m_news->SetWindowText (str);
		}
		return 0;
	}
	
		
	if(Pos.y >=y_Below*11/10-5)
	{
		if(m_score >m_hiscore)
		{
			File.SeekToBegin ();
	    	CString str;
         	str.Format ("记录:\n");
			File.WriteString (str);
		    str.Format (" %d\n",m_score);
			File.WriteString (str);
		}
		return 1;
	}
	if(Pos.y <=5)
	{
		if(m_score >m_hiscore)
		{
			File.SeekToBegin ();
	    	CString str;
         	str.Format ("记录:\n");
			File.WriteString (str);
		    str.Format (" %d\n",m_score);
			File.WriteString (str);
		}
		return 1;
	}
	return 0;

}

void CSingleMode::Failure()
{
	AfxMessageBox("你咋挂了,嗷嗷丢人");
}

void CSingleMode::InitOther()
{
    x_dir = y_dir = 1;
	Pos.y = WinRect->bottom *10/11-7;
	m_score = 0;
	CString str;
	if(!File.Open ("data.dat",CFile::modeReadWrite|CFile::typeText))
	{
		File.Open ("data.dat",CFile::modeReadWrite|CFile::modeCreate|CFile::typeText);
        
        str.Format ("记录:\n");
		File.WriteString (str);
		m_hiscore = 0;
		str.Format (" %d\n",m_hiscore);
		File.WriteString (str);
	}
	else
	{   File.ReadString (str);
		File.ReadString (str);
		m_hiscore =atoi (str.GetBuffer (0));
	}
	
	if(m_hiscore<0)m_hiscore=0;
}

void CSingleMode::ResetEx()
{
    x_dir = y_dir = 1;
	PrePos.x = Pos.x = m_BelowBarPos;
	PrePos.y = Pos.y =WinRect->bottom *10/11-7;
	
	File.SeekToBegin ();
	CString str;
	File.ReadString (str);
	if(str == "记录:")
	{
		
		File.ReadString (str);
		m_hiscore =atoi (str.GetBuffer (0));
	}
	if(m_hiscore<0)m_hiscore=0;
	m_score = 0;
	str.Format ("战绩: %d  记录: %d",m_score,m_hiscore);
    	m_news->SetWindowText (str);
	
}






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -