Error message

  • Notice: Undefined index: comment_node_geshinode_form in drupal_retrieve_form() (line 752 of /home/realdev/public_html/includes/form.inc).
  • Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'comment_node_geshinode_form' not found or invalid function name in drupal_retrieve_form() (line 787 of /home/realdev/public_html/includes/form.inc).

C# - Minimap Tut (part 1) - #xna

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Minimap_Tut
{
///
/// This is the main type for your game
///
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D MinimapTex;

Color MinimapBGCol = new Color(150, 150, 150, 150);
Rectangle MinimapBGRect = new Rectangle(10, 10, 110, 110);

Rectangle NextMinimapItem = new Rectangle(0, 0, 3, 3);

List Enemies = new List();
List Allies = new List();

public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}

///
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
///
protected override void Initialize()
{
// TODO: Add your initialization logic here

base.Initialize();
}

///
/// LoadContent will be called once per game and is the place to load
/// all of your content.
///
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);

MinimapTex = new Texture2D(graphics.GraphicsDevice, 1, 1);
Color[] texcol = new Color[1];
MinimapTex.GetData(texcol);
texcol[0] = Color.White;
MinimapTex.SetData(texcol);

Random rand = new Random();
for (int i = 0; i < 5; i++)
{
Enemies.Add(new Vector2(rand.Next(1, 100), rand.Next(1, 100)));
Allies.Add(new Vector2(rand.Next(1, 100), rand.Next(1, 100)));
}
// TODO: use this.Content to load your game content here
}

///
/// UnloadContent will be called once per game and is the place to unload
/// all content.
///
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}

///
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
///
/// Provides a snapshot of timing values.
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();

// TODO: Add your update logic here

base.Update(gameTime);
}

///
/// This is called when the game should draw itself.
///
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);

// TODO: Add your drawing code here
spriteBatch.Begin();

spriteBatch.Draw(MinimapTex, MinimapBGRect, MinimapBGCol);

foreach (Vector2 tmp in Allies)
{
NextMinimapItem.X = (int)tmp.X + 9;
NextMinimapItem.Y = (int)tmp.Y + 9;
spriteBatch.Draw(MinimapTex, NextMinimapItem, Color.Blue);
}
foreach (Vector2 tmp in Enemies)
{
NextMinimapItem.X = (int)tmp.X + 9;
NextMinimapItem.Y = (int)tmp.Y + 9;
spriteBatch.Draw(MinimapTex, NextMinimapItem, Color.Red);
}

spriteBatch.End();

base.Draw(gameTime);
}
}
}

No comments available.

Add new comment