Jump to content

  • Log In with Google      Sign In   
  • Create Account


EngineProgrammer

Member Since 19 Aug 2012
Offline Last Active May 15 2013 04:11 PM
-----

#4987806 starting game engine

Posted by EngineProgrammer on 07 October 2012 - 06:28 PM


Win32, DIrectX, OpenGL:
Win32 is the standard library of C++. It's only supporting windows.
DirectX is the best choice, even it's not supporting cross-platforming yet. With the possibilities of this library you can create any application you have in mind!
OpenGL and DirectX were racing neck on neck a few years ago but they update of DirectX made OpenGL run behind. But it's an easy language to use.


Why do you drag Win32 into a discussion of graphics APIs? Win32 is not the C++ standard library for windows, Win32 is the basic Windows API which exposes Windows core functionality to developers.
The latest OpenGL release also made it basically on par with DirectX again, so there's no issue there. I also wouldn't expect DirectX to ever go cross-platform (at least not in a way condoned by microsoft), but that doesn't mean an engine shouldn't support DirectX even if that engine will be cross-platform.

If you want to make it open source, be sure to really have everything bug-free, error-free. You don't want the clients to complain about your engine, even it's open source.


There's no such thing as bug-free or error-free software Posted Image


Sorry for my misunderstanding about Win32. I meant the header file <windows.h> with Win32. And that can also be used to write a game engine with, so I dragged it into this discussion.

About OpenGL, my programming lecturer said 3 weeks ago that OpenGL is running behind DirectX and he is looking updates about programming stuff every day so I assume he is right. Posted Image
Though I should have checked first on their sites before posting it here. My apologize.
But still, I've programmed with OpenGL last year for a month, I think it was child coding to be honest. But in a year allot can happen of course. Posted Image


There is no such thing as a bug-free and error-free game engine?
Yes there is... With enough checking code, and a good team of programmers. Posted Image
But yes, it all depends on the client who uses your engine. If he can't work with it properly failing stuff will happen indeed. But that's not the fault of the engine but of the client. Still, a good engine would be prepared for moments like that and be sure to have enough error checking.

But my experience in programming isn't that much, I just try to help others with the knowledge I have at the moment.
If you can give me an example of an unfix-able piece that you can't keep error-free, please tell because I want to know. Posted Image


~EngineProgrammer


#4987801 starting game engine

Posted by EngineProgrammer on 07 October 2012 - 05:44 PM

Write games, not engines: http://scientificnin...mes-not-engines
If you, after reading the article, still want to write a game engine. Continue reading.

What can the game engine you have in mind do? Is it capable of cross-platforming(Windows,Mac,Xbox,Ps3,etc)? Do you want to work with Win32, DirectX, OpenGL, etc?
Is it a 2D or a 3D engine? Will it be commercial, open source, private?

cross-platforming:
To get the cross platforming done you need to check how a window is created on all consoles, how the type id's are called, etc.
Here are some defines that will help you:
#ifdef _WIN32 || _WIN64
#elif __APPLE__
	 #if TARGET_OS_IPHONE
	 #elif TARGET_OS_MAC
	 #endif
#elif __linux
#elif __unix
#elif __posix
#else // unknown platform
#endif

Win32, DIrectX, OpenGL:
Win32 is the standard library of C++. It's only supporting windows.
DirectX is the best choice, even it's not supporting cross-platforming yet. With the possibilities of this library you can create any application you have in mind!
OpenGL and DirectX were racing neck on neck a few years ago but they update of DirectX made OpenGL run behind. But it's an easy language to use.

Commercial, open source, private:
If you want to make a commercial engine like CryEngine, Unity... No chance on your own so forget this. Posted Image
If you want to make it open source, be sure to really have everything bug-free, error-free. You don't want the clients to complain about your engine, even it's open source.
If you want to make it private, I think you are better of with a simple framework instead of an engine. Posted Image


~EngineProgrammer


EDIT: I'm regretting this post immediately. Posted Image


#4986624 How Do You Plan?

Posted by EngineProgrammer on 03 October 2012 - 07:45 PM

Assume I want to create a game for example 'MotherLoad': http://www.miniclip..../motherload/en/

I write down everything I need. In this case:
- Tileable sprites for the dirt, copper, tin, etc
- sprite of a vehicle
- Bitmaps for buildings
- Bitmaps for menu's when your vehicle comes closes to a building
- Sounds
- Day/Night -> Bitmap of a sun that moves in a circle.

Ok I got kinda the basics. After this I draw on a piece of paper what classes I'll need and link them.
class main; // entry point of the application
class Window; class System; class Graphics; // will be created in the main.cpp
class Bitmap; class Sound; class Text; // stores handles to the images, fonts, etc
class Vehicle; // this will store an object of Bitmap for your vehicle.
class GameState; // will keep a state ( static int m_GameState = STATE_IN_GAME; // or STATE_MENU_MODE; such things.
class Game; // this will create all game objects, sounds, etc. Also checks collisions.
class Level; // contains information how the level looks like
class LevelProp; // props like dirt, copper, etc. Can be a virtual class and support sub-classes.
Linking I do with drawing arrows from class to class.

Still don't have any code.
Now I think "What possible methods can the classes contain?"
I give 1 example:
class Bitmap
{
public:
	Bitmap(string path); // Loads an image from a file
	~Bitmap();

	Bitmap* GetBitmap();

	void SetAnimationRect(RECT bounds);
	RECT GetAnimationRect();

	void StartAnimation(int from = 0);
	void StopAnimation();
	void PauseAnimation();
	void SetAnimationSpeed(int speed);
	void IncreaseAnimationSpeed(int speedDelta);
	void DecreaseAnimationSpeed(int speedDelta);

	void Render(int posX, int posY); // The position can also be stored and called with a method: SetPosition(int posX, posY);

private:
	HBITMAP m_hBitmap;
	RECT m_Bounds;
	int m_AnimationCounter, m_AnimationSpeed;
};

Of course this class sucks. Posted Image It was just an example so don't copy that one. Posted Image

And in case you are wondering, why not painting(Photoshop) and typing instead of drawing(on paper) and writing?
Answer: You only need to have a basic idea for your whole game. So don't waste time with with PS or Notebook.. Drawing & Writing goes allot faster.


~EngineProgrammer


#4985547 [SFML] Breakout Help :(

Posted by EngineProgrammer on 30 September 2012 - 05:37 PM

0xC0000005: Access violation writing location 0x00000005

I haven't looked into your code but this means 2 things.

1) You are trying to read on an address where no object has been created.
2) You are reading out of an array. example: m_Array[max+1];

I think it's here:
void Ball::Test_For_Collision(sf::FloatRect LeftWall, sf::FloatRect RightWall, sf::FloatRect Top, sf::FloatRect Bottom, Paddle MyPaddle, Block Blocks[20])
{
for (int index = -1; index < 19; ++index)
{
  if (Collision.Intersects(Blocks[index].GetCollision()) && Blocks[index].GetIsHit() == false)
  {
   speedy = -speedy;
   Blocks[index].SetIsHit(true);
  }
}

You start with index -1, but array[-1] is out of its memory. So memory access violation.


~EngineProgrammer


#4985535 Should you make games easy or hard?

Posted by EngineProgrammer on 30 September 2012 - 05:15 PM

If you want the average player to like your game, don't make it too hard.
Try to balance the easy and hard parts.

Get some content in your game that is only meant to the pro players. Like when you die you lose Everything what you have! But if you win, you gain everything the other player has. This can really gets frustrated even for pro players. If you don't know how to play you will probably lose.
This is a bit too hard indeed, but it's the point I'm trying to make. You need to game content that an average player just can't do.
And this will bring some limitations to the average player and they will lose some motivation. So then you need other content, more easy and meant for them. Battles to only gain some resources or money, average quests, etc.

Choosing a difficulty of a game can be pretty hard. If you don't know what to pick, pick something where an average player can have fun with. Pro players will stop playing your game if you only have average content because it's just 'too' easy for them. No challenge at all. But you'll have 70% Average players, 5% Pro's and 25% Noobs. So it's kind of easy which difficulty you should pick. Unless you want to aim for the pro's only. Posted Image


~EngineProgrammer


#4985513 Advice needed

Posted by EngineProgrammer on 30 September 2012 - 04:21 PM

When you let normal game characters die. It's more logic sense a soldier will die also. Some people won't mind if they don't but I'm pretty sure 2/5th of the players do mind.

So you want to make a world simulation. Every country has other laws. For example we aren't forced to go to the army. In some other countries you are forced to.
Meaning that country will have more soldiers and better trained. Because they sometimes need to join the military at their 16's.
Are you going to work with kings & queens? Marketing, business, factories, farms, etc?

A world simulation game can be quite huge.

But back to the point. Posted Image
- Let the 'game years' go very slow, so they don't die the first 5 minutes.
- The military needs technology. Try to balance the soldiers <-> Technology. The better the technology, the more stronger your army will be.
- In real life some countries have a million+ soldiers. So you need to make it possible a player also can get that amount of soldiers in a game-life.
- Also balance the intelligence and damage of a soldier. If a soldier go to the military from a young age, his intelligence is less.
- You can do all sorts of things with the soldiers. Working with experience, intell, damage, technology, economics will "make" your game. So don't only look at the soldiers in a world simulation. Posted Image

~EngineProgrammer


#4985473 I present: SFML SimpleGUI v1.0

Posted by EngineProgrammer on 30 September 2012 - 02:21 PM

Well I'm taking a look at it hehe. Posted Image
Just started looking at your Render_Button class.

If you use "using namespace sf" you don't need to put the 'fs::' infront of each fs function. Posted Image
Also when you start with animations there are some times you want to 'update' your Button.
Example: http://www.yasudastu...ttonBlueWM1.gif

so just call it: class Button. Render_Button seems like the button only can render. but has no actions. Posted Image Naming classes is a hard part for me also Posted Image

My Button looks something like this:
class Button
{
public:
	Button(int posX, int posY);
	Button(Image& image, int posX, int posY);
	~Button();

	void Update();
	void Draw();
	bool IsHit(); // returns true if you hover your mouse over the button
	bool IsPressed(); // returns true if you pressed with your left mouse button on the button

private:
	int m_PositionX, m_PositionY;
	Image m_Image;
	int m_AnimationSpeed; // this name is terrible xD
};

Your button class is decent! Posted Image Features can be: rotating trough matrices, move in a formation, etc
I'm not going to look at your other classes, I don't have plenty of time left. Posted Image


~EngineProgrammer


#4985469 Jump Feature Breaking My Game?

Posted by EngineProgrammer on 30 September 2012 - 02:04 PM

MrChrisnis, don't send your ipch, debug folder and the .sdf file. We don't need those files Posted Image
As soon as we open your project and rebuild those files are created again. Your rar file takes 12MB+ ... without the files from the sentence above your rar file should be around 170Kb.

By the way, I can't run your project. I think you have separated your your SDL files from your game files. Unless you have linked them in the properties? And also, I opened your project and looking at your code, honestly. I see allot of bad coding there.Posted Image

I'm sorry but I can't find the problem because I can't get out of your code.

When you make a player class you need to think a game-logic. How do you want your player to act in-game. You want to say: "I give you all info, you take care about it' A player has an AI, 'also in coding..'. the class needs to collect information around them and use them.

class Player
{
public:
Player();
~Player();

void Update(EnemyList* pEnemyList, LevelObjects* pLevelObjects;); // something like this, NOTE: this isn't done this way for big games.
void Draw();
};

Your player can receive the information about everything, there are design patterns for this, not showing them now. It's called the Observer if I'm correct.

So your Player can check if he has hit a wall, hits another player, has hit a player with a bullet, and so on. You just need to Update and Draw him in the main function.
To handle key/mouse input I would suggest you for now to use a global(or singleton) Input class. Which stores all the keyboard and mouse info.
I know singletons are bad.. But everyone, really every programmer has made a singleton is his life because it's 'cool' and 'easy' Posted Image
Though I don't know how SDL works, maybe you need to send all the input through the Update method also.

Have a look at this: http://www.angelfire...lusin21days.pdf
Look at the day 6: basic classes. Look at how they structure their classes.


~EngineProgrammer


#4985450 2d game background and level art

Posted by EngineProgrammer on 30 September 2012 - 01:17 PM

It depends.
And what do you mean exactly with hand drawn? Do you mean hand drawn in a software like Photoshop? Or drawn on paper and scanned?

A game like Warcraft 2: Tides of darkness. The sprites are drawn with a software(like we have Photoshop now) and made tileable. Warcraft is 2.5D I know but it can also be done for 2D games. It just depends on how your level need to look like.

Assume I want to make a maze game.
With this maze: http://www.colourbox...llustration.jpg I can't use anything tileable.
With this maze: http://i1-games.soft...-Map-maze_1.jpg I can use everything tileable.

Tiles are mostly drawn with software.(sometimes with support of photographs that will be used as a layer on the hand drawn picture to make it more realistic)
Backgrounds with no tiles are drawn with software also. But Photoshop is not really used for this. More something like Illustrator, to create vectors drawings.

And if you meant drawing, like drawing on paper. No that's not done for games. Unless you want to create a cartoony game maybe. Posted Image

This all said I'll repeat: it all depends on how your levels needs to look like.


~EngineProgrammer


#4985419 Struggling a little

Posted by EngineProgrammer on 30 September 2012 - 11:49 AM

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


~EngineProgrammer


#4985386 Pong Hit Detection

Posted by EngineProgrammer on 30 September 2012 - 10:12 AM

Actually I was thinking he was programming in C++.. Posted Image
I don't see a single tag it was C# so sorry for the misunderstanding!
And yes I also meant too much rectangles are created. There are only 2 paddles so there should be only 2 Rectangles. And 1 ball so 1 Circle(Or Ellipse, don't know what typedef you use in C#)

JDCAce, sorry for the non-mathematics terms, it was late so didn't really want to think on those English words ^^ (My native is not English)
I meant an addition of vectors. The ball has a velocity(represented as vector).

Example:
the ball has a position: X 24 Y 28 and a velocity of X -1 Y 2
Each time a gamecycle has past you need to add the velocity to the position. So next game cycle the ball has moved left/down and his position will be X 23 Y 30.
When the ball hits a paddle you calculate a new vector(with the angle the paddle and the ball has hit), you make a sum with that new vector and the velocity.

Here is a link, write down how a vector works in mathematics and try for your own to change it to computer language. It's very good practice.: http://programmedles...00/vch00_1.html
You will see in the future you will need mathematics now and then so I suggest you to buy a book. Posted Image


~EngineProgrammer


#4985043 Pong Hit Detection

Posted by EngineProgrammer on 29 September 2012 - 07:47 AM

You don't need 3 Rectangles on 1 paddle to calculate the movement of the ball.

- The ball has a velocity(X,Y) and a position(X,Y) as type: double or float. Each update you do m_Position += m_Velocity; So the ball moves depending on his velocity.
- Create 1 Hitregion(Rectangle) for 1 paddle
- When the hitregion of the paddle and the ball return true...
- Calculate a vector from the center of the paddle and the center of the ball.
- Merge that vector and the velocity of the ball.
- (This depends on how the vector is calculated) you might need to reverse the X-value of the new velocity so the ball goes the other way.

The new velocity will be added to the position of the ball. So if the ball hits the top of the paddle the Y-value will be less than if the ball hits the bottom of the paddle.
Have I explained the idea decently? Posted Image

Note: m_Velocity is a vector. Have a look in a book how vectors are calculated! m_Position is a Point, which has an operator += that add the velocity to the position.


Also. Try to avoid allocating and deallocating objects at run-time. Create the paddles and their hit-regions at compile-time. Posted Image
By the way are you having memory leaks? You are allocating Rectangles but aren't deallocating them in that function..... That function is called in a while-loop right? If so, you need to delete the Rectangles at the end of the function.


~EngineProgrammer


#4978574 Keeping Recourse Collection Entertaining

Posted by EngineProgrammer on 10 September 2012 - 07:58 AM

A nice example is Runescape.
Gathering resources (cutting trees, fishing, mining, etc) is fun because you gain levels through the gathering. And after a certain level you can gather better/more expensive resources which make you want to reach That needed level.

That's the number 1 reason why resource collecting in that game is fun. The second one is that they use quests.
For the quests you need a some requirements.(example: you need level 17 woodcutting, 10cooking, 35mining).
The quests give nice rewards meaning you also want to get those levels.(and you still gather resources on a fun way)

And then the third reason, when you reach around 90+ in a skill you can collect very expensive resources which you can sell to get rich fast. :-)


#4975447 RPG Inventory HUD

Posted by EngineProgrammer on 01 September 2012 - 09:16 AM

Hi Djfix,

You should have some classes with inheritance I suppose?
Class Item -> Class ItemSword, class ItemRing, class ItemPotion which all use the class Item.

If you have this I should recommend you to make 2 classes, class ItemList, class Inventory.

The ItemList class keeps every item, a dropped item and an item in the inventory. So all your items will be stored in this class using a vector.
The Inventory class only hold what you have picked up. To receive all the picked up items you want to say something like:

m_pInventory = m_pItemList->GetAllStoredItems();

So what this means if each item needs to have a bool which says it is stored or not stored.
Then to receive all the stored items you do something like this:
vector<Items*> ItemList::GetAllStoredItems()
{
	vector<Items*> tempVec;
	for(/* look through the vector */)
	{
		if(m_VecItems.at(i)->IsStored() {
		tempVec.pushback(m_VecItems.at(i));
	}
	}
}

This is how I should do it. Certainly there are better ways but this should do also.

EDIT: Ah you are working in Python? I have no idea how it works so I'm doubting Python uses classes. But you say you can handle each language so I won't edit the code I've written. :D Good luck.

~EngineProgrammer


#4975324 Tutorials - How to Learn a Game's Mechanics

Posted by EngineProgrammer on 31 August 2012 - 10:14 PM

The well known game "Runescape" has a nice way to learn their game mechanics. Posted Image

If you want to get your players motivated to keep playing try "Operant Conditioning".
In the game mario, if you pickup a mushroom there is an awesome sound and you grow. meaning you really want to pick another mushroom because it's good! This is Positive reinforcement. You receive a cool sound and you gain something.

But if you hit an enemy a bad sound appear and you shrimp or die. This is a negative and positive punishment. Negative because they take away a life, Positive because there is a bad sound.

You can go very, very far with psychology. The better you get these conditioning into your game. The more "addicted" you can make the player.




PARTNERS