Game

In articles there is a game by
Foxefde
Oct 30, 2013

for c++ console

I copied the code but screen jumps up and down and causes headache
What should I change in his code to solve the problem?



Here is its link
http://www.cplusplus.com/articles/3Cpk4iN6/
well i think I shouldn't post it in beginners section how can i take my question to other section?
I don't think that program is a very good example.
Some problems:
line 597: y is uninitialized giving unpredictable results to the loop and crashes the program.
line 845: game is never released resulting in a memory leak. There is no reason that game even needs to be dynamically allocated.
General comments:
The use of arrays is poorly thought out (map should be 2d array, not 1d).
Begging for the use of switch statements and constant value arrays.

The console is not a good output device for this kind of game. Better to use a true graphics library such as QT or SFML.

I agree
Add this at the beginning in the main() function

1
2
HWND console = GetConsoleWindow();
MoveWindow(console,10, 10, 470, 790, TRUE);
will try
ops
error
`GetConsoleWindow' undeclared (first use this function)
Last edited on
Try this.
Add this before #include<windows.h>

#define _WIN32_WINNT 0x0500

(works for me without it)
i have Dev c++ IDE what you have?
Code::Blocks 12.11 mingw32-gcc 4.8.1
Dev is old :(
Last edited on
i will try using it
But anyway you can update your dev ide if you want?!
no matching function for call to `game::LevelMenu(int)'
I did as you said but compiler is showing the above error

memb->LevelMenu(2); this line is highlighted
Last edited on
By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to?

you mean this???
memb->LevelMenu(2); this line is highlighted

In the original article, LvelMenu does not take any arguments. You're trying to pass an integer to it and the compiler is telling you there is no version of LevelMenu that accepts an integer.


i have to update and set my dev c++ or get new IDE
then try again
Topic archived. No new replies allowed.