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

AndrewBlalock

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

100 Neutral

About AndrewBlalock

  • Rank
    Member
  1. Hey,, your code is just amazing I like it... some user has posted this code in our portal
    http://www.programr.com/Games/tictactoe3
  2. [quote name='SiCrane' timestamp='1312749729' post='4845889'] C++ is case sensitive. At least one of your problems comes from the fact that isHitting is not the same as IsHitting. [/quote] You were right I know thats its case sensitive just didnt pick up on that thanks for the help
  3. I am learning about abstract classes and when I go through the example I am getting an error saying that I cannot use a class beacuse its base class is an abstract class. This is the abstract class that I am dealing with. [code] class GenericPlayer : public Hand { friend ostream& operator<<(ostream& os, const GenericPlayer& aGenericPlayer); public: GenericPlayer(const string& name = ""); virtual ~GenericPlayer(); // indicates where or not the generic player wants to keep hitting virtual bool isHitting() const = 0; // returns wethere generic player has busted - has a total greater than 21 bool isBusted() const; // announces the gnereic player busts void Bust() const; protected: string m_Name; }; GenericPlayer::GenericPlayer(const string& name): m_Name(name) {} GenericPlayer::~GenericPlayer() {} bool GenericPlayer::isBusted() const { return (GetTotal() > 21); } void GenericPlayer::Bust() const { cout << m_Name << " busts.\n"; } [/code] Now These are two players that are dervied from the GenericPlayer class. One is a Computer and one is a Player. [code] class Player : public GenericPlayer { public: Player(const string& name = ""); virtual ~Player(); // returns whther or not the player wants another hit virtual bool IsHitting() const; // announces that the player wins void Win() const; // announces that the player loses void Lose() const; // announces that the player pushes void Push() const; }; Player::Player(const string& name): GenericPlayer(name) {} Player::~Player() {} bool Player::IsHitting() const { cout << m_Name << ", do you want a hit (Y/N): "; char response; cin >> response; return (response == 'y' || response == 'Y'); } void Player::Win() const { cout << m_Name << " wins.\n"; } void Player::Lose() const { cout << m_Name << " loses.\n"; } void Player::Push() const { cout << m_Name << " pushes.\n"; } class House : public GenericPlayer { public: House(const string& name =""); virtual ~House(); // indicates wether the house is hitting - will alawys hit on 16 or less virtual bool IsHitting() const; // flips over firsts card void FlipFirstCard(); }; House::House(const string& name): GenericPlayer(name) {} House::~House() {} bool House::IsHitting() const { return (GetTotal() <= 16); } void House::FlipFirstCard() { if(!(m_Cards.empty())) m_Cards[0]->Flip(); else cout << "No card to flip!\n"; } [/code] Now I have a game class and which hands the computer and player objects and process them depending on which one they are using [code] class Game { public: Game(const vector<string>& names); ~Game(); // plays the game of blackjack void Play(); private: Deck m_Deck; House m_House; vector<Player> m_Players; }; Game::Game(const vector<string>& names) { // create a vector of players from a vector of names vector<string>::const_iterator pName; for(pName = names.begin(); pName != names.end(); ++pName) m_Players.push_back(Player(*pName)); srand(time(0)); // seed the random number generator m_Deck.Populate(); m_Deck.Shuffle(); } [/code] Now the game class is where I am getting my errors [font="Consolas"][size="1"][font="Consolas"][size="1"] cannot instantiate abstract class [/size][/font][/size][/font]and this is refering to both the Player and the House objects. But I thought that the GenericPlayer was the abstract class and I am not trying to initliaize any methods from that as I can see. Im kind of confused as to why this is happening. [font="Consolas"][size="1"][font="Consolas"][size="1"] [/size][/font][/size][/font]
  4. ok I figured it out I had commented the function decleration in the Lobby class when I was trying to figure out what was wrong so I uncommented it and made m_pHead private and it worked find. Thanks
  5. I changed the reference and also make Player *m_pHead in the Lobby class public but since the function is a friend in the Lobby class I thought that let you access the variable even though its private.
  6. [font="Consolas"][size="1"][font="Consolas"][size="1"]1>c:\users\andrew blalock\desktop\game lobby\main.cpp(109): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'Lobby' (or there is no acceptable conversion) [/size][/font][/size][/font]
  7. I am currently going through the book C++ through game programming 2nd edition by Michael Dawson. I am on the 9th chapter and the final excerise and Ive looked through it and understand whats going on and how its doing it but I cant get it to compile. There is one error. I have tried making stuff public or having another function that returns m_pHead as you will see where it is. I believe the error is in the overloaded operator function. Here is that function by itself. [code] ostream& operator<<(ostream os, const Lobby& aLobby) { Player *pIter = aLobby.m_pHead; os << "\nHere's who's in the game lobby:\n"; if(pIter == 0) { os << "The lobby is empty.\n"; } else { while(pIter != 0) { os << pIter->GetName() << endl; pIter = pIter->GetNext(); } } return os; }[/code] here is the whole code for the whole program to see it in its context. [code]// Game Lobby // Stimulates a game lobby where players wait #include <iostream> #include <string> using namespace std; class Player { public: Player(const string& name = ""):m_Name(name) , m_pNext(0) {} string GetName() const { return m_Name; } Player *GetNext() const { return m_pNext; } void setNext(Player *next) { m_pNext = next; } private: string m_Name; Player *m_pNext; // Pointer to next player in list }; class Lobby { //friend ostream& operator<<(ostream os, const Lobby& aLobby); public: Lobby(): m_pHead(0) {} ~Lobby() { Clear(); } void AddPlayer(); void RemovePlayer(); void Clear(); private: Player *m_pHead; }; void Lobby::AddPlayer() { // create a new player node cout << "Please enter the name of the new player: "; string name; cin >> name; Player *pNewPlayer = new Player(name); //if list is empty, make head of list this new player if(m_pHead == 0) { m_pHead = pNewPlayer; } // else find the end of the list and add the player there else { Player *pIter = m_pHead; while(pIter->GetNext() != 0) { pIter = pIter->GetNext(); } pIter->setNext(pNewPlayer); } } void Lobby::RemovePlayer() { if(m_pHead == 0) { cout << "The game lobby is empty. No one to remove!\n"; } else { Player * pTemp = m_pHead; m_pHead = m_pHead->GetNext(); delete pTemp; } } void Lobby::Clear() { while (m_pHead != 0) { RemovePlayer(); } } ostream& operator<<(ostream os, const Lobby& aLobby) { Player *pIter = aLobby.m_pHead; os << "\nHere's who's in the game lobby:\n"; if(pIter == 0) { os << "The lobby is empty.\n"; } else { while(pIter != 0) { os << pIter->GetName() << endl; pIter = pIter->GetNext(); } } return os; } int main() { Lobby myLobby; int choice; do { cout << myLobby; cout << "\nGAME LOBBY\n"; cout << "0 - Exit the program.\n"; cout << "1 - Add a player to the lobby.\n"; cout << "2 - Remove a player from the lobby.\n"; cout << "3 - Clear the lobby.\n"; cout << endl << "Enter choice: "; cin >> choice; switch(choice) { case 0: cout << "Good-Bye.\n"; break; case 1: myLobby.AddPlayer(); break; case 2: myLobby.RemovePlayer(); break; case 3: myLobby.Clear(); break; default: cout << "That was not a valid choice.\n"; } } while (choice != 0); return 0; }[/code] I understand what the code is doing like I said but I am curious why it wont compile. My understanding of the error is that it is not being allowed to access m_pHead at the beginning of the overloaded operator function beacuse it is private in the Lobby class. But since the function is declared a friend function in the Lobby class shouldnt it be allowed to access m_pHead. That is my understanding of friend functions.
  8. I was just going to stick with C++ since that is what I mainly have used and have some experience with it before. Also I am going to be a CS major as well. I am taking my into to programming class this fall in school and im pretty sure they start out with C if im not mistaken. I go to a community college and we had to do a flowchart/pseuedocode class before we could take a programming course. I will have my A.A. at the end of the spring semester and that summer I will start my core CS classes.
  9. Hey I have not programmed in about 3 - 4 years and even when I was programming I was still a beginner and never really got crazy into it and got my feet off the ground. Now I have more time and am getting more back into it. The farthest I ever got was making a simple console game that let you choose one 4 chars and then you would fight your way through 5 different monsters with different attacks. I never got to learning any graphics API's or anything. I am currently about to finish one of my old books called Learning C++ through Game Progamming by Michael Dawson. Now when I finish that I am picking up alot of stuff I have forgotten and I do know the book dosnt go that in depth but just gives you the basics and a starting point. But before I start mabye trying to learn a graphisc API like SDL or something similar I was wondering if I should go through a book like Thinking in C++. I know there are two volumes and if I should go through it should I do both volumes or just the second one. Or would just start programming and pick up stuff as I go. Any suggestions?
  10. yep that was it damm typos. I was looking for more of a logical error something wrong with how it was made not a typo.
  11. I have some programming experience but it has been a very long time since I have messed around with anything. I am currently using C++ and going through the book Beginning C++ through game programming by Michael Dawson second edition since it is a book I have used before but am stuck on the final project making Tic-Tac-Toe with references. I understand what refernces are and how they work but there is a logical error in my game and I know where it is happening but I can't find out why I know it is happening in the winner() function but im lost. Ive stepped though it with the debugger and cant figure it out any help would be appericated thanks. [code]// Tic-Tac-Toe //Plays the game of tic-tac-toe against a human opponent #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; //global constants const char X = 'X'; const char O = 'O'; const char EMPTY = ' '; const char TIE = 'T'; const char NO_ONE = 'N'; // function prototypes void instructions(); char askYesNo(string question); int askNumber(string question, int high, int low = 0); char humanPiece(); char opponent(char piece); void displayBoard(const vector<char>& board); char winner(const vector<char>& board); bool isLegal(const vector<char>& board, int move); int humanMove(const vector<char> &board, char human); int computerMove(const vector<char> board, char computer); void announceWinner(char winner, char computer, char human); // main function int main() { int move; const int NUM_SQUARES = 9; vector<char> board(NUM_SQUARES, EMPTY); instructions(); char human = humanPiece(); char computer = opponent(human); char turn = X; displayBoard(board); while(winner(board) == NO_ONE) { if(turn == human) { move = humanMove(board, human); board[move] = human; } else { move = computerMove(board,computer); board[move] = computer; } displayBoard(board); turn = opponent(turn); } announceWinner(winner(board), computer, human); system("PAUSE"); return 0; } void instructions() { cout << "Welcome to the ultimate man-machine showdow: Tic-Tac-Toe.\n"; cout << "-where human brain is pit against silicon processor\n\n"; cout << "Make your move known by entering a number, 0 - 8. The number\n"; cout << "corresponds to the desired board position, as illustrated:\n\n"; cout << " 0 | 1 | 2\n"; cout << " ------\n"; cout << " 3 | 4 | 5\n"; cout << " ------\n"; cout << " 6 | 7 | 8\n\n"; cout << "Prepare youself, human, The battle is about to begin.\n\n"; } // ask yes or no question char askYesNo(string question) { char response; do { cout << question << " (y/n): "; cin >> response; }while((response != 'y') && (response != 'n')); return response; } int askNumber(string questions, int high, int low) { int number; do { cout << questions << " (" << low << " - " << high << "): "; cin >> number; }while(number < low || number > high); return number; } char humanPiece() { char go_first = askYesNo("Do you require the first move?"); if(go_first == 'y') { cout << "\nThen take the first move. You will need it.\n"; return X; } else { cout << "\nYour bravery will be your undoing... I will go first.\n"; return O; } } char opponent(char piece) { if(piece == X) return O; else return X; } void displayBoard(const vector<char>& board) { cout << "\n\t" << board[0] << " | " << board[1] << " | " << board[2]; cout << "\n\t" << "------"; cout << "\n\t" << board[3] << " | " << board[4] << " | " << board[5]; cout << "\n\t" << "------"; cout << "\n\t" << board[6] << " | " << board[7] << " | " << board[8]; cout << "\n\n"; } char winner(const vector<char>& board) { // all winning rows const int WINNING_ROWS[8][3] = { {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6} }; const int TOTAL_ROWS = 8; // if any winning row has three values that are the same and not empty then we have a winner for(int row = 0; row < TOTAL_ROWS; ++row) { if((board[WINNING_ROWS[row][0]] != EMPTY) && (board[WINNING_ROWS[row][0]] == board[WINNING_ROWS[row][1]]) && (board[WINNING_ROWS[row][1]] == board[WINNING_ROWS[row][2]])); { return board[WINNING_ROWS[row][0]]; } } // if no one has won, checek for a tie no empty squares left if(count(board.begin(), board.end(),EMPTY) == 0) return TIE; // since no one has won and there is no tie return NO_ONE; } inline bool isLegal(int move, const vector<char>& board) { return (board[move] == EMPTY); } int humanMove(const vector<char>& board,char human) { int move = askNumber("Where will you move?", (board.size() - 1)); while(!isLegal(move,board)) { cout << "\nThat square is alread occupied, foolish human.\n"; move = askNumber("Where will you move?", (board.size() - 1)); } cout << "Fine...\n"; return move; } int computerMove(vector<char> board, char computer) { cout << "I shall take square number "; //if computer can win on next move take it for(int move = 0; move < board.size(); ++move) { if(isLegal(move,board)) { board[move] = computer; if(winner(board) == computer) { cout << move << endl; return move; } // done checking this move, undo it board[move] = EMPTY; } } // if human can win on the next move, block it char human = opponent(computer); for(int move = 0; move < board.size(); ++move) { if(isLegal(move,board)) { board[move] = human; if(winner(board) == human) { cout << move << endl; return move; } // done checking this move, undo it board[move] = EMPTY; } } // the best moves to make, in order const int BEST_MOVES[] = {4,0,2,6,8,1,3,5,7}; for(int i = 0; i < board.size();++i) { int move = BEST_MOVES[i]; if(isLegal(move,board)) { cout << move << endl; return move; } } } void announceWinner(char winner, char computer, char human) { if(winner == computer) { cout << winner << "'s won!\n"; cout << "As I predicted, human, I am triumphent once more - proof\n"; cout << "that computers are superior to humans in all regards.\n"; } else if(winner == human) { cout << winner << "'s won!\n"; cout << "No, no! It cannot be! Somehow you tricked me, human.\n"; cout << "But never again! I, the computer, so swear itself.\n"; } else { cout << "It's a tie.\n"; cout << "Your were most lucky, human, and somehow managed to tie me.\n"; cout << "Celebrate.. for this is the best you will ever achieve.\n"; } } [/code]
  12. I would agree to wait untill college untill physics. I dont have much of a game progamming background but im in school right now to start my CS degree. But high school physics is alot different then physics with calculus same general material different workload and looked at differently. I would say trig first or both at same time if you need to but there is alot of tri involed in calc as far as knowing which trig functions are inverses etc as well as domain and ranges it would be easier if you know those. This is just coming from a math background as I am still learning programming at the moment but I am taking calc 3 and physics 2 starting this fall.
  13. I am working on a project for my C programming class and I have the whole program done. Now we have just started the class so we dont know much but I do have some other programming experience. I get the program to run through the first time with a selection but the it will display the info once more but wont let the user selection another option after the first time it jumps right to another function and I am not sure why. I have changed stuff around and tried to figure it out but I can so if someone could point me in the right direction or give me a hint anything would be helpful thanks. [code] #include<stdlib.h> #include<stdio.h> #define SALES_TAX .07 #define INCHES_IN_FEET 12 #define COVERAGE_BAG 2 void display(); char entry(); float mulchBed(); float numberOfBags(float area); int main() { printf("welcome to Andrew's Home Improvement Store!\n\n"); // variables for different types of mulch using parallel arrays float mulchPriceOne = 3.97; float mulchPriceTwo = 4.97; float mulchPriceThree = 2.25; float area; // the area of the mulch bed float bags; // number of bags of mulch float mulchPrice; float price; float tax; float totalPrice; char mulchType; mulchType = entry(); while( mulchType != 'Q') { if(mulchType == 'E') { printf("You choose the Earth Gro mulch\n."); mulchPrice = mulchPriceOne; } else if(mulchType == 'N') { printf("You choose the Nature Scapes mulch\n."); mulchPrice = mulchPriceTwo; } else if(mulchType == 'G') { printf("You choose the Gardens Pro mulch\n."); mulchPrice = mulchPriceThree; } area = mulchBed(); bags = numberOfBags(area); price = mulchPrice * bags; tax = price * SALES_TAX; totalPrice = price + tax; printf("The area of your mulch bed is %.0f square feet\n", area); printf("The number of bags you will need %.2f bags\n", bags); printf("The price of your mulch will be $%.2f\n", price); printf("The tax on your bags will be $%.2f\n", tax); printf("The total price including sales tax will be $%.2f\n\n\n", totalPrice); mulchType = entry(); } printf("Results were provided by Andrew Blalock") return 0; } void display() { printf("Mulch\t\t\tSq Footage\t\t\tPrice Sq Ft\n\n"); printf("Earth Gro\t\t\t2 cu ft\t\t\t$3.97\n"); printf("Nature Scapes\t\t\t2 cu ft\t\t\t$4.97\n"); printf("Gardens Pro\t\t\t2 cu ft\t\t\t$2.25\n\n\n\n"); } char entry() { char selection; display(); printf("Choose what type of mulch you wish to purchase or exit the program.\n"); printf("(E)Earth Gro\n(N) Nature Scapes\n(G)Garden Pro\n(Q)Quit\n"); scanf("%c", &selection); return selection; } float mulchBed() { int length; int width; int depthInches; float depthFeet; printf("What the is length of you mulch bed going to be(in feet):"); scanf("%i", &length); printf("What the is width of you mulch bed going to be(in feet):"); scanf("%i", &width); printf("What the is depth of you mulch bed going to be(in inches):"); scanf("%i", &depthInches); depthFeet = depthInches / INCHES_IN_FEET; float area; area = length * width * depthFeet; return area; } float numberOfBags(float area) { float bags; bags = area / COVERAGE_BAG; return bags; } [/code]