Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Sep 2012
Offline Last Active Oct 07 2012 01:29 PM

#4985424 Struggling a little

Posted by on 30 September 2012 - 12:05 PM

I'm sorry but I can't give my code away. Our game has been supported with a Game Engine from our docent Programming.

I assume allegro has matrices?
Check this game: http://www.rocksolid...ames/robokill2/

Play a few missions, but not to "play" but to observe.
Look how the robot is moved. Look from where the bullets are fired. Look what happens when a bullet has touched a wall. Look how many bullets a breakable box can take. Look at your inventory, map, checkpoints, items you can buy. You can drag and drop items, figure out(on paper) how you should make that work.
For all the things I said: use a piece of paper! Writing down is very important when you want to create a game.

If you aren't interested in this game find a game yourself and do the same thing. Look how the game mechanics work. Write it down, and figure out how you will code those mechanics.
You have trouble with applying it to programming games because you don't have a diagram/sketch. So make one after you got all the game mechanics.

You have game-logic, and game-creation-logic. And they are almost exact the same.
When you play a game for example COD, Your weapon has 40 bullets, you've shot 28 and you are in a safe area, you know you need to reload that moment.
So when you program the class Weapon and class Bullet, you know you need a method: Reload();
When you program a game it's important to find a structure through the game-logic.

This is sort of how my Weapon class of a COD game will look like: ( and I'm not even thinking at the game-creation-logic, just thinking how the weapon should work when I play the game. so at game-logic level )

class Weapon() // You know there are more than 1 type of weapon so I make this class a virtual class
virtual ~Weapon();

virtual void SetFireRate(int fireRate); // Maybe you can buff your character with faster firepower.
virtual void SetBulletDamage(int damage); // When you got a death-streak your character can be buffer with more damage the first kill.

static const int DEFAULT_FIRE_RATE = 4;
static const int DEFAULT_DAMAGE = 20;

virtual void Fire();
virtual void Reload();
virtual bool IsActive();
virtual bool IsPrimary();
virtual bool IsSecondary();
virtual bool IsOutOfAmmo();

virtual int GetMagazine(); // returns the size of how many bullets I have left in my magazine(arsenal)
virtual int GetAmmo(); // returns the size of how many bullets I have left in my ammo(so the total amount)

This is how I do it. just writing down the class + the methods. So I don't think at linking classes yet, or data members. Posted Image
After I got the methods ready of how I think my game will work. I create a diagram, sketch, structure, plan of how I will program that game.
Thereafter I just start programming class by class, method by method.
Sorry for the long post. Posted Image


Aww that helps put it into better perspective , maybe ill start by rewriting the game pong using a more organized way like you did above then send u the code and let you tell me how i did haha call me old fashion but i really get into building some of the older arcade games adding my own twist to them so maybe ill stick with things like pong,breakout, asteroids etc.. for now to get more into game programming then move onto things like RPGS

#4985233 Coding

Posted by on 29 September 2012 - 08:57 PM

As always id suggest allegro along side c++ if your a beginner its 100% free not pro/free version

#4984949 [SFML] I Finished Pong! I Can't Believe It!

Posted by on 28 September 2012 - 09:48 PM

First you store the variable as a integer, and that's what you increment when the paddle is hit.

Then, when ready to draw, you MyString.SetText() a std::string, not an integer directly.

//When paddle is hit...
score++; //Update the score.

//Convert the score to text.
std::string scoreAsText = convert_a_int_to_a_string(score); //'convert_a_int_to_a_string' is an imaginary function that doesn't exist.

//Set the new text.

//When ready to draw each frame
RenderWindow.Draw(MyString); //Or whatever...

To convert an int to a string, you could use std::stringstream.
std::stringstream is used to format text, similar to how std::cout works (same interface).
std::stringstream formattedText;
formattedText << "Score: " << score;

std::string convertedToText = formattedText.str(); //Turn the data stream into a std::string.

mm i could be wrong as to how pong works, but why would you update the score when the paddle is hit? i thought in pong the score should only be updated if that persons paddle does not end up hitting the ball

#4984895 Will teach c++ to beginners

Posted by on 28 September 2012 - 05:19 PM

No one is an expert in Programming eheh.(commented on your name) Posted Image

People can follow tutorials everywhere, maybe put some selling points of yourself on here so people are interested in you and can trust you?
Have you worked in teams on a game/project? Or have you just graduated and thinking you know it all now? Posted Image


nah just hard times and need some extra money :) but i love teaching ive taught languages like PHP before so thought it would be fun to teach a language as beautiful as c++ haha and when i put expert in my name i was just honestly making up a name lol your right no one you can really call an expert except idk maybe bill gates but none the less i love anything programming ive coded in PHP,JAVASCRIPT,PERL,some visual basic,C++ and a little python.