Skalowanie tekstur
This commit is contained in:
parent
deeb13eb82
commit
dc380b2b89
9
Trunk/MonoGameView/DataModels/Interfaces/IDrawables.cs
Normal file
9
Trunk/MonoGameView/DataModels/Interfaces/IDrawables.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Interfaces
|
||||
{
|
||||
public interface IDrawables
|
||||
{
|
||||
void Draw(SpriteBatch spriteBatch, int size);
|
||||
}
|
||||
}
|
@ -1,14 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.GeneralModels.Models
|
||||
namespace CzokoŚmieciarka.MonoGameView.DataModels.Models
|
||||
{
|
||||
public class GarbageCollector : AGarbageCollector
|
||||
public class GarbageCollector : AGarbageCollector, IDrawables
|
||||
{
|
||||
public GarbageCollector(Coords startPosition, IEnumerable<AGarbageCollectorContainer> trashContainers, int columns, int rows) : base(startPosition, trashContainers, columns, rows)
|
||||
public Texture2D Image { get; set; }
|
||||
public GarbageCollector(ContentManager content, Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c,l,rows,cols)
|
||||
{
|
||||
Image = content.Load<Texture2D>("collector");
|
||||
}
|
||||
public GarbageCollector(Texture2D image, Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c, l, rows, cols)
|
||||
{
|
||||
Image = image;
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch batch,int size)
|
||||
{
|
||||
batch.Draw(Image, new Rectangle(Coords.X*500/size, Coords.Y*500/size, 500/size, 500/size), Color.White);
|
||||
}
|
||||
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
var cloneList = new List<AGarbageCollectorContainer>();
|
||||
return new GarbageCollector(Image, new Coords(Coords.X,Coords.Y), cloneList, rows,columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using MonoGameView;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -18,6 +17,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
||||
/// </summary>
|
||||
public class Game1 : Game
|
||||
{
|
||||
private static int size = 20;
|
||||
GraphicsDeviceManager graphics;
|
||||
SpriteBatch spriteBatch;
|
||||
Texture2D road1;
|
||||
@ -30,7 +30,7 @@ namespace CzokoŚmieciarka.MonoGameView
|
||||
int stepN;
|
||||
List<IStep> steps;
|
||||
GarbageCollector collector;
|
||||
object[,] grid = new object[10, 10];
|
||||
object[,] grid = new object[size, size];
|
||||
public Game1()
|
||||
{
|
||||
graphics = new GraphicsDeviceManager(this);
|
||||
@ -52,18 +52,18 @@ namespace CzokoŚmieciarka.MonoGameView
|
||||
// TODO: Add your initialization logic here
|
||||
roadPos = new Vector2(0, 0);
|
||||
timer = 0.2f;
|
||||
for (int x=0;x<10;x++)
|
||||
for (int x=0;x<size;x++)
|
||||
{
|
||||
for (int y=0;y<10;y++)
|
||||
for (int y=0;y<size;y++)
|
||||
{
|
||||
if (x % 2 == 0 || y % 2 == 0) grid[x, y] = new Road1();
|
||||
if (x % 2 == 0 || y == 1 || y == 5 || y == 9 || y == 13 || y == 17) grid[x, y] = new Road1();
|
||||
else grid[x, y] = null;
|
||||
}
|
||||
}
|
||||
|
||||
grid[4, 0] = new House();
|
||||
grid[6, 4] = new House();
|
||||
collector = new GarbageCollector(Content,new Coords(0, 0), new List<AGarbageCollectorContainer>(), 10, 10);
|
||||
collector = new GarbageCollector(Content,new Coords(0, 0), new List<AGarbageCollectorContainer>(), size, size);
|
||||
|
||||
|
||||
stepN = 0;
|
||||
@ -137,17 +137,17 @@ namespace CzokoŚmieciarka.MonoGameView
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
spriteBatch.Begin();
|
||||
|
||||
for (int x = 0; x < 10; x++)
|
||||
for (int x = 0; x < size; x++)
|
||||
{
|
||||
for (int y = 0; y < 10; y++)
|
||||
for (int y = 0; y < size; y++)
|
||||
{
|
||||
if (grid[x, y] is Road1) spriteBatch.Draw(road1, new Vector2(x*50,y*50), Color.White);
|
||||
else if (grid[x,y] is Road2) spriteBatch.Draw(road2, new Vector2(x * 50, y * 50), Color.White);
|
||||
else if (grid[x, y] is House) spriteBatch.Draw(house, new Vector2(x*50, y*50), Color.White);
|
||||
else spriteBatch.Draw(grass, new Vector2(x * 50, y * 50), Color.White);
|
||||
if (grid[x, y] is Road1) spriteBatch.Draw(road1, new Rectangle(x*500 / size, y*500 / size, 500/size, 500/size),Color.White);
|
||||
else if (grid[x,y] is Road2) spriteBatch.Draw(road2, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
else if (grid[x, y] is House) spriteBatch.Draw(house, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
else spriteBatch.Draw(grass, new Rectangle(x * 500 / size, y * 500 / size, 500 / size, 500 / size), Color.White);
|
||||
}
|
||||
}
|
||||
collector.Draw(spriteBatch);
|
||||
collector.Draw(spriteBatch, size);
|
||||
|
||||
spriteBatch.End();
|
||||
// TODO: Add your drawing code here
|
||||
|
@ -1,40 +0,0 @@
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.GarbageCollector;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Interfaces.TrashCans;
|
||||
using CzokoŚmieciarka.MonoGameView.DataModels.Models;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MonoGameView
|
||||
{
|
||||
public class GarbageCollector : AGarbageCollector
|
||||
{
|
||||
public Texture2D Image { get; set; }
|
||||
public GarbageCollector(ContentManager content, Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c,l,rows,cols)
|
||||
{
|
||||
Image = content.Load<Texture2D>("collector");
|
||||
}
|
||||
public GarbageCollector(Texture2D image, Coords c, List<AGarbageCollectorContainer> l, int rows, int cols) : base(c, l, rows, cols)
|
||||
{
|
||||
Image = image;
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch batch)
|
||||
{
|
||||
batch.Draw(Image, new Vector2(Coords.X*50, Coords.Y*50), Color.White);
|
||||
}
|
||||
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
var cloneList = new List<AGarbageCollectorContainer>();
|
||||
return new GarbageCollector(Image, new Coords(Coords.X,Coords.Y), cloneList, rows,columns);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@
|
||||
<Compile Include="DataModels\Interfaces\GarbageCollector\IGarbageCollector.cs" />
|
||||
<Compile Include="DataModels\Interfaces\Garbage\AGarbage.cs" />
|
||||
<Compile Include="DataModels\Interfaces\Garbage\IGarbage.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IDrawables.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IGarbageLocalization.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IHouse.cs" />
|
||||
<Compile Include="DataModels\Interfaces\IRoad.cs" />
|
||||
@ -64,7 +65,6 @@
|
||||
<Compile Include="DataModels\Models\Coords.cs" />
|
||||
<Compile Include="DataModels\Models\Dump.cs" />
|
||||
<Compile Include="DataModels\Models\Garbage.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageCollector.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageCollectorContainer.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageLocalization.cs" />
|
||||
<Compile Include="DataModels\Models\House.cs" />
|
||||
@ -77,7 +77,7 @@
|
||||
<Compile Include="DataModels\Models\TrashCan.cs" />
|
||||
<Compile Include="DataModels\Models\TypeOfGarbage.cs" />
|
||||
<Compile Include="Game1.cs" />
|
||||
<Compile Include="GarbageCollector.cs" />
|
||||
<Compile Include="DataModels\Models\GarbageCollector.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user