Show More
Commit Description:
Added tag 0.24.30 for changeset cd33afae1ee2
Commit Description:
Added tag 0.24.30 for changeset cd33afae1ee2
File last commit:
Show/Diff file:
Action:
isometric-park-fna/FNAGame.cs
770 lines | 19.7 KiB | text/x-csharp | CSharpLexer
Add ImGui.
r16 using System.Collections.Generic;
using Microsoft.Xna.Framework;
Add parameter to Line for width.
r1 using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using System;
using System.IO;
using SpriteFontPlus;
using isometricparkfna;
Add draw time counter.
r3 using System.Diagnostics;
Add basic simulation. AKA Procgen, baby!
r28 using static isometricparkfna.TileMap;
Visual tweaks mostly for the benefit of a screen shot.
r21
#if DEBUG
Add ImGui.
r16 using ImGuiNET.SampleProgram.XNA;
Add start of dialog.
r18 using ImGuiNET;
Visual tweaks mostly for the benefit of a screen shot.
r21 #endif
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
Add parameter to Line for width.
r1 class FNAGame : Game
{
private KeyboardState keyboardPrev = new KeyboardState();
private SpriteBatch batch;
private Texture2D texture;
private SoundEffect sound;
private Song music;
private SpriteFont font;
Add header.
r17 private SpriteFont monoFont;
Add parameter to Line for width.
r1
Fix cursor overlay.
r13 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
Random random_generator = new Random();
Add parameter to Line for width.
r1 int frameRate = 0;
int frameCounter = 0;
TimeSpan elapsedTime = TimeSpan.Zero;
Add draw time counter.
r3 TimeSpan drawTime = TimeSpan.Zero;
Add ImGui.
r16 Queue<float> past_fps = new Queue<float>(100);
Add rudimentary (disabled) culling.
r19 int tilesDrawn = 0;
Add parameter to Line for width.
r1
private const int width = 1280;
private const int height = 640;
//new tile stuff
Add basic simulation. AKA Procgen, baby!
r28 int squaresAcross = 150;
int squaresDown = 150;
Add parameter to Line for width.
r1 int baseOffsetX = -14;
int baseOffsetY = -14;
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 GraphicsDevice device;
Factor out some details into Simulation.
r27 Simulation simulation;
Add basic TileMap.
r9
Add (broken) tile picker.
r11 Vector2 mouseGrid;
Vector2 original_point;
Switch to drawing from top middle rather than upper-right corner.
r12 Vector2 mousePos;
Visual tweaks mostly for the benefit of a screen shot.
r21 #if DEBUG
Add ImGui.
r16 private ImGuiRenderer _imGuiRenderer;
private DebugWindow debugWindow;
Visual tweaks mostly for the benefit of a screen shot.
r21 #endif
Add header.
r17 bool show_another_window;
Add start of dialog.
r18 private bool showInitial;
int messageIndex;
Add parameter to Line for width.
r1
Add rudimentary (disabled) culling.
r19 //buggy
Remove leftovers from previous Pong project.
r20 private static bool enableCulling = false;
Add rudimentary (disabled) culling.
r19
Visual tweaks mostly for the benefit of a screen shot.
r21 private bool showGrid = true;
Add rudimentary (disabled) culling.
r19 private static void Main(string[] args)
Add parameter to Line for width.
r1 {
using FNAGame g = new FNAGame();
g.Run();
}
private FNAGame()
{
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 //this.device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.)
Add parameter to Line for width.
r1 GraphicsDeviceManager gdm = new GraphicsDeviceManager(this)
{
// Typically you would load a config here...
PreferredBackBufferWidth = width,
Add scrolling via the mouse.
r5 PreferredBackBufferHeight = height,
Add parameter to Line for width.
r1 IsFullScreen = false,
SynchronizeWithVerticalRetrace = true
};
//gdm.SynchronizeWithVerticalRetrace = false;
IsFixedTimeStep = false;
Add basic simulation. AKA Procgen, baby!
r28 this.simulation = new Simulation(this.squaresAcross, this.squaresDown, 16.66667f*30);
Add basic TileMap.
r9
Factor out some details into Simulation.
r27 foreach (List<Cell> row in this.simulation.map.cells)
Add basic TileMap.
r9 {
foreach (Cell cell in row)
{
if (this.random_generator.NextDouble() > 0.75)
{
cell.hasTree = true;
}
}
}
Add start of dialog.
r18 showInitial = true;
messageIndex = 0;
Add parameter to Line for width.
r1 Content.RootDirectory = "Content";
}
protected override void Initialize()
{
/* This is a nice place to start up the engine, after
* loading configuration stuff in the constructor
*/
Add scrolling via the mouse.
r5 this.IsMouseVisible = true;
Visual tweaks mostly for the benefit of a screen shot.
r21 #if DEBUG
Add start of dialog.
r18 _imGuiRenderer = new ImGuiRenderer(this);
Add ImGui.
r16 _imGuiRenderer.RebuildFontAtlas(); // Required so fonts are available for rendering
Visual tweaks mostly for the benefit of a screen shot.
r21 #endif
Add parameter to Line for width.
r1 base.Initialize();
}
protected override void LoadContent()
{
// Load textures, sounds, and so on in here...
// Create the batch...
batch = new SpriteBatch(GraphicsDevice);
// ... then load a texture from ./Content/FNATexture.png
texture = Content.Load<Texture2D>("FNATexture");
sound = Content.Load<SoundEffect>("FNASound");
music = Content.Load<Song>("IfImWrong");
Tile.TileSetTexture = Content.Load<Texture2D>(@"part4_tileset");
Line.initialize(GraphicsDevice);
var fontBakeResult = TtfFontBaker.Bake(File.OpenRead(@"Content/DroidSans.ttf"),
25,
1024,
1024,
new[]
{
CharacterRange.BasicLatin,
CharacterRange.Latin1Supplement,
Factor out some details into Simulation.
r27 CharacterRange.LatinExtendedA
Add parameter to Line for width.
r1 }
);
Add header.
r17
var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-medium.ttf"),
15,
1024,
1024,
new[]
{
CharacterRange.BasicLatin,
CharacterRange.Latin1Supplement,
CharacterRange.LatinExtendedA,
Factor out some details into Simulation.
r27 CharacterRange.Cyrillic,
CharacterRange.LatinExtendedB,
new CharacterRange((char) 0x00B7)
Add header.
r17 }
);
Factor out some details into Simulation.
r27
Visual tweaks mostly for the benefit of a screen shot.
r21 #if DEBUG
Add ImGui.
r16 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
Visual tweaks mostly for the benefit of a screen shot.
r21 #endif
Add parameter to Line for width.
r1 font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
Add header.
r17 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
Add parameter to Line for width.
r1 //DynamicSpriteFont font = DynamicSpriteFont.FromTtf(File.ReadAllBytes(@"Content/DroidSans.ttf"), 20);
}
protected override void UnloadContent()
{
// Clean up after yourself!
batch.Dispose();
texture.Dispose();
sound.Dispose();
music.Dispose();
}
Add (broken) tile picker.
r11 Vector2 calculateMousegrid(Vector2 normalizedMousePos)
Fix cursor overlay.
r13 {
Switch to drawing from top middle rather than upper-right corner.
r12
//int gridx = (int)(normalizedMousePos.X / Tile.TileSpriteWidth);
//int gridy = (int)(normalizedMousePos.Y / Tile.TileSpriteHeight);
Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight);
Vector2 adjustedMousePos = normalizedMousePos - adjust;
Fix cursor overlay.
r13 float boardx = ((adjustedMousePos.X / Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight));
Switch to drawing from top middle rather than upper-right corner.
r12 float boardy = ((adjustedMousePos.Y / Tile.TileSpriteHeight) - (adjustedMousePos.X / Tile.TileSpriteWidth));
Fix object positioning.
r14 return new Vector2((int)boardx, (int)boardy);
Switch to drawing from top middle rather than upper-right corner.
r12 /*
int gridx = (int)((normalizedMousePos.X + (this.baseOffsetX + 4)) / Tile.TileWidth) ;
int gridy = (int)((normalizedMousePos.Y + (this.baseOffsetX + 4) + (2*baseOffsetY)) / (Tile.TileStepY));
Add (broken) tile picker.
r11
Switch to drawing from top middle rather than upper-right corner.
r12 int within_gridx = (int)((normalizedMousePos.X) % Tile.TileWidth) - (Tile.TileWidth/2);
int within_gridy = (int)((normalizedMousePos.Y) % Tile.TileHeight) - (Tile.TileHeight / 2);
Add (broken) tile picker.
r11
int middle_distance = Math.Abs(within_gridx) + Math.Abs(within_gridx);
Vector2 adjustment_vector;
Switch to drawing from top middle rather than upper-right corner.
r12 return new Vector2(gridx, gridy);
Add (broken) tile picker.
r11 if (middle_distance < (Tile.TileWidth / 2))
{
return new Vector2(gridx, gridy);
}
else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == 1))
{
adjustment_vector = new Vector2(-1, -1);
return new Vector2(gridx, gridy) + adjustment_vector;
}
else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == -1))
{
adjustment_vector = new Vector2(-1, 1);
return new Vector2(gridx, gridy) + adjustment_vector;
}
else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == 1))
{
adjustment_vector = new Vector2(0, -1);
return new Vector2(gridx, gridy) + adjustment_vector;
}
else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == -1))
{
adjustment_vector = new Vector2(0, 1);
return new Vector2(gridx, gridy) + adjustment_vector;
}
else {
return new Vector2(gridx, gridy);
}
Switch to drawing from top middle rather than upper-right corner.
r12 */
Add (broken) tile picker.
r11
}
Add parameter to Line for width.
r1
protected override void Update(GameTime gameTime)
{
float volume = 1.0f;
float pitch = 0.0f;
float pan = 0.0f;
// Run game logic in here. Do NOT render anything here!
KeyboardState keyboardCur = Keyboard.GetState();
if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q))
{
System.Console.WriteLine("Quitting");
Environment.Exit(0);
}
Fix cursor overlay.
r13 if (keyboardCur.IsKeyDown(Keys.Down))
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 {
Visual tweaks mostly for the benefit of a screen shot.
r21 this.camera.Move(new Vector2(0, 2));
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 }
Fix cursor overlay.
r13 else if (keyboardCur.IsKeyDown(Keys.Up))
{
Visual tweaks mostly for the benefit of a screen shot.
r21 this.camera.Move(new Vector2(0, -2));
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
}
Fix cursor overlay.
r13 else if (keyboardCur.IsKeyDown(Keys.Left))
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 {
this.camera.Move(new Vector2(-2, 0));
}
Fix cursor overlay.
r13 else if (keyboardCur.IsKeyDown(Keys.Right))
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 {
this.camera.Move(new Vector2(2, 0));
}
else if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract))
{
Fix debouncing and only apply to certain keys.
r7 this.camera.ZoomOut();
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 }
else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add))
{
Fix debouncing and only apply to certain keys.
r7 this.camera.ZoomIn();
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 }
Add start of dialog.
r18 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash))
Add header.
r17 {
Add start of dialog.
r18 this.show_another_window = !this.show_another_window;
Add header.
r17
}
Visual tweaks mostly for the benefit of a screen shot.
r21 if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G))
{
this.showGrid = !this.showGrid;
}
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
Add scrolling via the mouse.
r5
Add parameter to Line for width.
r1 if (keyboardCur.IsKeyDown(Keys.Space) && keyboardPrev.IsKeyUp(Keys.Space))
{
sound.Play(volume, pitch, pan);
}
//if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P))
// {
// this.player_state = !this.player_state;
// }
//if (player_state )
//{
// MediaPlayer.Play(music);
//}
Add scrolling via the mouse.
r5 MouseState mouseCur = Mouse.GetState();
Refactor and cleanup.
r6 if (MathUtils.Between(mouseCur.X, 0, 50))
Add scrolling via the mouse.
r5 {
this.camera.Move(new Vector2(-4, 0));
}
Refactor and cleanup.
r6 else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width))
Add scrolling via the mouse.
r5 {
this.camera.Move(new Vector2(4, 0));
}
Refactor and cleanup.
r6 if (MathUtils.Between(mouseCur.Y, 0, 50))
Add scrolling via the mouse.
r5 {
this.camera.Move(new Vector2(0, -4));
}
Fix cursor overlay.
r13 else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50), FNAGame.height))
Add scrolling via the mouse.
r5 {
this.camera.Move(new Vector2(0, 4));
}
Switch to drawing from top middle rather than upper-right corner.
r12
Add basic simulation. AKA Procgen, baby!
r28 this.simulation.update(gameTime.ElapsedGameTime);
Add (broken) tile picker.
r11
this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
//int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX);
/* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */
//int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2));
/* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */
//this.mouseGrid = new Vector2(gridx, gridy);
this.mouseGrid = this.calculateMousegrid(this.original_point);
Add parameter to Line for width.
r1 elapsedTime += gameTime.ElapsedGameTime;
if (elapsedTime > TimeSpan.FromSeconds(1))
{
elapsedTime -= TimeSpan.FromSeconds(1);
frameRate = frameCounter;
frameCounter = 0;
}
Fix debouncing and only apply to certain keys.
r7 this.keyboardPrev = keyboardCur;
Add parameter to Line for width.
r1 base.Update(gameTime);
}
Fix cursor overlay.
r13
Add rudimentary tree drawing.
r2 protected void drawTileAt(int x, int y, int tileIndex, int height)
Fix cursor overlay.
r13 {
float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth);
drawTileAt(x, y, tileIndex, height, depthOffset);
}
Add rudimentary (disabled) culling.
r19 protected Boolean cull(int gridX, int gridY)
{
int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
return (!FNAGame.enableCulling ||
(MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width)
&& MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
}
Fix cursor overlay.
r13 protected void drawTileAt(int x, int y, int tileIndex, int height, float depth)
Add rudimentary tree drawing.
r2 {
Switch to drawing from top middle rather than upper-right corner.
r12 /*
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 Vector2 firstSquare = Vector2.Zero;
Vector2 squareOffset = Vector2.Zero;
Add rudimentary tree drawing.
r2
int offsetX = (int)squareOffset.X;
int offsetY = (int)squareOffset.Y;
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 int firstX = (int)firstSquare.X;
int firstY = (int)firstSquare.Y;
int rowOffset = 0;
float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
int mapx = (firstX + x);
int mapy = (firstY + y);
float depthOffset = 0.7f - ((mapx + (mapy * Tile.TileWidth)) / maxdepth);
if ((firstY + y) % 2 == 1)
rowOffset = Tile.OddRowXOffset;
Add rudimentary tree drawing.
r2
batch.Draw(
Tile.TileSetTexture,
new Rectangle(
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 (x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX,
Add basic TileMap.
r9 (y * Tile.TileStepY) - offsetY + baseOffsetY-(Tile.TileHeight*(height-1)),
Add rudimentary tree drawing.
r2 Tile.TileWidth, Tile.TileHeight*height),
Tile.GetExtendedSourceRectangle(tileIndex, height),
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 Color.White,
0.0f,
Vector2.Zero,
SpriteEffects.None,
depthOffset);
Switch to drawing from top middle rather than upper-right corner.
r12 */
Fix object positioning.
r14 int height_adjust = 0;
Switch to drawing from top middle rather than upper-right corner.
r12
Fix object positioning.
r14 if (height > 1) //not sure why this is necessary :/
{
height_adjust = height;
}
int adjustedx = x - height_adjust;
int adjustedy = y - height_adjust;
int screenx = (adjustedx - adjustedy) * Tile.TileSpriteWidth / 2;
int screeny = (adjustedx + adjustedy) * Tile.TileSpriteHeight / 2;
Switch to drawing from top middle rather than upper-right corner.
r12
Add rudimentary (disabled) culling.
r19 if (this.cull(x, y))
{
batch.Draw(
Switch to drawing from top middle rather than upper-right corner.
r12 Tile.TileSetTexture,
new Rectangle(
screenx,
screeny,
Tile.TileWidth, Tile.TileHeight * height),
Tile.GetExtendedSourceRectangle(tileIndex, height),
Color.White,
0.0f,
Vector2.Zero,
SpriteEffects.None,
Fix cursor overlay.
r13 depth);
Add rudimentary (disabled) culling.
r19 }
Add basic simulation. AKA Procgen, baby!
r28
Add rudimentary tree drawing.
r2 }
Add ImGui.
r16
Add parameter to Line for width.
r1 protected override void Draw(GameTime gameTime)
{
// Render stuff in here. Do NOT run game logic in here!
frameCounter++;
string fps = string.Format("fps: {0}", frameRate);
Add draw time counter.
r3 Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Add parameter to Line for width.
r1 GraphicsDevice.Clear(Color.CornflowerBlue);
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 batch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null,
null,
null,
null,
camera.get_transformation(GraphicsDevice));
Add parameter to Line for width.
r1
//New tile stuff
Switch to drawing from top middle rather than upper-right corner.
r12 /*
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 Vector2 firstSquare = Vector2.Zero;
Add parameter to Line for width.
r1 int firstX = (int)firstSquare.X;
int firstY = (int)firstSquare.Y;
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 Vector2 squareOffset = Vector2.Zero;
Add parameter to Line for width.
r1
int offsetX = (int)squareOffset.X;
int offsetY = (int)squareOffset.Y;
Switch to drawing from top middle rather than upper-right corner.
r12
Add parameter to Line for width.
r1 for (int y = 0; y < this.squaresDown; y++)
{
int rowOffset = 0;
if ((firstY + y) % 2 == 1)
rowOffset = Tile.OddRowXOffset;
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 for (int x = 0; x < this.squaresAcross; x++) {
Add parameter to Line for width.
r1 batch.Draw(
Tile.TileSetTexture,
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 new Rectangle(
Add basic TileMap.
r9 ((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX),
((y * Tile.TileStepY) - offsetY + baseOffsetY),
Tile.TileWidth, Tile.TileHeight),
Add parameter to Line for width.
r1 Tile.GetSourceRectangle(1),
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 Color.White,
0.0f,
Vector2.Zero,
SpriteEffects.None,
0.9f);
Add (broken) tile picker.
r11
Add parameter to Line for width.
r1 }
Switch to drawing from top middle rather than upper-right corner.
r12 }*/
Add rudimentary (disabled) culling.
r19 //reset
this.tilesDrawn = 0;
Add ImGui.
r16
Switch to drawing from top middle rather than upper-right corner.
r12 for (int y = 0; y < this.squaresDown; y++)
{
for (int x = 0; x < this.squaresAcross; x++)
{
int screenx = (x - y) * Tile.TileSpriteWidth/2;
int screeny = (x + y) * Tile.TileSpriteHeight / 2;
Add rudimentary (disabled) culling.
r19 if (this.cull(x, y)) {
batch.Draw(
Switch to drawing from top middle rather than upper-right corner.
r12 Tile.TileSetTexture,
new Rectangle(
screenx,
screeny,
Tile.TileWidth, Tile.TileHeight),
Tile.GetSourceRectangle(1),
Color.White,
0.0f,
Vector2.Zero,
SpriteEffects.None,
0.9f);
Add rudimentary (disabled) culling.
r19
this.tilesDrawn++;
}
Switch to drawing from top middle rather than upper-right corner.
r12 }
}
Visual tweaks mostly for the benefit of a screen shot.
r21 if (this.showGrid)
Switch to drawing from top middle rather than upper-right corner.
r12 {
Visual tweaks mostly for the benefit of a screen shot.
r21 //need to go one extra so gridlines include the far side of the final tile:
for (int y = 0; y < (this.squaresDown + 1); y++)
{
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 Line.drawLine(batch,
new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
//new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust,
Color.White, 0.8f);
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 }
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 for (int x = 0; x < (this.squaresAcross + 1); x++)
{
Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 Line.drawLine(batch,
new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
//new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
Color.White, 0.8f);
Switch to drawing from top middle rather than upper-right corner.
r12
Visual tweaks mostly for the benefit of a screen shot.
r21 }
Switch to drawing from top middle rather than upper-right corner.
r12 }
Add parameter to Line for width.
r1
//Gridlines
//Lines going down and to the right:
Switch to drawing from top middle rather than upper-right corner.
r12 /*
for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++)
Add parameter to Line for width.
r1 {
int rowOffset = 0;
Switch to drawing from top middle rather than upper-right corner.
r12
Add parameter to Line for width.
r1 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
Vector2 start = new Vector2(startX, -baseOffsetY+4);
Vector2 stop = new Vector2(startX + this.squaresAcross* Tile.TileStepX/2,
this.squaresDown*Tile.TileStepY- baseOffsetY+4);
Switch to drawing from top middle rather than upper-right corner.
r12
Limit lines to grid.
r8
Line.drawLine(batch,
Line.departurePoint(stop, start, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
Line.departurePoint(start, stop, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
Color.White, 0.8f);
Add parameter to Line for width.
r1
}
//Lines going down and to the left:
Limit lines to grid.
r8 for (int x = 0; x < (int)(1.5*this.squaresAcross); x++)
Add parameter to Line for width.
r1 {
Switch to drawing from top middle rather than upper-right corner.
r12
Add parameter to Line for width.
r1 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
Vector2 start_reverse = new Vector2(startX, -baseOffsetY + 4);
Vector2 stop_reverse = new Vector2(startX + -(this.squaresAcross * Tile.TileStepX / 2),
(this.squaresDown * Tile.TileStepY) - baseOffsetY + 4);
Limit lines to grid.
r8 Line.drawLine(batch,
Line.departurePoint(stop_reverse, start_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
Line.departurePoint(start_reverse, stop_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
Color.White, 0.8f);
Add parameter to Line for width.
r1
}
Switch to drawing from top middle rather than upper-right corner.
r12 */
Add parameter to Line for width.
r1
Add rudimentary tree drawing.
r2 drawTileAt(4, 4, 140, 3);
drawTileAt(6, 4, 141, 3);
drawTileAt(8, 4, 142, 2);
drawTileAt(10, 4, 142, 3);
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
Fix cursor overlay.
r13 drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
Add (broken) tile picker.
r11
Limit lines to grid.
r8 /*
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
for (int i = 0; i< 80; i++)
{
for (int j = 0; j < 50; j += 1)
{
Fix debouncing and only apply to certain keys.
r7 //Warning: creates a flashing effect because tree positions update every 1/60th of a second
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 if (this.random_generator.NextDouble() > 0.75)
{
drawTileAt(i, j, 142, 2);
Limit lines to grid.
r8 }
Fix debouncing and only apply to certain keys.
r7
if ((i + j) % 3 == 0)
{
drawTileAt(i, j, 142, 2);
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 }
Fix debouncing and only apply to certain keys.
r7
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 }
}//*/
Add draw time counter.
r3
Factor out some details into Simulation.
r27 for (int i = 0; i < this.simulation.map.MapHeight; i++)
Add basic TileMap.
r9 {
Factor out some details into Simulation.
r27 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
Add basic TileMap.
r9 {
Factor out some details into Simulation.
r27 if (this.simulation.map.cells[i][j].hasTree)
{ //until we actually simulate:
if((i+j)%8 == 0)
{
drawTileAt(i, j, 141, 2);
}
else
{
drawTileAt(i, j, 142, 2);
}
Visual tweaks mostly for the benefit of a screen shot.
r21
Add basic TileMap.
r9 }
}
}
Visual tweaks mostly for the benefit of a screen shot.
r21 drawTileAt(2, 2, 140, 2);
drawTileAt(1, 1, 140, 2);
drawTileAt(3, 2, 140, 2);
Add basic TileMap.
r9
Add parameter to Line for width.
r1 batch.End();
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4
batch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null,
null,
null,
null);
Add ImGui.
r16 bool has_tree = false;
Fix object positioning.
r14 if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross))
{
Factor out some details into Simulation.
r27 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
Add ImGui.
r16 //batch.DrawString(font, has_tree.ToString(), new Vector2(500, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
//batch.DrawString(font, has_tree.ToString(), new Vector2(499, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
Add header.
r17 }
//*/
Fix object positioning.
r14
Factor out some details into Simulation.
r27
String header_left = String.Format("${0:}|{1:} trees⚘𐂷🌳", this.simulation.money, this.simulation.map.tree_count);
String header_middle = String.Format("{0:yyyy MMMMM}", this.simulation.DateTime);
Add header.
r17 Vector2 dimensions = monoFont.MeasureString(header_middle);
float middle_start = (FNAGame.width / 2) - (dimensions.X / 2);
FilledRectangle.drawFilledRectangle(batch, new Rectangle(0, 0, width, (int)dimensions.Y), Color.White, 0.51f);
batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
Fix object positioning.
r14
Add zooming, scrolling, and proper sprite layering (changes from last night).
r4 batch.End();
Add ImGui.
r16 //Calcs for debug window:
if ((this.frameCounter % 15) == 0) {
past_fps.Enqueue(this.frameRate);
}
Add header.
r17
Add ImGui.
r16 DebugInfo debugInfo = new DebugInfo
{
fps = this.frameRate,
pastFps = past_fps.ToArray(),
cameraPosition = camera.position,
drawTime = this.drawTime,
Factor out some details into Simulation.
r27 treeCount = this.simulation.map.tree_count,
Add ImGui.
r16 mouseGrid = this.mouseGrid,
Add rudimentary (disabled) culling.
r19 hasTree = has_tree,
tilesDrawn = this.tilesDrawn
Add ImGui.
r16 };
Visual tweaks mostly for the benefit of a screen shot.
r21 #if DEBUG
Add ImGui.
r16 //Finally, draw the debug window
_imGuiRenderer.BeforeLayout(gameTime);
Add header.
r17 debugWindow.Layout(debugInfo, new Dictionary<string, string>(),ref show_another_window);
Add ImGui.
r16
Add start of dialog.
r18 String[] messages = { "Message1", "Message2" };
if (showInitial && (messageIndex < messages.Length))
{
ImGui.Begin("Welcome", ref showInitial);
ImGui.PushFont(debugWindow.monoFont);
ImGui.Text(messages[messageIndex]);
if(ImGui.Button("Okay"))
{
messageIndex++;
}
ImGui.PopFont();
}
_imGuiRenderer.AfterLayout();
Visual tweaks mostly for the benefit of a screen shot.
r21 #endif
Add ImGui.
r16
Add draw time counter.
r3 stopWatch.Stop();
this.drawTime = stopWatch.Elapsed;
Add parameter to Line for width.
r1
base.Draw(gameTime);
}
Add (broken) tile picker.
r11 }