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
XNA Tile Concept
Page 1 of 13 Replies - 212 Views - Last Post: 07 February 2013 - 04:26 AM
Replies To: XNA Tile Concept
#2
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.
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.
You can easily add on properties to each class as you find better ways of representing them.
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.
#3
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?...
#4
Re: XNA Tile Concept
Posted 07 February 2013 - 04:26 AM
Do you have any 2D game development experience?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|