Advertisement Jump to content
  • Advertisement

Adamb

Member
  • Content Count

    22
  • Joined

  • Last visited

Community Reputation

124 Neutral

About Adamb

  • Rank
    Member
  1. Wow, not quite the type of replies I expected, thanks for all the input though! I guess what I failed to mention is that this a small side project at a job I work at part-time, so I don't exactly have the time to write my own compiler, create an entire scripting language, or anything of that nature. If anyone's got something better that can be implemented in an hour or two, I'm all ears... All I was looking to do is allow people to modify a few objects without having to mess around with pointers, structs, etc. You were right about natural language being a bad idea, so I'll be modifying it to be more C-like, while still hiding some of the more complicated aspects of the language. Yes, the fact that the compiler errors don't resemble the actual written code is a problem, but the compiler still points to the line causing the error, so it's usually pretty easy to figure out what's wrong. Like I said, I needed a quick solution. Thanks again for all the suggestions!
  2. Hello, I've got a program written in C, and I'm trying to modify it so that people who aren't experienced with programming can modify the program. The idea was to create a sort of scripting language using macros, so that something like BEGIN_FUNCTION( func1 ) set xpos to 0 add 5 to ypos END_FUNCTION would turn into something like void func1(Object* o) { o->xpos = 0; o->ypos += 5; } So then I started trying to create the macros... it was a little hackey, but I came up with the following: #define to , #define BEGIN_FUNCTION(name) void name(Object* o) { do{}while(0 #define set ); set2( #define add ); add2( #define END_FUNCTION ); } Which after being run through the preprocessor creates something like void func1(Object* o) { do{} while(0); set2(xpos, 0); add2(5, ypos); } Ok, looks good. All that's left to do is create the set2 and add2 macros, right? #define set2(var, val) o->var = val #define add2(val, var) o->var += val Wrong! The compiler gives "unterminated argument list invoking macro "set2"". If I just paste the code in from the preprocessor output before defining set2 and add2, and then define them, it works just fine. Or by making set2 and add2 functions. Or by changing the script syntax so the user just types something like set(xpos, 0). I'm just curious to know, why the hell doesn't this work?
  3. Hi, at my work we're using Mac OS 9.2 (I'm used to windows and a bit of linux), and programming in C... and I'm having two problems. 1) I need to create a bunch of directories... how can I do this in C? I tried system("mkdir whatever") but nothing happened... as far as I know there isn't even a command prompt in os 9, so I don't know what to do. 2) I need to navigate to other directories and open files in them.. how can I do this? basically I need info on how the file system is organized on mac. I created a subdirectory called Data in the program's main folder, and tried an fopen("Data\\file.dat", "w"), but it just made a file named Data\file.dat, apparently \ is allowed in filenames... so how can I navigate to subdirectories? I searched google but wasn't able to turn up anything useful... I really just need to see some example code of how this is done, can anybody help? Thanks.
  4. Adamb

    Item generator program

    Try taking the srand() out of the constructor and putting it somewhere else. I'm guessing you created 2 instances of the class at the same time, so when the second one is created you reseed with the same value.
  5. Adamb

    A new Tetris game

    Sorry to burst your bubble, but it's been done before in a little game called Nyet 3. See here. But don't let that stop you from making it though! :)
  6. Adamb

    Vector pointers

    Why not just use a reference instead of a pointer? i.e. float Neuron::Train(vector<int>& Input, int correctOutput) Then it won't be copying the vector. If you use pointers, you have to dereference them. ( *vector instead of vector to retrieve the i element of the vector ).
  7. I think I've come accross a bug in the STL or gcc maybe. Can anyone else reproduce this? Here's the code: #include <iostream> #include <vector> using namespace std; int main() { vector<int> numbers; for(int limit = 2; limit < numbers.size()-2; limit++) cout << limit << endl; return 0; } On my computer, this goes into an endless loop, printing 2, 3, 4 ... and so on. I thought it had something to do with the vector being empty, but this works fine: #include <iostream> #include <vector> using namespace std; int main() { vector<int> numbers; for(int limit = 2; limit < numbers.size()/2; limit++) cout << limit << endl; return 0; } Nothing gets printed out at all, which is what I would expect to happen. This also works fine: #include <iostream> #include <vector> using namespace std; int main() { vector<int> numbers; int x = numbers.size()-2; for(int limit = 2; limit < x; limit++) cout << limit << endl; return 0; } So what the heck? Any ideas? I'm using Dev-C++ with mingw.
  8. Hello, I'm trying to make a game with the minmax/alpha-beta algorithm. I've used minmax before in a tic tac toe clone, so I kind-of know how it works. However, the game I'm trying to create now can support up to 4 players. Can the minmax algorithm work with more than 2 players? If so, how?
  9. Adamb

    first Java app

    Quote:Original post by hisDudeness I get a funny warning saying "example\Main.java modified in the future". And then, absolutely nothing happens. Sounds like your computer clock is off, or the clock of the person who made the example. If there clock was set too far ahead, it might cause that error.
  10. Adamb

    Tetris scoring formula

    Yeah, that's how I made it when I made a tetris clone. 1 line was like 1000 points, 2 was 2000, 3 was 4000, and 4 was 8000, multiplied by the level number. The point of giving points every time a piece touches the bottom was probably to reward the player for surviving longer. Also, tetris usually has an unlimited number of levels, the pieces just drop a little bit faster each level. And every 10 lines or so cleared it's a new level.
  11. Adamb

    License for classical music

    This reminds me of a similar question I've always wondered... I play a few different instruments. Let's say I made a recording of some classical piece, and wanted to use it in a game. Would this be legal, even if the sheet music I used was copyrighted?
  12. Adamb

    Rotation

    Would this work? temp_array[4][4]; for(int i = 0; i < 4; ++i) for(int j = 0; j < 4; ++j) temp_array[j] = array[j]; then if you want to you can copy them all back into the original array.
  13. Adamb

    I just got an LCD monitor

    I have almost the same monitor as you (Samsung 730b), and I too was initially dissapointed with it. But I've gotten used to it, now, and there's a lot I like about it (sharper text, no flickering). BTW, do you have a DVI cable? I know mine didn't come with one, but I bought one for $10, and it helped out a lot.
  14. Adamb

    Tetris clone input

    Quote:Original post by Cacks Thanks for the help! Don't suppose there is anyway of colouring chars in the console? Yes, but it depends on the operating system you're using. In windows, it works like this: SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0xXY); Where X is the background color you want (0 is black, F is white, the rest are all different colors) and Y is the forground color. For example, if you wanted a red background, and black text, it would be SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0xC0); Hope this helps :)
  15. Adamb

    Tetris clone input

    Quote:Original post by Cacks How did you go about creating your Tetris? I made the playing board a matrix of booleans. If a brick existed on the board the boolean for that position equaled true. And the bricks were made of boolean matrices too. Any better ways to go about it? Also, in the future i'd like to make my own input. I suppose I would need to create something like the 'MainWindowProc' like in Win32 apps? Is this what one would call a messaging system? I've nothing against SDL but I don't really like using alternative libraries, I don't like not knowing how the code works, silly I know LOL Yeah, that's pretty much how I did it, except instead of bools, it was ints, and the ints stood for what color to draw the pieces. Then there was a struct for the current block, like struct block { x[4], y[4] }; or some such thing. There's probably a better way to do it, but I was a complete noob when I made it, so... :) About making your own input: SDL is definitly easier, but it's not too difficult to do everything with the windows API, tho it won't be portable. There's a good tutorial here: http://www.winprog.org/tutorial/
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!