Struggling a little
#1 Members - Reputation: 121
Posted 30 September 2012 - 10:27 AM
#2 Members - Reputation: 291
Posted 30 September 2012 - 10:42 AM
Here is a pdf, have a look at the introduction and see if you have learned all the 'days'. http://www.angelfire...lusin21days.pdf
My first game(school project) was: supersonic warrions 2: Dragonball
We had 2 months for it. So you can already make pong, try to make a game like this as well in a deadline of 2 months.
If you accept the challenge post your progress on this site. I gladly help you with any problem!
~EngineProgrammer
#3 Members - Reputation: 121
Posted 30 September 2012 - 10:49 AM
Hi GameC++Expert93. I would say, first check to be sure it you got all basics done.
Here is a pdf, have a look at the introduction and see if you have learned all the 'days'. http://www.angelfire...lusin21days.pdf
My first game(school project) was: supersonic warrions 2: Dragonball
We had 2 months for it. So you can already make pong, try to make a game like this as well in a deadline of 2 months.
If you accept the challenge post your progress on this site. I gladly help you with any problem!
~EngineProgrammer
Thanks for the link ive looked over it and can say i do have a pretty good understanding of all the days
#4 Members - Reputation: 291
Posted 30 September 2012 - 11:49 AM
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
{
Weapon();
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.
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.
~EngineProgrammer
#5 Members - Reputation: 121
Posted 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 { Weapon(); 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.
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.
~EngineProgrammer
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
#6 Members - Reputation: 121
Posted 30 September 2012 - 12:29 PM
[source lang="cpp"]#include <allegro.h>/***Our class that handles paddle 1 and paddle 2**/class Paddles{};/***Our class that handles the pong ball**/class Ball: public Paddles{public:int x;int y;int direction;int tmpX;int tmpY;void BallMoveRandom();void DrawBall();};void Ball::BallMoveRandom(){x = 330;y = 240;direction = 1;tmpX = x;tmpY = y;/***Set up a switch statement to handle 4 different directions**/switch(direction){case 1://Code for direction 1break;case 2://Code for direction 2break;case 3://Code for direction 3break;case 4://Code for direction 4break;default:direction = rand() % 4 + 1;}}int main(){ //Initialize Allegro allegro_init(); //Set the resolution to 640 x 480 with SAFE autodetection. set_gfx_mode(GFX_SAFE, 640, 480, 0, 0); //Install the keyboard handler install_keyboard(); //Loop until escape is pressed while(! key[KEY_ESC]) poll_keyboard(); //Exit program allegro_exit(); return 0; } END_OF_MAIN();[/source]
#7 Members - Reputation: 291
Posted 30 September 2012 - 01:00 PM
#include "GameTypes" // this will create a struct Position and Velocity
#include "Paddle.h"
class Ball
{
public:
Ball(Position pos, Velocity vel, int radius); // Create a ball with an initial position and velocity. Is not necessarily. radius: how big is the ball.
~Ball();
void Update();
void Draw();
void SetPosition(Position pos);
void SetVelocity(Velocity vel);
void IncreaseVelocity(Velocity velDelta);
void DecreaseVelocity(Velocity velDelta);
void Disable(bool draw); // You can use this when you make a countdown after a point has made. The Boolean will tell to to keep the ball drawn of hided from the screen.
void Enable(bool left); // This will create a random velocity for your ball. The Boolean will tell you what direction you want the random velocity go to.
void CollisionDetection(Paddle& paddle); // This will reserve the X-velocity when you hit a paddle.
private:
Position m_Position;
Velocity m_Velocity;
int m_Radius;
Hitregion* m_pHitRegion; // create new Hitregion.
bool m_bIsEnabled; // init of false
};And this is how my Paddle class should look like:
#include "GameTypes" // this will create a struct Position and Velocity
class Paddle
{
public:
Paddle(Position pos, Velocity vel); // Create a ball with an initial position and speed. Is not necessarily.
~Paddle();
void Update();
void Draw();
void SetPosition(Position pos);
void SetVelocity(Velocity vel);
void IncreaseVelocity(Velocityve velDelta);
void DecreaseVelocity(Velocity velDelta);
HitRegion* GetHitregion(); // return the hitregion of the paddle. This can also be a RECT if you like to.
private:
Position m_Position;
Velocity m_Velocity;
RECT m_Bounds; // how big the brick will be
HitRegion* m_pHitRegion;
};All methods will be handled in the main message loop. I'm not familiar with Allegro so I don't know how your keyboard will function to move your paddles. I also don't know how those messages are handled. So with using the methods of the class I can't really help you.
In the main you need to say something like:
ball.CollisionDetection(paddlePlayer1);
ball.CollisionDetection(paddlePlayer2);
The structs aren't hard to make:
struct Position
{
int x, y;
};
struct Velocity
{
int x, y;
};
Each gamecycle you say: m_Position += m_Velocity;So maybe you need to put an operator += in your struct ;)
~EngineProgrammer
Edited by EngineProgrammer, 30 September 2012 - 01:02 PM.
#8 Crossbones+ - Reputation: 1373
Posted 30 September 2012 - 01:30 PM
Whatever angle the ball starts at, it's always bouncing at the same angle, because the walls and the paddles are rectangles. So essentially, whatever angle it starts at doesn't change. Which means all you have to do is reverse speedx whenever the ball hits a wall and reverse speedy whenever the ball hits a paddle. All of this can be handled by a Check_For_Collision function that says if (Collision) {speedx = -speedx //or speedy = -speedy}. If you set these variables to random in the constructor the games different every time!
Here's Breakout:
Breakout!
If you need some photo editing done, contact me:
superman3275@gmail.com
if you want some programming help, or are recruiting for a game development team, either PM me on here or email me up there
#9 Members - Reputation: 291
Posted 30 September 2012 - 01:39 PM
Assume you want to write PONG REVOLUTION!..
And the features are:
- There is a boost pickup:
The pickup can boost your paddle movement speed, or increase the speed of the ball for a shorten time of for 1 hit.
- There is a a movement pickup:
This pickup will enable your paddle to move a little bit to the left or to the right for a shorten time.
I know it's only a pong game but you never know.. I always think while I create a class "What if I want that feature in that class in the Future?"
Meaning you already write the possibility of that feature. Meaning you don't need to change allot of code when you implement it.
That's my way of thinking, I don't recommend anyone to follow my way of coding though. Because I also need to ask for help to get my coding better.
~EngineProgrammer
#10 Members - Reputation: 121
Posted 30 September 2012 - 01:42 PM
This is how my Ball class should look like:
#include "GameTypes" // this will create a struct Position and Velocity #include "Paddle.h" class Ball { public: Ball(Position pos, Velocity vel, int radius); // Create a ball with an initial position and velocity. Is not necessarily. radius: how big is the ball. ~Ball(); void Update(); void Draw(); void SetPosition(Position pos); void SetVelocity(Velocity vel); void IncreaseVelocity(Velocity velDelta); void DecreaseVelocity(Velocity velDelta); void Disable(bool draw); // You can use this when you make a countdown after a point has made. The Boolean will tell to to keep the ball drawn of hided from the screen. void Enable(bool left); // This will create a random velocity for your ball. The Boolean will tell you what direction you want the random velocity go to. void CollisionDetection(Paddle& paddle); // This will reserve the X-velocity when you hit a paddle. private: Position m_Position; Velocity m_Velocity; int m_Radius; Hitregion* m_pHitRegion; // create new Hitregion. bool m_bIsEnabled; // init of false };
And this is how my Paddle class should look like:#include "GameTypes" // this will create a struct Position and Velocity class Paddle { public: Paddle(Position pos, Velocity vel); // Create a ball with an initial position and speed. Is not necessarily. ~Paddle(); void Update(); void Draw(); void SetPosition(Position pos); void SetVelocity(Velocity vel); void IncreaseVelocity(Velocityve velDelta); void DecreaseVelocity(Velocity velDelta); HitRegion* GetHitregion(); // return the hitregion of the paddle. This can also be a RECT if you like to. private: Position m_Position; Velocity m_Velocity; RECT m_Bounds; // how big the brick will be HitRegion* m_pHitRegion; };
All methods will be handled in the main message loop. I'm not familiar with Allegro so I don't know how your keyboard will function to move your paddles. I also don't know how those messages are handled. So with using the methods of the class I can't really help you.
In the main you need to say something like:
ball.CollisionDetection(paddlePlayer1);
ball.CollisionDetection(paddlePlayer2);
The structs aren't hard to make:struct Position { int x, y; }; struct Velocity { int x, y; };Each gamecycle you say: m_Position += m_Velocity;
So maybe you need to put an operator += in your struct ;)
~EngineProgrammer
Haha u write some pretty advance classes
if(key[KEY_UP] && paddleY > 0){
--paddleY;
}else if(key[KEY_DOWN] && paddleY < 410){
++paddleY;
}






