• 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.

Archived

This topic is now archived and is closed to further replies.

Fractal

cahar only allows a max of 5 characters...

6 posts in this topic

Im making a text-based computer game in DOS and one of my lines of code goes like this - int element; char player; if (element == ''1'') {player = ''fire'';} else if (element == ''2'') {player = ''earth'';} else if (element == ''3'') {player = ''forest'';} else {player = ''air'';} the error occurs in the words ''earth'' and ''forest'', the compiler tells me that they have too many characters, but ''air'' and ''fire'' are just fine. How could my problem be solved? Could I be any more dumber? (What do you mean, "No"?)
0

Share this post


Link to post
Share on other sites
Using single quotes is like saying ''The value of''. For example, the letter A has a numerical value. You shouldn''t be able to use any more then a single character in single quotes, so I dont know why it let the 3 letter words through.

What I would do, is make #define''s. For example:
#define FIRE 1
This would let you use the word FIRE, and the compiler replaces it with the value of 1 in the program itself. This allows you to place values for every element without having to do any drastic changes. Basically (I suck at explaining), you can use the word FIRE instead of ''fire'' which doesn''t work, and it would always represent a predefined number.

You can also use constants, which may be better, I believe it makes debugging easier when you made an error that would be harder to track using #define.

You could also use a character string (like char player[6] and store entire elemental words, but this may not be the best method. You would need to use strcmp() and maybe even strcpy().

I hope this helps in some way, explaining isn''t my best skill


If you can read this, All your base are belong to us!
0

Share this post


Link to post
Share on other sites
I''ll expand SirSmoke''s method slightly.

Rather than trying to assign strings of different length to the player variable, use a static string table (elements below) and use the player value as an index to that table.

char elements[5][] = {
"Fire",
"Earth",
"Forest",
"Air"
};

int player; // notice that player is now an integer!
//...
// if we get element as the input from the player
player = element;
//...
// now when we want to display the what the player is/uses:
cout << elements[player] << endl;

If the player is 1, you''d get "Fire" as your output.
0

Share this post


Link to post
Share on other sites
When I try this, I get two different errors, one goes like this:

"error C2117: ''Fire'' : array bounds overflow"

and the other like this:

"error C2087: '''' : missing subscript" which points at the "char elements[5][] = {" line.

Could I be any more dumber?
(What do you mean, "No"?)
0

Share this post


Link to post
Share on other sites
My bad. I think the only unspecified dimension permitted is the first. I''ll cook up another solution (when I get back later this evening). Meanwhile, you go read your documentation for once...
0

Share this post


Link to post
Share on other sites