Jump to content

  • Log In with Google      Sign In   
  • Create Account


SoundFX

Member Since 01 Jul 2006
Offline Last Active May 25 2013 09:42 AM

Topics I've Started

DirectX Programming with DEV C++

18 November 2006 - 07:50 PM

This is a hard problem to describe... Im using DEV C++ v4.9.9.2 in conjunction with "Programming role-playing games with directX" 2nd edition by Jim Adams. (Pages 35-41 if anyone happens to have the book) I believe I have the project set-up right with the include files and library files contained in the DirectXSDK I have installed. Anyway, I wrote out the code and I dont get any compile errors that makes it fail...i just get this permission denied thing and I am not sure how to fix it. This is my compile log:
Quote:
Compiler: Default compiler Building Makefile: "C:\Dev-Cpp\Makefile.win" Executing make... make.exe -f "C:\Dev-Cpp\Makefile.win" all g++.exe DirectXProject/WinMain.o -o "DirectXProject.exe" -L"C:/Dev-Cpp/lib" -L"E:/DX90SDK/Lib" -L"E:/DX90SDK/Lib" -mwindows E:/DX90SDK/Lib/strmiids.lib E:/DX90SDK/Lib/amstrmid.lib E:/DX90SDK/Lib/d3d8.lib E:/DX90SDK/Lib/d3d9.lib E:/DX90SDK/Lib/d3dx.lib E:/DX90SDK/Lib/d3dx8.lib E:/DX90SDK/Lib/d3dx8d.lib E:/DX90SDK/Lib/d3dx8dt.lib E:/DX90SDK/Lib/d3dx9.lib E:/DX90SDK/Lib/d3dx9d.lib E:/DX90SDK/Lib/d3dx9dt.lib E:/DX90SDK/Lib/d3dxd.lib E:/DX90SDK/Lib/d3dxof.lib E:/DX90SDK/Lib/ddraw.lib E:/DX90SDK/Lib/dinput.lib E:/DX90SDK/Lib/dinput8.lib E:/DX90SDK/Lib/dmoguids.lib E:/DX90SDK/Lib/dplayx.lib E:/DX90SDK/Lib/dsetup.lib E:/DX90SDK/Lib/dsound.lib E:/DX90SDK/Lib/DxErr8.lib E:/DX90SDK/Lib/DxErr9.lib E:/DX90SDK/Lib/dxguid.lib E:/DX90SDK/Lib/dxtrans.lib E:/DX90SDK/Lib/encapi.lib E:/DX90SDK/Lib/ksproxy.lib E:/DX90SDK/Lib/ksuser.lib E:/DX90SDK/Lib/msdmo.lib E:/DX90SDK/Lib/quartz.lib C:\Dev-Cpp\Bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot open output file DirectXProject.exe: Permission denied collect2: ld returned 1 exit status make.exe: *** [DirectXProject.exe] Error 1 Execution terminated
And this is my code if it is helpful:
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>

//Main application instances
HINSTANCE g_hInst; //global instance handle
HWND g_hWnd; //Global window handle

//application window dimensions, type, class and window name
#define WNDWIDTH 400
#define WNDHEIGHT 400
#define WNDTYPE WS_OVERLAPPEDWINDOW
const char g_szClass[] = "FrameClass";
const char g_szCaption[] = "FrameCaption";

//Main application prototypes

//Entry point
int pascal WinMain(HINSTANCE hInst, HINSTANCE hPrev,
                    LPSTR szCmdLine, int nCmdShow);

//Function to display an error message
void AppError(bool Fatal, char *Text, ...);

//Message procedure
long far pascal WindowProc(HWND hWnd, UINT uMsg, 
                            WPARAM wParam, LPARAM lParam);

//Functions to register and unregister windows' classes
bool RegisterWindowClasses(HINSTANCE hInst);
bool UnregisterWIndowsClasses(HINSTANCE hInst);

