Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

graveyard filla

LINK : fatal error LNK1168: cannot open Debug/FTA_NEW.exe for writing

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

does anyone know why im getting this error when i try to compile? (this is just a simple text game i started working on a few days ago) the weird thing is, if i cut and paste my code into a new c++ source file, it compiles fine without problems. it just wont compile in the file that its already in. this has happened to me a couple of times and im wondering WTF the problem is. its not a big deal, i just cut and paste to a new file, but still. anyone have a clue? thanks.

Share this post


Link to post
Share on other sites
Advertisement
I think the program does not exit properly, do Ctrl,Alt,Del and see if the exe is still open after closing, and if it is then end it and the compile again.

Share this post


Link to post
Share on other sites
Means your output exe is still running somewhere. I''ve never seen this happen with a console app (because normally the window is destroyed only at program termination time), but something is keeping the process alive. The ideal solution is to fix your code so the app closes when you tell it to, completely. A temporary fix (on Windows +98) is to close the process manually with the Task Manager.

If you''d like to post code, we''ll see if we can figure out what causes the process to continue to run invisibly.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post


Link to post
Share on other sites
well, i am testing the program frequently. do i have to properly exit through the program? ive just been clicking the X at the top of the console. heres the source


#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>

using namespace std;

void intro_screen (); //a simple print screen function that prints the welcome screen


void player_attack (int &enemy_health,int attack_type,int &player_stamina,int &player_mana);
//this calculates the players attack. it sends back enemies new health(after attack),

//the players stamina, and the players mana after the attack


void enemy_attack (int &player_health);
//this function calculates the enemies attack, and sends back the players updated health


void player_movement (int &spaces_moved);//this prints the movment keys and also

//starts a counter called spaces_moved

//which records how many spaces the player moved


void rand_attack (int spaces_moved,bool &battle_now); //this calculates the chances of a random

//attack. it doesnt start untill the player

//moves at least one space. it returns a

//boolean value of true if combat is started

//and false if no combat started.


void enter_combat(int &enemy_health, int &player_health,int &player_stamina,int &player_mana,int &attack_type);
//this manages all combat. it called the player_attack and enemy_attack functions, updates

//all health,stamina, and mana. it also prints out results of each hit etc.


int main()
{

int spaces_moved = 0;
int attack_type = 0;
int player_health = 100;
int enemy_health = 50;
int player_stamina = 40;
int player_mana = 60;//players

bool battle_now;

srand (time (NULL)); //set the seed to the internal clock of the computer



intro_screen(); //simply prints the intro screen to the screen



do
{

player_movement(spaces_moved); //pop up the movement screen


rand_attack(spaces_moved,battle_now);//check for random attack (80% chance of attack)



if (battle_now == true) //if the attack is true, then enter combat, if not, go back

//to the top, ask for movement, and look for another random attack

{
enter_combat(enemy_health,player_health,player_stamina,player_mana,attack_type);
}
}
while (player_health > 0); //do this all untill the player dies



if (player_health < 0) //if the player died, say game over.

{

cout<<"You are dead"<<endl;

cout<<"Game Over"<<endl;
}


return 0;
}

void intro_screen () //simply prints the welcome screen to the player.

{
cout<<"********************************************************************************"<<endl;
cout<<"*********************************WELCOME TO FTA*********************************"<<endl;
cout<<"********************************************************************************"<<endl;
cout<<"**************************DONKEY PUNCH PRODUCTIONS INC.*************************"<<endl;
cout<<"********************************************************************************"<<endl;
}

void player_attack (int &enemy_health,int attack_type,int &player_stamina,int &player_mana)
//calculates players attack and sends back updated enemy health, player stamina, and player mana


