Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Cleaning up Runner name space, optimizing parser logic, and simplifyi…
Browse files Browse the repository at this point in the history
…ng core runner logic.
  • Loading branch information
jessefreeman committed Jan 30, 2021
1 parent 9ead889 commit 582c166
Show file tree
Hide file tree
Showing 149 changed files with 1,388 additions and 1,729 deletions.
47 changes: 20 additions & 27 deletions Disks/APIExamples/NewCanvas/code.cs
Expand Up @@ -11,8 +11,7 @@
https://www.pixelvision8.com/getting-started
**/

using PixelVision8.Engine;
using PixelVision8.Engine.Chips;
using PixelVision8.Player;

namespace PixelVision8.Examples
{
Expand All @@ -39,50 +38,44 @@ public override void Init()
canvas = NewCanvas(Display().X, Display().Y);

// Set the canvas stroke to a 1x1 pixel brush
canvas.SetStroke(new int[] { 6 }, 1, 1);
canvas.SetStroke(6, 1);

// Draw the line label to the canvas
canvas.DrawText("Line", 8, 8, "large", 15);
canvas.DrawText("Line C#", 8, 8, "large", 15);

// Draw a line between the two points
canvas.DrawLine(8, 24, 80, 32);

// Change the spacing between the line's x pixels to 2 for a dotted line
canvas.LinePattern(2, 0);
canvas.DrawLine(8, 24, 80, 24);

// Draw a line between the two points
canvas.DrawLine(93, 24, 165, 32);

// Reset the space between the line's pixels back to 1
canvas.LinePattern(1, 0);

// Draw the circle label to the canvas
canvas.DrawText("Circle", 8, 40, "large", 15);
// Draw the Ellipse label to the canvas
canvas.DrawText("Ellipse", 8, 40, "large", 15);

// Circle 1
canvas.DrawCircle(8, 80, 64, 80);
// Ellipse 1
canvas.DrawEllipse(8, 52, 64, 64);

// Circle 2
// Ellipse 2
canvas.SetPattern(solidPattern, 1, 1);
canvas.DrawCircle(74, 80, 130, 80, true);
canvas.DrawEllipse(79, 52, 64, 64, true);

// Circle 3
// Ellipse 3
canvas.SetPattern(checkeredPattern, 4, 4);
canvas.DrawCircle(140, 80, 196, 80, true);
canvas.DrawEllipse(150, 52, 64, 64, true);

// Draw the square label to the canvas
canvas.DrawText("Square", 8, 120, "large", 15);
// Draw the Rectangle label to the canvas
canvas.DrawText("Rectangle", 8, 120, "large", 15);

// Square 1
canvas.DrawSquare(8, 136, 64, 192);
// Rectangle 1
canvas.DrawRectangle(8, 136, 64, 64);

// Square 2
// Rectangle 2
canvas.SetPattern(solidPattern, 1, 1);
canvas.DrawSquare(76, 136, 132, 192, true);
canvas.DrawRectangle(79, 136, 64, 64, true);

// Square 3
// Rectangle 3
canvas.SetPattern(checkeredPattern, 4, 4);
canvas.DrawSquare(142, 136, 198, 192, true);
canvas.DrawRectangle(150, 136, 64, 64, true);

// Draw the canvas to the display
canvas.DrawPixels();
Expand Down
44 changes: 19 additions & 25 deletions Disks/APIExamples/NewCanvas/code.lua
Expand Up @@ -28,50 +28,44 @@ local checkeredPattern = {
function Init()

-- Set the canvas stroke to a 1x1 pixel brush
canvas:SetStroke({6}, 1, 1)
canvas:SetStroke(6, 1)

-- Draw the line label to the canvas
canvas:DrawText("Line", 8, 8, "large", 15)
canvas:DrawText("Line Lua", 8, 8, "large", 15)

-- Draw a line between the two points
canvas:DrawLine(8, 24, 80, 32)

-- Change the spacing between the line's x pixels to 2 for a dotted line
canvas:LinePattern(2, 0)
canvas:DrawLine(8, 24, 80, 24)

-- Draw a line between the two points
canvas:DrawLine(93, 24, 165, 32)

-- Reset the space between the line's pixels back to 1
canvas:LinePattern(1, 0)

-- Draw the circle label to the canvas
canvas:DrawText("Circle", 8, 40, "large", 15)
-- Draw the Ellipse label to the canvas
canvas:DrawText("Ellipse", 8, 40, "large", 15)

-- Circle 1
canvas:DrawCircle(8, 80, 64, 80)
-- Ellipse 1
canvas:DrawEllipse(8, 52, 64, 64)

-- Circle 2
-- Ellipse 2
canvas:SetPattern(solidPattern, 1, 1)
canvas:DrawCircle(74, 80, 130, 80, true)
canvas:DrawEllipse(79, 52, 64, 64, true)

-- Circle 3
-- Ellipse 3
canvas:SetPattern(checkeredPattern, 4, 4)
canvas:DrawCircle(140, 80, 196, 80, true)
canvas:DrawEllipse(150, 52, 64, 64, true)

-- Draw the square label to the canvas
canvas:DrawText("Square", 8, 120, "large", 15)
-- Draw the Rectangle label to the canvas
canvas:DrawText("Rectangle", 8, 120, "large", 15)

-- Square 1
canvas:DrawSquare(8, 136, 64, 192)
-- Rectangle 1
canvas:DrawRectangle(8, 136, 64, 64)

-- Square 2
-- Rectangle 2
canvas:SetPattern(solidPattern, 1, 1)
canvas:DrawSquare(76, 136, 132, 192, true)
canvas:DrawRectangle(79, 136, 64, 64, true)

-- Square 3
-- Rectangle 3
canvas:SetPattern(checkeredPattern, 4, 4)
canvas:DrawSquare(142, 136, 198, 192, true)
canvas:DrawRectangle(150, 136, 64, 64, true)

-- Draw the canvas to the display
canvas:DrawPixels()
Expand Down
2 changes: 0 additions & 2 deletions Program.cs
Expand Up @@ -5,7 +5,6 @@ namespace PixelVision8.Runner
{
public static class Program
{

[STAThread]
public static void Main(string[] args)
{
Expand All @@ -15,7 +14,6 @@ public static void Main(string[] args)
{
game.Run();
}

}
}
}
15 changes: 14 additions & 1 deletion README.md
Expand Up @@ -18,7 +18,20 @@ The platform was designed to be incredibly modular. This allows you to customize

### Credits

Pixel Vision 8 was created by Jesse Freeman ([@jessefreeman](http://twitter.com/jessefreeman)) in collaboration with Christina-Antoinette Neofotistou ([@CastPixel](http://twitter.com/CastPixel)), Pedro Medeiros ([@saint11](http://twitter.com/saint11)) for art and Christer Kaitila ([@McFunkypants](http://twitter.com/McFunkypants)) for music. With additional coding contributions by Drake Williams and Shawn Rakowski ([@shwany](http://twitter.com/shwany)).
Pixel Vision 8 was created by Jesse Freeman ([@jessefreeman](http://twitter.com/jessefreeman)) in collaboration with Christina-Antoinette Neofotistou ([@CastPixel](http://twitter.com/CastPixel)) for art, and Christer Kaitila ([@McFunkypants](http://twitter.com/McFunkypants)) for music.

With additional contributions by the following people:

* Pedro Medeiros
* Shawn Rakowski
* Drake Williams
* Matt Hughson
* Dean Ellis

And special thanks to the following sponsors:

* Jan Rochat
* Ethan Shaughnessy

### License

Expand Down
28 changes: 14 additions & 14 deletions SDK/Editor/Audio/SfxrMusicGeneratorChip.cs
Expand Up @@ -88,7 +88,7 @@ public InstrumentType InstrumentType
{
_instrumentType = value;

var typeID = (int)InstrumentType;
var typeID = (int) InstrumentType;

// if (typeID < defaultOctaves.Length)
// {
Expand All @@ -105,7 +105,7 @@ public InstrumentType InstrumentType
public bool Generate => InstrumentType != InstrumentType.None;


public string InstrumentSettings => ReadInstrumentSoundData((int)InstrumentType);
public string InstrumentSettings => ReadInstrumentSoundData((int) InstrumentType);

public string ReadInstrumentSoundData(int value)
{
Expand Down Expand Up @@ -260,12 +260,12 @@ public void ConfigureGenerator(int tracks)
settings = trackSettings[i];
}

settings.InstrumentType = (InstrumentType)i;
settings.InstrumentType = (InstrumentType) i;
settings.SfxId = i;
}

// forces scale to the default value
UpdateScale((int)Scale.Major);
UpdateScale((int) Scale.Major);

//workspace.InvalidateSave();
}
Expand Down Expand Up @@ -352,7 +352,7 @@ public void GenerateSong(PixelVision chips)
if (trackSettings[trackNum] == null)
trackSettings[trackNum] = new TrackSettings
{
InstrumentType = (InstrumentType)trackNum,
InstrumentType = (InstrumentType) trackNum,
SfxId = trackNum
};

Expand Down Expand Up @@ -447,7 +447,7 @@ public void GenerateSong(PixelVision chips)

// is silence appropriate for this moment?
//restHere = UnityEngine.Random.Range(0f,1f - noteChangeBoost) > pcgComplexity;
randy = (float)r.NextDouble(); //Random.value;
randy = (float) r.NextDouble(); //Random.value;
restHere = randy + noteChangeBoost < pcgComplexity;

// never rest the first beat of the song on bass
Expand Down Expand Up @@ -488,25 +488,25 @@ public void GenerateSong(PixelVision chips)
}
else if (instrument == InstrumentType.Kick

//|| (trackNum == pcgTrackSFX) // snare drum, usually
//|| (trackNum == pcgTrackDRUMS)
//|| (trackNum == pcgTrackSFX) // snare drum, usually
//|| (trackNum == pcgTrackDRUMS)
) // high hat, usually
{
// drums have no tonality
trackData.notes[noteNum] = pcgKeyRootNote + noteTranspose;
}
else if (instrument == InstrumentType.Bass) // and not beat 1, done above
{
if (!wasFunkyLastNote && (float)r.NextDouble() < pcgFunk
if (!wasFunkyLastNote && (float) r.NextDouble() < pcgFunk
) // we want a funky OCTAVE bass note
{
wasFunkyLastNote = true;

// either stay the same, or jump higher or lower by an entire octave
var funkyOffset = 12;
if ((float)r.NextDouble() > 0.5f) // octave higher half the time
if ((float) r.NextDouble() > 0.5f) // octave higher half the time
{
if ((float)r.NextDouble() > 0.5f) // stay same 25% of the time
if ((float) r.NextDouble() > 0.5f) // stay same 25% of the time
funkyOffset = 0;
else // octave lower %25 of the time
funkyOffset = -12;
Expand Down Expand Up @@ -542,18 +542,18 @@ public void GenerateSong(PixelVision chips)
public void UpdateScale(int value)
{
scale = value;
pcgScale = scaleTable[(Scale)value];
pcgScale = scaleTable[(Scale) value];
}

/////////////////////////////////////////////////////////////////////////////
private int RandomNote() // output a random MIDI note number
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
{
// TODO use pcg params to select notes that fit the current scale/mode/chord/harmony
var aNote = 0;
var noteDistance = r.Next(pcgNoteDistanceMin, pcgNoteDistanceMax); // 0,1,2
var noteDir = 1; // +1 or -1 only
if ((float)r.NextDouble() > 0.5f) noteDir = -1; // down
if ((float) r.NextDouble() > 0.5f) noteDir = -1; // down

// pure random noise - works
// aNote = Mathf.CeilToInt(UnityEngine.Random.Range(32f,64f));
Expand Down

0 comments on commit 582c166

Please sign in to comment.