//Function to create the application window
HWND CreateMainWindow(HINSTANCE hInst);

//Functions to init, shutdown, and handle per-frame functions
bool DoInit();
bool DoShutdown();
bool DoPreFrame();
bool DoFrame();
bool DoPostFrame();

bool RegisterWindowClasses(HINSTANCE hInst) {
    WNDCLASSEX wcex;

    //create the window size here and register it
    wcex.cbSize = sizeof(wcex);
    wcex.style = CS_CLASSDC;
    wcex.lpfnWndProc = WindowProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInst;
    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = NULL;
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = g_szClass;
    wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wcex))
        return false;
    
    return true;

}

bool UnregisterWindowsClasses(HINSTANCE hInst) {
    //unregister the window class
    UnregisterClass(g_szClass, hInst);
    return true;
}
   
HWND CreateMainWindow(HINSTANCE hInst) {
    HWND hWnd;
    
    //create the main window
    hWnd = CreateWindow(g_szClass, g_szCaption, WNDTYPE, 0, 0, WNDWIDTH,
                        WNDHEIGHT, NULL, NULL, hInst, NULL);

    if(!hWnd)
        return NULL;
    
    //show and update the window
    ShowWindow(hWnd, SW_NORMAL);
    UpdateWindow(hWnd);
    
    //return the window handle
    return hWnd;
}

void AppError(bool Fatal, char *Text, ...) {
    char CaptionText[12];
    char ErrorText[2048];
    va_list valist;

    //build the message box caption based on fatal flag
    if (Fatal == false)
        strcpy(CaptionText, "Error");
    else
        strcpy(CaptionText, "Fatal Error");
   
    //build variable text buffer
    va_start(valist, Text);
    vsprintf(ErrorText, Text, valist);
    va_end(valist);
    
    //display the message box
    MessageBox(NULL, ErrorText, CaptionText, MB_OK | MB_ICONEXCLAMATION);

    //Post a quit message if error was fatal
    if(Fatal == true)
        PostQuitMessage(0);
}

//the message procedure empty except destroy message

long FAR pascal WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    
    switch(uMsg) {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    } //end switch

    return DefWindowProc(hWnd, uMsg, wParam, lParam);

}

bool DoInit() {
    //perform application intialization functions here
    //such as those that set up graphics, sound, network, etc...
    //return true for success, false otherwise
    return true;
}

bool DoShutdown() {
    //perform application shutdown functions here
    //such as those that shut down the graphics sound etc..
    return true;
}

bool DoPreFrame() {
    //perform preframe processing such as setting up a timer
    return true;
}

bool DoFrame() {
    //perform per frame processing such as rendering
    return true;
}

bool DoPostFrame() {
    //perform post frame processing such as time syncing etc
    return true;
}

int pascal WinMain(HINSTANCE hInst, HINSTANCE hPrev, 
                    LPSTR szCmdLine, int nCmdShow)
{
    MSG Msg;
    
    //Save application instanec
    g_hInst = hInst;
    
    //Register window classes = return on false
    if(RegisterWindowClasses(hInst) == false) {
        return false;
    }//end if

    //Do application initialization = return on false
    if(DoInit() == true) {
        
        ZeroMemory(&Msg, sizeof(MSG));
        while(Msg.message != WM_QUIT) {
            //Handle windows messages if any
            if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
                TranslateMessage(&Msg);
                DispatchMessage(&Msg);
            } else {
            
                //Do pre-frame processing, break on false return value
                if(DoPreFrame() == false)
                    break;
                
                //do per-frame processing
                if(DoFrame() == false)
                    break;
                
                //do post-frame processing
                if(DoPostFrame() == false)
                    break;
            } //if-else end
        }//whle end
    } //if end

    //do shutdown functions
       DoShutdown();

    //unregister window
    UnregisterWindowsClasses(hInst);

    return true;
}
  


EDIT: I just checked my processes and apparently I have a ton of my programs running which could possibly explain my error... but why cant I see it?

