[edit]Must learn to read for comprehension...[/edit]
[edit]Must learn to read for comprehension...[/edit]
Last edited by Prelude; 08-29-2004 at 01:31 PM.
My best code is written with the delete key.
I don't but this just sin't working. And that is all there was on the error thing.
Edit: This is just plain stupid now! The more I add the more errors that make no sence come. The most errors I had so far were 54.
Last edited by Rune Hunter; 08-29-2004 at 12:55 PM.
your main() is nested inside of startprogram(). That's not allowed.
DaveCode:void startprogram() { // lots of stuff int main() { // other stuff } //this is the closing bracket for main() } //this is the closing bracket for startprogram()
ok so now I need to know how to be able to use a variable in side of a void function()
Edit: It keep saying it is undicleared.
first thing I would do is make a struct with all of that info your using for your traits.
which i personally would put in a header file.Code:struct info{ int health; int attack; int def; int magic; int alreadyset; int totaldamage; int dead; };
Rune think of it like this
Code://fight.h #ifndef fight_h #define fight_h void fight(); #endif //fight_hCode://fight.cpp #include "fight.h" void fight() { //blah blah //kill something //if you die then exit }your code is able to find the fight function because you protyped it in the header file so as long as you include that your fineCode://main.cpp #include <iostream> #include "fight.h" int main { //whatever if(playerwants to fight) { fight(); } return 0; }
Woop?
Ok here is what I got...
I got info.h wich has all the variables in it.
Then I got createplayer.h and .cpp.
In create player .cpp I had to use some of the variables used in info.h. But it says that the variables are undiclared. Even if I put
I have even triedCode:#include "info.h"
Any help now, lol, Please.Code:#include "info.cpp"
Last edited by Rune Hunter; 08-29-2004 at 02:00 PM.
variables need to be like this
Now in a cpp fileCode://+---Variables.h---+ #ifndef _VARIABLES_H #define _VARIABLES_H //+--This is not the actual declaration of the variable, Its almost like a prototype--+ extern int Var1; #endif
Now in another cpp file you can get access to the variable by including the header file.Code:#include "Variables.h" //+---Here you declare the variables--+ int Var1; //+---Other code that uses the varibles---+
It works like this
The variable is declared in a source file, but the variables scope is only in the file it is declared in.
This is where extern comes into play. It lets that variable be external of its original scope so you can use it globaly through out your project.
Keep in mind that most of the time globals are not good to use, but thats something to worry about later on.
Thanks alot now I can continue working on my game!
alright now I got this error...it's always error after error...-sigh-
Here is the error log thing...
80 C:\Documents and Settings\Alex\Desktop\RPG Game\mainmenu.cpp
ISO C++ forbids declaration of `P_attack' with no type
I have that error a couple of times with P_ def too.
here is the code now were it happens...
P_health=P_health+10;
P_attack=P_attack+2;
P_def=P_def+2;
P_mp=P_mp+3;
Those varaibles worked in other places but here and a couple other places it doesn't like for some reason.
Hmm, I would need to see the code of the actual declarations of those variables.
did you make them int's?
Maybe you could put your code into a zip file or something and post it so we can see what the problem is.
Is P_health declard in the file? If it's in variables.h/cpp, are you including variables.h?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
well ok if you really want to look throw it...
I gotta eat so I'll be back later to see if anyone actauly looked at it.
In callmainmenu() you're missing a closing bracket on your while loop... I'm surprised you didn't get an error before. Other than that, I didn't see anything particularly wrong when I glanced over your code.
Last edited by Hunter2; 08-29-2004 at 04:34 PM.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
I am seeing a few brackets you forgot to close. Thats probably the problem
Go back and check your opening and closing brackets
EDIT:
ARGH, fricken hunter
Yep close that bracket and it will work!
Last edited by Vicious; 08-29-2004 at 04:36 PM.
lol pretty soon I will have people swaring at me LOL. Ok I'll go and close some brackets lol.
Edit: Well that one bracket caused alot o truble.
But you still didn't sware at me yet...
Last edited by Rune Hunter; 08-29-2004 at 05:07 PM.