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

Commit b409eb1

Browse files
committed
Cleaning up API examples and fix to Sound() API in LuaGameChip.
1 parent 170c26a commit b409eb1

File tree

80 files changed

+646
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+646
-169
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ColorChip":{"maxColors":128,"backgroundColor":2,"maskColor":"#FF00FF","unique":false,"debug":false,},"DisplayChip":{"width":264,"height":248,"overscanX":1,"overscanY":1,"layers":6},"FontChip":{},"GameChip":{"lockSpecs":false,"maxSize":512,"saveSlots":8},"MusicChip":{"totalSongs":32,"notesPerTrack":127,"totalPatterns":24,"totalLoop":24},"SoundChip":{"totalChannels":5,"totalSounds":32,"channelTypes":[-1,-1,-1,-1,-1]},"SpriteChip":{"maxSpriteCount":0,"unique":false,"spriteWidth":8,"spriteHeight":8,"pages":8,"cps":8},"TilemapChip":{"columns":68,"rows":32,"totalFlags":16,"autoImport":false,}}
1+
{"ColorChip":{"maxColors":128,"backgroundColor":2,"maskColor":"#FF00FF","unique":false,"debug":false,},"DisplayChip":{"width":256,"height":240,"overscanX":1,"overscanY":1,"layers":6},"FontChip":{},"GameChip":{"lockSpecs":false,"maxSize":512,"saveSlots":8},"MusicChip":{"totalSongs":32,"notesPerTrack":127,"totalPatterns":24,"totalLoop":24},"SoundChip":{"totalChannels":5,"totalSounds":32,"channelTypes":[-1,-1,-1,-1,-1]},"SpriteChip":{"maxSpriteCount":0,"unique":false,"spriteWidth":8,"spriteHeight":8,"pages":8,"cps":8},"TilemapChip":{"columns":68,"rows":32,"totalFlags":16,"autoImport":false,}}
-199 Bytes
Binary file not shown.
-365 Bytes
Binary file not shown.

Disks/APIExamples/Flag/code.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,39 @@ Learn more about making Pixel Vision 8 games at
1616

