要求:1,界面上有静态物体若干,静态物体有方形的,圆形的,两条线组成的道路,还有曲折的线。(GDI+画)
      2,有一个长方形的动态物体,随鼠标移动而移动!
      3,动态物体在移动过程中不得与静态物体相撞,如果相撞,静态物体则发生变化。
重点:随鼠标移动的方形物体,与静态物体不能有任何角度的接触。

解决方案 »

  1.   

    google "collision detection"
      

  2.   

    Here is an example you can try. It shows how to detect the intersection of two lines. 
    My code is simple but you might need some geometry knowledge to understand it.请教一下:C#如何实现在一个矩形框内四次反射
      

  3.   

    物理引擎啊,,啥时候国内也出个Doom和虚幻似的牛X引擎,就好了.
      

  4.   

    Following is my post this morning, which might be helpful to you.最近在写一个画图程序。遇到一个算法问题。望大家指教You have to do hit tests.
    But there are optimizations for complex scene, like Bounding Box,           // a bounding box is a rectangle, so it is easier for pre-intersect-detection than a circle
    Spatial partitioning,   // divide the space into sub-spaces and hit-test within the smaller area
    Temporal coherence,     // a far away object is unlikely to intersect the next moment
    ...
      

  5.   

    如果是GDI+我觉得可以用图像的像素来判断啊~ 每次移动前先截取当前移动矩形范围的像素,如果存在背景以外的像素那么就说明有"实体"存在~