Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by SkylearJ

  1. SkylearJ

    I Have Returned!

    Hey, guys! I've returned to GameDev and I'll be bringing my BattleGame project along with me. For those who've been waiting these past few months to finish up, I'll be doing so this week. Recently, I've been trying to establish my website/company and started on an animation project, so I've been busy. Anywho, I'll be posting Part 3 soon!
  2. [color=#ff8c00]Introduction![/color] Hello again, people! In Part 2, we're going to fill out all the .cpp files we made last tutorial. These are the meat and potatoes, the thing that makes it all run, what'll give us our game (mostly)! Hopefully the last tutorial was easy to follow, and you've already prepared the headers for everything we'll be doing here. [color=#ff8c00]Coding Time![/color] Alright, first off, we're going to create the attack types we defined in Being.h. Open up the Being.cpp you made yesterday, and type this:#include "Being.h"using namespace std;void Being::meleeAttack(Being& target) { target.health -= baseDamage; cout
  3. [color=#ff8c00][font=verdana]Introductions![/font][/color] [font=verdana]Hello everehbody! [/font] [font=verdana]This is my first journal entry/tutorial here on GameDev, and I hope I do a good job at explaining the concepts I want to get across. This tutorial series is mainly aimed at beginners (given the blog's name) and I hope it's simple enough.[/font] [color=#ff8c00][font=verdana]What We'll Be Making.[/font][/color] Using the fantastical language of C++ (which is what this blog is primarily for), we'll be making a turn-and-text-based combat game. [font=verdana]"What's a turn-and-text-based combat game," you ask? Well, you'll see by the end of this tutorial.[/font] [font=verdana]The point of this series is to introduce beginners to the basic game loop and to simple algorithms, such as would be seen in any basic RPG game. We'll be making a game where you have a set of things you can do while fighting an enemy.[/font] [font=verdana]The target product of the first few tutorials is a game where you:[/font] [font=verdana]Have an intro to set your name[/font] Allow the player to allocate his/her stat points to various upgrades Allow the player to choose what enemy he/she will be fighting Give the player three options during combat: Melee Attack, Gun Attack and using a Health Potion Create an enemy that can perform all three of the above Hopefully, as we go along, this list will become more apparent. [color=#ff8c00]Let's Get Started![/color] Alright, so fire up whatever IDE you're using and let's get started! So, first off, we're only making the barebones of the system in this tutorial. We'll be implementing an Engine later. Open up a new C++ file and name it Being.h.#ifndef Being_h#define Being_h#include class Being { protected: std::string name; int health, maxHealth; int baseDamage, damage, gunDamage; int ammo, maxAmmo; int potions, maxPotions; public: void meleeAttack(Being& target); void gunAttack(Being& target); void useHP(Being& target); std::string getName(); int getHealth(); int getAmmo(); int getPotions(); void Reset();};#endif What're we doing here? This is actually pretty simple. We're going to use inheritance to make our Character and Monster classes smaller and simpler. In Protected, we're defining the values that both Character and Monster will need. Protected makes sure that only Being and it's 'children' will be able to get/modify those values. In Public, we're defining the methods that other classes (outside of Character and Monster) will need to use; for example, since string name; is a Protected value, we'll need some way for other classes to find out what that Being's name is. The attack types will also need to be used outside of Being. Not too bad, right? Grab a cup of joe and let's continue. Alright, so we've got our Being class now. Create a new file and name it Being.cpp, but leave it alone for now. Create a new header file and call it Character.h. Put this stuff in it:#ifndef Character_h#define Character_h#include "Being.h"class Character : public Being { public: Character(string newName, int newHealth, int newDamage, int newAmmo, int newPotions); void Display();};#endif Much shorter, thanks to Being. Time for explanations! Character is inheriting all the values that Being.h has, and that's why we don't need to redefine all the ints. You can call Character a 'child' of Being. Like before, make a new file called Character.cpp and leave it be. Now, we're going to need to be able to create a Monster just like we will for Character. Create a new header called Monster.h.#ifndef Monster_h#define Monster_h#include "Being.h"class Monster : public Being { public: Monster(string newName, short newHealth, short newDamage);};#endif Hopefully, this is self-explanatory. Monster is also a 'child' of Being, since we're inheriting it from Being as well. If you haven't noticed, we're defining fewer values in Monster's constructor; this is because (for now) Monster will only have the Melee Attack type. Once we delve into a more involved combat system, we'll give the monsters their own special attacks. [color=#ff8c00]Mortal Combat~![/color] I'm sure you've gathered what class is next, based on the title of this section. We'll need to have our Combat class up and ready for the next part of the tutorial, and I think this will be the most interesting part of our game.#ifndef Combat_h#define Combat_h#include "Character.h"#include "Monster.h"class Combat { private: Monster& M; void combatChoice(Character& C); public: Combat(Monster& newM); void combat1(Character& C);};#endif Although the class itself is small, our Combat.cpp is going to be pretty involved. Alright, time to explain the things we see in here... Monster& M; - This is creating a reference to Monster, and it's how we'll be affecting the monster in Combat.cpp. Our reference here will be referencing the instance of the Monster we'll make in Main.cpp. Combat(Monster& newM); - This is Combat's constructor, which is how we'll create new combat instances for when we start a fight with a monster. We're referencing a new Monster here, similar to Monster& M. void combatChoice(Character& C); - Here, we're going through loop for the player's options in battle. We're referencing the Character instance (or object?) that will be created in Main.cpp. void combat1(Character& C); - This will be the loop for our combat. We'll use this to go through the attacks, and check to see wether or not the Monster died. We're referencing the Character instance (or object?) here. Simple enough, right? Now, the reason we're putting our reference to Monster (Monster& M) and our combatChoice() into Private, is because only Combat will need to use these. For an explanation of the reasons behind using Public, Private and Protected, click here. [color=#ff8c00]Conclusion[/color] Well, we've set up all the classes we'll need to begin our game, and that's what we'll be doing in the next part. Hopefully I get it out by tomorrow, or tonight if I'm lucky. Leave all the feedback, positive or negative, you want! I'm taking all criticisms into account.
  4. First off, learning the basic game system would be the best start. If you're planning on graphics, look for tutorials on recreating classics like Pong. If you want to learn basic game structure, there are badoodles of tutorials on here that can get you started. I've been working on my own tutorial series for beginning game programmers. ^_^   As for what language to choose; that's all up to you. I'd recommend the SFML library for 2D games, though OpenGL can do it, as well.
  5. SkylearJ

    Let's Make: BattleGame! [Part 2 - The Meat]

    Thanks for your feedback, BeerNutts!   I actually didn't mean to put the random values in just yet; forgot to edit those out when I copied it from my project. Thanks for pointing those out, 'cause now I can improve my code once more. :P   As for using Being's constructor to construct both Monsters and Characters; I don't know how to apply that. Could you send me a PM with an example if you have the time? ^_^   Thanks again!
  6. SkylearJ

    Let's Make: BattleGame! [Part 1 - Classes]

    Thanks for those tips, Frob!   I edited the code here again, and hopefully minimized on unused headers. I usually include anything that need to be included in the header, and then just include the header in my .cpp files. I missed the mark by forgetting that, since I'm using inheritance, I wouldn't need to include iostream into Character and Monster, haha.   Hopefully I fixed most, if not all, of the issues you pointed out.   Thanks again! ^_^
  7. Well, after a bit of thinking, I decided to begin making a tutorial series for beginning game programmers. Of course, it's primarily in C++, so you'll need to have a little background in it, but it's overall (hopefully) easy to follow.   You can check out the first part here.   Second part published!   I want lots o' feedback on it.        The forum needs a Delete Post button. 
  8. SkylearJ

    Starting a Simple Series for Beginners

    Sorry for the double post, but part 2 was released, and I'm gonna bump this thread up for the newbies. 
  9. SkylearJ

    Starting a Simple Series for Beginners

      Ah, musta been because it was a draft. Try again. :)
  10. SkylearJ

    Starting a Simple Series for Beginners

    I redrafted the first part, and hopefully it's better.    EDIT: Apologies for double posting... 
  11. SkylearJ

    Let's Make: BattleGame! [Part 1 - Classes]

    Thanks for your feedback, Juliean!   At this point, I'm actually writing this program myself, while teaching it as I go along. Right now, I don't see much use for Private. I think I could put some things into Private later, but we'll see once I release Part 2. Also, I'm not entirely sure how composition works, so I'm going to use the method I've tried-and-tested.   As for it's 'absolute beginner' aspect, I'm hoping that whomever decides to read this has enough C++ background to understand what's going on here. It's fairly simple to myself, and I included a couple links that might help.   I know it's not the most efficient design, but I'll be changing that in future tutorials.   Thanks again! ^_^
  12. Working on the Let's Make: BattleGame! tutorial series. :D
  • 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!