Jump to content
  • Advertisement

yahn

Member
  • Content Count

    266
  • Joined

  • Last visited

Community Reputation

108 Neutral

About yahn

  • Rank
    Member
  1. yahn

    Script language with C++ grammar

    Quote:But consider, C++ has horrible syntax Really? It's odd that so many people think differently.
  2. 1. Major in Computer Science. You learn a lot more about computers that helps you understand how programming works in Computer Science. Software Engineering is good, but I think you get a better full understanding with Computer Science. 3. http://www.cplusplus.com/ You should be able to get a very good understanding of programming from that website. It's the best one available. 4. Pay attention in class. That's all you have to do.
  3. yahn

    Isometric Shadows

    I'm rendering an isometric world in two dimensions. Each object has an x coordinate a y coordinate and a z coordinate, though. The objects actual position on the screen is represented (x, y + z*ZHEIGHT) where ZHEIGHT is a constant multiple. So, to calculate the shadow from a light to a tile, I need to know the angle between the corner of the tile and the light. The tile is a surface that is 64*32 pixels. So, the left corner is at (0, 16). The top corner is at (31, 0). The right corner is at (63, 16). And the bottom corner is at (31, 31). // the angle between the left corner and the light is: a0 = arctan2( (tile.y + tile.z*ZHEIGHT + 16) - (light.y + light.z*ZHEIGHT), tile.x - light.x); // The "+ 16" is for the y offset of the left corner. To get the length of the vector, I use similar right triangles to get that the magnitude of the vector should be: shadowLength = tile.z*ZHEIGHT*distance(tile, light)/((light.z - tile.z)*ZHEIGHT); // Where distance is a function returning the distance between the tile and the light. Anyway, after getting the correct coordinates for the outline of the shadow, I can render something like this: http://img266.imageshack.us/i/lightexample.png/ That works great when everything is level, but I need to have the tiles render the shadow on themselves rather than have the tile render it's shadow. I'm wondering how I should do this. I can put the vertex for the shadow in the tile on which it should be rendered. However, I'm wondering how I would move that vertex to the correct position. I know that the angle of the vector wouldn't change, but the magnitude would. So, I need to recalculate shadowLength to take into account the height of the tile on which the shadow is being drawn. So, I think this should work: // assuming that tile is now the tile on which the shadow is being drawn // and that sTile is the tile which the shadow is being cast from shadowLength = (sTile.z - tile.z)*ZHEIGHT*distance(tile, light)/((light.z - tile.z)*ZHEIGHT); However, once the vertex is moved, the primitive is no longer proportionate. I need to add another vertex on the edge of the tiles, I think. But I'm not sure exactly. I can't figure out what I need to do to get the correct shape of the shadow. Can anyone help? Thank you,
  4. yahn

    2d sweep and prune

    Sorry -- Double Posted
  5. yahn

    2d sweep and prune

    Quote:No - for each point, you check it's radius against the spatial structure, and then agains the points in the matching cells/nodes. That gives you all points within the radius of that specific point. Either way, a naive approach would only need roughly n^2/2 checks, not n^2 checks. I know how to do it without breaking it up into cells. It's pretty straight forward. When broken into cells, if a points radius extends into another cell, I could binary search through the cells points to find the location I should check from. That would just add a log(n) to the algorithm. That isn't too bad. Is this what you were talking about? Quote:You can do sweep and prune on both axes, and then perform a set intersection on the results to generate a list of objects that could possibly intersect on both axes. This could help if you're generating tons of false hits on the y-axis. I thought of doing this, but the problem is that there are way too many points around the axis that are being considered. Adding another axis just adds more points that shouldn't be considered. At least that's the only way I can see it.
  6. yahn

    2d sweep and prune

    I thought of doing that, but won't the points that touch the search radius need to perform an n^2-like search with the touching cell's instances?
  7. For each instance, I want to find all other instances within a given distance of that instance. The most efficient way I can think to do this is to sort the instances on the x or y axis and then check the instances after until the distance along the axis is greater than the d possible distance. The problem is that there are a lot of instances within the given distance that are so far away on the y axis that I should somehow be able to not include them, but I can't think of a way to eliminate them. I'm checking the squared distance, so calculating the distance isn't that expensive. The problem is that for every instance that is reasonable to consider there are 20 fold that I shouldn't even need to consider. Any suggestions? Thank you
  8. I was thinking about using sweep and prune, but I think that will also be fairly inefficient. I think a simple grid may actually be the best thing I can use for this problem. Thank you
  9. I'm working on a game with a lot of NPCs that are persistent and need to carry out complex routines at all time. One thing the NPCs need to be aware of their neighbors in a region (rectangular or circular is sufficient). The problem is that I have thousands of NPCs in a relatively small space (I'm trying to create a simulated city) and some of these NPCs move around a lot -- enough of them that I think it will really make the KD-tree useless since it will have to be rebalanced so much. However, the vast majority of the objects "hang out" around the same area indefinitely. I originally tried using a quad-tree but the objects moved to much and it honestly wasn't very efficient. What do you think?
  10. yahn

    IRC protocol

    EqualityAssignment, I actually found that article. I didn't read it entirely, but I spent a good deal of time on it and it wasn't helping very much at all. SimonForsman, I never thought to look at the IRCd source. That will probably be adequate, but I'm hoping there is something more straightforward. It seems odd that IRC is such a commonly used protocol but it doesn't seem to have anywhere near the documentation as say HTTP.
  11. I've been working on a lot of multiplayer games. This one in particular, I plan to be more of an IM/IRC client than a game. So, getting the chat system right is going to be crucial. It seems that IRC is the best choice considering it is so widely used. However, I need to host my own server and it has to be tightly integrated into the framework of the game. I think the easiest way to do this will be to completely code an IRC server from scratch. However, I've searched for the IRC protocol and IRC daemon source code, but havn't really come up with anything useful. I'm sure there is a place that the IRC protocol is well documented online, but I'm unaware of such a place. Could anyone point me in the right direction. Thanks you
  12. yahn

    Multithreading

    I'm trying to develop a game with a lot of complex AI and I'm fairly certain I need to start multithreading, but I don't even know where to start learning when are where to apply it. I tried a few searches for beginning mutlithreading programming and multithreaded tutorial, but neither turned up anything that I was expecting. Does anyone know where I can find some really good articles for beginning multithreaded programing? Thank you
  13. yahn

    Line Segment Rectangle Collision

    It seems there are two popular algorithms for this. I've read that the slab algorithm is the better of the two, but it seems all the algorithms I have found are nearly identical, so I don't know if this is the right one. Basically, the algorithm is: | | | | * P0 | | \ | | \tymin | | --------*-----+++++++----------- \ + + \ + + -----------*--+++++++----------- tymax\ | | \| | txmin * | |\ | | \ | | \ | | \ | | \| | *txmax | |\ | | *P1 (P0.x < P1.x && tymax.x < txmin.x) no intersection Basically the algorithm is that in order for a line to intersect the rectangle, if the edges of the rectangle are extended, the line would have to intersect a line parallel to the x-axis first then a line parallel y-axis then a line parallel to the x-axis and then a line parallel to the y-axis (or the other way around). If the line does not intersect then it will cross both lines parallel to the y-axis and then both lines parallel to the x-axis (or the other way around). Is this the right algorithm and do I understand it correctly? Thank you
  14. I've searched online enough to know this is not a trivial task. I don't need the rectangles to be able to rotate, so that makes it a little easier, I think. The only way I can think to do it is to check all four edges of the rectangle for a collision with the line (line line collision). That seems pretty inefficient and I'm sure there is a much better solution. Can anyone tell me how it is done? Thank you
  • 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!