00:00:00
hi everyone today I thought I'd show you
00:00:03
my Mario game that I built with the ESP
00:00:06
32 using that Arduino IDE the sketch
00:00:12
itself would run on Arduino mega as well
00:00:15
the only reason I abused an ESP 32 was
00:00:19
because it has two cores and it allows
00:00:22
me to easily use the MIDI tones without
00:00:25
having to use the timer such as playing
00:00:29
WAV files so I've kept the footprint of
00:00:31
the total sketch very small and as they
00:00:34
put me just showing in the running but I
00:00:37
described the layup it's of course here
00:00:40
we've got our TFT LCD display and you
00:00:44
can see down there so rather odd size it
00:00:46
says it's 128 by 128 160 by 128 and
00:00:54
you've got five buttons here your normal
00:00:57
kind of game layout as you can see I
00:01:00
kind of jerry-rigged this together
00:01:02
myself one of those matrix PCBs you can
00:01:06
get Edison tactile buttons yes
00:01:10
relatively quite small if I was to
00:01:12
measure it I'd say it's about three
00:01:16
centimeters by three centimeters of
00:01:19
course here we've got there a SP 32
00:01:22
as I said it's dual core running it 260
00:01:26
megahertz here we've got you know acting
00:01:30
need this it's a pam 84 a3 and it's
00:01:35
really just to control the volume I did
00:01:38
originally have these one more speakers
00:01:41
powered directly from the SP 32 but it
00:01:44
probably would have killed the ESP first
00:01:46
time from drawing too much power from
00:01:48
the internal chip because they were are
00:01:51
using just GPIO outputs
00:01:55
25 and 26 which are DAC though I'm not
00:01:59
using the DAC functionality as I said
00:02:02
I'm just playing and your standard MIDI
00:02:05
files of course here we've got two
00:02:08
speakers as you can see us some nice and
00:02:11
neat using proto wire and right
00:02:13
then throat kind of jumper cables
00:02:15
because that would have just looked
00:02:17
horrible and yeah that's that yeah now
00:02:23
actually just before I started at yeah
00:02:27
I'll just finish quickly and say I've
00:02:32
got a bit bored whilst I was doing my
00:02:34
Master's finished at yesterday yeah
00:02:36
and that's finally out the way with and
00:02:38
of course I was procrastinating worse
00:02:41
was write my thesis so I've got a bit
00:02:44
bored and thought I'd make merry game
00:02:45
and that then meant I had to design a 2d
00:02:50
só engine which was actually incredibly
00:02:53
easy working with him display drivers
00:02:56
for a couple of years and you know 2d
00:02:59
arrays plays and stuff inside an array
00:03:01
in a 2d space you pretty quickly learned
00:03:06
how things were essentially and it's
00:03:10
just a large enough array that you've
00:03:13
formatted by the total number of cells
00:03:17
wide and high so let me just load up my
00:03:24
pain and I'll show you
00:03:27
so scales to my computer this is all of
00:03:31
use you're going to want to see this and
00:03:33
just go over here I just like that with
00:03:36
paint paint I love painting as simple as
00:03:39
it is it's really good for bitmaps
00:03:42
I just way too much story about it
00:03:44
where's my phone there I'd assume Royden
00:03:49
that's the cover screen that's not the
00:03:51
one I want of my main sheet that's the
00:03:55
one so looking at this you can see all
00:04:00
the different BMPs i've had to make for
00:04:03
it this is a representation of some
00:04:05
towers being used together as a special
00:04:08
and I explained that in a second but
00:04:10
looking back at this we can see the
00:04:15
meaning a so engine is quite literally
00:04:17
that the game is compromised is
00:04:20
consisted of an collection of cells
00:04:23
these other service here so each one of
00:04:26
these on the game is
00:04:27
ten pictures wise and even the pipe
00:04:31
itself and the plant by the the plant is
00:04:34
taken up to so so as actually ten by
00:04:37
twenty or officially one by two so wet
00:04:41
but insofar as pixels guys it's ten by
00:04:44
twenty everything else is ten pixels
00:04:47
you know this is all goes together these
00:04:49
clouds have made up of sections of
00:04:51
pixels that's just my mouse over there
00:04:55
you can see more detail here so your
00:04:58
average user is ten by ten and then when
00:05:02
he gets his power-ups he's 20 by 10 the
00:05:07
only other things that are an odd size
00:05:08
is the clouds in the background just
00:05:11
like the original game the clouds are
00:05:13
actually the bushes as well so you can
00:05:16
see that bush there's actually that
00:05:17
cloud up there part of my graphics
00:05:21
library has the capability where you
00:05:24
tell it to override colors you tell it
00:05:26
to look for the white and the blue ever
00:05:28
place it for green and brown therefore
00:05:30
you don't need to recreate or the beam
00:05:34
piece because again we want to save as
00:05:36
much memory as possible so even with
00:05:38
like the user here he would change color
00:05:41
again using the same function I called
00:05:44
it BMP overwrite color override and you
00:05:47
supply a list of colors to look for and
00:05:49
colors to replace and it's the same with
00:05:52
this so over here now this saddle is
00:05:56
that to a cell that does three different
00:05:57
things as you can see the cell on the
00:06:01
left
00:06:02
let me just refocus and say in the
00:06:06
middle you can see what colors were
00:06:08
looking for what we want to replace them
00:06:11
with say we're looking for the LA and
00:06:13
replacing it with the background color
00:06:14
oh sorry not able to ignore that color
00:06:17
completely so it just won't even be
00:06:19
drawn all its going to draw is the
00:06:22
bottom part so that would be these
00:06:26
little arches you see on the top of the
00:06:27
castle and the second ones saying to
00:06:31
look for the yellow black and green
00:06:34
arrow pasting all with black so you end
00:06:38
up getting these tiles in the middle
00:06:40
that um are all black and then the final
00:06:44
one it's saying to look for the arrow
00:06:47
replace for back look for red the place
00:06:49
of orange so you end up with a tile like
00:06:51
this which is actually these ones here
00:06:55
here and here so it's one tile or once a
00:07:01
sprite you could call it what you wish
00:07:03
that can do many things again sailing
00:07:06
lots of memory we really don't want to
00:07:08
recreate and think if I can just have
00:07:10
one function where I supply it an array
00:07:13
of colors and that's gonna save me loads
00:07:15
and loads of memory of course we've made
00:07:19
some fonts I made a fun engine for it as
00:07:22
well and dunk this how many overwrites
00:07:26
you need in a print function for chars
00:07:31
inside intz unsigned lungs lungs doubles
00:07:36
and of course you need to print function
00:07:38
to either take the P X pixel position
00:07:43
argument or will not take the pixel
00:07:46
position argument and it have a print
00:07:48
line function and just a print function
00:07:51
say I think I ended up with like 18
00:07:53
different overloads of the print
00:07:55
function there's quite ridiculous
00:07:57
anything so everything's create on this
00:08:00
game not one things been used externally
00:08:03
by that I mean of Christ's domain
00:08:05
libraries including this very driver and
00:08:08
[Music]
00:08:10
so yeah it's a so engine when you move
00:08:14
along if I'm walking forwards for each
00:08:17
pics for each pixel such a who is a px
00:08:21
fates pics I walk forwards these are all
00:08:25
the cells are scrolled back one and once
00:08:28
I've moved forward to the same amount as
00:08:31
to cell where so these are 10 pixels
00:08:33
wide
00:08:33
once I've walked for is 10 pixels these
00:08:36
have ofc scrolled back 10 pixels and in
00:08:39
the scroll resets to zero so what would
00:08:42
happen is this sir would move all he
00:08:44
said as a move back 10 and then it would
00:08:46
get to exact about there and then reset
00:08:49
and he wouldn't notice it's Reese exits
00:08:50
perfectly lined up so in other words
00:08:52
it's just
00:08:54
moving forwards to sell amount each time
00:08:55
and then resetting to zero the same for
00:08:58
the X and y-axis of course I've got
00:09:03
loads of sound in this Mario game which
00:09:06
is really hard to get a hold of by this
00:09:10
guy over here we can see in this
00:09:12
enumerator partner section here the
00:09:15
sounds we've got the main thing that
00:09:18
underground frame the castle theme that
00:09:20
underwater theme the coin sound pipe
00:09:22
sound fireball sound 1up sound jump
00:09:25
small jump loud bump break blocks out I
00:09:28
need to improve it on powerup sound
00:09:30
level complete the psalm and tune the
00:09:33
def sound damage walk game over
00:09:37
and the rescue fans lay upon me as you
00:09:42
can see every one of these global
00:09:45
variables before good practices in the
00:09:46
namespace so there won't be name
00:09:50
conflicts in the future basically
00:09:52
they're inside a class you could think
00:09:54
on the same name spaced in from
00:09:56
superclass 11 which is considered the
00:09:58
same as a class except with no
00:10:00
constructor any whom you've got that
00:10:03
over there so that's all the variables I
00:10:07
won't need to say that but what is
00:10:08
important is showing you how the levels
00:10:12
lay down so as I said it's one array
00:10:14
there is formatted I mean this is just
00:10:18
for it so I can edit it easy that the
00:10:20
game would see it the same way as you
00:10:23
can see it's 132 cells wide by 12 cells
00:10:25
high each one of these numbers
00:10:28
represents a different cell if I scroll
00:10:31
up so this is the underground one map as
00:10:35
you can kind of see here this is the
00:10:37
empty space 0 is an empty cell so the
00:10:41
user would come down drop down into
00:10:44
underground he's 31 2 coins
00:10:47
he always coins up and then he's going
00:10:50
to pipe and go up and as you can see
00:10:54
there's another animator up here and
00:10:57
this is all the different types of cells
00:10:58
that the engine will display so I can
00:11:01
just let you edit the map and it would
00:11:02
render it immediately
00:11:04
and of course see this isn't constant so
00:11:07
this map can change and as you can see
00:11:10
there's all the different types of
00:11:11
things here they would mean different
00:11:15
things so some need to get a bit
00:11:17
confused about bit this has to be that
00:11:19
way say you could have a pipe section
00:11:22
with divine planet on the top or just a
00:11:25
pipe section with now you vine plants on
00:11:28
the top and then let's say if you have
00:11:32
this pipe section obviously leads to the
00:11:35
underground hence it's in the name so if
00:11:37
you killed that plant it would then
00:11:39
change into a underground pipe top
00:11:41
section so then the user could go down
00:11:44
there something is there something new
00:11:47
cells that were to be rendered in
00:11:49
different colors the underground blue I
00:11:51
haven't actually implemented the
00:11:53
underground fully yet so you're not
00:11:54
gonna see that in this example this
00:11:56
really was does me procrastinating
00:11:58
masters write my thesis so home I
00:12:01
shouldn't really have spent too much
00:12:02
time on it beds that I finished my
00:12:04
master self well so happy so I hate it
00:12:07
as ammunition I can finally get back to
00:12:10
doing fun things and I'll go have a bit
00:12:14
more detailed in this video about how
00:12:15
the cell engine works but for now this
00:12:18
is meant to be about my Mario game so
00:12:20
let's show you the merry again
00:12:25
ok like in the pen boy so to start with
00:12:30
I'll show you some of the sounds it has
00:12:32
a it's gonna load up the mini
00:12:36
straightaway okay Lucas I liked and uh
00:12:45
I'm not using external battery now
00:12:48
sedums drawing too much current and
00:12:51
turning so I'll just turn it down nice
00:12:53
and low I'm sure you can hear so of
00:12:57
course this is just your standard chin I
00:12:59
need to get this one okay
00:13:02
and
00:13:04
this game as with most of my programs
00:13:07
I'll write a debugging function or more
00:13:09
like the testing function which allows
00:13:12
me to as the name suggests test
00:13:14
different parts of the game so I just
00:13:17
get up the command command processes too
00:13:21
much uni step to safe let the serial
00:13:25
monitor rather hardly over this spring's
00:13:29
camera does not also focus
00:13:32
that's the Chuck over it so I believe we
00:13:35
go into the debug games hmm and go down
00:13:43
it's camera focus it's F to set the
00:13:47
current chain and it does actually list
00:13:53
the song when it resets mmm so if we got
00:13:57
here tell it to play we're currently
00:14:01
playing song zero and we'll just have to
00:14:02
restart yeah it's gonna know that after
00:14:08
what that's right so let's go into
00:14:11
someone which is what is someone is that
00:14:15
the underground is go back sorry I
00:14:18
should've been a bit more prepared I
00:14:19
still a lot better for presentation
00:14:21
yesterday yeah so it's the main theme
00:14:23
the next one would be the underground
00:14:24
stream so that's the s1 there we go I'll
00:14:33
start playing again the second some goes
00:14:34
from the sounds
00:14:35
now these sounds are all MIDI sounds
00:14:39
they're not where they're extremely low
00:14:42
footprint you can pay the money you know
00:14:44
happily yeah I found them in some
00:14:51
gazillion website they needed a fair
00:14:55
amount of modification and they were in
00:15:00
many ways not finished and also in a
00:15:02
foreign language and it kept causing the
00:15:07
heat to crash the way he had designed it
00:15:09
or overflow rather so I had to rewrite
00:15:13
it a bit but nonetheless he done all the
00:15:16
legwork about chief selecting
00:15:17
the different MIDI notes so I'm ever
00:15:20
grateful to him I'd have to put a link
00:15:22
to him or a reference to him in this
00:15:24
video because these are his songs and
00:15:28
you won't find them anywhere else every
00:15:31
other example of the merit rooms are
00:15:33
quite terrible very short and brief
00:15:37
their actual main things for this one
00:15:39
pretty goes on for about two or three
00:15:41
minutes this is the underground things I
00:15:43
now play some twos which will be the
00:15:48
castle see my slide like this one it's
00:15:54
quite intense isn't it that way to
00:15:57
implement that level so currently
00:16:32
playing their castle theme we have the
00:16:36
underwater theme next which should be
00:16:38
for s3 s4 I've lost track yeah Geoffrey
00:16:47
of course this many before when it says
00:16:53
low game eh means - it's like the
00:16:55
obstacle versions you're only saving the
00:16:57
level number not saving the level state
00:16:59
so in other words when you complete
00:17:01
levels you can save those ends there
00:17:05
will be too much memory to save all this
00:17:06
whole state and that was the underground
00:17:11
stream so let's just play one more
00:17:15
number fourteen this star mansion when
00:17:18
you get pair up though I'll play the
00:17:22
game let's just reset it back to default
00:17:26
state so you can see help see this
00:17:42
health bar isn't generally implemented I
00:17:47
only added it there because in the
00:17:50
original game there's nothing to carry
00:17:52
your parent health he planted his flash
00:17:54
and then eventually died which for me
00:17:58
was really annoying I want to know what
00:18:01
was going on and I only just added the
00:18:06
score putts that I can see that a 0 is
00:18:08
gonna be in the wrong place for actually
00:18:10
play the game don't leave that to her
00:18:13
side in the original game it actually
00:18:17
starts on the left and pushes right so
00:18:20
actually prints right to left for this
00:18:23
source so I'm going to implement it the
00:18:25
same way since why start over I need to
00:18:31
focus
00:18:56
things like 8 times this mmm
00:19:08
[Music]
00:19:14
sadly back to them from a certain it's
00:19:19
gotta stop it's not a bug really but and
00:20:06
it is just possible to jump on these
00:20:10
bricks but you really animated to jump
00:20:13
up if you like to have a so I just avoid
00:20:15
that sexual crap go see your funny - a
00:20:29
few more NPC's in Hindi knows I need to
00:20:36
work on this flag effect animation so
00:20:42
this may or may not work I'll jump
00:20:45
interpret blue things registers
00:21:03
[Music]
00:21:08
so that's my m-marry okay so let's go
00:21:14
else just enjoy this
00:21:20
well then we just implemented yeah like
00:21:23
say that impress the next level um the
00:21:27
way that she calls real screen saying
00:21:29
level complete progressed the next level
00:21:32
but that is my merrier game using the TD
00:21:41
7 Jian