Server Help

Non-Subspace Related Coding - A3 Custom Pokemon

hellzlaker - Sat Mar 15, 2008 12:09 am
Post subject: A3 Custom Pokemon
This is my biggest project that i made and has 1218 lines of code alltogether (not including bat, .a3 files)

Pretty much like a console version of Pokemon, but comes with Customize.exe which allows you to change pokemon names, their evolutions, font, and make settings default

It has allot of glitches and i tried to fix all of them but... Write here all the glitches you found..

Also it has a save, and load function which i made (didnt know how to make one so got creative..)

and yea thats pretty much it, took me 3 days to make, and i learned so much from it biggrin.gif


BTW: I'm trying to learn how to make application like windows APP style, like menu and using the mouse to click buttons instead of typing biggrin.gif if you know please post some good tutorials, and if there are good tutorials on 2d games biggrin.gif (ofcourse in c++)
Bak - Sat Mar 15, 2008 1:52 am
Post subject:
no source? icon_sad.gif
hellzlaker - Sat Mar 15, 2008 11:52 am
Post subject:
crap i thought it was in that folder :S

so do you know any good tutorials on 2games or windows APPS?
Anonymous - Sat Mar 15, 2008 2:12 pm
Post subject:
http://www.meandmark.com/opengl2dbook.html
hellzlaker - Sat Mar 15, 2008 2:31 pm
Post subject:
thanks this is exactly what i needed, googled for a while and couldn't find anything good biggrin.gif
Bak - Sun Mar 16, 2008 3:51 am
Post subject:
In my opinion SDL is much easier to work with than openGL... and you can use openGL inside SDL if you really want to. There's also lots of great tutorials specifically for game development:

http://lazyfoo.net/SDL_tutorials/index.php
http://www.libsdl.org/index.php
http://www.libsdl.org/tutorials.php
Bak - Sun Mar 16, 2008 3:59 am
Post subject:
looks good.

Code: Show/Hide
font.open("bin\\font.bat");
    if (!font)
    {
             ...
    }
    font.close();
i'm not sure that this handles the case where the file doesn't exist correctly. It might, test it out and tell me.

Also in some places you don't test if a file opened correctly (customize.cpp)
Code: Show/Hide
pok.open("bin\\pokemon.a3");


but other than that it looks good. Once you learn loops and functions you'll be kicking yourself for writing so much code icon_smile.gif

one more thing, in generally it's a bad idea to call main in your code
Code: Show/Hide
return main();

what you want to do (start over) should be done using a loop, although it doesn't look like you use those yet.

good work (I like the custom file io)
hellzlaker - Sun Mar 16, 2008 10:55 am
Post subject:
Code: Show/Hide
    if (!font)
    {
             ...
    }
    font.close();
yup your right (!font) says if what ever file variable font opens could not be found then do the following biggrin.gif i learned it few days ago biggrin.gif



Also i have this question, how do you make your program return to the part like where it says "Enter your choice: " in the source code bellow

Code: Show/Hide
                       int newpokchoice;
                         
                         cout<<"\n\nCongratulations!! "<<mpn<<" has beat "<<p3<<"!\n";
                         system("pause");
                         cout<<"\n\nWould you like to make get a new pokemon,\n";
                         cout<<"or just level up "<<mpn<<"? (1 = new pokemon, 0 = lvl up)\n\n";
                         cout<<"Enter your choice: ";
                         cin>>newpokchoice;
                         
                         if (newpokchoice == 1)
                         {
                                         
                                          cout<<"\n\n\n\nYou decided to get a new pokemon, and you got a \n";
                                          cout<<"lvl "<<dmg4<<" "<<p4<<" who has "<<hp4<<"!\n";
                                          cout<<"And will evolve into "<<evol4<<"!\n\n";
                                          system("pause");
                                          cout<<"\n\nWhat nickname would you like to give your "<<p4<<"?";
                                          cin>>mpn;
                                          cout<<"\n\nYou nicknamed your "<<p4<<" "<<mpn<<"!\n";
                                          system("pause");
                                         
                                          ofstream sgame;
                                          sgame.open("bin\\savedgame.a3");
                                          sgame<<p4<<endl;
                                          sgame<<hp4<<endl;
                                          sgame<<dmg4<<endl;
                                          sgame<<evol4<<endl;
                                          sgame<<mpn<<endl;
                                          sgame<<trainername<<endl;
                                          sgame.close();
                                         
                                          cout<<"\n\nGame was saved with your new pokemon...";
                                          system("pause");
                                         
                         }
                         
                         else if (newpokchoice == 0)
                         {
                             
                              cout<<"\n\n\n\nYou decided to lvl up your "<<mpn<<".\n";
                              system("pause");
                             
                              dmgmp = dmgmp + 1;
                              hpmp = hpmp + 5;
                             
                              cout<<"\n\n Your "<<mpn<<"("<<mp<<") leved up to lvl"<<dmgmp<<"!";
                              cout<<"\n\nWholy Shit! Your "<<mp<<" evolved into "<<evolmp<<"!\n";
                             
                              mp[80] = evolmp[80];
                             
                              cout<<"\n\nWhat nickname would you like to give your "<<mp<<"?";
                              cout<<"\nAnswer: ";
                              cin>>mpn;
                              cout<<"\n\nYou nicknamed your "<<mp<<" "<<mpn<<"!\n\n";
                              system("pause");
                             
                              ofstream sgame2;
                              sgame2.open("bin\\savedgame.a3");
                              sgame2<<mp<<endl;
                              sgame2<<hpmp<<endl;
                              sgame2<<dmgmp<<endl;
                              sgame2<<"(OOPS CANNOT EVOLVE ANYMORE, WILL JUST LVL UP)"<<endl;
                              sgame2<<mpn<<endl;
                              sgame2<<trainername<<endl;
                              sgame2.close();
                             
                              cout<<"\n\nGame Saved...";
                              system("pause");
                             
                         }
                                     
                         else
                         {
                             
                             cout<<"\n\n\a\aPokeshit: You must enter only 2, 1 or 0 as your choice!!";
                             cout<<"\n\tSorry but in A3 Custom Pokemon if you enter wrong value game exits...\n\t";
                             cout<<"Hopefully in the next version this will be fixed...";
                             system("pause");
                             return 0;
                             
                         }



i tried many times but nothing happened ( I did
Code: Show/Hide
return newpokchoice;
and
Code: Show/Hide
return newpockchoice();
but neither worked



Quote:
Also in some places you don't test if a file opened correctly (customize.cpp)
Code: Show/Hide
pok.open("bin\\pokemon.a3");


In pok.open("bin\\pokemon.a3") it doesn't read from pokemon.a3, it creates pokemon.a3, so if i would do the (!pok){} then it would show up with errors since the file wasn't created yet
k0zy - Sun Mar 16, 2008 1:26 pm
Post subject:
Code: Show/Hide
int choice;
do {
    cout << "1 = bla" << endl;
    cout << "9 = exit" << endl;
    cout << "your choice: ";
    cin >> choice;

    /* more stuff here */

} while (choice != 9);


for example.

Maybe the "int choice;" can be moved into the loop... but I didn't try if that works.
I worked in Java for almost a year now, and I can't tell the scopes apart.
baseball43v3r - Sun Mar 16, 2008 1:38 pm
Post subject:
isnt his first method of doing so, ie returning newpokchoice an example of recursion? which in his case wouldnt work so well i would think. would just a simple loop work better?

edit: oh he hasnt gotten to that yet.
Bak - Sun Mar 16, 2008 1:45 pm
Post subject:
yeah kozy is right with the loop thing. (and your current method is recursion, but you don't need to know that yet icon_wink.gif )

As for
Quote:
In pok.open("bin\\pokemon.a3") it doesn't read from pokemon.a3, it creates pokemon.a3, so if i would do the (!pok){} then it would show up with errors since the file wasn't created yet


It knows it's not trying to read from pokemon.a3 since pok is of type ofstream (output file stream). You still need to check if it opened the file correctly for writing. Reasons it might fail include being out of disk space or not having permission to write in that location. More commonly though, if the file already exists and is open in another program you won't be able to overwrite it.
hellzlaker - Sun Mar 16, 2008 1:56 pm
Post subject:
[quote="Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole...."]
Code: Show/Hide
int choice;
do {
    cout << "1 = bla" << endl;
    cout << "9 = exit" << endl;
    cout << "your choice: ";
    cin >> choice;

    /* more stuff here */

} while (choice != 9);


crap im retarted, i knew the do while and i actually used it for something similar, but never put the two together :\

Quote:
It knows it's not trying to read from pokemon.a3 since pok is of type ofstream (output file stream). You still need to check if it opened the file correctly for writing. Reasons it might fail include being out of disk space or not having permission to write in that location. More commonly though, if the file already exists and is open in another program you won't be able to overwrite it.
oh i never thought of that
hellzlaker - Mon Mar 24, 2008 12:04 pm
Post subject:
crap i realized its impossible to win in this game, your opponent will never die and his health goes to like -250000 something like that I'll try fix that
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group