Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. A window into a big world

A window into a big world

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bilal Naveed
    wrote on last edited by
    #1

    You people have seen games like RedAlert, Starcraft etc, the way we have a little window into a large map. We can scroll that window to shift our focus to other regions of the map. I want to know how that is possible in MFC? I need a view that only looks at part of the whole "world", and then I want to be able to scroll to other parts without disturbing the underlying "world". Here's what I have in mind. The world will be a square with 6000 miles sides. I want to see, maybe, a 50 x 50 mile area through my view. So when the view scrolls I see a new portion of the world. I want to be able to make changes in the world(like change the (x,y) of a car) (without dealing with device coords), and the view updates at regular intervals to show the change(if the view is positioned above an area where a change took place). Someone help me! :confused:

    C D 2 Replies Last reply
    0
    • B Bilal Naveed

      You people have seen games like RedAlert, Starcraft etc, the way we have a little window into a large map. We can scroll that window to shift our focus to other regions of the map. I want to know how that is possible in MFC? I need a view that only looks at part of the whole "world", and then I want to be able to scroll to other parts without disturbing the underlying "world". Here's what I have in mind. The world will be a square with 6000 miles sides. I want to see, maybe, a 50 x 50 mile area through my view. So when the view scrolls I see a new portion of the world. I want to be able to make changes in the world(like change the (x,y) of a car) (without dealing with device coords), and the view updates at regular intervals to show the change(if the view is positioned above an area where a change took place). Someone help me! :confused:

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Two things: 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC. 2/ This sort of view is easy to achieve. You keep track of the whole world, and what it is doing, and remember the top left point you are at - then only try to draw things within the 50 x 50 box that is built from it, and compensate for these values when drawing. i.e. if I have an 800x600 screen ( you'd have to draw 600x600 to maintain aspect ratio - option bars on the edges ? ) and I am at point 1000/500, I draw anything between 1000/500 and 1050/550. I subtract 1000 from all X values and 500 from all Y values before I draw, and scale by 12 in both directions to go from 50 to 600. BTW, if you need to divide for any conversions you should multiply by a float, multiplication is faster than division. As for your little view, again it's a case of taking the point clicked on, normalising it ( making it's top left edge 0,0 and moving the other points so the size is unchanged ) and then getting a co-ordinate by scaling betwen the size of the scanner box and the size of your world. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

      P T 2 Replies Last reply
      0
      • C Christian Graus

        Two things: 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC. 2/ This sort of view is easy to achieve. You keep track of the whole world, and what it is doing, and remember the top left point you are at - then only try to draw things within the 50 x 50 box that is built from it, and compensate for these values when drawing. i.e. if I have an 800x600 screen ( you'd have to draw 600x600 to maintain aspect ratio - option bars on the edges ? ) and I am at point 1000/500, I draw anything between 1000/500 and 1050/550. I subtract 1000 from all X values and 500 from all Y values before I draw, and scale by 12 in both directions to go from 50 to 600. BTW, if you need to divide for any conversions you should multiply by a float, multiplication is faster than division. As for your little view, again it's a case of taking the point clicked on, normalising it ( making it's top left edge 0,0 and moving the other points so the size is unchanged ) and then getting a co-ordinate by scaling betwen the size of the scanner box and the size of your world. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

        P Offline
        P Offline
        Pros Chum
        wrote on last edited by
        #3

        >> 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC. OpenGL is another option also. For simple things, OpenGL is easier to pick up than DirectX. But if you're in it for the long run, DirectX will offer more flexibility at the expense of a high learning curve. - Pros

        C 1 Reply Last reply
        0
        • P Pros Chum

          >> 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC. OpenGL is another option also. For simple things, OpenGL is easier to pick up than DirectX. But if you're in it for the long run, DirectX will offer more flexibility at the expense of a high learning curve. - Pros

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I don't think it's that simple - Quake is/are written using GL, after all. I agree with the curve thing - I got GL working in less time than it took me to figure how to get DirectX started. But I presume that a RTS game will use an isometric view, which makes DX a better option, because you can use Direct Draw instead of having to create and draw 3D objects, and given that you'd use Direct Sound/ Direct Input anyhow, it seemed the way to go in this case. But it was remiss of me not to mention GL, all the same. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

          1 Reply Last reply
          0
          • B Bilal Naveed

            You people have seen games like RedAlert, Starcraft etc, the way we have a little window into a large map. We can scroll that window to shift our focus to other regions of the map. I want to know how that is possible in MFC? I need a view that only looks at part of the whole "world", and then I want to be able to scroll to other parts without disturbing the underlying "world". Here's what I have in mind. The world will be a square with 6000 miles sides. I want to see, maybe, a 50 x 50 mile area through my view. So when the view scrolls I see a new portion of the world. I want to be able to make changes in the world(like change the (x,y) of a car) (without dealing with device coords), and the view updates at regular intervals to show the change(if the view is positioned above an area where a change took place). Someone help me! :confused:

            D Offline
            D Offline
            David Fleming
            wrote on last edited by
            #5

            The answer you have already gotten is a good one, I think. However, since you expressly asked if it could be done in MFC, I figured I would toss in here that it can. I don't want to sound like a commercial, but there is a book called "Beginning Visual C++" from Wrox Press written by Ivor Horton that contains an example of a sketch program that imcorporates multiple views and scaling of the views. It sounds like a solution to what you want to do here. I have the book and learned a lot from it (but I am a beginner). You may want to check it out. The crux of it is multiple CViews of the CDocument. You then set your scale modes. I hope that helps. David.

            1 Reply Last reply
            0
            • C Christian Graus

              Two things: 1/ If you're writing a game, you'll want to use DirectX, not just GDI/MFC. 2/ This sort of view is easy to achieve. You keep track of the whole world, and what it is doing, and remember the top left point you are at - then only try to draw things within the 50 x 50 box that is built from it, and compensate for these values when drawing. i.e. if I have an 800x600 screen ( you'd have to draw 600x600 to maintain aspect ratio - option bars on the edges ? ) and I am at point 1000/500, I draw anything between 1000/500 and 1050/550. I subtract 1000 from all X values and 500 from all Y values before I draw, and scale by 12 in both directions to go from 50 to 600. BTW, if you need to divide for any conversions you should multiply by a float, multiplication is faster than division. As for your little view, again it's a case of taking the point clicked on, normalising it ( making it's top left edge 0,0 and moving the other points so the size is unchanged ) and then getting a co-ordinate by scaling betwen the size of the scanner box and the size of your world. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

              T Offline
              T Offline
              Ting
              wrote on last edited by
              #6

              Was this reply meant for someone else. My problem is an address book. Not a game! What does this have to do with my qustion???

              C 1 Reply Last reply
              0
              • T Ting

                Was this reply meant for someone else. My problem is an address book. Not a game! What does this have to do with my qustion???

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                I've noticed this forum mixing things up a little - your reply has appeared in the thread 'A window into a big world', where I answered a question relating to games such as Red Alert. Christian I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in. The early bird may get the worm, but it's the second mouse that gets the cheese.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups