Map editor help please! :} (changed my mind)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Map editor help please! :} (changed my mind)

Post by MadPumpkin »

I have decided to make both things in C++ now because i'm learning more about it and need some project to start with.
*'ed are changed things
I am making a map/level editor in *C++, for a arcade style top down shooter,(also in *C++) i need to know how to do basic things like...
1. File creating/writing/loading
I need to know how to create new documents, using *C++, and write them so that i can make map files for my game.
2. Cursor and tile clipping to a grid
I need to know how to... Lets say i have a red square as my cursor, i want to make this cursor automatically clip to a grid so
so that when i run functions and such, to lay a(n) tile/item/unit and it will be correctly placed
*
*
As you can see, i am still aiming for the same things, and still need help with the same things.
Once again,
Much appreciated,
MadPumpkin
Last edited by MadPumpkin on Sun Feb 15, 2009 6:10 pm, edited 1 time in total.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Map editor help please! :}

Post by MarauderIIC »

MadPumpkin wrote:I am making a map/level editor in BlitzBasic, for a arcade style top down shooter,(also in BB) i need to know how to do basic things like...
2. Cursor and tile clipping to a grid
I need to know how to... Lets say i have a red square as my cursor, i want to make this cursor automatically clip to a grid so
so that when i run functions and such, to lay a(n) tile/item/unit and it will be correctly placed
Not familiar enough with BlitzBasic personally to be able to help you with file/io but I'll tackle the easy problem: clip to grid in C++ (you surely have equivalent in BB) can be done by:

Code: Select all

float cursorX = mouse cursor's x position
float cursorY = mouse cursor's y position

cursorX = floor(cursorX); //1.2131 becomes 1, 1.9999 becomes 1, 1 becomes 1
cursorY = floor(cursorY);
In C++, you can duplicate this effect by

Code: Select all

cursorX = int(cursorX);
cursorY = int(cursorY);
Although in some cases you may prefer taking the ceiling:

Code: Select all

cursorX OR cursorY = ceil(cursorX); //1.2131 becomes 2, 1.99999 becomes 2, 1.000000000001 becomes 2, 1 becomes 1
You probably have equivalents, at least of floor() and ceil[ing]() in BlitzBasic.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Map editor help please! :}

Post by MadPumpkin »

Thank you very much! ill get started on that part of the code right away :}
thanks again
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Map editor help please! :} (changed my mind)

Post by MadPumpkin »

Hey People!! i am in dire need of help! seriously im bad at level editor creation!!!
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Map editor help please! :} (changed my mind)

Post by MarauderIIC »

Okay, file I/O in C++ goes like this:

Code: Select all

#include <fstream> //file operation thingies
#include <string> //for C++ style strings
#include <iostream> //for cout, cin

using namespace std;

int main() {
    string fname;
    string pants;
    cout << "Gimme filename: ";
    getline(cin, fname);
    ifstream myfile(fname.c_str()); //ifstream as in iutput filestream as in file acts as input as in read from file
    while (myfile) { //while myfile is open and accessible and isn't out of data to throw at us
        getline(myfile, pants); //pull a line from myfile
        cout << pants << endl; //write it to screen
    }
    myfile.close();

    string input;
    cout << "Gimme anudder filename: ";
    getline(cin, fname); //overwrite fname with console input
    ofstream myfile2(fname.c_str()); //ofstream as in output filestream as in output to file
    //by default, if file doesn't exist, it is created

    cout << "Tell me something!";
    //do a priming read
    getline(cin, input); //get some user input
    while (input != "") { //as long as the user doesn't input nothing, keep doing this stuff
        myfile2 << input << endl; //write input to file
        getline(cin, input); //get some more user input
    }
    myfile2.close();

    return 0;
}
Wrote that here in phpBB but I think it'll work as-is
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Map editor help please! :} (changed my mind)

Post by eatcomics »

Yeah it took me a day or two to get down file I/O but once you understand it and get it right it becomes fairly simple ;)
Image
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Map editor help please! :} (changed my mind)

Post by MadPumpkin »

eatcomics wrote:Yeah it took me a day or two to get down file I/O but once you understand it and get it right it becomes fairly simple ;)
well i understand file I/O now lol but yea your right
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
Post Reply