Skip to content

Instantly share code, notes, and snippets.

@rtgnx
Created January 14, 2016 11:23
Show Gist options
  • Save rtgnx/c098a43df4fb1b209940 to your computer and use it in GitHub Desktop.
Save rtgnx/c098a43df4fb1b209940 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
namespace Game1.Engine
{
public class DrawableObject
{
protected Texture2D sprite;
public string name;
protected Vector2 position;
protected Color color;
public DrawableObject(string name,Texture2D sprite, Vector2 position)
{
this.name = name;
this.position = position;
this.sprite = sprite;
this.color = new Color(1.0f,1.0f,1.0f,1.0f);
}
public void setColor(Vector4 color)
{
this.color = new Color(color);
}
public Texture2D getSprite()
{
return this.sprite;
}
public Vector2 getPosition()
{
return this.position;
}
public void setPosition(Vector2 pos)
{
this.position = pos;
}
public void move(int x, int y)
{
this.position = new Vector2(this.position.X + x, this.position.Y + y);
}
public void moveLeft(int i)
{
this.position.X -= i;
}
public void moveRight(int i)
{
this.position.X += i;
}
public void moveUp(int i)
{
this.position.Y -= i;
}
public void moveDown(int i)
{
this.position.Y += i;
}
public Color getColor()
{
return this.color;
}
public void control(Delegate update)
{
KeyboardState state = Keyboard.GetState();
update(state);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment