C++ Progress ish

The Partridge Family were neither partridges nor a family. Discuss.
ceofil
Posts: 39
Joined: April 13th, 2017, 8:35 pm

Re: C++ Progress ish

Post by ceofil » May 21st, 2017, 6:04 pm

It seems like a lot to learn for now. I mean I will definitely learn it at one point but until then I think this method of mimicking is good enough. Anyway...just finished the game. Same github link. Definitely check it out. I think it's the first project I'm actually proud of. Except some bugs (colliding with the wall corners) and player walking backwards to another player. I will try to fix them in the next few days, probably do a little bit more research, I mean, somebody must have had this problem before. Did a little bit of commenting, hopefully this will make it easier to read. There is some code that probably does not make sense. The code related to Text.h. In the future I will probably make some functions to alight stuff automatically.
Anyway. If you have any suggestion or anything to say, I really appreciate any kind of feedback. Really. Have a nice day.
Image

Edit: forgot to mention the instructions for the game...it is not very intuitive.
Esc to pause, enter to start.
If you are in pause mode you can make walls by clicking and releasing the mouse (like making rectangles in paint) and ctrl-z to delete the last wall created.
To move: Arrows and ctrl for player 1, wasd and space for player 2

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: C++ Progress ish

Post by chili » May 23rd, 2017, 1:26 am

I'll definitely be taking a look at this when I get some time. Looks pretty good man (from the screenshot).
Chili

User avatar
krautersuppe
Posts: 91
Joined: September 14th, 2015, 10:58 pm
Location: Istanbul

Re: C++ Progress ish

Post by krautersuppe » May 23rd, 2017, 9:34 am

ceofil wrote: Anyway...just finished the game. Definitely check it out.
[..]
Esc to pause, enter to start.
If you are in pause mode you can make walls by clicking and releasing the mouse (like making rectangles in paint) and ctrl-z to delete the last wall created. And 2 standard walls by pressing space
To move: Arrows and ctrl for player 1, wasd and space for player 2
This is awesome. I like it. I think it's worthy of
Seal2_by_Lynx.png
Seal2_by_Lynx.png (36.65 KiB) Viewed 3198 times
I will try to contribute to this if I find enough motivation. Here is a list of things that i would suggest
to add:
- some more sophisticated player collision (although probably irrelevant in a real PvP match)
- bullet counter
- player placement in level editor(pause)
- maybe some other map elements would be good like bridges, tunnels etc.(and with that there could
be a separate .cpp file with maps that forum members could contribute to)
- of course some sound effects
- power ups (like infinite bullets for a short time, shields etc.)
- game menu where one can select how many rounds to play(like best of 3 ,best of 5 etc.)
- of course start screen and end screen
DSU
Discord: dsu1, GitHub: https://github.com/DSpUz

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: C++ Progress ish

Post by chili » May 24th, 2017, 3:16 am

Just played it, good stuff man. One of the things I've mentioned over and over again is the idea of being able to work with the tools you have and be creative with them. I'm impressed with how you took the basic building blocks of Fart-Annoyed and used them to create something completely different (of course adding some new shit too, like the rotation).

Criticisms would be a) one thing I've noticed with your code is it lacks organization often. The structure of the code itself isn't bad, but things like your naming conventions need work. Also things like, there are unused empty classes and headers that make no sense.

I'd also like to see you figure out the sound system of the framework (check out the video for that if you need to!). Adding some simple sfx and music to a game really has a huge effect on the impression it gives, so I really recommend you do that for your projects.

Keep it up bro, I'm really digging what you're doing here and I think you have the right approach.
Chili

ceofil
Posts: 39
Joined: April 13th, 2017, 8:35 pm

Re: C++ Progress ish

Post by ceofil » May 24th, 2017, 6:16 pm

krautersuppe wrote:
This is awesome. I like it. I think it's worthy of
Seal2_by_Lynx.png
I will try to contribute to this if I find enough motivation. Here is a list of things that i would suggest
to add:
- some more sophisticated player collision (although probably irrelevant in a real PvP match)
- bullet counter
- player placement in level editor(pause)
- maybe some other map elements would be good like bridges, tunnels etc.(and with that there could
be a separate .cpp file with maps that forum members could contribute to)
- of course some sound effects
- power ups (like infinite bullets for a short time, shields etc.)
- game menu where one can select how many rounds to play(like best of 3 ,best of 5 etc.)
- of course start screen and end screen
Thanks man. Didn't even know this was a thing. Can I use it as reference on my future job applications? :idea:
I was thinking about starting Intermediate but that's some pretty sweet stuff you suggested there. I think I'm going to be messing around with this for a while.

ceofil
Posts: 39
Joined: April 13th, 2017, 8:35 pm

Re: C++ Progress ish

Post by ceofil » May 24th, 2017, 7:03 pm

