CameraAndScaleFix
This commit is contained in:
parent
e6d0f2b8a0
commit
dec773d290
4 changed files with 36 additions and 5 deletions
|
@ -1,7 +1,9 @@
|
||||||
using DangerousD.GameCore.Graphics;
|
using DangerousD.GameCore.Graphics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -10,6 +12,7 @@ namespace DangerousD.GameCore.GameObjects.Entities
|
||||||
{
|
{
|
||||||
public class SilasBall : LivingEntity
|
public class SilasBall : LivingEntity
|
||||||
{
|
{
|
||||||
|
private bool IsVisibility=true;
|
||||||
public SilasBall(Vector2 position) : base(position)
|
public SilasBall(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
Height = 60;
|
Height = 60;
|
||||||
|
@ -30,6 +33,17 @@ namespace DangerousD.GameCore.GameObjects.Entities
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(Rectangle).Count>0)
|
||||||
|
{
|
||||||
|
IsVisibility = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void Draw(SpriteBatch spriteBatch)
|
||||||
|
{
|
||||||
|
if (IsVisibility)
|
||||||
|
{
|
||||||
|
base.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
GraphicsComponent.CameraPosition = (_pos-new Vector2(200, 350)).ToPoint();
|
GraphicsComponent.SetCameraPosition(Pos);
|
||||||
if (!isAttacked)
|
if (!isAttacked)
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
Move(gameTime);
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace DangerousD.GameCore.Graphics
|
||||||
private List<Texture2D> textures;
|
private List<Texture2D> textures;
|
||||||
private List<string> texturesNames;
|
private List<string> texturesNames;
|
||||||
private AnimationContainer currentAnimation;
|
private AnimationContainer currentAnimation;
|
||||||
|
static private int scaling=3;
|
||||||
public AnimationContainer CurrentAnimation
|
public AnimationContainer CurrentAnimation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -167,6 +168,8 @@ namespace DangerousD.GameCore.Graphics
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
}
|
}
|
||||||
|
@ -191,10 +194,18 @@ namespace DangerousD.GameCore.Graphics
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
}
|
}
|
||||||
|
private Rectangle Scaling(Rectangle destinationRectangle)
|
||||||
|
{
|
||||||
|
destinationRectangle.X *= scaling;
|
||||||
|
destinationRectangle.Y *= scaling;
|
||||||
|
destinationRectangle.Width *= scaling;
|
||||||
|
destinationRectangle.Height *= scaling;
|
||||||
|
return destinationRectangle;
|
||||||
|
}
|
||||||
private void buildSourceRectangle()
|
private void buildSourceRectangle()
|
||||||
{
|
{
|
||||||
sourceRectangle = new Rectangle();
|
sourceRectangle = new Rectangle();
|
||||||
|
@ -222,6 +233,12 @@ namespace DangerousD.GameCore.Graphics
|
||||||
interval = lastInterval;
|
interval = lastInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Point CameraPosition = new Point(0, 0);
|
public static void SetCameraPosition(Vector2 playerPosition)
|
||||||
|
{
|
||||||
|
CameraPosition=(playerPosition).ToPoint();
|
||||||
|
CameraPosition.X -= 300;
|
||||||
|
CameraPosition.Y -= 200;
|
||||||
|
}
|
||||||
|
public static Point CameraPosition = new Point(-700, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace DangerousD.GameCore
|
||||||
public GameState gameState { get; private set; }
|
public GameState gameState { get; private set; }
|
||||||
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
public MultiPlayerStatus multiPlayerStatus { get; private set; } = MultiPlayerStatus.SinglePlayer;
|
||||||
public Point resolution = new Point(1920, 1080);
|
public Point resolution = new Point(1920, 1080);
|
||||||
public Point inGameResolution = new Point(1366, 768);
|
public Point inGameResolution = new Point(1920, 1080);
|
||||||
IDrawableObject MenuGUI;
|
IDrawableObject MenuGUI;
|
||||||
IDrawableObject OptionsGUI;
|
IDrawableObject OptionsGUI;
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
|
|
Loading…
Add table
Reference in a new issue