1717
namespace PixelVision8.Examples
1818
{
19-
class ExampleGameChip : GameChip
19+
class FlagExampleGame : GameChip
2020
{
2121
// This point will store the current tile's position
2222
private Point tilePosition;
2323

2424
// This will store the current flag ID
2525
private int flagID = -1;
2626

27+
public override void Init()
28+
{
29+
// Example Title
30+
DrawText("Flag()", 8, 16, DrawMode.TilemapCache, "large", 15);
31+
DrawText("C Sharp Example", 8, 24, DrawMode.TilemapCache, "medium", 15, -4);
32+
}
33+
2734
public override void Update(int timeDelta)
2835
{
2936
// Get the current mouse position
3037
tilePosition = MousePosition();
3138

39+
// Check to see if the mouse is out of bounds
40+
if(tilePosition.X < 0 || tilePosition.X > Display().X || tilePosition.Y < 0 || tilePosition.Y >= Display().Y)
41+
{
42+
43+
// Set all of the values to -1
44+
tilePosition.X = -1;
45+
tilePosition.Y = -1;
46+
flagID = -1;
47+
48+
// Return before the position and flag are calculated
49+
return;
50+
}
51+
3252
// Convert the mouse position to the tilemap's correct column and row
3353
tilePosition.X = (int)Math.Floor(tilePosition.X / 8f);
3454
tilePosition.Y = (int)Math.Floor(tilePosition.Y / 8f);
@@ -45,8 +65,8 @@ public override void Draw()
4565
RedrawDisplay();
4666

4767
// Display the tile and flag text on the screen
48-
DrawText("Tile " + tilePosition.X + "," + tilePosition.Y, 8, 8, DrawMode.Sprite, "large");
49-
DrawText("Flag " + flagID, 8, 16, DrawMode.Sprite, "large");
68+
DrawText("Tile " + tilePosition.X + "," + tilePosition.Y, 8, 40, DrawMode.Sprite, "large", 15);
69+
DrawText("Flag " + flagID, 8, 48, DrawMode.Sprite, "large", 15);
5070

5171
// Draw a rect to represent which tile the mouse is over and set the color to match the flag ID plus 1
5272
DrawRect(tilePosition.X * 8, tilePosition.Y * 8, 8, 8, flagID + 1, DrawMode.Sprite);

Disks/APIExamples/Flag/code.lua

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,30 @@ local tilePosition = NewPoint()
1717
-- This will store the current flag ID
1818
local flagID = -1
1919

20+
function Init()
21+
-- Example Title
22+
DrawText("Flag()", 8, 16, DrawMode.TilemapCache, "large", 15)
23+
DrawText("Lua Example", 8, 24, DrawMode.TilemapCache, "medium", 15, -4)
24+
end
25+
2026
function Update(timeDelta)
2127

2228
-- Get the current mouse position
2329
tilePosition = MousePosition()
2430

31+
-- Check to see if the mouse is out of bounds
32+
if(tilePosition.X < 0 or tilePosition.X > Display().X or tilePosition.Y < 0 or tilePosition.Y >= Display().Y) then
33+
34+
-- Set all of the values to -1
35+
tilePosition.X = -1;
36+
tilePosition.Y = -1;
37+
flagID = -1;
38+
39+
-- Return before the position and flag are calculated
40+
return
41+
42+
end
43+
2544
-- Convert the mouse position to the tilemap's correct column and row
2645
tilePosition.x = math.floor(tilePosition.x / 8)
2746
tilePosition.y = math.floor(tilePosition.y / 8)
@@ -37,8 +56,8 @@ function Draw()
3756
RedrawDisplay()
3857

3958
-- Display the tile and flag text on the screen
40-
DrawText("Tile " .. tilePosition.x .. ",".. tilePosition.y, 8, 8, DrawMode.Sprite, "large")
41-
DrawText("Flag " .. flagID, 8, 16, DrawMode.Sprite, "large")
59+
DrawText("Tile " .. tilePosition.x .. ",".. tilePosition.y, 8, 40, DrawMode.Sprite, "large", 15)
60+
DrawText("Flag " .. flagID, 8, 48, DrawMode.Sprite, "large", 15)
4261

4362
-- Draw a rect to represent which tile the mouse is over and set the color to match the flag ID plus 1
4463
DrawRect(tilePosition.x * 8, tilePosition.y * 8, 8, 8, flagID + 1, DrawMode.Sprite)

Disks/APIExamples/Flag/data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ColorChip":{"maxColors":128,"backgroundColor":2,"maskColor":"#FF00FF","unique":false,"debug":false,},"DisplayChip":{"width":264,"height":248,"overscanX":1,"overscanY":1,"layers":6},"FontChip":{},"GameChip":{"lockSpecs":false,"maxSize":512,"saveSlots":8},"MusicChip":{"totalSongs":32,"notesPerTrack":127,"totalPatterns":24,"totalLoop":24},"SoundChip":{"totalChannels":5,"totalSounds":32,"channelTypes":[-1,-1,-1,-1,-1]},"SpriteChip":{"maxSpriteCount":0,"unique":false,"spriteWidth":8,"spriteHeight":8,"pages":8,"cps":8},"TilemapChip":{"columns":68,"rows":32,"totalFlags":16,"autoImport":false,}}
1+
{"ColorChip":{"maxColors":128,"backgroundColor":2,"maskColor":"#FF00FF","unique":false,"debug":false,},"DisplayChip":{"width":256,"height":240,"overscanX":1,"overscanY":1,"layers":6},"FontChip":{},"GameChip":{"lockSpecs":false,"maxSize":512,"saveSlots":8},"MusicChip":{"totalSongs":32,"notesPerTrack":127,"totalPatterns":24,"totalLoop":24},"SoundChip":{"totalChannels":5,"totalSounds":32,"channelTypes":[-1,-1,-1,-1,-1]},"SpriteChip":{"maxSpriteCount":0,"unique":false,"spriteWidth":8,"spriteHeight":8,"pages":8,"cps":8},"TilemapChip":{"columns":68,"rows":32,"totalFlags":16,"autoImport":false,}}
1.31 KB
Loading

Disks/APIExamples/Flag/tilemap.png

-101 Bytes
Loading

Disks/APIExamples/IsChannelPlaying/code.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ class IsChannelPlayingExample : GameChip
2020
{
2121
public override void Init()
2222
{
23+
24+
// Example Title
25+
DrawText("IsChannelPlaying()", 8, 16, DrawMode.TilemapCache, "large", 15);
26+
DrawText("C Sharp Example", 8, 24, DrawMode.TilemapCache, "medium", 15, -4);
27+
2328
// Display the instructions
24-
DrawText("Press the 1 or 2 key", 1, 1, DrawMode.Tile, "large", 15);
25-
DrawText("Channel 0 is playing ", 1, 2, DrawMode.Tile, "large", 15);
26-
DrawText("Channel 1 is playing ", 1, 3, DrawMode.Tile, "large", 15);
29+
DrawText("Press the 1 or 2 key", 1, 5, DrawMode.Tile, "large", 15);
30+
DrawText("Channel 0 is playing ", 1, 6, DrawMode.Tile, "large", 15);
31+
DrawText("Channel 1 is playing ", 1, 7, DrawMode.Tile, "large", 15);
2732

2833
}
2934

@@ -52,8 +57,8 @@ public override void Draw()
5257
RedrawDisplay();
5358

5459
// Draw channel 0 and 1's current playing state to the display
55-
DrawText(IsChannelPlaying(0).ToString(), 176, 16, DrawMode.Sprite, "large", 14);
56-
DrawText(IsChannelPlaying(1).ToString(), 176, 24, DrawMode.Sprite, "large", 14);
60+
DrawText(IsChannelPlaying(0).ToString(), 176, 48, DrawMode.Sprite, "large", 14);
61+
DrawText(IsChannelPlaying(1).ToString(), 176, 56, DrawMode.Sprite, "large", 14);
5762

5863
}
5964
}

Disks/APIExamples/IsChannelPlaying/code.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
function Init()
1515

16+
-- Example Title
17+
DrawText("IsChannelPlaying()", 8, 16, DrawMode.TilemapCache, "large", 15)
18+
DrawText("Lua Example", 8, 24, DrawMode.TilemapCache, "medium", 15, -4)
19+
1620
-- Display the instructions
17-
DrawText("Press the 1 or 2 key", 1, 1, DrawMode.Tile, "large", 15)
18-
DrawText("Channel 0 is playing ", 1, 2, DrawMode.Tile, "large", 15)
19-
DrawText("Channel 1 is playing ", 1, 3, DrawMode.Tile, "large", 15)
21+
DrawText("Press the 1 or 2 key", 1, 5, DrawMode.Tile, "large", 15)
22+
DrawText("Channel 0 is playing ", 1, 6, DrawMode.Tile, "large", 15)
23+
DrawText("Channel 1 is playing ", 1, 7, DrawMode.Tile, "large", 15)
2024

2125
end
2226

@@ -42,7 +46,7 @@ function Draw()
4246
RedrawDisplay()
4347

4448
-- Draw channel 0 and 1's current playing state to the display
45-
DrawText(tostring(IsChannelPlaying(0)), 176, 16, DrawMode.Sprite, "large", 14)
46-
DrawText(tostring(IsChannelPlaying(1)), 176, 24, DrawMode.Sprite, "large", 14)
49+
DrawText(tostring(IsChannelPlaying(0)), 176, 48, DrawMode.Sprite, "large", 14)
50+
DrawText(tostring(IsChannelPlaying(1)), 176, 56, DrawMode.Sprite, "large", 14)
4751

4852
end

0 commit comments

Comments
 (0)
X Tutup