Browse Source

add ground texture

GitOrigin-RevId: 2313a9c038
master
Colin McMillen 4 years ago
parent
commit
1fbcacecfc
  1. 4
      Jumpy.Shared/Camera.cs
  2. 14
      Jumpy.Shared/JumpyGame.cs
  3. 3
      Jumpy.Shared/Player.cs

4
Jumpy.Shared/Camera.cs

@ -4,7 +4,7 @@ using System.Text;
namespace Jumpy {
class Camera {
public const int Width = 1920 / 4;
public const int Height = 1080 / 4;
public const int Width = 1920 / 6;
public const int Height = 1080 / 6;
}
}

14
Jumpy.Shared/JumpyGame.cs

@ -25,6 +25,7 @@ namespace Jumpy {
FpsCounter fpsCounter = new FpsCounter();
Player player;
Texture2D grassland;
public JumpyGame() {
graphics = new GraphicsDeviceManager(this);
@ -52,6 +53,7 @@ namespace Jumpy {
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("font");
player = new Player(Content.Load<Texture2D>("player_1x"));
grassland = Content.Load<Texture2D>("grassland");
}
// Called once per game. Unloads all game content.
@ -91,7 +93,19 @@ namespace Jumpy {
GraphicsDevice.SetRenderTarget(renderTarget);
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
// Draw player.
player.Draw(gameTime, spriteBatch);
// Draw foreground tiles.
int size = 16;
Rectangle textureSource = new Rectangle(3 * size, 0 * size, size, size);
for (int i = 0; i < Camera.Width / size; i++) {
Vector2 drawPos = new Vector2(i * size, Camera.Height - size);
spriteBatch.Draw(grassland, drawPos, textureSource, Color.White);
}
// Aaaaand we're done.
spriteBatch.End();
// Draw RenderTarget to screen.

3
Jumpy.Shared/Player.cs

@ -12,10 +12,11 @@ namespace Jumpy {
private Texture2D texture;
private const int spriteSize = 48;
private const int spriteWidth = 7;
private const int bottomPadding = 5;
private const int moveSpeed = 200;
private const int jumpSpeed = 600;
private const int gravity = 2000;
private const int groundLevel = Camera.Height - spriteSize / 2;
private const int groundLevel = Camera.Height - spriteSize / 2 + bottomPadding - 16;
private Point position = new Point(Camera.Width / 2, groundLevel);
private Facing facing = Facing.Right;

Loading…
Cancel
Save