Verfügbare Informationen zu "XNA - Codeschnipsel - IP Adresse"
Qualität des Beitrags: Beteiligte Poster: Snowball Forum: Webdesigner's Forenbeschreibung: Das Hilfe Forum für alle Webdesigner aus dem Unterforum: C# XNA Antworten: 1 Forum gestartet am: Freitag 20.07.2007 Sprache: deutsch Link zum Originaltopic: XNA - Codeschnipsel - IP Adresse Letzte Antwort: vor 16 Jahren, 5 Monaten, 23 Tagen, 5 Stunden, 25 Minuten
Alle Beiträge und Antworten zu "XNA - Codeschnipsel - IP Adresse"
Re: XNA - Codeschnipsel - IP Adresse
Snowball - 04.11.2007, 16:00XNA - Codeschnipsel - IP Adresse
So hier zeige ich euch wie man in unetnlich vileie himmelsrichtungen laufen kann und seine eigene ip adresse auslesen kann!
Code: #region Using Statements
using System;
using System.Net;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion
namespace x9
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
ContentManager content;
SpriteBatch spriteBatch;
Texture2D tree;
Texture2D kugel;
Vector2 spritePosition = Vector2.Zero;
SpriteBatch Sprite;
SpriteFont Arial;
float moveSpeedPerFrame = 30.0f;
Vector2 playerPosition = new Vector2(400, 300);
Vector2 mousePosition;
KeyboardState ksState;
float y3;
float x3;
private Vector2[] playerPosition2 = new Vector2[100];
Vector2 a = new Vector2(400, 300);
private float[] shotmovespeed = new float[100];
private Vector2[] shotPosition = new Vector2[100];
private Vector2[] mousePosition2 = new Vector2[100];
int x5 = 400;
int y5 = 300;
private Vector2[] direction2 = new Vector2[100];
private Vector2 playerposition2 = new Vector2(400, 300);
private Vector2[] shotPosition2 = new Vector2[100];
private Vector2[] xxx = new Vector2[100];
int shot;
int totalsec;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
content = new ContentManager(Services);
graphics.IsFullScreen = true;
for (int i = 0; i < 100; i++)
{
shotPosition[i] = new Vector2(x5, y5);
playerPosition2[i] = new Vector2(x5, y5);
}
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
this.tree = Texture2D.FromFile(this.graphics.GraphicsDevice,
"tree.png");
this.kugel = Texture2D.FromFile(this.graphics.GraphicsDevice,
"kugel.png");
this.spriteBatch = new SpriteBatch(this.graphics.GraphicsDevice);
this.IsMouseVisible = true;
}
Arial = content.Load<SpriteFont>("Arial");
Sprite = new SpriteBatch(graphics.GraphicsDevice);
}
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
if (unloadAllContent)
{
content.Unload();
}
}
protected override void Update(GameTime gameTime)
{
ksState = Keyboard.GetState();
MouseState mouse = Mouse.GetState();
totalsec++;
if (mouse.RightButton == ButtonState.Pressed)
{
if (totalsec > 30)
{
if (shot < 100)
{
shot++;
if (shot == 100)
{
shot = 0;
}
playerPosition2[shot] = new Vector2(400, 300);
mousePosition2[shot] = new Vector2(mouse.X, mouse.Y);
shotmovespeed[shot] = 6.0f;
shotPosition[shot] = new Vector2(400, 300);
totalsec = 0;
}
}
}
if (mouse.LeftButton == ButtonState.Pressed)
{
mousePosition = new Vector2(mouse.X, mouse.Y);
Vector2 direction = playerposition2 - mousePosition;
direction.Normalize();
playerPosition = playerPosition + moveSpeedPerFrame * direction;
xxx[shot] = direction * moveSpeedPerFrame;
}
if (ksState.IsKeyDown(Keys.Escape))
{
this.Exit();
}
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
this.spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
this.spriteBatch.Draw(this.tree, (playerPosition), Color.White);
for (int k = 0; k < 100; k++)
{
direction2[k] = mousePosition2[k] - playerPosition2[k];
direction2[k].Normalize();
shotPosition[k] = (shotPosition[k] + shotmovespeed[k] * direction2[k]) + xxx[shot];
this.spriteBatch.Draw(this.kugel, (shotPosition[k]), Color.White);
}
for (int m = 0; m < 100; m++)
{
xxx[m] = new Vector2(0, 0);
}
this.spriteBatch.End();
Sprite.Begin();
// Hostnamen und IP-Adresse abrufen.
string hostName = Dns.GetHostName();
// Die erste passende IP-Adresse abrufen.
string ipAddress = Dns.GetHostEntry(hostName).AddressList[0].ToString();
Sprite.DrawString(Arial, "Hostname: " + hostName, new Vector2(10, 60), Color.Black);
Sprite.DrawString(Arial, "IP-Adresse: " + ipAddress, new Vector2(10, 75), Color.Black);
Sprite.DrawString(Arial, "Y: " + playerPosition, new Vector2(10, 26), Color.Black);
Sprite.DrawString(Arial, "X: " + mousePosition2[shot], new Vector2(10, 45), Color.Black);
Sprite.End();
base.Draw(gameTime);
}
}
}
Mit folgendem Code, können Sie den Beitrag ganz bequem auf ihrer Homepage verlinken
Weitere Beiträge aus dem Forum Webdesigner's
Ähnliche Beiträge wie "XNA - Codeschnipsel - IP Adresse"
Lagerverkauf Adresse - kirsche (Sonntag 26.08.2007)
Neue EMail-Adresse - OzzKaa (Montag 18.06.2007)
Forums-Adresse - urlaub (Mittwoch 24.01.2007)
Infotool adresse - LittleWiggle (Mittwoch 08.08.2007)
Adresse für unsere Homepage - Anonymous (Dienstag 15.11.2005)
WICHTIG: eMail-Adresse in eurem nfs4life-Profil - boemmel (Donnerstag 14.09.2006)
e-mail adresse meisner - karpfen (Freitag 04.05.2007)
Neue Adresse! - Anonymous (Samstag 14.08.2004)
Neue Adresse - wobblerfish (Sonntag 17.06.2007)
FREESTEAM IST ON! BLOß MIT NER ANDEREN ADRESSE! - Eddy-K (Dienstag 07.11.2006)