Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Dezzles

  • Rank
  1. My best guess is to handle one collision first, then check to see if the other is still an issue, if so then handle it... But you're probably doing that already. What sort of incorrect results are you getting?
  2. You could always represent the world using the bitmap but have the physics calculated using line segments. The trick is just having the physics geometry matching the bitmap
  3. Oh you're writing it for GBA, that does make things a lot more difficult (not much I can do to help you with it really). How well does the GBA handle floating point numbers? There's always the option of building in a quick box2d app and testing it out? After further investigation, the DS only handles fixed-point numbers which means that the GBA probably does the same...
  4. If you're using c/c++ you could probably use box2d (http://www.box2d.org). Then modify my code above so that it doesn't move up and down when creating the groups. Then for the left most cell in each group create a shape to use dynamicBox.SetAsBox(tilewidth*tilesInSet, tileheight); Then attach each one to fixture, use it for a body and set the body's position to the centre of the cell group, make sure that they're static objects and it should work nicely
  5. You could probably use a flooding technique to determine which blocks are joined. For example, #include <iostream> #include <deque> using namespace std; typedef struct Tile { bool collidable; int collisionSet; } Tile; void SortGroups(Tile* tiles, int wid, int hei); int main() { int wid = 10; int hei = 10; // Create an array of tiles, the system would also work with a 2 dimensional array Tile* tiles = new Tile[wid * hei]; for (int i = 0; i < wid * hei; i ++) { // Default set tiles to non-collidable tiles.collidable = false; // Tile doesnt' belong to a collision set tiles.collisionSet = -1; // Randomly setting whether a tile is collidable if (rand() % 3 == 0) { tiles.collidable = true; } } // Print out the way the world looks printf("|"); for (int i = 0; i < wid * hei; i ++) { if (tiles.collidable) printf("#"); else printf(" "); if ((i % wid) == wid-1) printf("|\n|"); } // Assigns a group to collidable tiles SortGroups(tiles, wid, hei); // Prints out the tiles according to their group printf("\n\n|"); for (int i = 0; i < wid * hei; i ++) { if (tiles.collidable) printf("%c", tiles.collisionSet + 'A'); else printf(" "); if ((i % wid) == wid-1) printf("|\n|"); } } void SortGroups(Tile* tiles, int wid, int hei) { // A deque is like a vector but allows pop_front as well as pop_back deque<int> checks; // The first set id you can use int currentSet = 0; int currentCell; // We'll go through each of the tiles we have for (int i = 0; i < wid * hei; i ++) { // If the tile is collidable but not in a collision set if (tiles.collidable && (tiles.collisionSet == -1)) { // Put it in our list of checks checks.push_back(i); tiles.collisionSet = currentSet; // While we have items in our checks keep going while (checks.size() > 0) { // Assign the first item in checks to currentCell then remove that item // from the list currentCell = checks[0]; checks.pop_front(); // This checks to see whether we have the left most tile on our map if ((currentCell % wid) > 0) { // If not we check whether we can collide to the tile to the left, and check if it's been assigned // a collision set if (tiles[currentCell - 1].collidable && (tiles[currentCell - 1].collisionSet == -1)) { // If not, we add it to our list of tiles to check and set its collision set tiles[currentCell-1].collisionSet = currentSet; checks.push_back(currentCell-1); } }/**/ // Do the same for checking to the right if ((currentCell % wid) < (wid - 1)) { if (tiles[currentCell + 1].collidable && (tiles[currentCell + 1].collisionSet == -1)) { // If not, we add it to our list of tiles to check and set its collision set tiles[currentCell+1].collisionSet = currentSet; checks.push_back(currentCell+1); } } // Moving upwards if ((currentCell - wid) > 0) { if (tiles[currentCell - wid].collidable && (tiles[currentCell - wid].collisionSet == -1)) { // If not, we add it to our list of tiles to check and set its collision set tiles[currentCell-wid].collisionSet = currentSet; checks.push_back(currentCell - wid); } } // Moving down if ((currentCell + wid) < (wid * hei)) { if (tiles[currentCell + wid].collidable && (tiles[currentCell + wid].collisionSet == -1)) { // If not, we add it to our list of tiles to check and set its collision set tiles[currentCell + wid].collisionSet = currentSet; checks.push_back(currentCell + wid); } } } // It wouldn't be too hard to add in diagonal checks if you wanted to // Increase the set number currentSet ++; } } } This isn't necessarily the quickest way to go about grouping them but it seems to run pretty quickly when wid=100 hei=100 so that's something. From then on there's still the issue of how to merge the blocks that are in the same collision set. How are you currently storing the blocks? (If it's a 2D array I can easily change the above code over). What are you using for the collision detection?
  6. Dezzles

    I really need some guidance

    c++ is (in my opinion) one of the best languages to learn. It's possibly not the best place to start as the learning curve can be quite nasty at times, especially when you try to learn pointers. A lot of games are written in c/c++ nowadays as it is quite portable and faster in most cases than other languages. I'm not entirely sure what consoles are developed in (I expect c/c++) and looking to code for them is difficult as you often have to spend alot of money on purchasing the SDK from the company that makes the console (looking at thousands of dollars here). As for how useful it is, if you have a browse around online you'll find that there are ALOT of libraries that are written for c/c++ which make building games significantly easier. When it comes down to it the language that you choose to learn is very important. Chances are to work in the games industry you'll need at least some c/c++ knowledge. If you want to build Indie games then it depends on where you want to go, developing for Mac and Windows you'll probably want to focus on c/c++ or java, if you just want to focus on Windows then there is a huge assortment but you'll probably want to stick to c/c++, c#, java or XNA. Each of which have their pros and cons. Really, XNA is using c# but it also allows for deployment to the Xbox 360
  7. Dezzles

    What's wrong with my A* algorithm?

    I don't think it's abnormal for an A* search algorithm to spread out a little bit like in your above example. As you get closer to the target, your cost along the path you're exploring is getting higher, while the distance is getting smaller. The result of this often means that you'll get a little bit of spread happening depending on how you pick the next node. I'm not completely sure what the issue is (it's been a while since I've worked in python) but there is definitely something funny happening (your first example doesn't look like it's following the shortest path) I'd recommend looking at http://www.policyalmanac.org/games/aStarTutorial.htm
  • 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!