game design, framerate architecture..

Pages: 12
Thanks.

Now to work on making some classes and functions and getting this all a little more dynamic...

will be the start of a collision detection class I guess.

baby steps :D

thanks for all the help & suggestions
wait, Im guessing its not as simple as setting:
1
2
3
const int conX = 30;
const int conY = 12;
const int arraySize = conX * conY;

or is it..


It is in this case.

in the mean time ill find another compiler..

No need for that. Either be aware of the extensions or just disable them. I believe using the -pedantic switch when compiling will disable all extensions in gcc.
Last edited on
I'm using Microsoft Visual C++ 2010. You could get the 2012 Express version for free. Although your current compiler should work fine too if you follow cire's instructions -- I believe you're using gcc at the moment?

You're welcome. Yeah, breaking this up in classes and functions would be a good idea.
Last edited on
You might want to wrap those code segments into classes if you want to use them again. It looks not too reusable.
im working on that dexecipher

at the moment I got visual stuido 2010 but I am getting all kinds of errors..

at the moment:

"(159): warning C4309: '=' : truncation of constant value"
which is line
writeArray[curCoord.X + conX * curCoord.Y].Char.AsciiChar = 0xE9; //set char X at top left

i dont really know what to make of this.. part of me thinks its because of the conX which is constant.. part of me thinks its the declaration to a hex value?

and im getting

>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

:ugh:
Last edited on
got it to compile by setting 0xE9 to a char 'X'

but its odd because it didnt say anything bad about other lines where I used a hex value for a char.. yet its not creating a space to write over previous positions, and the chars arent displaying, only as a question mark.

im tempted to say this compiler sucks but i know that cant be right and its just my coding sucks and other more relaxed compilers let me get away with it.. but I dont get it :/
got it to compile by setting 0xE9 to a char 'X'


Warnings don't keep things from compiling. Only errors keep things from compiling, unless you supply a switch that indicates the compiler should treat warnings as errors. 0xE9 is an int type. 0xE9 exceeds the value that can be held by a char, thus the warning. char may be either of the signed or unsigned variety depending entirely on the implementation. So, it is entirely possible the previous environment you were working with char was equivalent to unsigned char.

Why go with VS2010 instead of VS2012 if you're going to switch?
Hmm well I am a bit confused by the massive amount of VS bloat.. no longer simple cpp and h files.. I had troubles getting 2012, so I went for 2010.

So what I was trying to do was build my project, and it gave those warnings and the linker issue. I figured out the linking thing, and by changing the 0xE9 to 'X' it built and then compiled.

I understanding signing floats and integers, but I dont see how a char would ever need a sign.. I guess then yeah if a bit out of the byte was used as a sign bit then 0xE9 would definitely exceed the value,

However, the other char assignments I made such as '.' and space 0x20 didnt show up correctly, and neither did the 'X' when I changed it from 0xE9..
The colors display right, but the characters do not at all, rather they give a '?'

As this is a hobby for me I feel torn between learning and utilizing industry standards like VS even though theyre complex and convoluted and if you ask me bloated beyond belief with functionality Ill probably never even begin to touch upon, or just sticking with a gcc/g++ type compiler that I know works

You say a warning doesnt stop it from compiling, and I guess it doesnt, but it doesnt mean its compiling the code the way I intended, thus I am led to believe I should fix such warnings.. but I have no idea how to.

Is it a cop-out to give up and go back to devc++ or some other free/non-bloatware?
Try using WriteConsoleOutputA rather than WriteConsoleOutput.

As this is a hobby for me I feel torn between learning and utilizing industry standards like VS even though theyre complex and convoluted and if you ask me bloated beyond belief with functionality Ill probably never even begin to touch upon, or just sticking with a gcc/g++ type compiler that I know works


VC++ is no more complex or convoluted than gcc, and one doesn't need to use VS to use VC++. IDEs are not compilers.

Use whatever editor/compiler combination you feel comfortable with, but I would suggest refraining from calling stuff "bloatware" just because it doesn't jive with your personal tastes.

It just bothers me that even with standards one thing can compile in one and not in another.. makes you wonder where youve gone wrong. I could spend a long time learning c++ in one environment only to have it crash down on me should I switch to another.

Perhaps bloatware wasnt a good word, im sure a lot of the features are handy, but they seem to be endless, and a lot of stuff that I, as a non 'enterprise' person would ever begin to learn to use. VS seems like it would take just as long if not longer to learn to use than leanring C++ itself.

And it is a lot more complex and convoluted. in devc++ I hit compile+run and if no errors it works, or i make a project with my .cpps and .h and hit compile and run and it builds and compiles and runs.

my vs2010 version of the same project contains 10 files and 2 folders, one containing 10 other files plus the final .exe and the other containing god knows what. sql server files, visual studio solution files vc++ files, filter files, user options files, extra included headers, cpps files, all sorts of useless stuff if you ask me.

Ill keep my opinion to myself from now on but, at this point in time I see VS as something that limits my growth into the language with all its magic

