My Game

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

My Game

Post by Nosferatu » September 15th, 2012, 1:34 pm

Hello guys,
like a month ago I made this "game" and now I want to share it with you. It's quite unfinished as you will see but it works just fine ( no errors and such ( maybe with an exception for sounds asserts, so it's better to run it in release mode ) ). I would really appreciate if you could spend some of your time a have a quick look at my code and check on some things:
1. Firstly, I'm not quite satisfied with my collision code ( it's located in the Platform.cpp file ) so maybe you can give me some advice to improve it.
2. Please, take a look onto my classes. Until now I didn't do much in object-oriented languages, so I'm a little rusty in their organisation.

I made this "game" mainly to test if I remember something from Chili's videos ;), so I used almost everything I've learned so far : animations, font, linked lists, arrays and so on. I my opinion it's not even a game because it lacks any point ( it's just meaningless running around and shooting ), but as I've said I made it to test my skills.

It has also a tool to quick level creation so here's a little guide on how to use it.
1. Use your mouse to move cursor to position where you want to place something.
2. Press space to begin drawing a platform, press again to place it. While drawing press Esc to exit platform creation.
3. Press Enter to create player, if you press it more than just once it will replace the old one.
4. Press Insert to create exit. ( also replaceable )
5. Press Shift to place enemy, but be aware that it cannot be replaced ( mainly of the fact that the enemies are made with linked list and I didn't want to spend eternity thinking how to implement it ),
also don't place them into platforms because they won't move. Place them above platforms and they will slowly fall down onto them.
6. Once done press Esc to save the level, and press play in menu to test it.
When in game use arrows to jump and move, shift to shoot.

So have fun with my "game" feel free to comment on how boring it is :roll:, and if you know any way to improve it ( and I'm sure there are lots of way ) just let me know :D.

Thanks in advance.

P.S. : I did not use deconstructors, because I'm not very familiar with using them yet.
P.P.S. : Sorry for all those assert errors ( mainly caused by different sample rates, which also makes some sounds sound dull ), but I didn't want to remove assertion from sounds and I was too lazy to find any audio converter.
P.P.P.S : Thank you Chili for such great tutorials :).
Attachments
My game.zip
(307.25 KiB) Downloaded 424 times

User avatar
viruskiller
Posts: 399
Joined: June 14th, 2012, 5:07 pm

Re: My Game

Post by viruskiller » September 15th, 2012, 3:36 pm

can's say much about the game .but i can say great job on coding it so simple and easy to read:)
also nice feature for creating your own level.
i think every1 will agree that u used mostly everything that chili tought us:).
didn't look much at how u coded it but all i can say is that i was surprised to see it that small in code length after i played it:)

dunno if u really wanna improve it to the point of a real game, but if u want i think u could make it so u can't lay platforms too close to eachother(one above the other) so the player /enemy can't pass under them,i had to redo my first map as i didn't knew the height of the player lol, so make it either to draw it at player height or allow drawing if the new platform touches another one below,basicaly the horisontal gaps should all be player height or no gap at all.
then u could implement ladder platforms ,or elevator platforms,or enemy's that shoot back,beeing able to fire at mouse pointer instead of straight forward:),ther's tons of things u can test your skills on:P
but since u got the basics is a question of inovation on how u code the later stuff,i mean u can build a house with all the building blocks chili teached us to use, but now u need to make a fancy one to trully test your skills:P.
so pick the most dificult feature u can think of and do it,if is to hard pick another one,don't waste time on small stuff unless u'r spending too much on the bigger things,

i've stoped developing two of my games just because i was too lazy to code font loading and show the score for them,and to implement new features lol, was quite odd if u'r talkin about tetris and snake games:)),i mean they just plain simple games.
anyway's great work and happy coding!

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: My Game

Post by Nosferatu » September 17th, 2012, 4:29 pm

I'm glad that you think my code is alright :). Today I've started with upgrades, first of all I've added ladders and will definitely add more features in following days. Thanks for sharing your ideas for improvements :)

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

Re: My Game

Post by chili » September 23rd, 2012, 2:15 pm

I looked at this a while back but forgot to comment! Anyways, from what I remember it was pretty sweet, and I like how you used the stickman sprite to make an actual controllable character. Doesn't move too poorly either. If memory serves me correctly, your style and organization of code was very good as well. Keep up the good work!
Chili

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: My Game

Post by Nosferatu » July 14th, 2013, 8:21 pm

Sooo, I've been doing some upgrades and one of them was taking file manipulation from stdio to streams. While I used stdio( fpritnf( "%d%c.... ) everything was just fine, but after re-coding it to use streams things got all weird and to make it short I got it working after putting one 'char' between each number I needed to save or load.

Before the code looked something like this :
fwrite( &posX, sizeof( float ), 1, pFile );
fwrite( &posY, sizeof( float ), 1, pFile );
loading:
fread( &posX, sizeof( float ), 1, pFile );
fread( &posY, sizeof( float ), 1, pFile );
No extra data was needed.

but now if I want it to work it has to be for some reason like this:
fout << posX << 'somerandomchar' << posY << 'somerandomchar';
and likewise for loading :
char input;
fin >> posX >> input >> posY >> input;

which I find kind of stupid( really stupid )

So I would like to ask if any of you has some previous experience with streams and why I cant just do this : fout >> posX >> posY; ( I mean I can but then it completely messes with the save file and it won't load correctly ).
Is it something specific ? Or am I just being dumb ( possible )

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: My Game

Post by LuisR14 » July 15th, 2013, 1:02 am

Nosferatu wrote:Is it something specific ? Or am I just being dumb ( possible )
haha, most likely that xD
Nosferatu wrote:why I cant just do this : fout >> posX >> posY; ( I mean I can but then it completely messes with the save file and it won't load correctly ).
hehe, well ofc it's obvious you can't do it that way, values aren't being separated by anything that way (and well depends on what type of access you open the file with and the type of values you're handling)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: My Game

Post by Nosferatu » July 15th, 2013, 9:58 am

Wouldn't it be better to use fwrite() then ? That way I don't have to put in there any separators.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: My Game

Post by LuisR14 » July 15th, 2013, 12:30 pm

probably you're not opening it in binary mode?

edit: nvm, looking at the docs i see that fwrite isn't the same as using the "<<" or the ">>" lol
fread/fwrite reads/writes from/to the file as binary (even if file is opened in text mode), ">>" / "<<" reads/writes from/to the file as text (even if opened in binary mode)
Last edited by LuisR14 on July 15th, 2013, 2:44 pm, edited 1 time in total.
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

User avatar
Nosferatu
Posts: 36
Joined: July 25th, 2012, 7:08 am
Location: Slovakia

Re: My Game

Post by Nosferatu » July 15th, 2013, 2:43 pm

Bah, should have known I would be better off using stdio...
Thanks for help anyways.

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: My Game

Post by LuisR14 » July 15th, 2013, 3:00 pm

also, fstream seems to be for text (tho not sure about that heh)
i've just never used c++ stream based stuff lol, and i've only used stdio during the tuts and some test stuff for me lol, im' more of win32 file lol
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply