ok so i need to output it in MainGame but how? i cant use i and j outside fo the loops, unless i need to make i and j outside of the for loops then i can use them again, idk, i never used for loops to make a graphical map before so its all very confusing but im understanding it very well so far.
Your map generator function is fine except for the cout's. If you want to successfully print this map with the pet and all, you should make a function that (again) goes through both for loops but instead of initializing what the map has it in it, it just has the cout's and prints the map, spaces and pet and all.
could you just show me what you mean? Im a visual learner its too difficul to try to guess this stuff. I know im supposed to put the couts in a different function but i have no idea how its all supposed to look.
One thing you will notice is that if you ever change the size of the map, you are going to have to change the size in numerous places. Do yourself a favor and before you go on, do as I suggested before and start using variables.
Yes but you didn't tell it to do anything. It wont know what to do unless you tell it to.
Addition:
Also, pretty much everything you're declaring in your map generator function should be in your MainGame function. If not when you later use the map (to move the pet etc.) it wont actually work. ATM your map only exists in the MapGenerator function, you want it to be part of your game so you should be declaring it in your MainGame function.
You don't have a map generator type you're trying to make do you? You could have a map class, where you make maps, but you're only going to be using one, so I see little help in that.
Okay, that's fine. It sounded as if you were going to have one map that the pet moved around in. When you create a class you are (for all intense and purposes) creating a new data type. So if you create a map generator class then you'll have a data type (with member functions and the whole shebang) that is a map generator. You'd be able to make new map generators etc. Not new Maps.
You have more than one map? At the same time? That seems a little out of the reach of a console program for you right now. I'd stick to having one. In which case you will only need functions.
The map generator type is what you will use in conjunction with your class. If I have a class called class myClass(){...}. When you go to use the class the variable will be of type myClass.
ok well i'll just stick with functions for now then, ok so now i need to call the map generator right? so in main game i called it, so then... i dont even know. I havbe a learning disorder that makes things very difficult sometimes, its taken me 5 years just to get the basics of C++ down, it should only take the average person 2, so i apologive if im repeating questions. can you just modify my code to make it work? Seeing it completed will help me understand it, and if theres something i dont get i'll ask.
No, we won't write your code for you because you need to learn to do it yourself. I may work on some pseudo-code later on but until then you need to work on the code some more.
Not to sound rude, but I'm not going to give you your code simply because you have a learning disorder. I have an issue with not being able to understand simple concepts and am unable to do basics tasks, but that doesn't mean I have someone do them for me.
The biggest advice I can give you is just take everything slowly, step by step. If you want to do ____ you'll need A, B, and C. So, how do you do A? Well to do A you need 1 and 2. To do B you need 3, 4, and 5. And to do C you need 6, and 7. Make 1, 2, 3, 4, 5, 6, and 7 all functions that do what they need to do. Make functions A, B, and C and have them call their respective helper functions. Then make function _____ and have it call A, B, and C. It always helps to break things up, almost like a tree, focus on the leafs, then branches, then the trunk. Maybe drawing it out visually will help. Take it slow and think very specifically.
I wont write you code because doing it is the best way to learn anything. I have a LD too and doing something (especially doing it wrong) can help a lot. If you have specific questions about why something is working, please contact us, but I know Protomega wont write code, and neither will I. It's for your own good, so you can learn. Good Luck and Good night.
She gives some pretty good advice and her saying good night is a queue that she is tired, which means I think it's time for me to turn off my computer in the basement and head up to my laptop upstairs. Leave me a Private Message with some contact info if you want and we can talk about this elsewhere versus filling up a post which what is essentially a tutorial.
Ok i think i got it working for the most par, now im trying to make an AI so it will move on its own but im having a little trouble with that, what do i need to do here?
#include <iostream>
#include <string>
#include <time.h>
#include <stdlib.h>
#include "Prototypes.h"
using std::string;
using std::cout;
using std::endl;
using std::cin;
int main()
{
int PETXCOORD;
int PETYCOORD;
int MOVEX;
int MOVEY;
MainGame(PETXCOORD, PETYCOORD, MOVEX, MOVEY);
}
void MapGenerator(int PETXCOORD, int PETYCOORD, int MOVEX, int MOVEY)
{
char pet = '*';
char gameMap[20][40];
int mapRows = 20;
int mapColumns = 40;
int number;
for(int i = 0; i < mapRows; i++) // How many rows to loop through.
{
for(int j = 0; j < mapColumns; j++) // How many columns to loop through.
{
gameMap[i][j] = ' '; //create a space in each element
gameMap[MOVEX][MOVEY] = pet;
cout << gameMap[i][j];
for(int k = 0; k < PETXCOORD; k++)//move Left/Right
{
MOVEX;
for(int l = 0; l < PETYCOORD; k++)//Move up/down
{
MOVEY;
}
}
}
cout << endl;
}
}
void MainGame(int PETXCOORD, int PETYCOORD, int MOVEX, int MOVEY)
{
MapGenerator(PETXCOORD, PETYCOORD, MOVEX, MOVEY);
}
void PetAI(int PETXCOORD, int PETYCOORD, int MOVEX, int MOVEY)
{
srand(time(0));
int LR_Movement;
int UD_Movement;
LR_Movement = rand() % 2;
UD_Movement = rand() % 2;
PETXCOORD = rand() % 20;
PETYCOORD = rand() % 40;
switch(LR_Movement)
{
case 0:
MOVEX++;
break;
case 1:
MOVEX--;
break;
}
switch(UD_Movement)
{
case 0:
MOVEY++;
break;
case 1:
MOVEY--;
break;
}
}