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

Commit

Permalink
Adding NewPoint, Rect, Canvas back into C# API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed Dec 26, 2019
1 parent 9cd44cb commit 1a43078
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
35 changes: 35 additions & 0 deletions SDK/Engine/Chips/Game/GameChip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,5 +2203,40 @@ public void WriteMetadata(string key, string value)
}

#endregion

#region Factories

/// <summary>
/// A Rect is a Pixel Vision 8 primitive used for defining the bounds of an object on the display. It
/// contains an x, y, width and height property. The Rect class also has some additional methods to aid with
/// collision detection such as Intersect(rect, rect), IntersectsWidth(rect) and Contains(x,y).
/// </summary>
/// <param name="x">The x position of the rect as an int.</param>
/// <param name="y">The y position of the rect as an int.</param>
/// <param name="w">The width value of the rect as an int.</param>
/// <param name="h">The height value of the rect as an int.</param>
/// <returns>Returns a new instance of a Rect to be used as a Lua object.</returns>
public Rectangle NewRect(int x = 0, int y = 0, int w = 0, int h = 0)
{
return new Rectangle(x, y, w, h);
}

/// <summary>
/// A Vector is a Pixel Vision 8 primitive used for defining a position on the display as an x,y value.
/// </summary>
/// <param name="x">The x position of the Vector as an int.</param>
/// <param name="y">The y position of the Vector as an int.</param>
/// <returns>Returns a new instance of a Vector to be used as a Lua object.</returns>
public Point NewPoint(int x = 0, int y = 0)
{
return new Point(x, y);
}

public Canvas NewCanvas(int width, int height)
{
return new Canvas(width, height, this);
}

#endregion
}
}
31 changes: 1 addition & 30 deletions SDK/Engine/Chips/Game/LuaGameChip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public override void Reset()
// Register PV8's rect type
UserData.RegisterType<Canvas>();
luaScript.Globals["NewCanvas"] =
new Func<int, int, Canvas>((width, height) => new Canvas(width, height, this));
new Func<int, int, Canvas>(NewCanvas);

// Load the default script
LoadScript("code.lua");
Expand Down Expand Up @@ -367,34 +367,5 @@ public void AddScript(string name, string script)

#endregion

#region Geometry

/// <summary>
/// A Rect is a Pixel Vision 8 primitive used for defining the bounds of an object on the display. It
/// contains an x, y, width and height property. The Rect class also has some additional methods to aid with
/// collision detection such as Intersect(rect, rect), IntersectsWidth(rect) and Contains(x,y).
/// </summary>
/// <param name="x">The x position of the rect as an int.</param>
/// <param name="y">The y position of the rect as an int.</param>
/// <param name="w">The width value of the rect as an int.</param>
/// <param name="h">The height value of the rect as an int.</param>
/// <returns>Returns a new instance of a Rect to be used as a Lua object.</returns>
public Rectangle NewRect(int x = 0, int y = 0, int w = 0, int h = 0)
{
return new Rectangle(x, y, w, h);
}

/// <summary>
/// A Vector is a Pixel Vision 8 primitive used for defining a position on the display as an x,y value.
/// </summary>
/// <param name="x">The x position of the Vector as an int.</param>
/// <param name="y">The y position of the Vector as an int.</param>
/// <returns>Returns a new instance of a Vector to be used as a Lua object.</returns>
public Point NewPoint(int x = 0, int y = 0)
{
return new Point(x, y);
}

#endregion
}
}

0 comments on commit 1a43078

Please sign in to comment.