chili wrote:Just played it, good stuff man. One of the things I've mentioned over and over again is the idea of being able to work with the tools you have and be creative with them. I'm impressed with how you took the basic building blocks of Fart-Annoyed and used them to create something completely different (of course adding some new shit too, like the rotation).
Thanks man. I really enjoy doing stuff in c++, watching your videos, being part of this community, following discord and all that good stuff. Tbh I can't imagine my life without all that, as cheesy as it sounds, it's kinda true. I was kinda depressed before this mainly because I didn't have anything to do while having nobody to talk to. Now I have something to do. But that's a story for another day.
Love you all guys. Keep up the good work.

chili wrote:
Criticisms would be a) one thing I've noticed with your code is it lacks organization often. The structure of the code itself isn't bad, but things like your naming conventions need work.
Totally agree with you. Can you be more specific about which names are confusing? It could be because english isn't my first language and sometimes what I think in my head does not match the actual meaning of the words. Or is it the order of functions in the cpp files? I should really spend some time working on this aspect. Probably gonna search stuff about this as soon as I can. God, I can't wait for school to be over in a few weeks so I can spend more time coding.
chili wrote:
Also things like, there are unused empty classes and headers that make no sense.
I thought that if I delete a file from inside VS it will get the job done but it doesn't actually work that way. Anyway, fixed that.

chili wrote:
I'd also like to see you figure out the sound system of the framework (check out the video for that if you need to!). Adding some simple sfx and music to a game really has a huge effect on the impression it gives, so I really recommend you do that for your projects.
Oooo yeah, caaan doo!
chili wrote:
Keep it up bro, I'm really digging what you're doing here and I think you have the right approach.
Love you, sorry for the long post.
Also I want to see if something works
chili wrote:
I like pubes

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: C++ Progress ish

Post by albinopapa » May 24th, 2017, 9:40 pm

One thing I noticed was single character variables which makes things very difficult to reason about what they are used for.

like:
float n and
int k

Even if you code with nouns and verbs from your own language, it will be easier for you or someone else that speaks your language to look at the code and be able to read the variable names and be able to tell what they are and what they are used for.

One thing I suggest would be to find a way to differentiate between functions, function parameters and member names. Some use a notation where member names might start with m_ globals with g_ just as examples.

Others might do:
int x_; While the paramter to a function would be void Foo( int x );

I've seen some code that uses the hungarian notation plus preface the name with the type:

// member x is signed int
int m_iX or int m_siX
// member is a single precision float
float m_fx;
// member is a vector
Vector m_vPosition

Some capitalize public member function names while only leaving the private ones lower case.

Some don't use Get or Set in their member names, but the member name itself.

// instead of
float GetSpeed()const;
void SetSpeed( float fSpeed );
// it would be
float Speed()const;
void Speed( float fSpeed );

usage Get: const float currentSpeed = car.Speed();
usage Set: car.Speed( currentSpeed + 7.f );
or
car.Speed( car.Speed() + 7.f );

In the end, it's mostly about writing code that helps other when they read your code to assist or when you need help figuring out why your code isn't working and making sure when you leave a project and come back to it a few weeks or months from then, you can easily look back through your code and figure out what it's doing and pick up where you left off.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: C++ Progress ish

Post by chili » May 26th, 2017, 3:28 am

ceofil wrote:Can you be more specific about which names are confusing?
In addition to what papa says above, just generally better (more logical) naming would be nice. For example, the projectile the tank shoots is called 'Ball', but that's kinda misleading. Bullet/Projectile/Shell would be better. Also Player is vague, should be named Tank. Player sounds more like a class representing the control (command source) of a human player, not an entity in the game simulation model. A tank might not be controlled by a player once you implement AI, so naming it player is confusing and misleading. Notice how in the games I do in the videos, there is no 'Player'. It's named more specifically, like Snake, Paddle, Face, etc.

Just stuff like that.
Chili

ceofil
Posts: 39
Joined: April 13th, 2017, 8:35 pm

Re: C++ Progress ish

Post by ceofil » May 28th, 2017, 12:39 pm

Added ball counter. Now the balls timer does not reset if it hits the other player. Even if it sounds balanced, you get rewarded if you hit your target, in close range it does not feel right.
Added some sound.
The bouncing sound works but the pop sound (when you shoot) does not.
Image
Chili said something about this in the video but how do I modify the file the have those properties. Or is there a way to search for sound effects with specific properties except format?

One more thing. For example if I want to use the same sound for something in Ball.cpp and in Player.cpp. I can't load it twice. Is it ok if I load it in Game and then pass it by pointer in Update and then do pointer.Play(); ?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: C++ Progress ish

Post by chili » May 28th, 2017, 2:52 pm

You can use software like Audacity to change the format. Also, if you search for .wav files on a website like https://www.freesound.org/ it will list the format.

You can load the same sound twice, but it might be better to pass a reference or a pointer to Ball/Player in it's constructor, and they can hold the ref/ptr for their lifetime.
Chili

Post Reply