By the way there is no WriteConsoleOutputA, unless msdn is lying to me.

Unless you meant to try splitting it up into using WriteConsoleOutputAttribute and WriteConsoleOutputCharacter, since both of those dont require a CHAR_INFO type.
Seems like a lot of extra work to get it to work in VS.

I will take this time to ask another question though, in a definition like:
1
2
3
4
5
6
7
typedef struct _CHAR_INFO {
  union {
    WCHAR UnicodeChar;
    CHAR  AsciiChar;
  } Char;
  WORD  Attributes;
} CHAR_INFO, *PCHAR_INFO;


Why the leading _CHAR_INFO?

using typedef this is C style correct? meaning that the CHAR_INFO and *PCHAR_INFO are the type identifiers since they lie between the closing brace and the semi-colon right? Not that they are automatically initialized types right?
Last edited on
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687404%28v=vs.85%29.aspx

Go down to the "See Also" section. Just above that you'll see:

Unicode and ANSI names: WriteConsoleOutputW (Unicode) and WriteConsoleOutputA (ANSI)


You may also want to take a look at
http://msdn.microsoft.com/en-us/library/windows/desktop/dd317766%28v=vs.85%29.aspx


using typedef this is C style correct? meaning that the CHAR_INFO and *PCHAR_INFO are the type identifiers since they lie between the closing brace and the semi-colon right? Not that they are automatically initialized types right?


The Windows API is C. All correct.
Ahh thats why I was missing that. Appreciate it.

Im still really fuzzy on the whole header macros

Anywho, im back to a gnu compiler and its working well. Ill have to learn about these extensions to see if anything is going on there, its a lot to take in, I just want to code :)

Thanks for your patience
You'll probably see that type of generic Windows function prototypes often, since it's used in functions with text arguments. The idea is to allow the use of generic prototypes in your application, which, depending on whether you're using Unicode or ANSI, compile accordingly by means of the macros in the header files. The final "A" or "W" in the function name indicates ANSI or Unicode, respectively.

The last link cire provided gives a concise description. Another good source of information for this subject is Petzold's "Programming Windows".
Last edited on
Ive really jumped in the deep end here it seems :o

good thing I dont truly need to delve into much more winapi at the current moment for my desires.. I understand whats going on so far though. but I need to focus on the core c++ stuff rather than trying to get more involved in the api stuff. Itll all come in time.

One thing I am slightly confused about is those header file macros. My book tells me they are necessary so you dont include the same header twice and confuse the compiler.. im kinda just crossing my fingers at the moment that I dont run into that issue but I want to start breaking my programs into a main.cpp, a declarations header and a definitions.cpp
I think you are confusing the concept of a header file's "include guard" with Windows API's macros used for generic function prototypes involving text arguments. The two are entirely different types of macros.

The first is this:
1
2
3
4
5
6
7
8
//inside myheader.h

#ifndef MYHEADER_H
#define MYHEADER_H

// ... (content of header file goes here)

#endif 


This is a technique often used to make sure the header isn't included more than once, and is in no way specific to the Windows API. If MYHEADER_H is already defined, the content of the header is skipped due to the preprocessor returning false during the #ifndef test, and moving all the way to the #endif , which coincides with the end of the header file's content (thus avoiding the double declaration of the content by skipping the content altogether). If it isn't already defined, this implies that this is the first inclusion of this header file, so we define MYHEADER_H (thus preventing any future double inclusions), and the content of the header follows and is parsed.

"MYHEADER_H" is simply chosen because it reflects the name of the header file the include guard belongs to. Another name could be used in it's place, but it would create confusion and would potentially inhibit the include guard's functionality. Another approach you might see, again based on the header file's name, is "_MYHEADER_H_", etc. .


Now, on the other hand, The macros referred to regarding generic function prototypes are like this:
1
2
3
4
5
6
7
//inside the body of a Windows API header file (and after the include guard for that file)

#ifdef UNICODE
#define SetWindowText SetWindowTextW
#else
#define SetWindowText SetWindowTextA
#endif // !UNICODE 


This is a macro that determines the definition of SetWindowText() based on whether UNICODE is defined. If it is, SetWindowText() is defined as SetWindowTextW(), and takes Unicode text arguments. If not, it is defined as SetWindowTextA(), and takes ANSI text arguments. The functionality of this is that the generic prototype takes generic data types of type LPCTSTR as arguments, which also have similar macros:

1
2
3
4
5
#ifdef UNICODE
 typedef LPCWSTR LPCTSTR; 
#else
 typedef LPCSTR LPCTSTR;
#endif 


So that, again based on UNICODE being defined, the generic LPCTSTR becomes either LPCWSTR (pointer to a constant null-terminated string of Unicode characters) or LPCSTR (pointer to a constant null-terminated string of ANSI characters).



So, the two are entirely different concepts. Hopefully this clarified them a bit for you.
Last edited on
Topic archived. No new replies allowed.
Pages: 12