Sub's coding pool party

Member
✔️ HL Verified
🎈 Advanced
Joined
Oct 16, 2006
Messages
379
Best answers
0
Can you create a class diagram of your program? This usually shows you the problem.

I haven't done that many graphical C++ applications/games from scratch so I can't tell you for sure what to do.
What you could do is pass on pointers of different managers to the appropriate objects.
The following setup is based on the XNA framework and is in my opinion quite nice, but I'm not sure if Harsen's agrees on this one.
Perhaps I'm giving away too much right now, if so, sorry for that. I'm not telling you to do it this way, but it might give you some inspiration.

Snippet;
Code:
class IUpdateable { virtual void update(long gameTime); }
class IDrawable { x, y, width, height, virtual draw(long gameTime) }
class IPrimitve : IDrawable : IUpdateable { int r, g, b; //colors }
claas IScreen : IDrawable, IUpdateable { ScreenManager *screenManager, draw(), update() ... } 

class Application { ScreenManager *screenManager, GameManager *gameManager, InputManager *inputManager...}
class ScreenManager : IUpdateable, IDrawable { Application *application, IScreen *parent, Vector<IDrawable*> children ... }
class Circle : IPrimitive { int radius, bool filled, ... } 
class GameManager : IUpdateable { Application *application, IGameState *activeGameState, ...}
class GameScreen : IScreen { ... }

- Application
        ... ze application loop () ! 
	- ScreenManager 
		- GameScreen
			... do something like this->screenManager->getScreenSize() for example
			... children.push_back(new Circle());
	- GameManager 
		... do something like this->application->screenManager->createScreen(new GameScreen());
	- Input Manager
As you can see every class is responsible for it's own functionality, yet you can get to other managers using the application pointer if needed.
 
New Member
Joined
Nov 24, 2001
Messages
692
Best answers
0
I don't :p

You've now made your GameManager dependent on Application, which is in turn depends on basically everything, thus GameManager is now coupled to everything, which essentially destroys its reusability. Note that you also introduced a dependency loop Application->GameManager->Application, that you now need to get around with empty class declarations... I would say a GameManager should not need to know that an Application exists, and probably shouldn't need to know about the screenmanager either (one way to do that is to register the ScreenManager as an listener to updates in gamestates from the GameManager, another way is to have a third class run the game manager, take the game state and pass it to the screenmanager).

I'm not religiously against globals. If you're sure there is only one of a certain object, you're too lazy to pass it around in functions/constructors and it gets initialized at the start of your program a global is fine IMO. Most of the time it might be more elegant to use a singleton pattern there though (check your patterns book).
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
All right, thanks for the answers guys, I appreciate it. I'm going to stick with what I have now, the only one using the code is me at the moment and I know never to make another Application object. I'll look into making it a singleton if I think anyone else will have to work with it.
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
I haven't run into any problems, but I've been reading around and apparently you're supposed to avoid having any global SFML objects, as it could result in undefined behavior. So I broke my Application class up into two parts, with the global class having the random number generator, variables which tell you the camera and window size (and whether a point is within the camera), and an enum which keeps track of what state the program is in. I think that's a pretty reasonable tradeoff for global functions. The only change you can make from the global object is the program state.
 
Just a nice person :)
✔️ HL Verified
Joined
Jul 17, 2009
Messages
262
Best answers
0
Hey Sub,

You could easily over-engineer your project when you're splitting all the little things into classes.

In the perfect world you would create a framework with all the tools/functions you need into nicely named classes/namespaces (just like an internal game engine of a company). But I
suggest for a small/solo project like this one you should go with creating global functions just like your window size function is.

If you're sure that your program will only contain ONE Application variable and that you aren't creating properties in Application that access data that can be disposed, might throw error or worse return invalid data then
I don't see anything wrong with making it accessible everywhere especially when you're working on it alone.

Advise on using singleton:
1. Watch out with creating new properties that won't make sense to some classes in your program.
2. Prefer singleton over perfect time-consuming code.
3. Make sure all variables in your singleton class will return sensible data. Prevent nulls because it will be used throughout your program.
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
As usual, thanks Shoddie.

