Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

181 Neutral

About thebigbossman

  • Rank
  1. If you love lambdas, I advice you to learn a truly functional language, like Scheme or Haskell. Of course, that is not game development related, but you would learn a whole new world of programming that you've not come across before and it will improve and sharpen your programming and problem solving skills.
  2. thebigbossman

    2d Game Making Blog

    This is a good concept (to document your progress). I would suggest a white colour scheme with full-width of the browser used because it's easier to read code that way.
  3. thebigbossman

    Global variable?

    While I agree, in principle (and it is easy to be theoritical)... In actual coding practice however, there are many situations where the most elegant and readable solution is probably using a global variable or object. Sometimes having to pass around a lot of data in functions belonging to different classes it just makes more sense to store certain program-wide information not belonging to any particular class (such situations do arise!) in globals. They should be minimized, but they exist for a purpose and that purpose may arise in some situations. Not saying it is recommended as a general practice. But it has its uses.
  4. thebigbossman

    From where to start

    Pacman is a tough challenge for any beginner. But it would teach you all about: 1. 2D graphics. 2. Moving, animating sprites and sprite collision detection. 3. Game loops. 4. User interaction/input control. 5. Level building or creating. 6. Simple Pathfinding for AI (ghosts). 7. Game logic and game states (e.g. when you've eaten a power pill you can eat ghosts instead of ghosts killing you). Enough to get you started with.
  5. thebigbossman

    Question concerning beginner project

    Speed depends on your code also to some extent. SDL (from my experience) is good enough for handling fast-paced 2D graphics without choking and remember, SDL itself is written in C and pygame is only a wrapper to the C graphics library. Even commercial games are written in SDL. If you handle your game logic properly, there should be no speed problems with using Python. If, of course, you are going to crunch a ENORMOUSLY HUGE lot of numbers or data in your game, C or C++ might be better suited. Otherwise, Python will be just fine for arcade type 2D shooters.
  6. thebigbossman

    Question concerning beginner project

    Python would work perfectly for 2D shooters using a library like SFML (python-sfml) or SDL (pygame). Could you describe a bit more of what kind of shooter you wish to make?
  7. Yes, you could use the function's parameters of each function to pass around the data. Of course, those data that are already members of the same class (e.g. Player) will not need to be passed around as each of the member functions can access it directly thus reducing the list of parameters. You would pass around only the extra information necessary which is not part of the class itself or when you're calling a member function of another class that does not otherwise have access to the data. ( Note: for the parameters that need to be affected/modified by the function that has been called, you would probably pass by reference. )
  8. Oh, yes, I can see how that can become a really huge mess of confusing switches. I suggest putting each of those combat options in a separate function that will evaluate the result and return it to the main Combat() function or simply just perform that combat operation and affect the necessary data within it. For example you could have an Attack () function that is called by the "A" option and which asks for the user to swing or thrust, and which calls in turn, the Swing () function or a Thrust () function from within it. [font="Courier New"] "A" | Attack () | ------------------------ | | "S" "T" | | Swing() Thrust() [/font]That will make the whole thing more manageable and easier to modify/maintain in the long run.
  9. I've not written a C++ program in ages and thought that a simple TicTacToe game would be fun to cook up. Mind you, I've never written a TicTacToe game before (at least not one that you play against the computer) so this is a first for me. I realize that the most optimal AI uses the Minimax algorithm, but I wanted to try out my own AI after reading the "rules" of the game on Wikipedia. Nothing really special this code, particularly, but I have a sense of achievement in writing C++ code after such a long [source lang="cpp"]// Simple command line TicTacToe game // (C) 2011 V.Harishankar // Released under the GNU GPL v3 #include <iostream> #include <cstdlib> #include <ctime> class TicTacToeGame { protected: enum Turn { PLAYER = 0, AI = 1 }; // Represents the current turn Turn current_turn; // Character (O or X for player) char player_char, ai_char; // Represents the board char board[3][3]; // Clear the board void initialize_board (); // Display the board void print_board (); // Chekc if all slots are filled bool all_slots_filled (); // Find a winning position for given player (O or X) and fill the // row and column parameter void find_winning_position (char noughtorcross, int &row, int &col); // Check if the specified player has won (O or X) bool check_if_won (char ch); // Human player move void player_move (); // Computer player move void ai_move (); // Game loop void play_game (); public: // Constructor TicTacToeGame () { // Note that these values are flipped when the game is initialized // for the first time current_turn = PLAYER; player_char = 'X'; ai_char = 'O'; main_menu (); } // Main game menu loop void main_menu (); }; void TicTacToeGame::player_move () { int row, col; // Get the row and column from human player while (1) { std::cout << "Enter row for " << player_char << " [1..3]: "; std::cin >> row; std::cout << "Enter col for " << player_char << " [1..3]: "; std::cin >> col; row -= 1; col -= 1; // Row and column must be valid if ((row >= 3 || row < 0) || (col >= 3 || col < 0)) std::cout << "Invalid row/column.\n"; else { // if it is a blank this is a valid move if (board[row][col] == ' ') break; else std::cout << "Cell is occupied.\n"; } } // Set the player move board[row][col] = player_char; } void TicTacToeGame::find_winning_position (char noughtorcross, int &row, int &col) { // check if specified character (nought or cross) can win along any row int i, j, chcount, emptycol, emptyrow; // Loop through rows for (i = 0; i < 3; i ++) { // Chcount -number of either O or X along the row chcount = 0; emptycol = -1; // Loop through columns for (j = 0; j < 3; j ++) { // If the specified player is occupying the cell, add to chcount if (board[j] == noughtorcross) chcount ++; // If specified cell is blank mark the column as empty else if (board[j] == ' ') emptycol = j; } // If there are two of the specified player in the row and there is an // empty cell, then the empty cell is the winning position if (chcount == 2 && emptycol != -1) { row = i; col = emptycol; return; } } // The same logic as above applies for columns // check if specified character can win along any column for (j = 0; j < 3; j ++) { chcount = 0; emptyrow = -1; for (i = 0; i < 3; i ++) { if (board[j] == noughtorcross) chcount ++; else if (board[j] == ' ') emptyrow = i; } if (chcount == 2 && emptyrow != -1) { row = emptyrow; col = j; return; } } // Check if specified character can win along diagonal top-left to bottom-right chcount = 0; emptyrow = -1; emptycol = -1; // Loop through the diagonal for (i = 0; i < 3; i ++) { if (board == noughtorcross) chcount ++; else if (board == ' ') emptyrow = emptycol = i; } if (chcount == 2 && emptyrow != -1 && emptycol != -1) { row = emptyrow; col = emptycol; return; } // Check if specified character can win along diagonal top-right to bottom-left chcount = 0; emptyrow = -1; emptycol = -1; // Loop through the diagonal for (i = 0; i < 3; i ++) { if (board[2-i] == noughtorcross) chcount ++; else if (board[2-i] == ' ') { emptyrow = i; emptycol = 2 - i; } } if (chcount == 2 && emptyrow != -1 && emptycol != -1) { row = emptyrow; col = emptycol; return; } } void TicTacToeGame::ai_move () { // Check if AI can win in this move int row=-1, col=-1; // See if AI can win in this move find_winning_position (ai_char, row, col); // if AI can win, play the winning move if (row != -1 && col != -1) { board[row][col] = ai_char; return; } row = col = -1; // see if player can win next move and block // if possible find_winning_position (player_char, row, col); if (row != -1 && col != -1) { board[row][col] = ai_char; return; } // check if the centre can be played if (board[1][1] == ' ') { board[1][1] = ai_char; return; } // Corner positions int corners[4][2] = {{0, 0}, {0, 2}, {2, 0}, {2, 2}}; // If any one or more corners are blank if (board[0][0] == ' ' || board[0][2] == ' ' || board[2][0] == ' ' || board[2][2] == ' ') { // randomly select corner while (1) { int corner = rand () % 4; row = corners[corner][0]; col = corners[corner][1]; if (board[row][col] == ' ') { board[row][col] = ai_char; return; } } } // Edge positions int edges[4][2] = {{0, 1}, {1, 0}, {1, 2}, {2, 1}}; // if any one or more edges are blank if (board[0][1] == ' ' || board[1][0] == ' ' || board[1][2] == ' ' || board[2][1] == ' ') { // randomly select edge while (1) { int edge = rand () % 4; row = edges[edge][0]; col = edges[edge][1]; if (board[row][col] == ' ') { board[row][col] = ai_char; return; } } } } bool TicTacToeGame::check_if_won (char ch) { bool win = false; // Check across int i; for (i = 0; i < 3; i ++) if (board[0] == ch && board[1] == ch && board[2] == ch) { win = true; break; } // Check down for (i = 0; i < 3; i ++) if (board[0] == ch && board[1] == ch && board[2] == ch) { win = true; break; } // check diagonals if (board[0][0] == ch && board[1][1] == ch && board[2][2] == ch) win = true; if (board[0][2] == ch && board[1][1] == ch && board[2][0] == ch) win = true; return win; } bool TicTacToeGame::all_slots_filled () { bool filled = true; for (int i=0; i < 3; i++) { for (int j=0; j < 3; j++) if (board[j] == ' ') filled = false; if (filled == false) break; } return filled; } void TicTacToeGame::print_board () { std::cout << "\n"; for (int i=0; i < 3; i ++) { for (int j=0; j < 3; j++) { std::cout << board[j] << "\t"; if (j < 2) std::cout << "|\t"; } if (i < 2) std::cout << "\n---------------------------------\n"; } std::cout << "\n"; } void TicTacToeGame::play_game () { // Initialize the board first initialize_board (); // If player char was X then make it O if (player_char == 'X') { player_char = 'O'; ai_char = 'X'; current_turn = AI; } else { ai_char = 'O'; player_char = 'X'; current_turn = PLAYER; } // So long as gameover is false, keep playing bool gameover = false; while (! gameover) { print_board (); // if turn is that of the player if (current_turn == PLAYER) { player_move (); current_turn = AI; } else { std::cout << "\nComputer played: \n"; ai_move (); current_turn = PLAYER; } // check for winner nought if (check_if_won ('O')) { print_board (); std::cout << "\nNoughts won! Game over...\n"; break; } else if (check_if_won ('X')) { print_board (); std::cout << "\nCrosses won! Game over...\n"; break; } else if (all_slots_filled ()) { print_board (); std::cout << "\nGame drawn.\n"; break; } } } void TicTacToeGame::initialize_board () { for (int i = 0; i < 3; i++) for (int j=0; j < 3; j++) board[j] = ' '; } void TicTacToeGame::main_menu () { while (1) { std::cout << "\n -------------------------"; std::cout << "\n Welcome to TicTacToe game"; std::cout << "\n -------------------------"; std::cout << "\n 1. Play"; std::cout << "\n 2. Exit"; char ch; std::cout << "\n Your choice: "; std::cin >> ch; switch (ch) { case '1': play_game (); break; case '2': return; } } } int main () { // initialize randomizer srand (time (NULL)); TicTacToeGame game; return 0; }[/source] I made this deliberately verbose and preferred to use the "rules" of the game, rather than a technique like the Minimax algorithm (which I confess, I don't fully grasp except in a theoritical sense). Any comments? I am not sure whether this is unbeatable or not. Could any of you try this out and see if you can beat the "AI"?
  10. thebigbossman

    Help with jumping

    I wanted to put forth effort,[/quote] So far as the evidence in this thread goes you've not even tried to debug the code yourself leave alone try to understand it. What exactly is meant by "effort"? And by the way, if I were you I would show some gratitude to the people who've actually bothered to take your code and worked with it to try and get the jumping code working whether the code works or not. They've spent their valuable time and effort for no material benefit. If you cannot do so, at least avoid insulting or belittling them. Your approach is wrong. Please understand that respect works wonders. Respecting the people who're trying to help will get you far.
  11. thebigbossman

    Modifying graphics.. is it legal to use?

    Thanks. Copyright is incredibly complex and so context-sensitive. Imagine a simple scenario. two photography enthusiasts visit a lovely location and for convenience sake, share the same camera. Each takes a picture one after the other of the same scene, a particularly beautiful one (from approximately the same angle and with the same camera but maybe with their own settings). One photo comes out underexposed and the other properly exposed. Later on, each claims that the properly exposed photo belongs to him. How does a court of law determine this question, particularly if there is no evidence as to who clicked the camera first? Also who owns the copyright of the actual "picture"? Both being similar pictures, how do you determine who "owns" the actual picture? Also remember, copying comic characters might be both a copyright and trademark violation depending on the circumstances. Trademarks is applicable in commercial contexts, while copyright applies both in commercial and non-commercial contexts. To avoid all this, of course, people simply advise against using any existing material as a base for your own creations.
  12. thebigbossman

    Modifying graphics.. is it legal to use?

    This question ideally should be answered only by a lawyer from a specific jurisdiction where you want advise as regards copyright law. Contrary to what musicians and artists state, copyright is nowhere near as strong as they think it is. However the fear of expensive litigation drives away a lot of people. A lot of people, for example, aren't even aware of fair use rights. So to answer specifically, if your final product is substantially different from the original even if you used the original as a "base" to build upon, then of course the final product cannot be said reasonably to belong to the other party and you own its copyright. If it is a mere derivative with few changes or additions and is identifiable with its original form, then it is a copyright infringement, most likely. What constitutes a derivative work is up to a court of law to decide. See, most of the "original" works are actually built upon pre-existing ideas or models. Copyright does not extend to ideas or designs, even. There are other IPR laws to deal with inventions (patents), designs (Designs Laws), and trademarks (Trademark Laws) and so on. Most people follow the maxim: if in doubt, don't! in regards to copyright law. Again, copyright is a very grey area and a lot of circumstances might make a particular thing a violation or not. Take it from me (I am a qualified lawyer). I am posting this just to clear some confusion. The statute book more often only talks about specifics and case laws (court decisions) build on the actual law of property rights. Again, each country has its own laws and interpretations of the value of intellectual property.
  13. Look at string padding functions to create fixed width fields for on-screen text display. http://msdn.microsof...=VS.110%29.aspx To create a padded string you need something like this (pseudo code): fixed_lengthstr = varlength_str.PadRight (10); (Where 10 is the total length of the string to pad. For example, if your string is 4 characters, the above will add 6 characters to the end of the string to make it a total of 10 characters. In such a case you need to limit the maximum number of chars you accept to 10). Also as an exercise, try to limit your character name to a certain number of maximum chars when asking for input. Anything less than that would be acceptable, but more than that, return an error or truncate it to 10 characters. Hint: Look at String.Length () functions.
  14. thebigbossman

    How to "care" about programming?

    There is no "cheating" involved. If that were the mentality, people would still be programming using assembly language or even machine language (0s and 1s) Tools to make it easier were created for a purpose. To free you from the tasks that are considered routine and to free up your creativity. A long time ago when I thought along similar lines as yours, I discovered GameMaker and even managed to create a fairly decent sidescroller. So there is no doubt in my mind. Stop breaking your head about programming if that's not really your interest area. To me, it seems like this. If I loved movies, and wanted to make my own movies, simply put, I buy a camera, and shoot.[/quote] Not quite. What about the "incidental" things, like getting a script, writing the screenplay, getting suitable actors for the parts, rehearsals, planning shoots, locations, actual shooting, camera work (panorama, closeups etc), lighting, props, putting together edits, sound editing, music work, post-production and so on? With a video camera you just shoot a video, not a full movie. To get a full movie, you need multiple skills. In some ways it's tougher than game programming because of the sheer range of skills required and no one man can do it all.
  15. thebigbossman

    How to "care" about programming?

    Man I think he missed my post about using tools like game maker etc. There you can learn to design games in principle without having to get your hands dirty with low-level code. I think that might be the best idea for now, until one develops a taste for programming and coding for its own sake.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!