More resolution independence

This commit is contained in:
Royce551 2022-08-14 16:10:46 -05:00
parent 8f08bfcc62
commit 5ff97f8098
7 changed files with 76 additions and 27 deletions

View file

@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Water.Graphics;
using Water.Graphics.Containers;
using Water.Graphics.Controls;
using Water.Graphics.Screens;
@ -32,11 +33,18 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.Fill
};
var co = new Container()
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(co);
var sp = new Sprite("Assets/FrivoloCoBackground.png")
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(Game.AddObject(sp));
co.AddChild(Game.AddObject(sp));
AddChild(rc);
var tb = new TextBlock(new(0, 0, 0, 0), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 40), "", Color.Black)
@ -53,7 +61,7 @@ namespace FrivoloCo.Screens.Menu
Margin = 10,
Color = Color.White * 0.5f
};
AddChild(Game.AddObject(box));
co.AddChild(Game.AddObject(box));
box.AddChild(Game.AddObject(tb));
var button = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); })
@ -62,7 +70,7 @@ namespace FrivoloCo.Screens.Menu
RelativePosition = new(0, 0, 250, 100),
Margin = 10
};
AddChild(Game.AddObject(button));
co.AddChild(Game.AddObject(button));
}
public override void Update(GameTime gameTime)

View file

@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Water.Graphics;
using Water.Graphics.Containers;
using Water.Graphics.Controls;
using Water.Graphics.Screens;
@ -40,11 +41,18 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.Fill
};
var co = new Container()
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(co);
sp = new Sprite("Assets/FrivoloCoBackground.png")
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(Game.AddObject(sp));
co.AddChild(Game.AddObject(sp));
AddChild(rc);
bt = new SpriteButton("Assets/endless.png", "Assets/endlessA.png", () => { beginGame = true; })
@ -52,21 +60,21 @@ namespace FrivoloCo.Screens.Menu
RelativePosition = new(0, 300, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt));
co.AddChild(Game.AddObject(bt));
bt2 = new SpriteButton("Assets/tutorial.png", "Assets/tutorialA.png", () => { ScreenManager.ChangeScreen(new OptionsScreen()); })
{
RelativePosition = new(0, 450, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt2));
co.AddChild(Game.AddObject(bt2));
bt3 = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); })
{
RelativePosition = new(0, 600, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt3));
co.AddChild(Game.AddObject(bt3));
}
private double counter = 1;

View file

@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Water.Graphics;
using Water.Graphics.Containers;
using Water.Graphics.Controls;
using Water.Graphics.Screens;
@ -33,6 +34,7 @@ namespace FrivoloCo.Screens.Menu
private Sprite bt2;
private Sprite bt3;
private Sprite bt4;
private TextBlock tx;
public override void Initialize()
{
@ -43,11 +45,19 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.Fill
};
var co = new Container()
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(co);
sp = new Sprite("Assets/FrivoloCoBackground.png")
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(Game.AddObject(sp));
co.AddChild(Game.AddObject(sp));
AddChild(rc);
logo = new Sprite("Assets/frivologo.png")
@ -56,36 +66,43 @@ namespace FrivoloCo.Screens.Menu
Layout = Water.Graphics.Layout.AnchorTop,
Margin = 50
};
AddChild(Game.AddObject(logo));
co.AddChild(Game.AddObject(logo));
bt = new SpriteButton("Assets/indulge.png", "Assets/indulgeA.png", () => { ScreenManager.ChangeScreen(new GamemodeScreen()); })
{
RelativePosition = new(0, 300, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt));
co.AddChild(Game.AddObject(bt));
bt2 = new SpriteButton("Assets/options.png", "Assets/optionsA.png", () => { ScreenManager.ChangeScreen(new OptionsScreen()); })
{
RelativePosition = new(0, 450, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt2));
co.AddChild(Game.AddObject(bt2));
bt3 = new SpriteButton("Assets/credits.png", "Assets/creditsA.png", () => { ScreenManager.ChangeScreen(new CreditsScreen()); })
{
RelativePosition = new(0, 600, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
AddChild(Game.AddObject(bt3));
co.AddChild(Game.AddObject(bt3));
bt4 = new SpriteButton("Assets/exit.png", "Assets/exitA.png", () => { Environment.Exit(0); })
{
RelativePosition = new(0, 750, 250, 100),
Layout = Water.Graphics.Layout.HorizontalCenter
};
co.AddChild(Game.AddObject(bt4));
AddChild(Game.AddObject(bt4));
tx = new TextBlock(new(0, 0, 400, 18), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 20), "Ver. 1 - initial Game Jam release", Color.White)
{
Layout = Water.Graphics.Layout.AnchorBottomLeft,
HorizontalTextAlignment = HorizontalTextAlignment.Left,
VerticalTextAlignment = VerticalTextAlignment.Bottom
};
co.AddChild(Game.AddObject(tx));
}
private double counter = 0;
@ -93,7 +110,7 @@ namespace FrivoloCo.Screens.Menu
{
counter += gameTime.ElapsedGameTime.TotalSeconds;
sp.Color = logo.Color = bt.Color = bt2.Color = bt3.Color = bt4.Color = Color.White * (float)counter;
sp.Color = logo.Color = bt.Color = bt2.Color = bt3.Color = bt4.Color = tx.Color = Color.White * (float)counter;
}
}
}

