Page 1 of 1
Map editor help please! :} (changed my mind)
Posted: Sun Feb 15, 2009 6:27 am
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
Re: Map editor help please! :}
Posted: Sun Feb 15, 2009 1:43 pm
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.
Re: Map editor help please! :}
Posted: Sun Feb 15, 2009 5:22 pm
by MadPumpkin
Thank you very much! ill get started on that part of the code right away :}
thanks again
Re: Map editor help please! :} (changed my mind)
Posted: Sat Feb 21, 2009 6:05 pm
by MadPumpkin
Hey People!! i am in dire need of help! seriously im bad at level editor creation!!!
Re: Map editor help please! :} (changed my mind)
Posted: Sun Feb 22, 2009 12:43 am
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
Re: Map editor help please! :} (changed my mind)
Posted: Sun Feb 22, 2009 11:27 am
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
Re: Map editor help please! :} (changed my mind)
Posted: Thu Feb 26, 2009 12:56 pm
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