This commit is contained in:
AnloGames 2023-08-14 18:50:27 +03:00
commit e6beffb420
4 changed files with 80 additions and 6 deletions

View file

@ -1,10 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects
{
class Entity
{
abstract class Entity : GameObject
{
private Vector2 targetPosition;
public float speed;
public Entity(Texture2D texture, Vector2 position) : base(texture, position) {}
public Entity(Texture2D texture, Vector2 position, GraphicsComponent animator) : base(texture, position, animator) {}
public void SetPosition(Vector2 position) { targetPosition = position; }
public override void Update(GameTime gameTime)
{
if (Vector2.Distance(Position, targetPosition) > 0.5f)
{
Vector2 dir = targetPosition - Position;
dir.Normalize();
Position += dir * speed;
}
}
}
}

View file

@ -2,15 +2,44 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore
{
class GameObject
public abstract class GameObject
{
GraphicsComponent graphicsComponent;
public GameObject()
protected Texture2D Texture;
public Vector2 Position;
protected GraphicsComponent Animator;
public GameObject(Texture2D texture, Vector2 position)
{
Texture = texture;
Position = position;
GameManager.Register(this);
}
public GameObject(Texture2D texture, Vector2 position, GraphicsComponent animator)
{
Texture = texture;
Position = position;
Animator = animator;
GameManager.Register(this);
}
public virtual void OnCollision()
{
}
public virtual void Draw(SpriteBatch spriteBatch)
{
}
public virtual void Update(GameTime gameTime)
{
}
}
}

View file

@ -1,10 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects
{
class LivingEntity : GameObject
abstract class LivingEntity : Entity
{
public LivingEntity(Texture2D texture, Vector2 position) : base(texture, position)
{
}
public LivingEntity(Texture2D texture, Vector2 position, GraphicsComponent animator) : base(texture, position, animator)
{
}
public override void Update(GameTime gameTime)
{
}
}
}

View file

@ -0,0 +1,11 @@
using Microsoft.Xna.Framework.Content;
using System;
using System.Collections.Generic;
using System.Text;
namespace DangerousD.GameCore
{
public class GraphicsComponent
{
}
}