View file

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Water.Graphics;
using Water.Graphics.Containers;
using Water.Graphics.Controls;
using Water.Graphics.Screens;
@ -31,11 +32,18 @@ namespace FrivoloCo.Screens.Menu
{
Layout = Water.Graphics.Layout.Fill
};
var co = new Container()
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(co);
var sp = new Sprite("Assets/FrivoloCoBackground.png")
{
RelativePosition = new(0, 0, 1920, 1080)
};
rc.AddChild(Game.AddObject(sp));
co.AddChild(Game.AddObject(sp));
AddChild(rc);
var tb = new TextBlock(new(0, 0, 0, 0), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 40), "", Color.Black)
@ -45,15 +53,14 @@ namespace FrivoloCo.Screens.Menu
VerticalTextAlignment = VerticalTextAlignment.Top,
Margin = 10
};
tb.Text = "Since we don't have an actual options menu yet, the config file should have been opened with your text editor.\n" +
"Once you're done, hit the back button and the new settings will be loaded :)";
tb.Text = "options coming soon :)";
var box = new Box()
{
Layout = Water.Graphics.Layout.Fill,
Margin = 10,
Color = Color.White * 0.5f
};
AddChild(Game.AddObject(box));
co.AddChild(Game.AddObject(box));
box.AddChild(Game.AddObject(tb));
var button = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); })
@ -62,7 +69,7 @@ namespace FrivoloCo.Screens.Menu
RelativePosition = new(0, 0, 250, 100),
Margin = 10
};
AddChild(Game.AddObject(button));
co.AddChild(Game.AddObject(button));
}
public override void Update(GameTime gameTime)

View file

@ -140,11 +140,13 @@ namespace FrivoloCo.Screens.Play
{
SoundEffect.FromFile(customer.ImDoneSound).Play();
state.Strikes++;
progress.TotalStrikes++;
happy = false;
}
if (happy)
{
progress.Money += (decimal)(10 * customer.Happiness * progress.Day);
progress.CustomersServed++;
SoundEffect.FromFile("Assets/Gameplay/kaching.wav").Play();
}
customer = null;
@ -188,6 +190,7 @@ namespace FrivoloCo.Screens.Play
{
SoundEffect.FromFile(customer.WrongOrderSound).Play();
state.Strikes++;
progress.TotalStrikes++;
return;
}
foreach (var entry in customer.Order)
@ -222,8 +225,7 @@ namespace FrivoloCo.Screens.Play
minIntervalBetweenCustomers -= gameTime.ElapsedGameTime.TotalMilliseconds;
if (minIntervalBetweenCustomers <= 0)
{
//var diceRoll = Random.Shared.Next(0, 5000);
if (/*diceRoll == 5 && */state.TimeDelayBetweenCustomers <= 0)
if (state.TimeDelayBetweenCustomers <= 0)
{
CustomerEnters();
ResetMinInterval();

View file

@ -66,17 +66,20 @@ namespace FrivoloCo.Screens.Play
HorizontalTextAlignment = HorizontalTextAlignment.Center,
VerticalTextAlignment = VerticalTextAlignment.Center
};
tb.Text = $"FAILED\nYour terrible performance caused people to stop going to FrivoloCo,\nso you were fired.\n(press esc to go back)\n\nScore: ${progress.Money:0..00}";
tb.Text =
$"FAILED\nYour terrible performance caused people to stop going to FrivoloCo,\n" +
$"so you were fired.\n" +
$"(press any key to go back)\n" +
$"\n" +
$"Score: ${progress.Money:0..00}\n" +
$"Mistakes: {progress.TotalStrikes} Customers Served: {progress.CustomersServed}";
co.AddChild(Game.AddObject(tb));
}
private void Input_KeyDown(object sender, Water.Input.KeyEventArgs e)
{
if (e.Key == Microsoft.Xna.Framework.Input.Keys.Escape)
{
MediaPlayer.Stop();
ScreenManager.ChangeScreen(new MenuScreen());
}
MediaPlayer.Stop();
ScreenManager.ChangeScreen(new MenuScreen());
}
private double counter;

View file

@ -13,5 +13,9 @@ namespace FrivoloCo.Screens.Play
public decimal Money { get; set; } = 1;
public int SongPlayed { get; set; } = 1;
public int TotalStrikes { get; set; } = 0;
public int CustomersServed { get; set; } = 0;
}
}