Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

93 Neutral

About Deadlybones

  • Rank
  1. Deadlybones

    Handling object collisions

    Hey there. I'm trying to implement some basic physics/collisions in my game. I have the formulas I need and I actually have working test collisions with objects(just looping through and checking if they collide). Right now I just have a player(circle physics body), a single enemy(circle physics body), and a static axis aligned rectangle(rectangle physics body obviously). However, I want to add a lot more enemies but I'm not quite sure of the "best" way to do it. Say there are 100 circular enemies and I want them to all check for collisions with each other. So I would go about this by looping for each of these enemies and checking if they collide with every other enemy on the list. I can see that this isn't really all that efficient so I'm wondering how I could make it better. I only want them to check the ones around them. So I guess I should have a simple distance check to see if they are in the radius of each other, and then do the more complicated checks. What can I do on top of this or instead of this? Thanks. EDIT: NOTE: I'm using C++ EDIT2: With some googlin' I have come across the term "broad-phase algorithms" and I think this is what I'm looking for. I've heard the term, just never knew what it was about. Any good sources on this would be really helpful(I'll continue looking). EDIT3: Or quadtrees? This seems like what I'm gonna roll with. I'll try it.
  2. Deadlybones

    C++ File browser/explorer?

    Thanks, I thought it might be quite involved but I knew there were system commands to open the file explorer so I thought there might be something similar, but whatever. I'll only need it to work for windows so I'll look in to QT perhaps in the future. For now I'll just do simple file loading with the command prompt
  3. I have a tile editor that I'm creating in C++ for my game but I'm stuck on something. For loading/saving files I want to open a file explorer/browser thing so the user can select where they want to save the file(or load a file). I could probably achieve something by just using text commands in the cmd but I'd rather have a file explorer. I'm not sure how the best way to do this would be. Thanks. PS I'm using SFML
  4. Thanks for the quick reply. I found someone else who had the same problem on google but I didn't have enough time to delete the thread. You're just too quick I guess ;)
  5. I was playing around with C++ file i/o today and couldn't seem to get it to work. I renamed my file from "example.txt" to just "example" and it worked(I still loaded it using .Open("example.txt") though in my program). Why is this? I would like to include the extention in my file name(specifically a custom name such as "example.custom", but it would still be a .txt file).
  6. Deadlybones

    SFML - Tile maps

    Well there isn't really a specific way to do it(like anything in game development), but perhaps I could offer some guidance as I'm making a tile based game too. There isn't really anything special to tile layers; it's just a term given to maps that can be layered on top of each other. You could even have one layer in your whole game, but you can see how that wouldn't work out. If a there was a 5X5 area of grass and you wanted to put a tree on it, then in between the branches you would just see whatever colour the background is because you replaced the grass tile that was there before. Some people tackle this by adding another layer to place the tree on. That way the first layer has grass on it, and the tree looks like it's on top. You might have to use multiple layers for multiple trees that are overlapping to get the effect you want though. Personally, I'm only having probably one tile layer in my game. This will be for basic landscape stuff like grass, dirt, etc. Then I will have an object layer where I will have pre-made objects(which can be trees, flowers, bad guys, houses, etc.) and my engine will take their positions and determine how to draw them. For starters, you could get your character to collide with the edges of the screen. For example, to collide with the left side of the screen, you would check if the player's x position was less than 0, and if so, set it to 0. Next you'll want to be able to draw tiles on the screen. You could represent a tile map using an array of integers. Different numbers would represent different tile textures that you would have to draw. So a 3X3 array of '0's would be a map that represents a 3X3 grid of grass tiles while '1's might be water or something. You could these numbers from a text/binary file or an XML file or something. Since you were wondering about XML, it's basically just a human-readable way to store information. XML files don't really do anything(in a sense), it's up to your program to interpret it. One more suggestion is that since you are using SFML, you can use "views" to move the camera around. Check the SFML website for how to use them. Now for my best piece of advice. My post is relatively vague, but everything I mentioned is covered in Nick Gravelyn's tile engine tutorials. It's written in C# and he does a lot more stuff like creating a tile editor, but you can still apply his stuff to your C++/SFML game. Look up "NIckGravelyn" on youtube. Good luck. Feel free to ask any questions if you want.
  7. Today I got really fed up with my use of header files in C++. Somewhere along the line I've been put under the assumption that every class should have a header file. I guess my only reasoning is for "[color=#000000][font=Arial,]separating the interface from the implementation" as some random person on a google search puts it. Is it considered good coding practice to create a header file for each class to do this? Basically none of my classes depend on functions in other header files but that is really the only reason that I might want to use them. I'll probably just scrap the header file per class thing unless someone persuades me not to as it's really annoying to have to declare all my variables in one place, define them in another, and same with functions. Any advice would be appreciated.[/font]
  8. Ok so I know how to calculate if two ellipses have intersected, but now I want to move my ellipses after they have intersected(ie one slides off of the other). I have an idea on how to do it in my head, but it will only work if two ellipses are the same size. I want to be able to handle the collision of two axis aligned ellipses of any size. For starters, I think I probably need to find the point of intersection but I'm not sure how to do that. Any help would be appreciated, thanks. Here's the code for seeing if two ellipses have intersected: //Returns true if the pixel is inside the ellipse bool CollisionCheckPixelInEllipse(Vector2d pixel, Vector2d center, Vector2d radius) { int asquare = radius.x * radius.x; int bsquare = radius.y * radius.y; return ((pixel.x-center.x)*(pixel.x-center.x)*bsquare + (pixel.y-center.y)*(pixel.y-center.y)*asquare) < (asquare*bsquare); } // returns true if the two ellipses overlap bool CollisionCheckEllipses(Vector2d center1, Vector2d radius1, Vector2d center2, Vector2d radius2) { int radiusSumX = (int) (radius1.x + radius2.x); int radiusSumY = (int) (radius1.y + radius2.y); return CollisionCheckPixelInEllipse(center1, center2, Vector2d(radiusSumX, radiusSumY)); } EDIT: It appears this thread was posted twice by accident EDIT2: I might just not use ellipse collisions after all
  9. EDIT: Duplicate post.
  10. Deadlybones

    Spells you´ve ever wanted to cast

    I've never really seen it in many games, but I like the idea of creating a wall, as in you click and drag to form it. It could just be a stone wall, a wall of fire, etc.
  11. Hello. I have been googling this and searching the gamedev forums all day but I can't seem to find what I'm looking for. There are a lot of articles on ellipse collisions/intersections but most of them are for rotated ellipses too. I feel like there should be a simpler way of doing things and I don't think I need to read a 50 page document on how to do it haha. What I'm trying to achieve, is that when two axis aligned ellipses are moving(lets call the ellipse A and ellipse B) intersect, if ellipse B is higher up then it will smoothly push up/slide past ellipse. If it is lower then it will do the opposite. I'm not sure if I have to find out where they intersect but if I do need to know that then I would like to be able to figure that out too Some pseudo-code would be much appreciated. Thanks!
  12. What is the longest you've spent on a game development project? Do you prefer to make smaller games or do you spend most of your time pursuing a giant "dream" project? Personally I'm doing the latter for now just because the challenge is so alluring(as long as I'm enjoying it, I'm fine), but with that said, creating any full game, no matter how big, can be a challenge. I just like the idea of having a project that can be completed but still have lots of room for improvement. After I'm done with this project I'll probably try to make smaller games though(perhaps mobile ones). I was just wondering about your guys' experiences with small and big projects, how you have managed your time with your projects, whether you have finished what you consider to be a "huge" project, or if you plan on tackling one in the future. The question sounds like it was more directed towards indie game devs, but feel free to share your experiences with all kinds of game development.
  13. Ok, so I'm having some trouble here. I have two different classes set up, each separated in to a .cpp and a .h file. Lets call the first class "First" and the second class "Second"(terrible class names just for the sake of discussion). So in the "First" class(in the header file), one of it's public members is an instance of the "Second" class. ex. Second second(parameter1, paramater2); //Pseudo-code; barely C++ Now I can instance it in the First.h file if there are no parameters aka "Second"'s default constructor, but there are parameters in my situation, so the .h file won't accept it. So I don't really know what my options are here. Do I create the instanced member using it's default constructor and just re set it after passing in a better instance of the class? Is there a better way to do this? If you need anything clarified or have further questions, feel free to ask.
  14. Deadlybones

    3D Graphics. Mojang Escape Style in Java

    There isn't really a great universal definition of a game engine, but most people think of it as a general code structure that can be reused, etc. It's quite common for new game programmers to want to make "an engine from scratch", but the simple answer that most people give is that you shouldn't. You should just learn/practice a programming language, then just focus on actually making a game. You can then take code from that game and reuse it to make your next games more quickly. "Make games, not engines." Good luck, and get programming!
  15. Hello. Can anyone recommend any applications that are good for organizing ideas? Some way to organize them in a hierarchical way would be nice. Right now I'm trying to organize a lot of jumbled ideas in to a .txt so it's time to migrate to something more efficient.
  • 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!