I'm working on a few different projects right now, because I can't decide on what I want to do. Long story short, I've started to work on my Civilization clone again. I've been trying to add underwater tiles (purely for aesthetic reasons). Admittedly I don't think they're an improvement yet, but it's not quite done, and so far it's been surprisingly annoying to implement, so rather than waste what I've done I'm going to keep trying to get it to look decent.



http://i.imgur.com/2s4Rq1J.png

Showed pretty shallow water, because it needs more improvement in deeper water...
 
Last edited:
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
Most of the games(projects) don't work.And the thing that i really like i can't even download it :p

But you re doing great Sub!
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
It looks like you're running Windows XP, which means that almost nothing that I made should work. Apparently things compiled with the default settings for Visual Studio 2012 don't work with Windows XP, and I didn't know that at the time I made everything on that list. So basically, it's Microsoft's fault.

I'd have to figure out the right settings, and then recompile everything. I'm not even sure if most of that stuff is in a compilable state.
 
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
I see...Thats too bad,i really want to try your stuff :p
:) :D goodluck bro!And make program for making animations!
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Thanks. It's not that bad though, all my stuff is terrible and barely playable regardless ;)

I'm still working on making the water transparent




I'm going to try making the deeper ocean tiles less transparent and darker and see what happens.

edit: Also, maybe make it a bit deeper...



final edit:
I could also leave the grid lines on the water
http://i.imgur.com/b2FEZwS.jpg
 
Last edited:
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
If you re very good at coding...maybe you should try and make a flash DBZ style game.
The only problem is...it takes alot of time!!

xD
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Did you make that signature you're using? I really like it.

Anyway, you've actually read my mind, sort of. Most of the reason I'm all over the place with projects is because I enjoy coming up with ideas and running with them until I run out of steam. A while ago I went through that process with a DBZ-like game. Apparently I posted a lot of videos of developing it on youtube

http://www.youtube.com/watch?v=wxhmR3WSc8g
http://www.youtube.com/watch?v=Rs7MMeUbo0I
http://www.youtube.com/watch?v=4dxFA3QFwPI
http://www.youtube.com/watch?v=ykvpOpsL1Ik
http://www.youtube.com/watch?v=j_eCLx9wpM4
http://www.youtube.com/watch?v=U04FhE_0sjI
http://www.youtube.com/watch?v=M1uhsL2oTn8

Currently thinking of a game using that prototype, sort of like a DBZ/Terraria/RPG mashup. I doubt I'll do it, but I like coming up with ideas like that. I actually pictured graphics similar to your sig, stylized stickfigures with ragdoll physics.
 
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
Did you make that signature you're using? I really like it.

Anyway, you've actually read my mind, sort of. Most of the reason I'm all over the place with projects is because I enjoy coming up with ideas and running with them until I run out of steam. A while ago I went through that process with a DBZ-like game. Apparently I posted a lot of videos of developing it on youtube

http://www.youtube.com/watch?v=wxhmR3WSc8g
http://www.youtube.com/watch?v=Rs7MMeUbo0I
http://www.youtube.com/watch?v=4dxFA3QFwPI
http://www.youtube.com/watch?v=ykvpOpsL1Ik
http://www.youtube.com/watch?v=j_eCLx9wpM4
http://www.youtube.com/watch?v=U04FhE_0sjI
http://www.youtube.com/watch?v=M1uhsL2oTn8

Currently thinking of a game using that prototype, sort of like a DBZ/Terraria/RPG mashup. I doubt I'll do it, but I like coming up with ideas like that. I actually pictured graphics similar to your sig, stylized stickfigures with ragdoll physics.
Yes,i made the signature.Thanks!
I used Macromedia flash 8...but i also have adobe flash cs6.I made alot of animations but most of them were a quick test.
I need to improve my skills and make a longer animation.Im not an expert :)
Im too lazy to do animations that don't include stickmans xD
That signature was also an rushed animation made in 15-20 mins.
Nice vids you got there bro :)
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Spent a lot of time learning some web based stuff -- HTML/CSS, Javascript, jQuery, Bootstrap, all that fun stuff. I'm also still plugging away at my civ clone (affectionately titled IT ALWAYS ENDS IN NUCLEAR WAR), which is honestly the project that I enjoy working on the most. It's pretty much the thing I work on by default.

So yeah, I've rethought a lot about how the game is going to function. I came up with some pretty bizarre concepts, but I've settled back to something which is akin to what I would have wanted out of a sequel to Civilization II (best version of Civilization!). Anyway, I rethought how I want units to work, so I reimplemented units and made some slight changes to the pathfinding. Check out my beautiful unit art, along with pathfinding to a whole two tiles away!

 
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
Spent a lot of time learning some web based stuff -- HTML/CSS, Javascript, jQuery, Bootstrap, all that fun stuff. I'm also still plugging away at my civ clone (affectionately titled IT ALWAYS ENDS IN NUCLEAR WAR), which is honestly the project that I enjoy working on the most. It's pretty much the thing I work on by default.

So yeah, I've rethought a lot about how the game is going to function. I came up with some pretty bizarre concepts, but I've settled back to something which is akin to what I would have wanted out of a sequel to Civilization II (best version of Civilization!). Anyway, I rethought how I want units to work, so I reimplemented units and made some slight changes to the pathfinding. Check out my beautiful unit art, along with pathfinding to a whole two tiles away!

http://i.imgur.com/pWUKlTz.png
You could use Battle for Wesnoth for somethin...
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
I've never played it. I tend not to like fantasy stuff, but I'll definitely check it out.

Anyway, I've added in a fog of war. A tile can either be unexplored (complete black), explored with fog of war (tile visible but visually darker and we can't see any unit currently on it), or explored without fog of war.



There are no grid lines in that picture because I'm currently considering getting rid of the grid lines by default (I'd leave an option in to enable it). I feel like it's hard to tell which tiles have fog of war, though, so if I do this, I'm thinking of making any explored tile without fog of war have a semi-transparent 1 pixel thick white line drawn around it.





Anyone have any thoughts on that idea?
 
Last edited:

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
I've been experimenting with different ways units can be implemented, which in turn means I've been playing with the combat model for the game. I think I have something that I like.

So in the civilization games, you build units which represent horsemen, or musketmen, or catapults, or whatever, and you move these units around and attack with these units individually. It's pretty abstract, you have no idea how many men are actually represented in these units, and to me, it never really made sense to have a unit called archers represent one discreet thing.

What I'm going to do is have one unit in the game called an army. The army is a container for different unit types. Essentially, a unit type is just a name along with two stats, number of men and combat effectiveness. There'd be a number of different army configurations you can build, but they'd all be preset, the player wouldn't have the option of assembling his own custom armies.

I'll give an example of something along the lines that I'm thinking of

ARMY: Total men: 23,000
Heavy Cavalry: 4,000 men, 5 effectiveness
Light Cavalry: 2,000 men, 3 effectiveness
Heavy Infantry: 16,000 men, 4 effectiveness.
Shield-bearers: 1,000 men, 8 effectiveness

Incidentally, that was a portion of the makeup of Alexander's army when he invaded Persia, although he had around 50,000 troops.

I wanted to have a representation of how many men were in an army, and I wanted it to be fairly simple, maybe a bit more complicated than Risk, so this actually works out pretty well. I built a prototype for it and it seems to work pretty well. Tanks would always beat spearmen under this model too, so that's pretty nice.
 
Last edited:
New Member
Joined
Aug 1, 2013
Messages
82
Best answers
0
Looks great so far!So you are making a RTS game like Age of mythology and other RTS's?It looks very interesting...If you re planing on making an RTS i ll definetly support it.:yes::smile:^_^;):rolleyes:
 

sub

Active Member
💻 Oldtimer
Joined
Jun 18, 2003
Messages
5,961
Best answers
0
Thanks for the kind words. You really need to play Civilization though :p

It's a turn based game. You start off with one city at the dawn of civilization and you have to grow your city, build other cities, raise armies, research technologies, compete with other civilizations, etc., all with the goal of thriving and reaching modern day without being wiped out. They're really good games.

http://en.wikipedia.org/wiki/Civilization_(series)
 

Users who are viewing this thread

Top