Creating and instance of a class in a class

06 July 2006 - 01:47 PM

Hello, somewhat new here, but Ill skip the introductions and get on with my problem. I am creating a text-based rpg (yea I know, not another one), but I am having a few problems. I have a job class, which holds all my spells and hit die and attack bonuses and such. I can create one of those on its own fine using my own constructor. job_info.h
#ifndef job_info_H
#define job_info_H
#include <string>
#include <vector>

class job_ability {
public:
	std::string name; //the name of our spell
	//when using an ability deal direct damage(melee or a spell) then do the damage boost
	//directDamage + damageBoost = totalDamage; ???
	int directDamage;	//the dice it will roll for damage (xd4-xd20)
	int damageBoost; //my damage boost
	double multiplier; //incase we need to do 2 or more dice	
	int manaCost; //mana consumed upon using
	int levelReq; //level required before gaining it
	std::string preReq; //pre-requisites?
	//skills with buffs/debuffs/and round-lasting effects (like bleeding/poison)
	int myAttackMod; //if the ability boosts my attack mod
	int myDefenseMod; //if the ability boosts my defense mod
	int enemyAttackMod; //if the ability lowers enemy attack mod
	int enemyDefenseMod; //if the ability lowers enemy defense mod
	int rounds; //the number of rounds an ability will last (0 is forever, like an Aura)	
	int actions; //number of actions this will take
	
	int mpDrain; //for use with mpDrain skills
	int hpDrain; //for use with hpDrain skills
	//Auras
	int on; //1 yes || 0 no

	//Stealth/Jump  Stealth can be seen through (Theif/Ninja), Jump you cannot be hit (Dragoon)
	int stealthMod; // 100 is cannot be hit

};

class job_info {
public:
    job_info(int choice); //this will allow us to choose our class via a prompt.
    std::string name;
	int hitDie;
	int manaDie;
	int attackBonus;
	int spellDefense;
	
	//store all of our abilities in this vector for use
	//they will be filled by the becomeClass functions
	std::vector<job_ability> myAbilities;
	
	//functions
    //void Berserker();
    //void BlackKnight();
	void BlackMage();
    //void BlueMage();
    //void Dragoon();
    //void Engineer();
    //void Fighter();
    //void Marksman();
    //void Monk();
    //void Ninja();
    //void Summoner();
    //void Thief();
    //void WhiteKnight();
    //void WhiteMage();

};
#endif



job_info.cpp
#include "job_info.h"
#include <string>
#include <vector>
#include <iostream>

using std::string;
using std::vector;


job_info::job_info(int choice)
{
	switch (choice) {
        case 0: job_info::BlackMage(); break;
        //more classes later
    };
}


void job_info::BlackMage()
{
	name = "Black Mage";
	hitDie = 4;
	manaDie = 12;
	attackBonus = 0;
	spellDefense = 0;
	
	//Fire spell
	job_ability Fire;
		Fire.name = "Fire";
		Fire.directDamage = 8; 
		Fire.multiplier = 1;
		Fire.manaCost = 4;
		Fire.levelReq = 1;
        Fire.actions = 1;
			
	
	//Start filling our container
	myAbilities.push_back(Fire);
    
/*note to Gamedev, i took out the other 20+ skills to save space :O */

}


As you can see I can ask for a choice of input, but only 1 option is available at the moment. The important part is that it works. If I try to create a character though, similary named 'character_info' with a member of type job_info, called 'myJob'. I cannot figure out how to be able to instantiate (that the right word?) a job_info inside my character_info's constructor. Sorry for the mess of comments inside the following code, im trying to figure out how to get it to work, its an uphill battle, my latest attempt was to return a value with a function and use it to create 'myJob'. character_info.cpp
#include <string>
#include <iostream>
#include <vector>
#include "job_info.h"
#include "character_info.h"
//#include "weapon_info.h"
//#include "race_info.h"

using std::cout;
using std::cin;
using std::string;
using std::endl;
using std::vector;


int character_info::selectJob() {
	cout << "\nPlease choose a class by selecting its corresponding number:\n0. Black Mage" << endl;
    int choice;
	
    cin >> choice;
    //job_info myJob(choice);

    //cout << "\nCongratulations, you are a: " << myJob.name << endl;

    //cout << "You have these abilities: \n";

    //for (vector<job_ability>::const_iterator it = myJob.myAbilities.begin();
    //        it != myJob.myAbilities.end(); ++it)
    //{
    //    cout << (*it).name << endl;
    //};
	
	return choice;
}


void character_info::setAttributes() {
    //we need to set all our attributes here as well as change the modfier accordingly
    while (attributePoints > 0) {
        cout << "\nPlease spend your attribute points.  You have " << attributePoints << " to spend." << endl;
        
        cout << "\nPlease choose an attribute to add points to: "
            << "\n1: Strength" << "\n2: Dexterity" << "\n3: Vitality" << "\n: Energy" << "\n: Spirit";

    int choice;
        switch (choice) {
            case 1: ++strength, --attributePoints; break;
            case 2: ++dexterity, --attributePoints; break;
            case 3: ++vitality, --attributePoints; break;
            case 4: ++energy, --attributePoints; break;
            case 5: ++spirit, --attributePoints; break;
            default: cout << "\nThat is not a valid option please choose again." << endl; break;
        };
    };    
    cout << " You have " << attributePoints << " to spend" << endl;
}

void character_info::selectRace() {
    //choose our race and change the attribute the racial bonus gives
}

void character_info::selectAbilities() {
    //show the a list of available abilties by level = 1 and pre-requisite == none
}

character_info::character_info() {
    //ask for name
    cout << "Please enter your characters name: " << endl;
    cin >> name;

    //set all defaults
    strength = 10;
    dexterity = 10;
    vitality = 10;
    energy = 10;
    spirit = 10;
    luck = 10;
    currentExp = 0;
    nextExp = 1000;
    level = 1;
    actions = 1;
    attributePoints = 15;
    abilityPoints = 3;
    isPoisoned = false;
    isBleeding = false;

    //ask to choose a job
    myJob(selectJob());
    //ask to plug in attribute points
    setAttributes();
    //ask for a race
    //setRace();
    //ask for abilities
    //selectAbilities();

}




character_info.h
#ifndef character_info_H
#define character_info_H
#include <string>
#include "job_info.h"
//#include "weapon_info.h"
//#include "race_info.h"

class character_info {
public:
    //Our default constructor will handle the name entry as well as set all the defaults for our character
    character_info();

	std::string name;
	job_info myJob;
	//weapon_info myWeapon;
	//race_info myRace;

	int level;
	double currentExp, nextExp; 
	int	currentHealth, maxHealth, currentMana, maxMana; 
	int strength, dexterity, vitality, energy, spirit, luck, strMod, dexMod, vitMod, engMod, sprMod; 
	int actions, attributePoints, abilityPoints; 
    bool isPoisoned, isBleeding;  //Will allow us to perform DoT() checks
    

    //We need to select a job
    int selectJob();
    //We need to spend our attribute points first
    void setAttributes();
    //We then need a race
    void selectRace();
    //Lastly, choose our abilities
    void selectAbilities();
    
	
};
#endif


main
#include <iostream>
#include <vector>
#include "job_info.h"
#include "character_info.h"

using namespace std;

int main()
{   
    character_info myInfo; //give us a character
	
    system("PAUSE");
    return 0;
}


Anyway, if someone could hint at what im doing wrong, that would be swell. For reference I am using MinGW Studio and DEV C++, fully updated. (I like them both :D) *Edit: The reason I know its with the job_info stuff is from the compiler. I can also make a jobless character with ease by commenting out the job stuff, but no one likes a plain character*

PARTNERS