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

pulpfist

Members
  • Content count

    1790
  • Joined

  • Last visited

Community Reputation

528 Good

About pulpfist

  • Rank
    Contributor
  1. Maybe this is the problem http://forums.asp.net/t/1239769.aspx/1
  2. It seems to me you are trying to separate the games event handling from the games content, but you are doing it in a way that convolutes your code in ways you don't want. Its hard to say though without the complete source.   The first thing that strikes me is, why do you have the GameItem inside the GameMechanics class? It doesn't seem right.   Another thing that strikes me is that the way the GameMechanics class is now, I would consider making it a static class with static variables/functions. Then I would put the GameItem somewhere else and pass it as an argument to Bounce.   [source]   class GameItem { }   static class GameMechanics {     const int SCREEN_WIDTH = 640;     const int SCREEN_HEIGHT = 480;               public static void Bounce(GameItem target)     {         // ...     } }   class Program {     static void Main(string[] args)     {         GameItem item = new GameItem();         GameMechanics.Bounce(item);     } } [/source]
  3. I would make a loop so that the program continues. Also, if you make functions that will continue to ask for input until the input is valid, you don't really need a default   class Program { static int GetOperand(string title) { int operand; while (true) { Console.Write(title + "\n> "); if (int.TryParse(Console.ReadLine(), out operand)) break; else Console.WriteLine("Invalid input. Try again"); } return operand; } static string GetOperator(string title) { string op; while (true) { Console.Write(title + "\n> "); op = Console.ReadLine(); if (op == "+" || op == "-" || op == "*" || op == "/") break; else Console.WriteLine("Invalid input. Try again"); } return op; } static void Main(string[] args) { int num1, num2, answer=0; string op; while (true) { num1 = GetOperand("Write Your First Number"); op = GetOperator("Write Your Operand"); num2 = GetOperand("Write Your Second Number"); switch (op) { case "+": answer = num1 + num2; break; case "-": answer = num1 - num2; break; case "*": answer = num1 * num2; break; case "/": answer = num1 / num2; break; } Console.WriteLine("Answer is " + answer.ToString()); } } }     edit: Don't forget to check for division by zero. If the denominator is zero, your program will crash edit2: For a more flexible design, search for "reverse polish notation", as Mercile55 mentioned
  4. I suggest you read up on classes, loops and lists (including the Dictionary)   If you do, you should be able to understand how this skeleton works   [source]   using System; using System.Collections.Generic; using System.Linq; using System.Text;   namespace RPG {     // A class representing a location in the game world     class Location     {         public Location(string description) // Class constructor         {             Description = description;             Exits = new Dictionary<string, Location>();         }           // Description of this location         public string Description;           // Available exits for this location (Could use a List instead, but I prefer a Dictionary)         public Dictionary<string, Location> Exits;     }       class Program     {                 static void Main(string[] args)         {             // A Dictionary of locations, representing the game world             Dictionary<string, Location> Locations = new Dictionary<string, Location>();                                   // Create the locations and add them to the "world"             Locations["Island"] = new Location("An island surrounded by turquoise water");             Locations["Town"] = new Location("A town with shops and houses");             Locations["Farm"] = new Location("A farm in the forrest");             Locations["Tavern"] = new Location("A tavern selling food and drinks");               // Connect the locations together             Locations["Island"].Exits["Town"] = Locations["Town"];             Locations["Town"].Exits["Island"] = Locations["Island"];               Locations["Town"].Exits["Farm"] = Locations["Farm"];             Locations["Farm"].Exits["Town"] = Locations["Town"];               Locations["Town"].Exits["Tavern"] = Locations["Tavern"];             Locations["Tavern"].Exits["Town"] = Locations["Town"];               // A reference to the "current" location             // This reference always points to the current location             Location currentLocation = Locations["Island"];                          // Game loop             while (true)             {                 // Print information                 Console.Clear();                 Console.WriteLine("You are here: " + currentLocation.Description);                                 Console.Write("You can go: ");                 foreach (string exit in currentLocation.Exits.Keys)                                     Console.Write(exit + " ");                                 Console.WriteLine();                   // Take input from player                 string input = Console.ReadLine();                 if (input == "Quit" || input == "quit") // Exit if the player types Quit                     break;                   // If the player typed the name of one of the current locations exits, update the current location                 if (currentLocation.Exits.Keys.Contains(input))                 {                     currentLocation = currentLocation.Exits[input];                 }                 else                 {                     Console.WriteLine("Can not go to " + input);                 }             }         }     } } [/source]
  5. [quote] [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Should I travel to the Himalayas and become a monk?[/background][/left][/size][/font][/color] [/quote] Nobody has commented on this yet so I might as well do it... I consider doing something similar to this myself after a couple of decades as a software engineer. I love writing software and create systems and I have done so against all odds all this time so I might as well be a monk doing it
  6. Aventurine is making a pretty ground breaking MMO these days =) 1. Python, Java and C# is commonly sugested as good beginner languages. For the Windows platform I would probably suggest C# over the others. 2. There is a _lot_ of game engines out there. I would say you should worry about that later. If you learn C#, Unity would be a good example of an interesting engine for a low budget. But again, there is hundreds of them. BTW. Greece will always be the number one european target for tourism, thats probably why germany want's a piece of it
  7. Hi, I'm not all that into OpenGL but if you provide more information and code maybe someone can spot the problem
  8. Which identifier is not found, is it GetKeyState or PlayerKeys? Is the PlayerKeys function declared before, after or inside the main function?
  9. This is a must have imo [url="http://net.pku.edu.cn/~course/cs101/2008/resource/The_C_Programming_Language.pdf"]http://net.pku.edu.cn/~course/cs101/2008/resource/The_C_Programming_Language.pdf[/url]
  10. [quote name='Brother Bob' timestamp='1331033139' post='4919733'] [quote name='pulpfist' timestamp='1331026662' post='4919711'] After that post from SegmentationFault, you got it, and I lost it. Everything is as it is supposed to be. [/quote] You are, of course, free to ask about what it is you don't understand... [img]http://public.gamedev.net//public/style_emoticons/default/ph34r.png[/img] [/quote] Thanks, but I'll chew on it first. I can't see how SegmentationFaults examples proves D.Chhetri's assumptions to be correct. Besides, it looks like a mix of C++ and C#. It's not important though
  11. After that post from SegmentationFault, you got it, and I lost it. Everything is as it is supposed to be.
  12. @D.Chhetri When I see a virtual function it tells me that if I have a pointer to base class of an inheritance hierarchy, and that pointer points to a type deep down into the hierarchy, C++ will travel all the way down to the correct type and call its version of the virtual function. Normal overridden functions does not have this property. Does that make sense?
  13. There is a few issues here First, you redeclare the enemyHealth inside the game loop. You don't want to do that, you want to use the enemyHealth that is already declared before the loop. The next thing to note here is that you pass the fightingGround by value to the fight function, so the fight function gets a copy of the fightingGround. Its important to understand that this copy contains pointers internally that still points to the same objects as the original fightingGround (the one created in main) And then at the end of the fight function you delete enemyFight, which is a pointer to the head of the list (both the original and the copy of fightingGround is affected by this!) I changed the code to pass the fightingGround by reference to the fight function so that no copy exists. I also removed int from the enemyHealth inside the game loop since redeclaring, and thereby hiding, the one declared earlier is not what we want. Finally, I moved the deletion of the player and the enemies to the end of main, which is the function that created them. This is probably not necessary but it makes the code path clearer Here is the result [code] #include<iostream> #include<string> #include<ctime> #include<cstdlib> using namespace std; class Player { protected: string* m_name; //players name int m_health; //the players health public: virtual int getHealth(); //returns the players health virtual int attack(); string getName(); //returns the users name Player(const string& name = " ", int health = 100); //constructor sets users name Player(const Player& aPlayer); //copy constructor ~Player(); }; Player::Player(const string& name, int health) { m_name = new string(name); m_health = health; } Player::~Player() { delete m_name; } Player::Player(const Player& aPlayer) { m_name = new string(*(aPlayer.m_name)); m_health = aPlayer.m_health; } int Player::getHealth() { return m_health; } string Player::getName() { return *m_name; } int Player::attack() { cout << "NOthing " << endl; int attack = 15; return attack; } class Warrior : public Player { public: int getHealth(); //returns warriors health int attack(); //the user attacks Warrior(string name = " ", int health = 100); }; Warrior::Warrior(string name, int health): Player(name, health) {} int Warrior::getHealth() { return m_health; } int Warrior::attack() { srand(time(0)); int choice; cout << "Pick an attack: " << endl; cout << "1 - Lunge" << endl; cout << "2 - Slash" << endl; cout << "3 - Stab" << endl; cin >> choice; switch(choice) { case 1: { int attack = ( (rand() % 20) + 1); return attack; } case 2: { int attack = ( (rand() % 25) + 1); return attack; } case 3: { int attack = ( (rand() % 15) + 1); return attack; } default: cout << "You choose an illegal move." << endl; } } class Mage : public Player { public: int attack(); //different attack for a mage Mage(string name = " ", int health = 100); }; Mage::Mage(string name, int health): Player(name, health) {} int Mage::attack() { srand(time(0)); int choice; cout << "Select an attack: " << endl; cout << "1 - Fire Blast" << endl; cout << "2 - Ice Strike" << endl; cout << "3 - Ground Strike" << endl; cin >> choice; switch(choice) { case 1: { int attack = ( (rand () % 30) + 1); return attack; } case 2: { int attack = ( (rand() % 25) + 1); return attack; } case 3: { int attack = ( (rand() % 35) + 1); return attack; } } } class Archer : public Player { public: int potion(); //add potion if user request int attack(); //attacks Archer(string name = " ", int health = 100); }; Archer::Archer(string name, int health): Player(name, health) {} int Archer::attack() { srand(time(0)); int choice; cout << "Select an attack: " << endl; cout << "1 - Short Range" << endl; cout << "2 - Long Range" << endl; cout << "3 - Potion" << endl; cin >> choice; switch(choice) { case 1: { int attack = ( (rand() % 20) + 1); return attack; } case 2: { int attack = ( (rand() % 25) + 1); return attack; } case 3: { int getPotion = potion(); return getPotion; } } } int Archer::potion() { int potion = 15; return potion; } class enemy { private: enemy* pNext; //gets the memory address of the next enemy string m_name; //enemies name int m_health; //the enemies health public: enemy* getNext() const; //returns the next pointer void setNext(enemy* next); //sets the next enemy on the list string getName() const; //returns enemies name int getHealth(); //returns health int attack(); //the computer attacks enemy(string name = " ", int health = 100); }; enemy::enemy(string name, int health): m_name(name), m_health(health), pNext(0) {} void enemy::setNext(enemy* next) { pNext = next; } enemy* enemy::getNext() const { return pNext; } string enemy::getName() const { return m_name; } int enemy::getHealth() { m_health += 100; return m_health; } int enemy::attack() { srand(time(0)); int attack = ( (rand() % 25) + 1); return attack; } class fightingGround { friend ostream& operator<<(ostream& os, const fightingGround& aFightingGround); private: enemy* m_pHead; //head of the chain public: void AddEnemies(); //adds enemies void DeleteEnemies(); //deletes enemies when done fighting void Clear(); //clears enemies int Attack(); //attacks the player the top user enemy* getHead(); //returns top pointer fightingGround(); ~fightingGround(); }; fightingGround::fightingGround(): m_pHead(0) {} fightingGround::~fightingGround() { Clear(); } enemy* fightingGround::getHead() { return m_pHead; } int fightingGround::Attack() { enemy* fightEnemy = m_pHead; srand(time(0)); int attack = ( (rand() % 25) + 1); return attack; } void fightingGround::AddEnemies() { cout << "Type in the name of an enemy: " << endl; string name; cin >> name; enemy* pNewEnemy = new enemy(name); if(m_pHead == 0) { m_pHead = pNewEnemy; } else { enemy* pIter = m_pHead; while(pIter->getNext() != 0) { pIter = pIter->getNext(); } pIter->setNext(pNewEnemy); } } void fightingGround::DeleteEnemies() { if(m_pHead == 0) { cout << "NO MORE ENEMIES" << endl; } else { enemy* pTemp = m_pHead; m_pHead = m_pHead->getNext(); delete pTemp; } } void fightingGround::Clear() { while(m_pHead != 0) { DeleteEnemies(); } } ostream& operator<<(ostream& os, const fightingGround& afightingGround) { enemy* pIter = afightingGround.m_pHead; os << "\nHere is a list of the enemies :\n"; if(pIter == 0) { os << "There are no more enemies.\n"; } else { while(pIter != 0) { os << pIter->getName() << endl; pIter = pIter->getNext(); } } return os; } void fight(Player* aPlayer, fightingGround& aFightingGround) { cout << "You've decided to fight, well this task isn't easy." << endl; enemy* enemyFight = aFightingGround.getHead(); int playerHealth = aPlayer->getHealth(); int computerHealth = enemyFight->getHealth(); bool loop = true; while(loop) { int attack = aPlayer->attack(); cout << "You hit a " << attack << "\n"; //int computerHealth = computerHealth - attack; computerHealth = computerHealth - attack; cout << "The computer has " << computerHealth << "\n"; int computerAttack = enemyFight->attack(); cout << "The computer hit " << computerAttack << "\n"; playerHealth = playerHealth - computerAttack; cout << "You have " << playerHealth << "\n"; if(playerHealth <= 0) { cout << "The computer has defeated you.." << endl; loop = false; } if(computerHealth <= 0) { cout << "You've beaten the computer !" << endl; loop = false; } } //delete enemyFight; //enemyFight = 0; //delete aPlayer; //aPlayer = 0; } int main() { int classChoice; Player* pPlayerClass; fightingGround theFightingGround; theFightingGround.AddEnemies(); cout << "Select a Class: " << endl; cout << "1 - Warrior" << endl; cout << "2 - Mage" << endl; cout << "3 - Archer" << endl; cin >> classChoice; switch(classChoice) { case 1: { cout << "You choose a Warrior." << endl; cout << "What is his name: " << endl; string name; cin >> name; pPlayerClass = new Warrior(name); break; } case 2: { cout << "You choose a Mage." << endl; cout << "What is his name: " << endl; string name; cin >> name; pPlayerClass = new Mage(name); break; } case 3: { cout << "You choose a Warrior." << endl; cout << "What is his name: " << endl; string name; cin >> name; pPlayerClass = new Archer(name); break; } } fight(pPlayerClass, theFightingGround); cout << "Welcome BACK !" << endl; delete pPlayerClass; theFightingGround.DeleteEnemies(); return 0; } [/code] The problem here is that the copy of fightingGround that fight receives will have its destructor called when fight returns (this deletes all the objects inside the fightingGround for both the copy and the original) The thing is that only the copy of fightingGround will have its m_pHead set to zero, so the fightingGround object that still exists in main has had all its objects removed under its feet without having its m_pHead pointer set to zero. This causes havoc when its destructor is called at program return. Passing the fightingGround by reference fixes this since there is no longer a copy around to mess things up with the m_pHead member. Basically, the way fightingGround is designed and implemented, you better not allow copies of it to exists. In C++ this is typically achieved by giving the class a private copy constructor and a private assignment operator.
  14. [quote name='D.Chhetri' timestamp='1330815720' post='4918994'] [quote name='YogurtEmperor' timestamp='1330795440' post='4918902'] It is forced virtual, and cannot be undone. Why don’t you try asking the opposite question? What if it could be non-virtual? Exactly what behavior would you expect, and how would it fit in with the “intentions” behind virtual overriding? L. Spiro [/quote] Using the example above, I would think that there is no need fo FastRunner::run to be virtual because( assuming vtable implementation ), the vtable only needs the address of FastRunner::run. Conceptually, I don't think it makes sense for FastRunner::run to be labeled virtual as well because when something is labeled virtual I would expect it to be overridden by a derived class. Wouldn't it be enough to just label IRun::run as virtual ? [/quote] I disagree. I think it would make more sense if FastRunner::run had to be labeled virtual, because it is virtual. And anyone deriving a class with a run function would know that run was virtual. I may be confused here but it seems to me that you argue that the last run function in the vtable doesn't have to be virtual because it is the last one in the table. If that is the case, you are wrong, because I want to derive a new class from FastRunner in a couple of years from now, and when I do, FastRunner::run will no longer be the last address in the vtable.