C++ Help please . .

currently :
Code:
if (! (( dy == 0) && (dx == 0)))
grid[dy][dx] = SWEET;
is just assigning SWEET to grid[dy][dx] even if its at 0,0 which is actually what your trying to prevent. you need to do
Code:
 if (! (( dy == 0) && (dx == 0)))
{
    grid[dy][dx] = SWEET; 
}
That is unless the php code thing on the website has messed up your formatting and you have actually indented the grid line.

Do you get the same errors with /wd 4430? try changing the common runtime support to clr : pure and try again.

To fix these errors properly you will need to go to the offending variable declaration and give them all types (eg int). This should fix this problem. Definately keep the stdafx.h at the beginning of the includes as that fixed the main problem of identifier not founds.
 
Last edited:
Same errors with /wd4430 with clr : pure I 4 errors and 3 warnings:

1>.\Assigment 2.cpp(11) : warning C4653: compiler option 'Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)' inconsistent with precompiled header; current command-line option ignored
1>.\Assigment 2.cpp(11) : warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>.\Assigment 2.cpp(11) : error C2855: command-line option '/clr' inconsistent with precompiled header
1>.\Assigment 2.cpp(11) : error C2855: command-line option '/clr : pure' inconsistent with precompiled header
1>.\Assigment 2.cpp(11) : error C2855: command-line option '/Gm' inconsistent with precompiled header
1>.\Assigment 2.cpp(11) : warning C4651: '/D__MSVC_RUNTIME_CHECKS' specified for precompiled header but not for current compile
1>.\Assigment 2.cpp(11) : fatal error C1903: unable to recover from previous error(s); stopping compilation

And all the errors I get take me to ConsoleUtils.h specifically where the colours all. I commented them out I got 44 errors.

This is not going well. I've been here trying for 7 hours and I've got a killer headache. I feel like i'm cracking up :(
 
ok change the comom runtime support back. after building it again go through each of the errors and make sure that everything in that file has a type.
 
Ladforce said:
ok change the comom runtime support back. after building it again go through each of the errors and make sure that everything in that file has a type.
Could you explain what you mean when you say that 'everything in the file has a type'?

Sorry, I've barely used VS for c++.
 
look for variables which have not been declared as a type such as int. so things such as int a are fine but if its just a its not.
 
I really am stumped :mad: :(

PHP:
1>.\Assigment 2.cpp(3) : warning C4653: compiler option 'Optimizations (one or more of /Oawstgp[y]) or debug checks (one or more of /GZ, /RTCcsu)' inconsistent with precompiled header; current command-line option ignored
1>.\Assigment 2.cpp(3) : warning C4652: compiler option 'C++ Exception Handling Unwinding' inconsistent with precompiled header; current command-line option will override that defined in the precompiled header
1>.\Assigment 2.cpp(3) : error C2855: command-line option '/clr' inconsistent with precompiled header
1>.\Assigment 2.cpp(3) : error C2855: command-line option '/clr:pure' inconsistent with precompiled header
1>.\Assigment 2.cpp(3) : error C2855: command-line option '/Gm' inconsistent with precompiled header
1>.\Assigment 2.cpp(3) : warning C4651: '/D__MSVC_RUNTIME_CHECKS' specified for precompiled header but not for current compile
1>.\Assigment 2.cpp(3) : fatal error C1903: unable to recover from previous error(s); stopping compilation
 
change the thing back to No Common Language Runtime Support to get rid of the compiler errors. try int swno = 0 in your for statement. I dunno what swno(1) is supposed to do though.
 
I've reverted back to using remote desktop as VS is just being an arse.

no the strange thing is when I add the array values instead of swno the program fires up. SW stands for sweet numbers so it adds a sweet to the defined const int of 3 sweets. That's how it worked in my previous program without any problems.
 
Sometimes I don't understand other peoples' C++ code or habits at all. Why do you have "prototypes" in the main, and not before the main? Why are you using compiler macro "defines" instead of const static variables?

You are also doing some weird things with those arrays. You are passing by value the array into a function, and then manipulating the array, does that even update the original array? I'd expect it to if you passed by reference (using &) or by pointer.

Lots of things I don't understand about your code...

EDIT : Instead of storing all of your game items into a single array, why not create a few simple structs (one for a position, then one for each type of game item with position, character to be displayed, etc etc) and recompose the final drawing grid each frame. You could then have a vector<fruit> for example and have as many as you wanted on screen, detect collision against game objects rather than a grid etc etc.
 
Last edited:
Shoseki said:
Sometimes I don't understand other peoples' C++ code or habits at all. Why do you have "prototypes" in the main, and not before the main? Why are you using compiler macro "defines" instead of const static variables?

You are also doing some weird things with those arrays. You are passing by value the array into a function, and then manipulating the array, does that even update the original array? I'd expect it to if you passed by reference (using &) or by pointer.

Lots of things I don't understand about your code...

EDIT : Instead of storing all of your game items into a single array, why not create a few simple structs (one for a position, then one for each type of game item with position, character to be displayed, etc etc) and recompose the final drawing grid each frame. You could then have a vector<fruit> for example and have as many as you wanted on screen, detect collision against game objects rather than a grid etc etc.
In a nutshell, I have to do it to the speicfication given in the skeleton. It's also how I've been taught. It's not matter of go away and do it, we have adopt what's been given to us.

I got most of the other parts sorted such as a scoreboard etc, i'm just having problems setting the sweets in manual co-ordinates (4-6,5-6,7-7).
 
Shoseki said:
Sometimes I don't understand other peoples' C++ code or habits at all. Why do you have "prototypes" in the main, and not before the main? Why are you using compiler macro "defines" instead of const static variables?

Because it seems that often C++ is taught as "C with classes", and not a properly separate language with a very different approach to many things.
C++ is much more sane and fun when you use it right :)
 
azteched said:
Because it seems that often C++ is taught as "C with classes", and not a properly separate language with a very different approach to many things.
C++ is much more sane and fun when you use it right :)

Yeah, without STLs, C++ would drive me nuts.

I'd be curious to see how people did virtual functions before c++...
 
Back
Top Bottom