{
int attack = 0;
int defence = 0;
int damage = 0;
int used_stamina = 0;
int used_mana = 0;



attack = (rand () % 11) + 2; //generates random number for attack

// a dice number (2-12)

defence = (rand () % 11) + 2; //generats random number for defence

// a dice number


if (attack > defence) //compares attack to defence, if bigger, it is a hit and

//then calculates damage and updates enemy_health


{

if(attack_type == 1) //if the attack type was a sword attack, then

{

if (player_stamina < 4) //check to see if the player has enough stamina to execute

//the attack

{
cout<<"|=|=|=|=|You are exhausted|=|=|=|=|"<<endl<<endl; //if player doesnt have enough stamina,

//will print "you are exhausted", and bail

//out of the function completely

}
else
{

cout<<"****You hit!****"<<endl<<endl; //else the player has enough stamina, print

//you hit, then


damage = ((rand () % 11) + 2); //calculate damage (random number 1-12)


used_stamina = 4; //use 4 stamina

}


if (damage > 10) //if damage is more then 10, say you sliced him

{
cout<<"You sliced the enemy for "<<damage<<" health"<<endl<<endl;
}
else if (damage > 0) //if its less then 10 but more then 0 (ie you had enough stamina)

//print you stabbed him

{
cout<<"You stabbed the enemy for "<<damage<<" health"<<endl<<endl;
}

}

else if(attack_type == 2) //OR if attack type was a magic attack

{

if (player_mana >= 5) //check to see if player has enough mana

{
cout<<"****You hit!****"<<endl<<endl; //since the player does, say "you hit"

damage = ((rand () % 20) + 2); //get damage from random number 2-20

used_mana = 5;//use 5 mana

cout<<"The enemy was burned "<<damage<<" health"<<endl<<endl;
//print the enemy was burned for "damage"


}

else //if player doesnt have enough mana

{
cout<<"|=|=|=|=|Not enough mana to cast spell|=|=|=|=|"<<endl<<endl; //say you dont have enough mana

}



}

}

else if (defence >= attack) //if defence is bigger, you miss.

{
damage = 0;

if (attack_type == 1) //if you miss and used a sword attack, do the follow:

{
if (player_stamina > 4) //check to see if they have enough stamina

{

used_stamina = 2; //if they do have enough stamina, take 2 away

cout<<"******You missed!*****"<<endl<<endl; //print "you missed"

}
else if (player_stamina < 4) //else if they dont have enough stamina

{
cout<<"|=|=|=|=|You are exhausted|=|=|=|=|"<<endl<<endl; //print you are exhausted.

}
}

else if (attack_type == 2) //if you misee and used magic,

{
if (player_mana >= 5) //check to see if they have enough mana

{
used_mana = 3; //if they do, use 3 mana and

cout<<"|=|=|=|=|The spell fizzled|=|=|=|=|"<<endl<<endl; // say the spell fizzled

}
else if (player_mana < 5) //if they dont have enough mana

{
cout<<"|=|=|=|=|=|Not enough mana to cast spell|=|=|=|=|=|"<<endl<<endl; //say "do not have enough mana"

}
}

}
enemy_health = enemy_health - damage; //update all damage done to the enemy

player_stamina = player_stamina - used_stamina; //update stamina used

player_mana = player_mana - used_mana; //update mana used


}

void enemy_attack (int &player_health) // calculates enemy attack "hit" or "miss" and

//calculates damage and updates health


{
int attack;
int defence;
int enemydmg;
int attack_type;


attack = (rand () % 11) + 2; //makes attack a random between 1-12


defence = (rand () % 11) + 2; //makes defence a random between 1-12




if (attack > defence) //if attack > defence, the PC hits the player

{

attack_type = rand () % 100; //generates a random number between 1-100, calling it attack_type


if(attack_type > 65) //if the number is > 50, then do a melee attack

{

cout<<"$=$=$=You were hit!=$=$=$"<<endl<<endl; //prints you were hit

enemydmg = (rand () % 11) + 2; //enemy damage for this melee attack is a random

//between 1-12

cout<<"Enemy bashed you for "<<enemydmg<<" health"<<endl<<endl;
//print the damage done

}

else //if the number is < 50, then do a magic attack

{

cout<<"$=$=$=$=You were hit!=$=$=$=$"<<endl<<endl; //prints you were hit

enemydmg = (rand () % 20) + 2; //enemy damage for this "lightning" attack

//is a random between 2-20

cout<<"Enemy bolted you for "<<enemydmg<<" health"<<endl<<endl;
//print the damage done



}
}

else if (defence >= attack) //if defence > attack, the pc missed the player


{
enemydmg = 0;
cout<<"=$=$=$=$They missed you!=$=$=$=$"<<endl<<endl; //print they missed you

}

player_health = player_health - enemydmg; //updated player health


}


