mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-25 16:18:56 +08:00
Sample game. Easing methods. Colors.
This commit is contained in:
parent
786b692a3f
commit
12ea2e43bc
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
SampleGame/build/*
|
8
SampleGame/BeefProj.toml
Normal file
8
SampleGame/BeefProj.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
FileVersion = 1
|
||||
Dependencies = {corlib = "*", SDL2 = "*", Strawberry = "*"}
|
||||
|
||||
[Project]
|
||||
Name = "SampleGame"
|
||||
TargetType = "BeefGUIApplication"
|
||||
StartupObject = "Strawberry.Sample.Program"
|
||||
DefaultNamespace = "Strawberry.Sample"
|
5
SampleGame/BeefSpace.toml
Normal file
5
SampleGame/BeefSpace.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
FileVersion = 1
|
||||
Projects = {SampleGame = {Path = "."}, Strawberry = {Path = ".."}, SDL2 = "*"}
|
||||
|
||||
[Workspace]
|
||||
StartupProject = "SampleGame"
|
218
SampleGame/BeefSpace_User.toml
Normal file
218
SampleGame/BeefSpace_User.toml
Normal file
|
@ -0,0 +1,218 @@
|
|||
FileVersion = 1
|
||||
LastConfig = "Debug"
|
||||
LastPlatform = "Win64"
|
||||
RecentFilesList = ["c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Static\\Ease.bf", "c:\\Program Files\\BeefLang\\BeefLibs\\corlib\\src\\Action.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\MovingJumpThru.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Player.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Struct\\Color.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Level.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\JumpThru.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Components\\Timer.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\Actor.bf", "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\Solid.bf"]
|
||||
|
||||
[MainWindow]
|
||||
X = 64
|
||||
Y = 64
|
||||
Width = 1200
|
||||
Height = 1024
|
||||
ShowKind = "Maximized"
|
||||
|
||||
[MainDockingFrame]
|
||||
Type = "DockingFrame"
|
||||
SplitType = 2
|
||||
|
||||
[[MainDockingFrame.DockedWidgets]]
|
||||
RequestedWidth = 500.0
|
||||
RequestedHeight = 350.0
|
||||
SizePriority = 350.0
|
||||
Type = "DockingFrame"
|
||||
SplitType = 1
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets]]
|
||||
RequestedWidth = 350.0
|
||||
RequestedHeight = 350.0
|
||||
Type = "TabbedView"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
Active = true
|
||||
TabLabel = "Workspace"
|
||||
TabWidth = 111.7143
|
||||
Type = "ProjectPanel"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets]]
|
||||
IsFillWidget = true
|
||||
Permanent = true
|
||||
RequestedWidth = 150.0
|
||||
RequestedHeight = 150.0
|
||||
SizePriority = 150.0
|
||||
DefaultDocumentsTabbedView = true
|
||||
Type = "TabbedView"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Action.bf"
|
||||
TabWidth = 89.14286
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Program Files\\BeefLang\\BeefLibs\\corlib\\src\\Action.bf"
|
||||
ProjectName = "corlib"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
Active = true
|
||||
TabLabel = "Ease.bf"
|
||||
TabWidth = 78.85714
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Static\\Ease.bf"
|
||||
CursorPos = 206
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "MovingJumpThru.bf"
|
||||
TabWidth = 151.4286
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\MovingJumpThru.bf"
|
||||
CursorPos = 406
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Color.bf"
|
||||
TabWidth = 83.42857
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Struct\\Color.bf"
|
||||
CursorPos = 588
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Timer.bf"
|
||||
TabWidth = 85.14286
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Components\\Timer.bf"
|
||||
CursorPos = 530
|
||||
VertPos = 130.0
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Actor.bf"
|
||||
TabWidth = 82.85714
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\Actor.bf"
|
||||
CursorPos = 2066
|
||||
VertPos = 2522.0
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "JumpThru.bf"
|
||||
TabWidth = 109.1429
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\JumpThru.bf"
|
||||
CursorPos = 1409
|
||||
VertPos = 1430.0
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Solid.bf"
|
||||
TabWidth = 81.71429
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\src\\Physics\\Solid.bf"
|
||||
CursorPos = 174
|
||||
ProjectName = "Strawberry"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Controls.bf"
|
||||
TabWidth = 90.57143
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Controls.bf"
|
||||
CursorPos = 433
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Player.bf"
|
||||
TabWidth = 76.85714
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Player.bf"
|
||||
CursorPos = 2419
|
||||
VertPos = 2180.5
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Level.bf"
|
||||
TabWidth = 72.85714
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Level.bf"
|
||||
CursorPos = 190
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "SampleGame.bf"
|
||||
TabWidth = 118.0
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\SampleGame.bf"
|
||||
CursorPos = 169
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Program.bf"
|
||||
TabWidth = 92.28571
|
||||
Type = "SourceViewPanel"
|
||||
FilePath = "c:\\Users\\Matt\\Documents\\Projects\\Strawberry\\SampleGame\\src\\Program.bf"
|
||||
CursorPos = 166
|
||||
ProjectName = "SampleGame"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets]]
|
||||
RequestedWidth = 437.0
|
||||
RequestedHeight = 327.0
|
||||
Type = "DockingFrame"
|
||||
SplitType = 1
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets]]
|
||||
RequestedWidth = 437.0
|
||||
RequestedHeight = 437.0
|
||||
SizePriority = 2558.0
|
||||
Type = "TabbedView"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
Active = true
|
||||
TabLabel = "Memory"
|
||||
TabWidth = 98.0
|
||||
Type = "MemoryPanel"
|
||||
AutoResize = "Auto_Mul8"
|
||||
RequestedWidth = 300.0
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Watch"
|
||||
TabWidth = 84.28571
|
||||
Type = "WatchPanel"
|
||||
Columns = [{Width = 200.0}, {Width = 200.0}, {Width = 200.0}]
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Auto"
|
||||
TabWidth = 76.28571
|
||||
Type = "AutoWatchPanel"
|
||||
Columns = [{Width = 200.0}, {Width = 200.0}, {Width = 200.0}]
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets]]
|
||||
RequestedWidth = 437.0
|
||||
RequestedHeight = 437.0
|
||||
SizePriority = 2558.0
|
||||
Type = "TabbedView"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Find Results"
|
||||
TabWidth = 114.5714
|
||||
Type = "FindResultsPanel"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Threads"
|
||||
TabWidth = 94.0
|
||||
Type = "ThreadPanel"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Call Stack"
|
||||
TabWidth = 102.0
|
||||
Type = "CallStackPanel"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
TabLabel = "Immediate"
|
||||
TabWidth = 109.4286
|
||||
Type = "ImmediatePanel"
|
||||
|
||||
[[MainDockingFrame.DockedWidgets.DockedWidgets.Tabs]]
|
||||
Active = true
|
||||
TabLabel = "Output"
|
||||
TabWidth = 88.85714
|
||||
Type = "OutputPanel"
|
||||
|
||||
[DebuggerDisplayTypes.""]
|
||||
IntDisplayType = "Default"
|
||||
MmDisplayType = "Default"
|
22
SampleGame/src/Controls.bf
Normal file
22
SampleGame/src/Controls.bf
Normal file
|
@ -0,0 +1,22 @@
|
|||
namespace Strawberry.Sample
|
||||
{
|
||||
static public class Controls
|
||||
{
|
||||
static public VirtualAxis MoveX;
|
||||
static public VirtualButton Jump;
|
||||
|
||||
static public void Init()
|
||||
{
|
||||
Jump = new VirtualButton()
|
||||
.AddKey(.Space)
|
||||
.AddKey(.X)
|
||||
.AddButton(0, .A)
|
||||
.PressBuffer(0.1f);
|
||||
|
||||
MoveX = new VirtualAxis()
|
||||
.AddKeys(.Left, .Right, .TakeNewer)
|
||||
.AddButtons(0, .DpadLeft, .DpadRight, .TakeNewer)
|
||||
.AddAxis(0, .LeftX, 0.3f);
|
||||
}
|
||||
}
|
||||
}
|
13
SampleGame/src/Level.bf
Normal file
13
SampleGame/src/Level.bf
Normal file
|
@ -0,0 +1,13 @@
|
|||
namespace Strawberry.Sample
|
||||
{
|
||||
public class Level : Scene
|
||||
{
|
||||
public this()
|
||||
{
|
||||
Add(new Player(.(50, 50)));
|
||||
Add(new Solid(.(0, 168), .(0, 0, 320, 12)));
|
||||
Add(new JumpThru(.(200, 132), 48));
|
||||
Add(new MovingJumpThru(.(136, 100), 32, .(124, 140), 2f));
|
||||
}
|
||||
}
|
||||
}
|
50
SampleGame/src/MovingJumpThru.bf
Normal file
50
SampleGame/src/MovingJumpThru.bf
Normal file
|
@ -0,0 +1,50 @@
|
|||
namespace Strawberry.Sample
|
||||
{
|
||||
public class MovingJumpThru : JumpThru
|
||||
{
|
||||
private Point moveFrom;
|
||||
private Point moveTo;
|
||||
private float moveTime;
|
||||
|
||||
private float movingLerp;
|
||||
private bool movingPositive;
|
||||
|
||||
public this(Point pos, int width, Point moveTo, float moveTime)
|
||||
: base(pos, width)
|
||||
{
|
||||
moveFrom = Position;
|
||||
this.moveTo = moveTo;
|
||||
this.moveTime = moveTime;
|
||||
|
||||
movingLerp = 0;
|
||||
movingPositive = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (movingPositive)
|
||||
{
|
||||
movingLerp += Time.Delta / moveTime;
|
||||
if (movingLerp >= 1)
|
||||
{
|
||||
movingLerp = 1;
|
||||
movingPositive = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movingLerp -= Time.Delta / moveTime;
|
||||
if (movingLerp <= 0)
|
||||
{
|
||||
movingLerp = 0;
|
||||
movingPositive = true;
|
||||
}
|
||||
}
|
||||
|
||||
let target = Vector.Lerp(moveFrom, moveTo, Ease.CubeInOut(movingLerp));
|
||||
MoveTo(target);
|
||||
}
|
||||
}
|
||||
}
|
108
SampleGame/src/Player.bf
Normal file
108
SampleGame/src/Player.bf
Normal file
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
|
||||
namespace Strawberry.Sample
|
||||
{
|
||||
public class Player : Actor
|
||||
{
|
||||
public Vector Speed;
|
||||
|
||||
private Timer tJumpGrace;
|
||||
private Timer tVarJump;
|
||||
|
||||
public this(Point pos)
|
||||
: base(pos)
|
||||
{
|
||||
Hitbox = Rect(-4, -8, 8, 8);
|
||||
|
||||
Add(tJumpGrace = new Timer());
|
||||
Add(tVarJump = new Timer());
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
const float coyoteTime = 0.1f; // Time after leaving a ledge when you can still jump
|
||||
const float varJumpTime = 0.2f; // Time after jumping that you can hold the jump button to continue gaining upward speed
|
||||
const float jumpSpeed = -160;
|
||||
const float jumpXBoost = 30; // If left or right is held at the moment of a jump, this horizontal speed boost is applied
|
||||
const float maxFall = 160;
|
||||
const float gravity = 1000;
|
||||
const float halfGravThreshold = 40; // Halves gravity at the peak of a jump, if the jump button is held
|
||||
const float maxRun = 100;
|
||||
const float runAccel = 800;
|
||||
const float runAccelAirMult = 0.8f; // Gives you slightly less control of horizontal motion in the air
|
||||
|
||||
let onGround = GroundCheck();
|
||||
if (onGround)
|
||||
tJumpGrace.Value = coyoteTime;
|
||||
|
||||
//Vertical Control
|
||||
{
|
||||
//Jumping
|
||||
if (tJumpGrace && Controls.Jump.Pressed)
|
||||
{
|
||||
Controls.Jump.ClearPressBuffer();
|
||||
tJumpGrace.Clear();
|
||||
tVarJump.Value = varJumpTime;
|
||||
Speed.Y = jumpSpeed;
|
||||
Speed.X += jumpXBoost * Controls.MoveX.Valuei;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Gravity
|
||||
{
|
||||
float mult;
|
||||
if (Controls.Jump.Check && Math.Abs(Speed.Y) <= halfGravThreshold)
|
||||
mult = 0.5f;
|
||||
else
|
||||
mult = 1;
|
||||
|
||||
Speed.Y = Calc.Approach(Speed.Y, maxFall, gravity * mult * Time.Delta);
|
||||
}
|
||||
|
||||
//Variable Jumping
|
||||
if (tVarJump)
|
||||
{
|
||||
if (Controls.Jump.Check)
|
||||
Speed.Y = jumpSpeed;
|
||||
else
|
||||
tVarJump.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Horizontal Control
|
||||
{
|
||||
float accel = runAccel;
|
||||
if (!onGround)
|
||||
accel *= runAccelAirMult;
|
||||
|
||||
Speed.X = Calc.Approach(Speed.X, Controls.MoveX.Valuei * maxRun, accel * Time.Delta);
|
||||
}
|
||||
|
||||
//Resolve Speed
|
||||
MoveX(Speed.X * Time.Delta, scope => OnCollideX);
|
||||
MoveY(Speed.Y * Time.Delta, scope => OnCollideY);
|
||||
}
|
||||
|
||||
private void OnCollideX(Collision col)
|
||||
{
|
||||
Speed.X = 0;
|
||||
ZeroRemainderX();
|
||||
}
|
||||
|
||||
private void OnCollideY(Collision col)
|
||||
{
|
||||
Speed.Y = 0;
|
||||
ZeroRemainderY();
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
|
||||
DrawHitbox(.Red);
|
||||
}
|
||||
}
|
||||
}
|
14
SampleGame/src/Program.bf
Normal file
14
SampleGame/src/Program.bf
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Strawberry.Sample
|
||||
{
|
||||
static public class Program
|
||||
{
|
||||
static public int Main(String[] args)
|
||||
{
|
||||
let game = scope SampleGame();
|
||||
game.Run();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
14
SampleGame/src/SampleGame.bf
Normal file
14
SampleGame/src/SampleGame.bf
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Strawberry.Sample
|
||||
{
|
||||
public class SampleGame : Game
|
||||
{
|
||||
public this()
|
||||
: base("Strawberry Sample Game!", 320, 180, 3)
|
||||
{
|
||||
Controls.Init();
|
||||
Scene = new Level();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,11 +26,13 @@ namespace Strawberry
|
|||
|
||||
public float Value
|
||||
{
|
||||
[Inline]
|
||||
get
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
[Inline]
|
||||
set
|
||||
{
|
||||
this.value = Math.Max(0, value);
|
||||
|
@ -38,6 +40,13 @@ namespace Strawberry
|
|||
}
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public void Clear()
|
||||
{
|
||||
value = 0;
|
||||
Active = false;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (value > 0)
|
||||
|
@ -54,5 +63,10 @@ namespace Strawberry
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public implicit operator bool(Timer timer)
|
||||
{
|
||||
return timer.value > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,6 @@ namespace Strawberry
|
|||
let hit = First<Solid>(.(sign, 0));
|
||||
if (hit != null)
|
||||
{
|
||||
ZeroRemainderX();
|
||||
|
||||
let c = Collision(
|
||||
Point.Right * sign,
|
||||
Math.Abs(amount),
|
||||
|
@ -110,8 +108,6 @@ namespace Strawberry
|
|||
|
||||
if (hit != null)
|
||||
{
|
||||
ZeroRemainderY();
|
||||
|
||||
let c = Collision(
|
||||
Point.Right * sign,
|
||||
Math.Abs(amount),
|
||||
|
|
|
@ -35,6 +35,32 @@ namespace Strawberry
|
|||
}
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public void Move(Vector amount)
|
||||
{
|
||||
MoveX(amount.X);
|
||||
MoveY(amount.Y);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public void MoveToX(float x)
|
||||
{
|
||||
MoveX(x - (X + remainder.X));
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public void MoveToY(float y)
|
||||
{
|
||||
MoveY(y - (Y + remainder.Y));
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public void MoveTo(Vector target)
|
||||
{
|
||||
MoveToX(target.X);
|
||||
MoveToY(target.Y);
|
||||
}
|
||||
|
||||
public abstract void MoveExactX(int amount);
|
||||
public abstract void MoveExactY(int amount);
|
||||
public abstract List<Actor> GetRiders(List<Actor> into);
|
||||
|
|
|
@ -6,14 +6,7 @@ namespace Strawberry
|
|||
public this(Point position, int width)
|
||||
: base(position)
|
||||
{
|
||||
Hitbox = Rect(0, 0, width, 6);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
MoveY(-10 * Time.Delta);
|
||||
Hitbox = Rect(0, 0, width, 2);
|
||||
}
|
||||
|
||||
public override void MoveExactX(int amount)
|
||||
|
@ -80,7 +73,7 @@ namespace Strawberry
|
|||
|
||||
public override void Draw()
|
||||
{
|
||||
DrawHitbox(.(255, 255, 255, 255));
|
||||
DrawHitbox(.LightGray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,6 @@ namespace Strawberry
|
|||
Hitbox = hitbox;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
MoveY(0.1f);
|
||||
}
|
||||
|
||||
public override List<Actor> GetRiders(List<Actor> into)
|
||||
{
|
||||
for (var a in Scene.All<Actor>(scope List<Actor>))
|
||||
|
|
36
src/Static/Ease.bf
Normal file
36
src/Static/Ease.bf
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Ease
|
||||
{
|
||||
public delegate float Easer(float t);
|
||||
|
||||
static public float CubeIn(float t)
|
||||
{
|
||||
return t * t * t;
|
||||
}
|
||||
|
||||
static public float CubeOut(float t)
|
||||
{
|
||||
return Invert(t, scope => CubeIn);
|
||||
}
|
||||
|
||||
static public float CubeInOut(float t)
|
||||
{
|
||||
return Follow(t, scope => CubeIn, scope => CubeOut);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
static public float Invert(float t, Easer easer)
|
||||
{
|
||||
return 1 - easer(1 - t);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
static public float Follow(float t, Easer a, Easer b)
|
||||
{
|
||||
return (t <= 0.5f) ? a(t * 2) / 2 : b(t * 2 - 1) / 2 + 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,6 +13,9 @@ namespace Strawberry
|
|||
static public readonly Color Cyan = 0xFF00FFFF;
|
||||
static public readonly Color Magenta = 0xFFFF00FF;
|
||||
static public readonly Color Yellow = 0x00FFFFFF;
|
||||
static public readonly Color DarkGray = 0x3F3F3FFF;
|
||||
static public readonly Color Gray = 0x7F7F7FFF;
|
||||
static public readonly Color LightGray = 0xBFBFBFFF;
|
||||
|
||||
public uint8 R;
|
||||
public uint8 G;
|
||||
|
|
|
@ -51,6 +51,16 @@ namespace Strawberry
|
|||
return Point((int)Math.Round(X), (int)Math.Round(Y));
|
||||
}
|
||||
|
||||
static public Vector Lerp(Vector a, Vector b, float t)
|
||||
{
|
||||
if (t == 0)
|
||||
return a;
|
||||
else if (t == 1)
|
||||
return b;
|
||||
else
|
||||
return a + (b - a) * t;
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.Set("Vector [ ");
|
||||
|
|
Loading…
Reference in New Issue
Block a user