Thread: A Simple Game

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    2

    Unhappy A Simple Game

    Hi there,so i started the tutorial A SIMPLE GAME and have struck a problem.
    At the moment i am at the end of the lesson titled "The View: Drawing Your Game"
    and the tutor wrote "your game should now look like this" so i rebuilt it and there are huggins of Errors.I have gone through the tutorials scrutinizing every last line trying my utter best to totally understand everything and i cannot find anything different whatsoever.Very frustrating.grrr
    The only difference is im using VS2010 and the tutorial i believe is using 2008 should this make a difference to any of the coding or is the program just simply not ready to be built at this stage?

    Any help/advice/Knowledge gained from this thread is much appreciated.

  2. #2
    Registered User
    Join Date
    Feb 2011
    Posts
    3
    Might help to link to the tutorial.

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    You need to provide information to get "help/advice/knowledge" ! You could be using any of a dozen API's, it could be characters in a console to 'draw' the view, it could be 3D hoona-hoona graphics extravaganza

    so post some code and a little more detail
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    2
    Right i managed to sort out most of the errors playing around and experimenting...There's just 3 left that are bugging me..The first two

    So it says that "AssertValid" cannot be redeclared outside its class;Here is the code were i have redeclared it

    Code:
    // CSameGameView diagnostics
    
    #ifdef _DEBUG
    void CSameGameView::AssertValid() const
    {  // It also expected a  ";"   before this point but i don't understand why ?
    	CView::AssertValid();
    }
    
    void CSameGameView::Dump(CDumpContext& dc) const
    {
    	CView::Dump(dc);
    }
    
    CSameGameDoc* CSameGameView::GetDocument() const // non-debug version is inline
    {
    	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSameGameDoc)));
    	return (CSameGameDoc*)m_pDocument;
    }
    #endif //_DEBUG
    and here is the class it is declared in



    Code:
    #pragma once
    
    
    class CSameGameView : public CView
    {
    protected: // create from serialization only
    	CSameGameView();
    	DECLARE_DYNCREATE(CSameGameView)
    
    // Attributes
    public:
    	CSameGameDoc* GetDocument() const;
    
    // Operations
    public:
    
    // Overrides
    public:
    	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
    	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    protected:
    
    // Implementation
    public:
    
    	void ResizeWindow();
    
    	virtual ~CSameGameView();
    #ifdef _DEBUG
    	virtual void AssertValid() const;              
    	virtual void Dump(CDumpContext& dc) const;
    #endif
    protected:
    
    // Generated message map functions
    protected:
    	afx_msg void OnFilePrintPreview();
    	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
    	DECLARE_MESSAGE_MAP()
    public:
    	virtual void OnInitialUpdate();
    };
    
    #ifndef _DEBUG  // debug version in SameGameView.cpp
    inline CSameGameDoc* CSameGameView::GetDocument() const
       { return reinterpret_cast<CSameGameDoc*>(m_pDocument); }
    #endif
    I hope my explanation is clear,i have never spoke to anybody about coding so i'm unsure of what terminology to use. I will get there soon

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    It also expected a ";" before this point but i don't understand why ?
    Haha, thats most amusing, do you mean your compiler gave an error: 'expected ; before...'?
    That is really a rather broad error when you get that and usually means something fundamentally wrong with your syntax somewhere, given the position it is reported at it suggests problems that could even be header include / class definition, inheritance related.
    Last edited by rogster001; 02-16-2011 at 08:17 AM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Same tutorial, same article (1), same place. Different problem. I cut-and-paste'd the ResizeWindow parts of the program and my "It should look like this" didn't seem to re-size the width.

    I, too, am using an eval copy of VS 2010-only way I know to get access to MFC-and I also 'paused' my AV software.

    Beyond checking for typos, which were the cause of the first 99% of my problems-since corrected, where else could I look for the failure of the program to correctly re-size in only one dimension?

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    window is still too wide and end of game procedure is not engaging. Does the fact that C++ doesn't generate a PDB have any effect?
    Last edited by ERand; 03-02-2011 at 10:06 AM. Reason: Found partial answer-maybe- to PDB item.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    PDB is Program DataBase.
    They're files used by the debugger to help you with say setting breakpoints, printing variables etc when you're using the debugger.

    They're of no use to the actual running code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Well, that's the conclusion I reached--hopefully a good sign. Still not sure how/where to trace a failure to execute end-of-game-state code. If others have had this problem, I could use their solution(s) as a starting point in my search.

    Update: Program terminates upon selecting lower-left corner block.
    Last edited by ERand; 03-02-2011 at 12:41 PM. Reason: Add'l symptom

  10. #10
    Registered User
    Join Date
    Mar 2011
    Posts
    4
    Here is an update: After my motherboard self-terminated, I moved my drive over to an older (2001 HP Pavilion) box. Program now works and end-state code functions, but I still have the horizontal width problem previously mentioned and "board" has 2 invisible, playable blocks. Any idea in what section of the code I should start? Hints greatly appreciated by this student.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple game with timing issues atm
    By Swarvy in forum Game Programming
    Replies: 1
    Last Post: 08-06-2009, 09:52 PM
  2. Creating a simple Windows game
    By ejohns85 in forum C Programming
    Replies: 1
    Last Post: 05-22-2009, 12:46 PM
  3. craps game & dice game..
    By cgurl05 in forum C Programming
    Replies: 3
    Last Post: 03-25-2006, 07:58 PM
  4. Whats a very simple but good game i can try to make?
    By bluehead in forum C++ Programming
    Replies: 2
    Last Post: 11-06-2001, 09:24 PM
  5. Replies: 1
    Last Post: 11-06-2001, 02:15 PM

Tags for this Thread