void player_movement (int &spaces_moved)
{
char direction;

cout<<"Press 'W' to move up"<<endl;
cout<<"Press 'A' to move left"<<endl;
cout<<"Press 'S' to move right"<<endl;
cout<<"Press 'Z' to move backwards"<<endl<<endl;
cin>>direction;

if (direction == 'w')
{
cout<<"You moved forward."<<endl<<endl;
}
else if (direction == 'a')
{
cout<<"You moved left."<<endl<<endl;
}
else if (direction == 's')
{
cout<<"You moved right."<<endl<<endl;
}
else
{
cout<<"You moved backwards."<<endl<<endl;
}

spaces_moved = spaces_moved + 1;

}

void rand_attack (int spaces_moved,bool &battle_now)
{
int attack_chance = 0;

if (spaces_moved > 1)
{
attack_chance = (rand () % 100) + 1;

if (attack_chance > 85)
{
battle_now = true;
}
else if (attack_chance <=85 )
{
battle_now = false;
}
}

else if (spaces_moved <=1)
{
battle_now = false;
}
}

void enter_combat(int &enemy_health, int &player_health,int &player_stamina,int &player_mana,int &attack_type)
{

cout<<"**************************YOU HAVE ENTERED COMBAT!*****************************"<<endl<<endl;
do
{

cout<<"You have: "<<" The enemy has: "<<endl;
cout<<"***********************"<<" *********************"<<endl;
cout<<"---"<<player_health<<"---"<<"--health------"<<" -------"<<enemy_health<<"------health"<<endl;
cout<<"---"<<player_stamina<<"---"<<"---stamina-----"<<endl;
cout<<"---"<<player_mana<<"---"<<"---mana--------"<<endl<<endl;
cout<<"********************************************************************************"<<endl<<endl;



cout<<"Type the number for the attack type and press enter"<<endl<<endl;
cout<<"[1 for sword attack, or 2 for fireball]"<<endl;
cin>>attack_type;
cout<<endl<<endl;

player_attack(enemy_health,attack_type,player_stamina,player_mana);
//this calculates the players attack, and updates enemyhealth/player stamina/mana


enemy_attack(player_health);
//this calculates the enemies attack, and updates player health.

}
while ((player_health > 0) && (enemy_health > 0));
//runs this battle untill one of the player dies.


if (enemy_health < 0)
{
cout<<"You have defeated the enemy"<<endl;
enemy_health = 50;
}

}



[edited by - graveyard filla on January 12, 2004 7:48:44 PM]

Share this post


Link to post
Share on other sites
can anyone help me with this? it keeps happening and is getting pretty annoying. is this going to effect my program in the long run? can anyone help? thanks. if you want the source it is

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string>

using namespace std;

bool random_bool();
//a function that randomizes the event of an event (block of code) happening. such as drop loot,

//etc.it basically just returns true or false on a 50/50 chance. could be switch to 70/30 or different.


void intro_screen (); //a simple print screen function that prints the welcome screen


void player_attack (int &enemy_health,int attack_type,int &player_stamina,int &player_mana);
//this calculates the players attack. it sends back enemies new health(after attack),

//the players stamina, and the players mana after the attack


void enemy_attack (int &player_health);
//this function calculates the enemies attack, and sends back the players updated health


void player_movement (int &spaces_moved);//this prints the movment keys and also

//starts a counter called spaces_moved

//which records how many spaces the player moved


void rand_attack (int spaces_moved,bool &battle_now); //this calculates the chances of a random

//attack. it doesnt start untill the player

//moves at least one space. it returns a

//boolean value of true if combat is started

//and false if no combat started.


void enter_combat(int &enemy_health, int &player_health,int &player_stamina,int &player_mana,int &attack_type);
//this manages all combat. it called the player_attack and enemy_attack functions, updates

//all health,stamina, and mana. it also prints out results of each hit etc.





int main()
{

int spaces_moved = 0;
int attack_type = 0;
int player_health = 100;
int enemy_health = 50;
int player_stamina = 40;
int player_mana = 60;//players

bool battle_now;


srand (time (NULL)); //set the seed to the internal clock of the computer



intro_screen(); //simply prints the intro screen to the screen



do
{



player_movement(spaces_moved); //pop up the movement screen


rand_attack(spaces_moved,battle_now);//check for random attack (80% chance of attack)



if (battle_now == true) //if the attack is true, then enter combat, if not, go back

//to the top, ask for movement, and look for another random attack

{
enter_combat(enemy_health,player_health,player_stamina,player_mana,attack_type);
}
}
while (player_health > 0); //do this all untill the player dies



if (player_health < 0) //if the player died, say game over.

{

cout<<"You are dead"<<endl;

cout<<"Game Over"<<endl;
}


return 0;
}

void intro_screen () //simply prints the welcome screen to the player.

{
cout<<"********************************************************************************"<<endl;
cout<<"*********************************WELCOME TO FTA*********************************"<<endl;
cout<<"********************************************************************************"<<endl;
cout<<"**************************DONKEY PUNCH PRODUCTIONS INC.*************************"<<endl;
cout<<"********************************************************************************"<<endl;
}

void player_attack (int &enemy_health,int attack_type,int &player_stamina,int &player_mana)
//calculates players attack and sends back updated enemy health, player stamina, and player mana


{
int attack = 0;
int defence = 0;
int damage = 0;
int used_stamina = 0;
int used_mana = 0;



attack = (rand () % 11) + 2; //generates random number for attack

// a dice number (2-12)

defence = (rand () % 11) + 2; //generats random number for defence

// a dice number


if (attack > defence) //compares attack to defence, if bigger, it is a hit and

//then calculates damage and updates enemy_health


{

if(attack_type == 1) //if the attack type was a sword attack, then

{

if (player_stamina < 4) //check to see if the player has enough stamina to execute

//the attack

{
cout<<"|=|=|=|=|You are exhausted|=|=|=|=|"<<endl<<endl; //if player doesnt have enough stamina,

//will print "you are exhausted", and bail

//out of the function completely

}
else
{

cout<<"****You hit!****"<<endl<<endl; //else the player has enough stamina, print

//you hit, then


damage = ((rand () % 11) + 2); //calculate damage (random number 1-12)


used_stamina = 4; //use 4 stamina

}


if (damage > 10) //if damage is more then 10, say you sliced him

{
cout<<"You sliced the enemy for "<<damage<<" health"<<endl<<endl;
}
else if (damage > 0) //if its less then 10 but more then 0 (ie you had enough stamina)

//print you stabbed him

{
cout<<"You stabbed the enemy for "<<damage<<" health"<<endl<<endl;
}

}

else if(attack_type == 2) //OR if attack type was a magic attack

{

if (player_mana >= 5) //check to see if player has enough mana

{
cout<<"****You hit!****"<<endl<<endl; //since the player does, say "you hit"

damage = ((rand () % 20) + 2); //get damage from random number 2-20

used_mana = 5;//use 5 mana

cout<<"The enemy was burned "<<damage<<" health"<<endl<<endl;
//print the enemy was burned for "damage"


}

else //if player doesnt have enough mana

{
cout<<"|=|=|=|=|Not enough mana to cast spell|=|=|=|=|"<<endl<<endl; //say you dont have enough mana

}



}

}

else if (defence >= attack) //if defence is bigger, you miss.

{
damage = 0;

if (attack_type == 1) //if you miss and used a sword attack, do the follow:

{
if (player_stamina > 4) //check to see if they have enough stamina

{

used_stamina = 2; //if they do have enough stamina, take 2 away

cout<<"******You missed!*****"<<endl<<endl; //print "you missed"

}
else if (player_stamina < 4) //else if they dont have enough stamina

{
cout<<"|=|=|=|=|You are exhausted|=|=|=|=|"<<endl<<endl; //print you are exhausted.

}
}

else if (attack_type == 2) //if you misee and used magic,

{
if (player_mana >= 5) //check to see if they have enough mana

{
used_mana = 3; //if they do, use 3 mana and

cout<<"|=|=|=|=|The spell fizzled|=|=|=|=|"<<endl<<endl; // say the spell fizzled

}
else if (player_mana < 5) //if they dont have enough mana

{
cout<<"|=|=|=|=|=|Not enough mana to cast spell|=|=|=|=|=|"<<endl<<endl; //say "do not have enough mana"

}
}

}
enemy_health = enemy_health - damage; //update all damage done to the enemy

player_stamina = player_stamina - used_stamina; //update stamina used

player_mana = player_mana - used_mana; //update mana used


}

void enemy_attack (int &player_health) // calculates enemy attack "hit" or "miss" and

//calculates damage and updates health


