3 Replies - 492 Views - Last Post: 07 February 2013 - 04:26 AM Rate Topic: -----

#1 Haldiron  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-February 13

XNA Tile Concept

Posted 05 February 2013 - 11:05 PM

Hello - I am new to game development, and have spent quite a while learning c#/xna through books and tutorials. My goal is to make (a really awesome!) 4x space strategy game with some mechanics that will make it special.

Unfortunately, programming is not my strongest suit. I want a tile map (squares for now... maybe hexes if I feel confident about it) very similar to galciv2 or more like Space Empires V (see: http://reviews.cnet....1518268-1.html)

The tiles need to be transparent and selectable like any standard TBS.

My question is this: What, conceptually, is a map tile? Is it triangles drawn in a trianlgestrip? If so, how to I make it see-through (testing w/ magenta in 3d gave odd results - it was all black). Is it a list of lines? But if so, then how could I make the tile selectable and have properties if it is just lines?

Cheers

Is This A Good Question/Topic? 0
  • +

Replies To: XNA Tile Concept

#2 bgammill  Icon User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • Posts: 39
  • Joined: 11-June 12

Re: XNA Tile Concept

Posted 06 February 2013 - 11:49 PM

What you have to do here is consider what a tile class would represent. Think about the basic elements of an object that is drawn onto the screen with XNA. Then consider how you could represent a map.


A tile is usually a texture at a certain position with a physical shape for bounds checking.
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame1
{
    class Tile
    {
        public Texture2D Texture;
        public Rectangle Rectangle;
        public Vector2 Position;
    }
}



A map should contain a collection of tiles. You can tack on helper methods for bounds checking, and call them during the Update method in your main class.
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace WindowsGame1
{
    class Map
    {
        public List<Tile> Tiles;

        public bool HitTest(Vector2 position)
        {
            foreach(Tile tile in Tiles)
            {
                if (tile.Position == position)
                {
                    return true;
                }
            }
            return false;
        }
    }
}



You can easily add on properties to each class as you find better ways of representing them.
Was This Post Helpful? 0
  • +
  • -

#3 Haldiron  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 05-February 13

Re: XNA Tile Concept

Posted 06 February 2013 - 11:59 PM

Thanks! And that would be sexy as anything but I'm trying for 3D... 2D would be aight b/c of the Rectangle class... but for 3D, how would one define a tile? If I just draw it with primitives, how would I be able to select them?...
Was This Post Helpful? 0
  • +
  • -

#4 bgammill  Icon User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • Posts: 39
  • Joined: 11-June 12

Re: XNA Tile Concept

Posted 07 February 2013 - 04:26 AM

Do you have any 2D game development experience?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1