Skip to content

Commit 6fb9d20

Browse files
committed
update readme, add particles and documentation
1 parent 87f9a0a commit 6fb9d20

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Noble Engine Example Project
2+
3+
This is a small example project that shows how to use the Noble Engine, along with a handful of libraries.
4+
5+
![demo](demo.gif)

demo.gif

4.52 MB
Loading

source/main.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ Noble.Text.FONT_NEWSLEAK_FAMILY = Graphics.font.newFamily({
3030
})
3131

3232
Noble.Settings.setup({
33-
playerSlot = 1
33+
playerSlot = 1 -- Save which player slot is active
3434
})
3535
Noble.GameData.setup({
36-
items = {}
37-
}, 4)
36+
items = {} -- An empty array to store the player's collected items
37+
}, 4) -- Allow 4 save slots (because there are 4 skins)
3838
Noble.GameData.saveAll()
3939

40-
COLLISION_LAYERS = enum({
40+
--
41+
COLLISION_LAYERS = enum({ -- Used for collision
4142
"PLAYER",
4243
"ITEM",
4344
})

source/scenes/BaseScene.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,29 @@ local gfx <const> = Graphics
44
BaseScene = {}
55
class("BaseScene").extends(NobleScene)
66

7-
BaseScene.backgroundColor = Graphics.kColorWhite
8-
97
function BaseScene:init()
108
BaseScene.super.init(self)
119

12-
pd.resetElapsedTime()
13-
self.menu = pd.getSystemMenu()
10+
pd.resetElapsedTime() -- Reset time so each scene starts at 0
11+
self.menu = pd.getSystemMenu() -- Store this so we have access to it in all scenes
1412
end
1513

1614
function BaseScene:update()
1715
BaseScene.super.update(self)
1816

19-
Particles:update()
17+
Particles:update() -- Update our particle library
2018
end
2119

2220
function BaseScene:exit()
2321
BaseScene.super.exit(self)
24-
self.menu:removeAllMenuItems()
22+
self.menu:removeAllMenuItems() -- Remove all custom menu items and reset menu image
2523
pd.setMenuImage(nil)
2624
end
2725

2826
function BaseScene:drawBackground()
2927
BaseScene.super.drawBackground(self)
3028

31-
if self.background ~= nil then
29+
if self.background ~= nil then -- Helper so you can set a scene's background to an image
3230
self.background:draw(0, 0)
3331
end
3432
end

source/scripts/Player.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ local gfx <const> = Graphics
44
Player = {}
55
class("Player").extends(AnimatedSprite)
66

7+
local particles = ParticleCircle(0, 0)
8+
particles:setSpread(0, 90)
9+
710
function Player:init(x, y, playerSlot)
811
Player.super.init(self, gfx.imagetable.new("/assets/images/character"))
912
self:remove() -- AnimatedSprite adds itself to the scene, we want to do that through Noble
@@ -31,9 +34,13 @@ function Player:update()
3134
if pd.buttonIsPressed(pd.kButtonLeft) then
3235
self.x_velocity = -1 * self.movement_speed
3336
self:changeState("left")
37+
particles:moveTo(self.x, self.y + 8)
38+
particles:add(1)
3439
elseif pd.buttonIsPressed(pd.kButtonRight) then
3540
self.x_velocity = 1 * self.movement_speed
3641
self:changeState("right")
42+
particles:moveTo(self.x, self.y + 8)
43+
particles:add(1)
3744
else
3845
self.x_velocity = 0
3946
self:changeState("idle")

0 commit comments

Comments
 (0)