Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 587 posts ]  Go to page Previous  1 ... 54, 55, 56, 57, 58, 59  Next
Author Message
 Post Posted: September 13th, 2017, 5:46 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
^ thanks, now that you mentioned it I've seen chili do this before, seems more clear that way.

I'm trying to make a pokemon battle simulator.
Usually when I make a program I just start coding and whatever happens, happens :D
Trying to actually plan it this time with UML, it's a bit hard becuase I don't know UML and it's kinda confusing.
Also running into some design problems.
The player should have 6 pokemons to choose from. Each pokemon should have 4 different moves.
I was planning on making a Move class and its function Use() would take 2 references to pokemon, target and attacker... but pokemons should have 4 moves so would need to store moves in pokemon which would mean circular dependancy.


Top 
 Profile  
Reply with quote  
 Post Posted: September 13th, 2017, 6:10 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
this is not done, but does this already look really dumb? Feels like spaghetti code?
batlleM has players,
players has a team
team has pokemons,
pokemons have moves...

Image


Top 
 Profile  
Reply with quote  
 Post Posted: September 13th, 2017, 8:52 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
Image

uugh, UML and this project already feels like aids.
I now have one day to write all the code so gonna get a good nights rest and start coding tomorrow. Just try and make it simple and dumb and then try and make it better


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 10:55 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3400
Location: Japan
Yeah man, starting simple is the way to go for sure.

I rather like UML. Kinda pointless when working by myself, but it's a good tool for communicating your architecture quickly to others. Well, quickly for them ;)

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 12:51 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
^ Yeah I think I'll like it once I get more used to it.

Written some code. What I'm still unsure about is how to set up the simulation with players, pokemons and moves... What I have so far is something like this:

Code:
moves["Tackle"] = new DamagingMove("Tackle", 10);
   moves["Leech Life"] = new AbsorbingMove("Leech Life", 8);
   moves["Thunder Shock"] = new DamagingMove("Thunder Shock", 12);
   moves["Fire Blast"] = new DamagingMove("Fire Blast", 15);
   moves["Ember"] = new DamagingMove("Ember", 10);
   moves["Water Gun"] = new DamagingMove("Water Gun", 10);
   moves["Slam"] = new DamagingMove("Slam", 12);
   moves["Quick Attack"] = new DamagingMove("Quick Attack", 10);
   moves["Scratch"] = new DamagingMove("Scratch", 12);

   Pokemon* pikachu = new Pokemon("Pikachu", 20);
   Pokemon* charmander = new Pokemon("Charmander", 20);
   Pokemon* bulbasaur = new Pokemon("Bulbasaur", 20);
   Pokemon* squirtle = new Pokemon("Squirtle", 20);

   pikachu->AddMove("Tackle");
   pikachu->AddMove("Thunder Shock");
   pikachu->AddMove("Slam");
   pikachu->AddMove("Quick Attack");

   charmander->AddMove("Tackle");
   charmander->AddMove("Scratch");
   charmander->AddMove("Ember");
   charmander->AddMove("Fire Blast");

   bulbasaur->AddMove("Tackle");
   bulbasaur->AddMove("Leech Life");
   bulbasaur->AddMove("Slam");
   bulbasaur->AddMove("Scratch");

   squirtle->AddMove("Tackle");
   squirtle->AddMove("Scratch");
   squirtle->AddMove("Water Gun");
   squirtle->AddMove("Scratch");

   players[0] = new Player("Ash");
   players[0]->AddPokemon(pikachu);
   players[0]->AddPokemon(charmander);

   players[1] = new Player("Gary");
   players[1]->AddPokemon(bulbasaur);
   players[1]->AddPokemon(squirtle);


Don't really like it. Once both players have 6 different pokemons and all pokemons have 4 moves this becomes many lines of code and it feels dumb. Should be some more efficient way of doing this but currently can't think of anything


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 1:20 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
Also, I think I started off doing it too complicated like always. Have been coding for a couple hours and not ran a singe test :D so no idea if what I'm doing will even work


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 4:22 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
Well the program works, but lots of stuff still needs to be done.

Realized that atm my game works like this
player 1 decides what to do and then his pokemon attacks
player 2 decides what to do and then his pokemon attacks

in the actual game it's supposed to be like this:
player 1 decides what to do
player 2 decides what to do
player 1s pokemon attcks
player 2s pokemon attacks.

Not sure how to make that happen but will try and figure something out or leave it like it is if I run out of time.

Also consider making it so one of the player is the computer and the other one is an actual player.

But first I have more important things to work on :)


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 8:19 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2711
Location: Oklahoma, United States
Hehem, state machine using enums?

_________________
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


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 8:37 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
albinopapa wrote:
Hehem, state machine using enums?


wat?


Top 
 Profile  
Reply with quote  
 Post Posted: September 14th, 2017, 10:03 pm 
User avatar

Joined: January 19th, 2017, 10:28 pm
Posts: 446
Location: Idiot from northern Europe
trying to delete all dynamically allocated objects.

Why does this not work for deleting the objects in my map?

Code:
for (; it != m_Moves.end(); it++)
   {     
      if (it != m_Moves.end())
      {
         delete it->second;
         it->second = nullptr;
         std::cout << "Destroying a move..." << std::endl;
      }
   }


"map/set iterator not dereferencable"


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 587 posts ]  Go to page Previous  1 ... 54, 55, 56, 57, 58, 59  Next

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: