Approaching a MOO 1 style game - Ways to do a map and place stars-VBForums
Results 1 to 8 of 8

Thread: Approaching a MOO 1 style game - Ways to do a map and place stars

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2012
    Posts
    22

    Approaching a MOO 1 style game - Ways to do a map and place stars

    Anyway if you aren't familiar with Masters of Orion 1, it uses a 2D map of space with stars spread randomly around. Although it shows stars in all practical terms the stars are actually planets that may or may not be habitable.

    The game map can be several sizes (24 to 100+ stars). When performing your turn you see only a portion of the entire game map (basically zoomed in so you can see details) then when the game is processing your commands and figuring out what the Computer players are doing it displays the entire map with ship movement etc being displayed. You can also get the zoomed out view during your turn by hitting the "Map" button. Clicking on stars/ships displays its details in a sidebar.

    Everything on the map is clickable and when you do click on a star, ship, monster, whatever, it switches back to the zoomed in view with the clicked item centered and highlighted (or close enough to centered if the object was on the edges of the map).

    Navigating around the map is done by simply clicking near the edges and the view slides in that direction.

    Ships in the game travel in a straight line between stars and distances are calculated as the crow flies, not by any kind of grid cell counts though there is obviously some form of grid use when it comes to star placements.

    So I'm looking for suggestions on how to achieve this kind of 2D graphics functionality (not necessarily code, just point to examples/write ups/whatever you think would be useful). I'm flying blind as I've never even attempted something in the 2D map realm, its all a mystery at the moment.

    As an example, how to place stars and ships and make them selectable?. Should I have some sort in internal grid (math only) for placements? Something like a grid where the click position is divided by the number of cells which gives an index to look up data (either X/Y or a single dimension calculated by an X index and adding Y * XMax (e.g. one row has 200 positions, clicking in the area of the first row gives X + 0, second row gives X + 200, third X + 400, you get the idea). Or am I barking up the wrong tree entirely?

    Next is the map graphic - sticking a picture in a scrolling picture box is probably not going to cut it (though it might, this is just my assumption).

    I found an old bit of source for a similar game and it used Gorgon library (which I believe is the same idea as XNA/Monoplay). I get the feeling I should probably look into some form of library for 2D games. Anyone have a favorite?

    I'll stop babbling now. Looking forward to any suggestions people may have!

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,054

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    I pulled up an image on Google by searching for "Masters of Orion 1" and it looks pretty straight forward. To me, this looks like a PictureBox that has a static background image of space and dynamic drawings of the stars. In terms of making the items selectable, what I'd do is create a class to store the information that would be pulled up when clicked and have at least one property indicate where the object is in relation to the map (a Point property). Then whenever the user clicks on the Image, you'd get the location of where the user just clicked and check if it is within the bounds of one of your stars/ships.

    Really, something this simple doesn't warrant any kind of external library. This could all be done very easily using GDI+.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2012
    Posts
    22

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    I messed around with XNA/Monogame and while the 2d stuff seems exceptionally easy it sure gobbles up CPU time. An empty game (no logic in update, nothing do draw) uses up 15% of my total CPU time on a 4 ghz 8 core processor. While I understand why it just seems a crime to waste all that CPU time for what is a completely event driven game. I guess if I wanted things to animate while the game is doing nothing it would be handy but i can probably achieve the same thing with a timer and GDI.

    I have been playing around with using pictureboxes and rotating images for depicting fleets and that's been a bit of a learning curve, but not bad. Going to see if having a few hundred picture boxes has any serious impact on performance. Someone also suggested using panels since I don't need most of the picture box functionality. I'll try both and see what happens. If there's too much overhead I'll try drawing the "sprites" directly though from what I've read (not extensive yet) it looks like I have to handle masking the background and re-drawing it when sprites move etc. I like the idea of using a container though since then I can have click events and not have to figure out what was clicked by coordinates (not that its hard in any way).

    Not that I mind all the experimentation. I picked MOO because I know the game so I can concentrate on learning 2D graphics rather than designing a game from scratch. Later perhaps I'll try working on my own game.

    Thanks for the suggestions. It confirms what I was thinking.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,054

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    By the way, I have a tutorial on how to use GDI+ for beginners in the utility bank here: http://www.vbforums.com/showthread.p...-for-Beginners

    It sounds like you have the basics down, but if I were you I'd still run through the tutorial to avoid some common pitfalls.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2012
    Posts
    22

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    Yeah I was perusing that area.

    I was going to get fancy and have fleets point in the direction of movement but then realized that mostly negates the usefulness of one of the technologies which shows you the destination of a fleet. So now I just have to figure out why a manually placed picturebox transparency works but the ones I add manually don't. I've set the parent to the background picturebox etc... More experimentation required.

  6. #6
    New Member
    Join Date
    Jun 2017
    Posts
    7

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    Just to add to this ... I had some trouble before with transparencies and it turned out, that even though I saved my images with a transparent color selected, it would not be recognized when loaded. even though it might not be your problem, keep in mind that in some cases, the difference between an Indexed image and a regular RGB, can sometimes be confused between your application and whatever raster editor you are using.

    Just a side note on some of my past troubles.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2012
    Posts
    22

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    Actually yeah, I read something somewhere about specifying the pixelformat when loading. Been busy so I haven't had a chance to look but that's probably it. I guess when you choose a pic from the properties menu it loads it as 32bpp but from the program it may not.

  8. #8
    New Member
    Join Date
    Jun 2017
    Posts
    7

    Re: Approaching a MOO 1 style game - Ways to do a map and place stars

    This is a go to website for me when it concerns visual basic. Chances are, that there is a code snippet there that might help you. also, check out the authors books, They are high quality references and tutorials

    http://vb-helper.com/index_vbnet.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.