GameObject stuff
This commit is contained in:
parent
0e1cb691b2
commit
01aeaaca37
8 changed files with 101 additions and 6 deletions
13
.idea/.idea.DangerousD/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.DangerousD/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/.idea.DangerousD.iml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
4
.idea/.idea.DangerousD/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.DangerousD/.idea/encodings.xml
generated
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
8
.idea/.idea.DangerousD/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.DangerousD/.idea/indexLayout.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
6
.idea/.idea.DangerousD/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.DangerousD/.idea/vcs.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,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
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
class GraphicsComponent
|
||||
public class GraphicsComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue