Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

102 Neutral

About BrandonSnider

  • Rank
  1. Thanks... XD I knew I would feel dumb at the end of this one... always the little things. Appreciate it. Sometimes it's just helpful to have someone else look at it.
  2. I've worked with other languages in the past including basic and a lot of scripting languages, and I have worked a decent bit on C++ too. I haven't worked on C++ in quite a while now, and last night I was trying to refresh myself on the basics... so--and this is a little embarrassing--I wrote this small piece of code for a console program to send my girlfriend: #include "stdafx.h" #include <iostream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //Vars string username = ""; //Execute cout << "Hello \n"; cin.get(); cout << "What is your name? "; getline (cin, username); cout << "Your name is: " << username; cin.get(); if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue") { cout << "Your name is Tiffany... \n The Creator has a message for you: \n I love you Cupcake"; cin.get(); } else { cout << "Your name is not Tiffany."; cin.get(); } return 0; } The problem is... it doesn't appear that the "if (username == "Tiffany" || "tiffany" || "Tiffany McClure" || "tiffany McClure" || "Tiffany Mcclure" || "tiffany mcclue")" statement evaluates correctly, as the program always displays the cout message in the "if" block, even if the if statement should be false. I know these are beginner C++ concepts that have nothing to do with game development, but... this is like the only forum acct. I have for anything like this, and I hate to create another just to ask this somewhat stupid question. I appreciate any help with this, I'm trying to pick up C++ again so that maybe I can do something useful with it. EDIT: Oops. I haven't been on this site in a while. Forgot there was a "For Beginners" Section. This probably belongs there. Sorry about that.
  3. BrandonSnider

    Anyone Here Know Anything About UnrealScript?

    Have you taken a look at the Development\Src\UTGame folder? Normally one would advise not looking at source code when learning to do something, however in the circumstance where you are working in an existing engine and trying to make things work in that engine, looking at existing code in my opinion is very valuable (The same constraints they have to make to work with the Unreal engine are probably the same constraints you will have). Also the '.' operator is used in that manner in Unreal Script. For instance from UTPlayerController, line 837 (roughly): reliable server function ServerProcessSpeechRecognition(SpeechRecognizedWord ReplicatedWords[3]) { local array<SpeechRecognizedWord> Words; local int i; local UTGame Game; Game = UTGame(WorldInfo.Game); if (Game != None) { for (i = 0; i < 3; i++) { if (ReplicatedWords.WordText != "") { Words[Words.length] = ReplicatedWords; } } Game.ProcessSpeechRecognition(self, Words); } } Main thing to note is that variables (in this case local variables) must be declared and initialized on two separate lines (as far as I know). Also you need to typecast to the appropriate type containing your methods. such as convertedInstance = MyClass(instanceToConvert) ect. Here we see Game = UTGame(WorldInfo.Game) . [/quote] Well I have seen many people typecasting variables from other classes but I'm not exactly sure how it works. Basically speaking, why can't (using my example) TestGamePawn.getwaterlevel(); why would this not call the function 'getwaterlevel()' from the TestGamePawn class? EDIT: Comparing it to C++ shouldn't it work like this: //Class Declaration class TestGamePawn { int charwaterlevel; Public: int getwaterlevel() { return charwaterlevel; } } //Main int main() { int i; //Calling the class function via member operator. i =TestGamePawn.getwaterlevel(); }
  4. Hello guys. I've only made a few posts here while I was (well, I'm still in the process of practicing) learning C++. I have since made the jump to using the Unreal Development Kit for my game projects. So far the Syntax is very similar to C++ which is helpful; however, I'm having a little problem Note: The reason I havn't posted to the Unreal Forums is that my account is currently not active and i am waiting in a Moderator Queue to allow me onto the forums. So I was wondering if anyone here knows Unreal Script and would be willing to answer a question I have. In C++ class functions and members can be accessed by the member operator '.' This seems to not be the case with unreal script. I'm trying to figure out how to call class member functions and access class members in Unrealscript for use with my HUD. Anyone know how accessing other classes works in Unreal Script?
  5. Actually it didn't change my program at all. The problem is that the computer is not waiting for user input at the 'getline'. It does this properly the first time through, however, it doesn't stop (doesn't work properly) after the loop. And actually, if it will help you, I can attach my current build. EDIT: Also, if it is helpful: 'charName' is a string class variable [ #include <string> | string charName; ] EDIT:EDIT: Also, How much money are we talking? Because even if I didn't add the braces and entered 'N' or 'n' the result would be the same. However, I will let you know I am glad you pointed that brace thing out, because when I actually did input 'Y' or 'y' it would have given me problems.
  6. I hate to be the bearer of bad news, but this did not solve my problem. However, I am taking your comment about indentation to heart.
  7. (NOTE: C++ in Viz C++ Express 2010) I hate to post again after posting something earlier today. I don't want to burden you guys, or wear out my welcome here. However, I have a problem that I have been working on for upwards of 30 Mins now, and I think I really need someone's input besides my own. so I have this function: void set_charName() { using namespace std; bool userSatisfied; char userInput; do { charName = ""; cout << "Name your character. Then press 'Enter/Return'. \n"; getline (cin,charName); //Entering a literal string here with whitespace. //Then: On loop, the program does not stop here (at 'getline') and allow the user to enter a new line for "charName" system ("cls"); cout << "You have decided to name your character " << charName << ", is this correct?\n (Enter Y/N)"; cin >> userInput; if (userInput == 'Y' || userInput == 'y') userSatisfied = true; else if (userInput == 'N' || userInput == 'n') { userSatisfied = false; system("cls"); } else cout << "Input not valid"; userSatisfied = false; system("cls"); } while (userSatisfied == false); } So, here is the problem: When I get to this part of the program, and enter a literal string, the function moves on as intended. Which is good; however, whenever I enter an 'n' or 'N' for userInput, the program loops, but does not pause and allow me (the user) to change the value of charName.
  8. Nope. It's just warning you that the same code may have had a different behavior in a prior version of Visual Studio. EDIT: Also: What does this error mean? "1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(16): error C2536: 'Character::Character::charstats' : cannot specify explicit initializer for arrays" [/quote] Drop the '0' between the parenthesis, and you're good. Also, if you want a detailed explanation of an error or warning, look it up on MSDN, or Google "msdn Cxxxx". For example, C4351 and C2536 [/quote] Yea, I've googled Error Codes in the past, but sometimes I don't understand the Microsoft Post. Sometimes it's helpful to get in lay-mans terms. Anyway, thank you very much for your help. And everyone else for theirs. I understand this all a lot better now.
  9. So is this warning not a bad thing? " 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(16): warning C4351: new behavior: elements of array 'Character::charstats' will be default initialized " EDIT: Also: [s] What does this error mean?[/s] Figured it out. I feel stupid. "1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(16): error C2536: 'Character::Character::charstats' : cannot specify explicit initializer for arrays" class Character { private: int charstats[5]; public: Character () : charstats(0) { } int statrecieve(int x) { return charstats[x]; } }; ALSO: Thanks for helping me. Sorry I'm a super novice.
  10. A "raw array" is a built-in type, constant-size array, which are quite rigid and unsafe (read: easy to shoot yourself in the foot, if you're not careful). (Raw arrays are typically contrasted with std::vectors. std::vectors are dynamic arrays, which can be resized, with automatic memory management, and extra safety checks when enabled.) int arr[] = {1, 2, 3, 4}; // <-- this is a raw array arr = {1, 2, 3}; //you aren't able to do change the size of raw arrays arr = {2, 3, 4, 5} // nor can you reassign their contents int foobar[5]; foobar = {}; // can't reassign contents Your error is on this line: charstats = {0}; chrastats has already been declared as int[5], and you can't reassign it's contents, so you have to use one of the methods described in my previous post. [/quote] I'm sorry for my ignorance, but... can you explain your Initalizer example above? I'm still not sure how that works. That is what I'm trying to use, an initalizer list. My main thing is, what is with the colon, and what looks like another function (meaning "charstats ()") EDIT: Excuse my stupidity. You provided me a link. XD DOUBLE EDIT: Ok, so I'm having a little bit of a problem understanding this page because I havn't reached the chapter on inheritance.
  11. Still having problems though: Current (Updated Code)): #include "stdafx.h" #include <iostream> #include <fstream> class Character { private: int charstats[5]; public: Character () { //Compiler Says The Next Line Is The Culprit Line. I know that it's not always the one that kicks the error though. charstats={0}; } int statrecieve(int x) { return charstats[x]; } }; int main() { using namespace std; return 0; } Current Compile Errors: " 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(17): error C2059: syntax error : '{' 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(17): error C2143: syntax error : missing ';' before '{' 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(17): error C2143: syntax error : missing ';' before '}' " Thanks Mr. Other Awesome guy. I now know about "this" and the fact I don't need "Character." But I still can't figure out where all these syntax errors are coming from. I believe my semi-colons are properly placed... gimme a sec to look over it again.
  12. First, members of objects should be accessed via the "this" pointer, either by "this->charstats = {0}" or "charstats = {0}". Second, C++ doesn't like raw arrays all that much. If you want to default-initialize your charstats, you can do either of the following: Initializer list: Character() : charstats() { } Fill: #include <algorithm> Character() { std::fill( charstats, charstats + 5, 0 ); } copy: #include <algorithm> Character() { int startstats[5] = { 1, 2, 3, 4, 5 }; std::copy( startstats, startstats + 5, charstats ); } Or DIY: Character() { for ( int i = 0; i < 5; i++ ) charstats = 0; } [/quote] Thanks for the help, I appreciate it. I feel like a noob saying this (because technically I am), but what exactly do you mean by Raw Array? EDIT: Also. As you can probably tell, I was trying to use an initalizer list. I was also wondering what the ' : ' colon is for in THIS: Character() : charstats() {
  13. BrandonSnider

    Concept Artist job definition

    I say it's a bit of both. My brother and I are the creative masterminds behind our world, which will hopefully be in a game sometime in the future, and we've done a lot of crappy concepts by hand. Our friend does some concept work for us, and by that we mean... He takes our shitty drawing and turns it into a masterpiece, and alters it until it's what my brother and I invisioned (or as close to). I believe the other point is valid too. On one of the crappy drawings we gave him, he returned with a concept that had a lot of changes to it... we liked the changes. It's nice for a concept artist to provide ideas for the group as well as just the designers. Although I see how this may not work in a big development studio.
  14. Ahhh so wait... I must missed this when I was fast-reading. The name of a constructor has to be the same as the class? Edit: I now have 4 Errors Kicked: 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(17): error C2143: syntax error : missing ';' before '.' X2 and the same error with brackets. It appears these are related to misplaced member operators and or semi-colons in the wrong place, but to the best of my knowledge my code is good, so can someone point them out to me? Also, my current code looks like this: #include "stdafx.h" #include <iostream> #include <fstream> class Character { private: int charstats[5]; public: Character () { Character.charstats = { 0 }; } int statrecieve(int x) { return charstats[x]; } }; int main() { using namespace std; return 0; } Also, Texus. You're cool because you're helpful and have an Abra icon
  15. That may be true, as it is a function, but that still doesn't fix the problem. It only adds more errors: New Compiler Complaint List after deleting ';' and recompiling: " 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(11): error C2059: syntax error : '{' 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(11): error C2334: unexpected token(s) preceding '{'; skipping apparent function body 1>c:\users\brandon\documents\visual studio 2010\projects\theworld\theworld\theworld.cpp(17): error C2065: 'charstats' : undeclared identifier " I understand the last one. My main problems are the C2059 and C2335 Errors.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!