{
int attack;
int defence;
int enemydmg;
int attack_type;


attack = (rand () % 11) + 2; //makes attack a random between 1-12


defence = (rand () % 11) + 2; //makes defence a random between 1-12




if (attack > defence) //if attack > defence, the PC hits the player

{

attack_type = rand () % 100; //generates a random number between 1-100, calling it attack_type


if(attack_type > 65) //if the number is > 50, then do a melee attack

{

cout<<"$=$=$=You were hit!=$=$=$"<<endl<<endl; //prints you were hit

enemydmg = (rand () % 11) + 2; //enemy damage for this melee attack is a random

//between 1-12

cout<<"Enemy bashed you for "<<enemydmg<<" health"<<endl<<endl;
//print the damage done

}

else //if the number is < 50, then do a magic attack

{

cout<<"$=$=$=$=You were hit!=$=$=$=$"<<endl<<endl; //prints you were hit

enemydmg = (rand () % 20) + 2; //enemy damage for this "lightning" attack

//is a random between 2-20

cout<<"Enemy bolted you for "<<enemydmg<<" health"<<endl<<endl;
//print the damage done



}
}

else if (defence >= attack) //if defence > attack, the pc missed the player


{
enemydmg = 0;
cout<<"=$=$=$=$They missed you!=$=$=$=$"<<endl<<endl; //print they missed you

}

player_health = player_health - enemydmg; //updated player health


}


void player_movement (int &spaces_moved)
{
char direction;

cout<<"Press ''W'' to move up"<<endl;
cout<<"Press ''A'' to move left"<<endl;
cout<<"Press ''S'' to move right"<<endl;
cout<<"Press ''Z'' to move backwards"<<endl<<endl;
cin>>direction;

if (direction == ''w'')
{
cout<<"You moved forward."<<endl<<endl;
}
else if (direction == ''a'')
{
cout<<"You moved left."<<endl<<endl;
}
else if (direction == ''s'')
{
cout<<"You moved right."<<endl<<endl;
}
else
{
cout<<"You moved backwards."<<endl<<endl;
}

spaces_moved = spaces_moved + 1;

}

void rand_attack (int spaces_moved,bool &battle_now)
{
int attack_chance = 0;

if (spaces_moved > 1)
{
attack_chance = (rand () % 100) + 1;

if (attack_chance > 85)
{
battle_now = true;
}
else if (attack_chance <=85 )
{
battle_now = false;
}
}

else if (spaces_moved <=1)
{
battle_now = false;
}
}

void enter_combat(int &enemy_health, int &player_health,int &player_stamina,int &player_mana,int &attack_type)
{
int bullets = 0;
int bullets_found = 0;
bool gun;
cout<<"**************************YOU HAVE ENTERED COMBAT!*****************************"<<endl<<endl;
do
{

cout<<"You have: "<<" The enemy has: "<<endl;
cout<<"***********************"<<" *********************"<<endl;
cout<<"---"<<player_health<<"---"<<"--health------"<<" -------"<<enemy_health<<"------health"<<endl;
cout<<"---"<<player_stamina<<"---"<<"---stamina-----"<<endl;
cout<<"---"<<player_mana<<"---"<<"---mana--------"<<endl<<endl;
cout<<"---"<<bullets<<"---"<<"---bullets--------"<<endl<<endl;
cout<<"********************************************************************************"<<endl<<endl;



cout<<"Type the number for the attack type and press enter"<<endl<<endl;
cout<<"[1 for sword attack, or 2 for fireball]"<<endl;
cin>>attack_type;
cout<<endl<<endl;

player_attack(enemy_health,attack_type,player_stamina,player_mana);
//this calculates the players attack, and updates enemyhealth/player stamina/mana


enemy_attack(player_health);
//this calculates the enemies attack, and updates player health.

}
while ((player_health > 0) && (enemy_health > 0));
//runs this battle untill one of the player dies.



if (enemy_health < 0)
{
cout<<"You have defeated the enemy"<<endl;

enemy_health = (rand () % 3) * 24;

gun = random_bool();

if (gun == true)
{
cout<<"Enemy dropped a gun"<<endl;
bullets_found = 12;
}

}
bullets = bullets_found + bullets;

}

bool random_bool()
{
bool chance;
int random = rand() % 100;

if (random >=50)
{
chance = true;
}
else
{
chance = false;
}

return chance;
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!