• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

arkane7

Members
  • Content count

    29
  • Joined

  • Last visited

Community Reputation

213 Neutral

About arkane7

  • Rank
    Member

Personal Information

  • Location
    Los Angeles
  1. [quote name='littletray26' timestamp='1350595688' post='4991555'] If all you're actually trying to do is find the first empty space and replace it with an O then this would do it: [CODE] //Set all spaces to ' ' when you initialize the board for (int i = 0; i < 8; ++i) //Where 8 is the size of the board { board[i] = ' '; } //Then when you're wanting to replace the first empty space wth 'O' for (int i = 0; i < 8; ++i) { if (board[i] == ' ') board[i] = 'O'; } [/CODE] [/quote] if you do not put a break in that if statement, it will change ALL empty spaces into O's, rather than the first one you find If (board[i] =='') { board [i] = 'O'; break; } that way only one empty is changed also i think you may want 9 instead of 8; arent there 9 tiles in TTT?
  2. in basic terms a loop is a conditional setting for code within in the loop to continue to repeat execution. say you want to count the number of 1's in an array (an array is just a simple "list" of data in successive memory) int [50] myNum = { 1,2, 1, 3 1, ..... //fill in the rest with whatever you want}' now lets count the number of 1's int numOf1 = 0; int indexOfArray = 0; while (indexOfArray != 50) // this is a condition to stop the loop. when indexOfArray equals 50, the repeition of the following will stop //everything in the brackets will be repeated as long as the above condition is true { if (myNum[indexOfArray] == 1) numOf1++; //this counts the number of 1s indexOfArray++; //this allows you to go to the next element in the array; } now it will first start off with both variables at 0; then it will run the code in the middle. indexOfArray will only be at 1 after the first run through, so indexOfArray !=50 will be true. this will repeat the inner code 50 times, updating the variable everyloop; indexOfArray increments EVERY loop. while numOf1 only increments when it finds a 1 inside the array if you just did this while (true) {} this will run FOREVER because it is always true. while (false) {...} this will NEVER run becuase it is always false another example index = 0; while (myNum [index] != 1) { index++;} now it will only stop when you find a 1 inside the myNum array. if there is no 1 it will run forever sorry for not knowing python this is in C++
  3. reference: [url="http://www.engr.sjsu.edu/wbarrett/SortFind.htm"]http://www.engr.sjsu...tt/SortFind.htm[/url] just go down until it talks about sort this is how i learned to use sort. using a function that is basically a < operator bool lessOp (YourClass a, YourClass b) { if (a.attribute < b.attribute) return true else return false; } then with your vector of objects, just call the sort function from the algorithm library sort (vec.begin(), vec.end(), lessOp); /////// you're passing a pointer to your lessOp function; using this pointer sort will call your function to compare the objects or doing what the website i used above, just create a operator< function for you classes like this: bool operator<(const Cperson& left, const Cperson& right) { return left.lastname < right.lastname; } now whenever you have 2 objects of that class and you do this var1<var2 it will called that function above. just use your class instead of Cperson
  4. To add on what RulerOfNothing noted, there is a C standard function called strcmp use it like this if ( strcmp(str1, str2) == 0) do some stufff..... it returns an integer, if it is zero then the strings are equivalent. From what i know it will return a negative number if the first string is less than the second (the first nonequivalent letter/character has an ASCII number less than the second strings) and will return positive if the first nonequivalent letter in the first has an ASCII number greater than the seconds basically like this: [list=1] [*]strcmp(s1, s2) < 0 /// s1 < s2 [*]strcmp(s1, s2) > 0 //// s1> s2 [*]strcmp(s1, s2) ==0 //// s1 == s2 [/list] the library for this function should be string.h or stdlib.h (possibly cctype.h) but im not really sure and as stated by rip-off, it is much safer to use C++ strings instead. You dont need a special function, s1==s2 is defined for those strings, as is a multitude of varying features. just #include <string> (not string.h, the C-style one) and you're ready to go.
  5. why do you have c and temp objects? and more importantly, do you only have 1 type of items for each type of class? What I'm asking is wont you have like 3 different swords with various stats? or different clothing/gear? The way you have set this up it seems like you can't expand it, the user can't have 5 differente unique weapons or clothing, only 1 of each. What i can see is that you edit the temp ones to accomodate changes to the particular item, where it can be a different weapon entirely, but this still prevents the user from having many different items of the same type. If this system serves your purposes that is fine, but this seems like a bad design approach. It is very limited and if you want to make changes to it later you most likely have to change the entire thing. The point of recommending inheritance to aid you was to make this whole thing simlper, shorter and cleaner. Your item hierarchy is fine, its just your c and temp globals that make this very unusual. I will come back to this thread and post an expanded example of how you may approach this (i am currently at work and cannot risk typing on here for an extended amount of time). Like i said if your layout is working fine and your game is behaving how you want, you can just ignore me. I just want to help
  6. Bill Door, that is a similar but more elongated version of what Brother Bob was talking about. Why make a special delete function and use a for_each? that seems a waste of time, since you can just do the delete in the predicate function. this is what i did on a homework assignment where i had to delete dead game actors del_func (takes object type or type pointer) { if (dead) delete} iterator newEnd = remove_if (vec.begin(), vec.end(), del_func); vec.erase(newEnd, vec.end()); again this is all similar to what Brother Bob already mentioned
  7. just as JDGamedev mentioned, using OOP is your best bet at making it simple, shorter, and efficient (in some sense, since inheritance = virtual call table) As he said, start with a base Item class that has everything that will be in common to everything in the inventory (i recommend not only name/proportionns etc but also a "type", so you can request anything that is an item what kind of item it is so you can do proper management) from there make classes that inherit Item to be more specialized (armour, weapons, potions etc). Just keep a nice hierarchy but dont go too deep, as everyone know too many levels means a huge virtual lookup table (this is know when to use a subclasses function instead of a base classes function) Then all you have to do is keep a vector/list/whathaveyou of Item pointers, then whenever something is added (like a Spear for example), just add its pointer to the list. Whenever you want to use an item, just find it (using its name or type) and use it; if its a weapon or potion that has specific functions that Item does not have, as long as you know it is the correct type you can use type-casting and call the function (Anyone here is free to correct me if I am wrong)
  8. [sub][quote name='iam73' timestamp='1342709877' post='4960956'] Being new at programming, I'm really pulling my hairs on this one. Been searching and trying all kind of moves since yesterday morning but I'm at a point where I need directions. The problem I have is at compile time, while trying to pass a struct as a function argument - Visual Studio 2010 Ultimate is giving me a C2061 Syntax Error on my struct identifier in the function prototype. Here's my shortened code: [b]reader.h[/b] [source lang="cpp"] typedef struct _fntHeader{ char FontTag[8]; // (5 bytes) Data Identifier 'BBF2' unsigned long misc; // (4 bytes) Future use char desc[50]; // (50 bytes) Artist comments int iFirstASCIIId; // (4 bytes) First ASCII Id int iLastASCIIId; // (4 bytes) Last ASCII Id int iBitDepth; // (4 bytes) BitDepth of Font int iMaxFontWidth; // (4 bytes) Widest font size int iMaxFontHeight; // (4 bytes) Tallest font size int iCharSpacing; // (4 bytes) Extra layout spacing between characters int iCharLineSpacing; // (4 bytes) Extra layout spacing between lines (rows) short wTransColor; // (2 bytes) transparent color (packed) long lCharacterBufferSize; // (4 bytes) Size of font data } [b]fntHeader; <-----------------------------Do you want a variable called fntHeader???[/b] ... [/quote][/sub] [sub]i believe fntHeader is a VARIABLE of type _fntHeader. i think this might be a possible issue. I don't know if that was your intention or not but putting a name at the end also declares an object of that struct type. What i think you want is to have the struct be [u]called[/u] fntHeader. otherwise whenevr you use fntHeader there might be problems of interpretting it as the variable[/sub] [sub]what i think you want is this:[/sub] [sub]struct fntHeader {[/sub] [sub]//your code here };[/sub] [sub]As for your issue in the header file of GUI, do what Serapth said, just declare it as struct fntHeader; inside GUI.h, just dont use it inside the header. do all your implementations and uses of fntHeader inside GUI.cpp while including reader.h[/sub]
  9. you can pass as an argument, i would recommend using a const reference, like const struct& var. This saves memory and time of having to copy your struct onto the stack if you want you can also use a pointer, but const references relieve you of having to use pointer syntax Edit: [img]http://public.gamedev.net//public/style_emoticons/default/sleep.png[/img] Serapth beat me to it PS: instead of using a typedef, you could have just removed the "_" from _fntHeader [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]
  10. I think SOAL and rnlf are correct, you need every player to have a reference not create its own (though personally I would use a pointer but its all the same) Make the player class have a reference to a M [quote name='rnlf' timestamp='1342173357' post='4958724'] Are you sure you want every player to have her own map? Because that's what you are doing right now. What you want to do, is pass a reference to your map to the player, like this: [CODE] class Player { Map& m; public: Player(Map& map) : m(map) { ... old constructor code ... } }; in main: set up the map as you did before, then when creating the player: Player player(map); // or largeMap [/CODE] This way you only have one map for all players, all referencing the same data. If you do it the way you did, you create an empty map for every player, and one in your main, which you never use. [/quote] this is pefect, should easily solve the issue also SOAL you forgot to include a check inside the isValid function if it is less than 0. I don't know if std::vector does that check or not.
  11. Also don't forget that using malloc/calloc etc you must actually put [i]how many bytes[/i] you want to allocate. int* c = (int *) malloc( sizeof(int) * 30); // this will give you 30 elements of integers
  12. Why were you downvoted??? you were spot on in everything you mentioned. oh and yeah i completely forgot about 2[var] syntax. I never use it since its confusing. What do you mean overloading new? I'm not sure i've come accross that use of new Also monkeyboi other things about memory management:[list] [*]When using new, as stated before, it goes to the heap. If you allocate too many items, you will run out of memory unless you deallocate them. When you continually allocate memory but never free it, this is called a Memory Leak [*]To deallocate, you use the delete key word. say I put SomeClass* x = new SomeClass(); to deallocate it just use [u]delete x;[/u] (keep in mind this calls the destructor for SomeClass and frees the memory that x was pointing to, allowing later allocations to use that memory) but if you allocate an array you have to do something else; in the case of char* ca = new char[3]; you will have to use [u]delete [] ca;[/u] [/list]
  13. I first came accross std::string before i learned about char arrays. This was way back in HS in intro programming. But i feel you are right he needs to understand pointers, allocation, and buffer limitations. Key thinks that monkeyboi needs to know about C-style strings (aka char arrays): [list=1] [*]There must be a zerobyte/null byte inside that determines the end of the string. '\0' is the ASCII symbol for it, but 0 is also fine. When using strlen it counts the number of characters up until it find this zerobyte. This is why he had odd answers since the char[] was [b]undefined upon initialization[/b]. When you put char[4] tc = "123"; you are really putting '1', '2', '3', '\0', filling it up; this extra step of putting the zerobyte at the end is just a feature of c++ (and C i believe), but only when you put var = "___", if you do it by individual bytes (var[4] = 'b') you MUST put a zerobyte in manually (tc[4] = '\0') [*]Even if it has a zerobyte,[b] never [/b]access/overwrite an element outside of its bounds (dont ever use tc[-2] or tc[n], or any larger number, only 0->n-1 ). [*]Keep in mind the compiler will not warn you if you go out-of-bounds, since it doesn't really know the size of the array, only in the case of declaration and putting something too big will it ever tell you something (char [4] tc = "1234", was too big since '\0' is a fifth additional byte added on) [*]When you use new, it goes to the heap in the CPU memory, which is a special place for dynamically allocated memory, or run-time(?) allocation. [*]Always remember that char[] is still a pointer, as are all arrays. tc itself is the pointer to the first element of the array, as in the case above *tc would be '1'; *(tc+1) is '2', *(tc+2) is '3' and *(tc+3) is '\0'. When you use tc[0] or tc[2], it is just a "shorter" way of doing *(tc+2). [*]char* and char[] are in many ways equivalent, just char[] is explicity announcing its array property, while char* could just be a pointer to a single char or possibly pointing to the beginning of a char array [/list] edit: i put this in a post below but this needs to be mentioned along with this ----other things about memory management:[list] [*]When using new, as stated before, it goes to the heap. If you allocate too many items, you will run out of memory unless you deallocate them. When you continually allocate memory but never free it, this is called a Memory Leak [*]To deallocate, you use the delete key word. say I put SomeClass* x = new SomeClass(); to deallocate it just use [u][u]delete x;[/u][/u] (keep in mind this calls the destructor for SomeClass and frees the memory that x was pointing to, allowing later allocations to use that memory) but if you allocate an array you have to do something else; in the case of char* ca = new char[3]; you will have to use [u][u]delete [] ca;[/u][/u] [/list]
  14. any time you use the "new" or malloc (C-style) allocation methods, it goes onto the heap, contrast to putting it on the stack (any local variables for example, like int f =3) So indeed your array IS on the heap, since you used new. What I think Ameise was getting at is that since it is on the heap there is less chance of encountering important data, such as things like returning addresses (the place to go back to after a function call for example) which are stored on the stack (if you overwrite a return address it may very well cause a page fault and crash the program) Edit: the point is that you do not want to go out of bounds of any array or invalid memory. Even if you overwrite harmless data, you risk the opportunity to contaminate either your own program executing, the operating system, or other programs. This is why std::string is much better alternative to C-style strings (char[]) because you don't directly deal with pointers. Also it has its own size() function, as well a multitude of manipulating functions. All in all std::string is more flexible, useful, and easier.
  15. [quote name='monkeyboi' timestamp='1342113513' post='4958478'] [quote name='boogyman19946' timestamp='1342110453' post='4958460'] Just because it's outside of the array range doesn't mean it's outside of a memory block allocated to your program as a whole. [/quote] I remember the program will automatically chech if it is out of bound, and if it is there will be an assertion or something. I also try [CODE] char tc[4] = "123"; //char tc[4] = "1234";failed tc[5] = 0; // why this line could work?? [/CODE] [/quote] I think this is only because upon declaration the compiler KNOWS it only has 4 bytes in memory to use, so putting "1234" is actually 5 bytes since the zerobyte at the end. But when you just put tc[5], you are directly dereferencing a pointer and the compiler is not aware of the size of the memory is has 'access' to. I'm guessing the compiler basically says "Oh i see only 4 bytes not 5, error". But in the other case it just says "Oh put this byte in this memory address". it doesn't check to see if that is legal