add ground texture
GitOrigin-RevId: 2313a9c0387ddb62ffca2aa563f9bab3ee10cdaf
This commit is contained in:
parent
06620ce368
commit
1fbcacecfc
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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…
Reference in New Issue
Block a user