File tree Expand file tree Collapse file tree 5 files changed +22
-11
lines changed
Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change @@ -30,14 +30,15 @@ Noble.Text.FONT_NEWSLEAK_FAMILY = Graphics.font.newFamily({
3030})
3131
3232Noble .Settings .setup ({
33- playerSlot = 1
33+ playerSlot = 1 -- Save which player slot is active
3434})
3535Noble .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)
3838Noble .GameData .saveAll ()
3939
40- COLLISION_LAYERS = enum ({
40+ --
41+ COLLISION_LAYERS = enum ({ -- Used for collision
4142 " PLAYER" ,
4243 " ITEM" ,
4344})
Original file line number Diff line number Diff line change @@ -4,31 +4,29 @@ local gfx <const> = Graphics
44BaseScene = {}
55class (" BaseScene" ).extends (NobleScene )
66
7- BaseScene .backgroundColor = Graphics .kColorWhite
8-
97function 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
1412end
1513
1614function BaseScene :update ()
1715 BaseScene .super .update (self )
1816
19- Particles :update ()
17+ Particles :update () -- Update our particle library
2018end
2119
2220function 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 )
2624end
2725
2826function 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
3432end
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ local gfx <const> = Graphics
44Player = {}
55class (" Player" ).extends (AnimatedSprite )
66
7+ local particles = ParticleCircle (0 , 0 )
8+ particles :setSpread (0 , 90 )
9+
710function 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" )
You can’t perform that action at this time.
0 commit comments