Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The code you have demonstrates a lack of understanding of Object Oriented Principles, everything in your game should be an object or an interface. </p> <pre><code>public class Item { private Texture2D texture; private Vector2 position; public Vector2 Position { get {return position; } } private Rectangle Bounds; public bool Collides(Vector2 position) { Bounds = new Rectangle(this.position.X, this.position.Y, this.texture.width, this.texture.height); if (Bounds.Intersects(position)) return true; else return false; } } </code></pre> <p>using the principles of Object Oriented Programming, you would make a specific item derive from the item base class, like so: </p> <pre><code>public class Sword : Item { public Sword() { } } </code></pre> <p>the idea behind OOP is that everything in your code is expressed literally, base classes contain properties and functions that encapsulate all of their derived children. So Sword would inherit position, Bounds, texture, so on and so forth. </p> <p>This is smart because it allows you to program things once and then re-use that code for each item. </p> <p>I'm not going to write your code for you, but start by defining your items like this:</p> <pre><code>private Item[,] Inventoryslots = new Item[6, 4]; </code></pre> <p>I'm going to keep this to a minimum because I don't have a lot of time, but if I could point you in a direction it would be to learn more about Object Oriented Principles in the C# computer programming language. Google that and you're golden. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload