Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing this puzzle game in the form of a C++ code. Can anyone help?

ID: 3629600 • Letter: I

Question

I need help writing this puzzle game in the form of a C++ code. Can anyone help?? Basically I need this application shown here http://pbskids.org/cyberchase/games/area/tangram.html into C++ form. Below are the requirements.

Write a C++ application to implement a puzzle game called Tangram (http://en.wikipedia.org/wiki/Tangram). There are seven wooden pieces in the puzzle: two large right triangles, two small right triangles, one medium right triangle, one square and one parallelogram as shown in the figure below. The goal is to use these seven pieces to form a meaningful shape such as a candle, a fox, etc. For a list of meaningful shapes they can form, please refer to http://pbskids.org/cyberchase/games/area/tangram.html



When the application starts, it shows the seven pieces forming a square. A user can move or rotate a piece as follows.

To move a piece, use the left mouse button to drag the piece.

To rotate a piece about a particular corner counterclockwise for five degrees, hold down the SHIFT key and then click the piece. (The programer can choose that particular corner.)

To rotate a piece about a particular corner clockwise for five degrees, hold down the CTRL key and then click the piece.

Explanation / Answer

I guess this should be the code #include "stdafx.h" #include "Tangram.h" #include "TangramShellObjFrame.h" #include "TangramDoc.h" #include "TangramWebClientManager.h" #include "TangramDesignerFormView.h" #include "WndSlider.h" #include "TangramLiteSplitterWnd.h" #include "TangramLiteTabbedFormView.h" #include "TangramDesignView.h" // CTangram CTangram::CTangram() { } CTangram::~CTangram() { } void CTangram::InitInstance() { CString strDocTemplateID = _T("tangramdoc"); ((CTangramImpl*)g_pTangramImpl)->m_pTangramServiceProvider = this; AfxSetResourceHandle(theApp.m_hInstance); ((CTangramImpl*)g_pTangramImpl)->m_WinAppCnnDictionary[strDocTemplateID] = &theApp; } INT_PTR CTangram::OnAppCenter() { return -1; } INT_PTR CTangram::OnFileNew() { return -1; } CXDocument* CTangram::Navigate(LPCTSTR lpszURL) { if(g_pTangramImpl) { CTangramWebClientManager* _pWebClientManager = new CTangramWebClientManager(); _pWebClientManager->m_pHostCtrl = NULL; _pWebClientManager->m_pHostFrame = NULL; _pWebClientManager->InitWebClientManager(true); _pWebClientManager->Start(W2T((LPWSTR)lpszURL)); return ((CTangramImpl*)g_pTangramImpl)->m_pRetDoc; } return NULL; } void CTangram::Connect() { CTangramImpl* pTangramImpl = (CTangramImpl*)g_pTangramImpl; #ifndef _TANGRAM_MINI_EDITION #endif g_pTangramImpl->AddClsInfo(_T(""),_T("TangramOutLookView"),TabbedWnd,RUNTIME_CLASS(CWndSliderView)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramTabWnd"),TabbedWnd,RUNTIME_CLASS(CTangramTabbedFormView)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramExcelTabWnd"),TabbedWnd,RUNTIME_CLASS(CTangramTabbedFormView)); //g_pTangramImpl->AddClsInfo(_T(""),_T("TangramTabWnd"),TabbedWnd,RUNTIME_CLASS(CTabWnd)); //g_pTangramImpl->AddClsInfo(_T(""),_T("TangramExcelTabWnd"),TabbedWnd,RUNTIME_CLASS(CTangramExcelTabCtrl)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramTabbedView"),TabbedWnd,RUNTIME_CLASS(CTangramTabbedFormView)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramSplitter"),Splitter,RUNTIME_CLASS(CTangramSplitterWnd)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramDesignView"),View,RUNTIME_CLASS(CTangramDesignView)); g_pTangramImpl->AddClsInfo(_T(""),_T("TangramDesignerFormView"),View,RUNTIME_CLASS(CTangramDesignerFormView)); } STDMETHODIMP CTangram::get_TangramServer(LONG* pVal) { if(!g_pTangramImpl) { g_pTangramImpl = new CTangramImpl(); ((CTangramImpl*)g_pTangramImpl)->m_pXMLDocDisp.CoCreateInstance(__uuidof(DOMDocument)); g_pTangramImpl->SetTangramObjRuntimeClsInfo(TANGRAM_RUNTIME_CLASS_DOC, RUNTIME_CLASS(CTangramDoc)); theApp.m_bCtrlMode = false; ((CTangramImpl*)g_pTangramImpl)->m_pTangramServiceProvider = this; Connect(); } *pVal = (LONG)g_pTangramImpl; return S_OK; } STDMETHODIMP CTangram::get_TangramServer2(LONG* pVal) { if(!g_pTangramImpl) { g_pTangramImpl = new CTangramImpl(); ((CTangramImpl*)g_pTangramImpl)->m_pXMLDocDisp.CoCreateInstance(__uuidof(DOMDocument)); AFX_MODULE_STATE* pModuleState = AfxGetStaticModuleState(); ((CTangramImplBase*)g_pTangramImpl)->m_pMainModuleState = pModuleState; ((CTangramImpl*)g_pTangramImpl)->m_pTangramServiceProvider = this; Connect(); } theApp.m_bAppModel = true; theApp.m_bBrowserModel = false; *pVal = (LONG)g_pTangramImpl; return S_OK; } STDMETHODIMP CTangram::CreateCtrlFrame(LONG hCtrl,LONG* pFrame) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); RECT rc; HWND m_hWnd = (HWND)hCtrl; ::GetClientRect(m_hWnd,&rc); CRuntimeClass* pClsInfo = RUNTIME_CLASS(CTangramShellObjFrame); CFrameWnd* m_pHostFrame = (CFrameWnd*)pClsInfo->CreateObject(); m_pHostFrame->Create(NULL,_T(""),WS_CHILD|WS_VISIBLE,rc,CWnd::FromHandle(m_hWnd),0,0,NULL); * pFrame = (LONG)m_pHostFrame; return S_OK; } STDMETHODIMP CTangram::DeleteInfoObj(LONG ID) { CTangramThreadInfo* pInfo = NULL; pInfo = theApp.GetThreadInfo(); if(pInfo)delete pInfo; return S_OK; }