for the past few game jams my goal has
been to learn a new framework or library
this started off with libgdx a java
framework i used in the libgdx game jam
then relive with c plus in ludumdar a46
and last weekend i participated in the
2020 gmtk game jam hosted by the
gamemaker's toolkit youtube channel with
the goal of creating a game with sdl2
i like libgdx and rayleigh but sdl is
appealing to me because it's high level
enough that i can easily create a window
get input and play sound
but i have to create my own systems for
handling things like sprite rendering
animations and physics
which seems like a fun way to go about
game development
i've still been looking for a go-to
framework for creating my simple
2d games and i think sdl is perfect for
me
that doesn't necessarily mean i'll be
able to learn how to use it in 48 hours
but i guess it's worth a try
before the jam started i wanted to set
some things up
first of all obviously i needed sdl
i followed the tutorial by coder gopher
that goes over setting up sdl2
on windows with sublime text i wasn't
too sure about sublime text at first
but holy f i think i'm in love with it
now
it's super customizable with json files
which is perfect for me since i use a
variety of compilers
and that leads me to the next thing i
needed to set up a way to compile my sdl
code to the web
since no one's going to play my game if
they have to download it
i set up in scriptin which is a compiler
that can convert c
and c plus plus code to javascript and
to test it out i made a
um well it's like a smiley face
and you see it like bounces off of the
walls
so all i needed now to get started was
the theme gmtk jams always have really
good themes and this year was no
exception
the theme was revealed to be out of
control and i wasn't the only one who
thought it was really clever
i started brainstorming ideas and
eventually i remembered a club penguin
mini game called puffle roundup where
you can't control the puffles but they
move away from your cursor so you can
kind of guide them around
this fit the theme really well so i
thought it would be fun to try to make a
game with a similar mechanic
so i created this basic prototype with a
square
but not just any ordinary square this
square is
allergic to your mouse cursor it moves
away from your cursor
and jumps in the air when you press the
left mouse button the closer you are to
the square the higher it jumps
and if you touch the square it dies so i
guess it makes sense that it's scared of
you
so yeah it's not a direct copy of puffle
roundup but you can kind of see the
inspiration
implementing this in stl wasn't very
difficult i wasn't planning on watching
coder gopher's entire sdl tutorial
series but
it kind of just happened so we're going
to end that line with a semicolon the
reason we end these things with
semicolons is because this is a real
programming language not python
okay okay okay
okay okay good
[Music]
i'm glad i did watch all of it though
since it taught me some good ways of
structuring my project
i have an entity class that contains a
texture and an x and y position
then in my render window class i have a
function for just rendering a texture at
any position but i also have a function
for rendering an
entity at its current position and then
all of the objects in my game like the
player and enemies can just extend this
entity class
it's a pretty basic concept so i'm
surprised i hadn't thought of doing it
in my past
projects i guess it's because i'm not
normally writing my own rendering
methods
so i have a player class that extends
the entity class and every frame i call
an update method on it that moves it
around based on its velocity which is
based on the cursor's position and
gravity
i also have a jump function that i call
in my main game loop when the left mouse
button is pressed
all this does is set the player's y
velocity to a constant multiplied by the
distance between the cursor and the
player
which i also created a function for now
that i had some basic gameplay i started
creating some art for the player
character
then i had to create a system for
animations
instead of drawing animations frame by
frame by hand i separated my player into
five layers and move each layer
individually using code to create simple
animations
to do this i modified my entity class to
be able to take a list of textures
instead of just a single texture
then in the render function for an
entity if there's more than one texture
i draw each of them to the screen
starting from the end of the list i
render each texture at the entity's
position plus an x and y offset that i
store in a list that corresponds to the
list of textures
so now i can just modify these offsets
to create simple animations
i made the eyes look at the cursor by
setting them to the cursor's position
and clamping their values within the
player's head
and the legs are animated using two
opposite sine waves which have
amplitudes based on the player's current
x velocity
so i had this cool little guy that moved
away from your cursor
but all i could think of now was what
next
i realized that i got kind of carried
away making these animations and didn't
really have any ideas for
actual gameplay there were a lot of
directions i could take this mechanic
i figured some kind of idea would come
to me eventually so i started working on
some ground tile sprites
i took inspiration from the cap kingdom
from super mario odyssey
originally i was planning on making the
cursor a ghost so i thought a gloomy
environment would be fitting
i drew a list of ground tiles to the
screen and decided to make the player
and ground scroll to the left
then i added collision to the ground and
some variation to the ground tiles that
respond
now this was starting to feel like an
actual game
here's the code for respawning a new
random ground tile once an existing tile
goes off screen
and here's the code for ground collision
i won't go into it too much since it's
really similar to the pipe spawning and
collision that i talk about in my flappy
bird video
but the entire source code and assets
for the game are available on github
if you want to check it out or need it
for your cringe compilation
i really wanted to add more obstacles
and things to interact with but it was
already almost 2 am with the deadline
the next morning
and i didn't know if i'd be able to
finish if i implemented anything else
so i decided to try and get a minimum
viable product of the game first
and add new features if i still had the
time spoiler alert
i did not i started working on the
sprite for the cursor
but nothing was really looking good
probably due to a mix of it being 2am
and my lack of art skills so i figured
it was probably better to have no cursor
sprite than an ugly one and moved on
i made a score counter that tracks the
distance you've traveled which is really
just a timer
at this point i was familiar enough with
stl that with the documentation writing
a function for drawing text to a
position was really straightforward
then i made a proper game loop with a
death screen that lets you reset the
game
after that i made a high score counter
and then made some simple sound effects
with
sfxr at this point it was getting really
close to the deadline so i quickly put
together a simple splash screen and
title screen
built a game to the web within scriptum
and finally submitted it three minutes
before the deadline
oh what a relief wait
wait what the f yeah i probably should
have tested my web build
first of all i forgot to build my game
with a minimal html file instead of this
one with the ugly watermark and tons of
options that just
break the game and more importantly if
you have eyes you can probably see that
the entire ui is broken
i think this might be because m scriptin
uses an outdated port of
sel ttf which is sdl's font rendering
library
but i'm not really sure so i guess that
means that my game won't be rated highly
but to be fair it's a pretty sh game
anyway
after the rating period i'll definitely
update the inch.io page with a working
version
and i might also add some extra stuff
that i didn't have time to create and
also implement
any feedback i get so far a lot of
people have found the game too hard
and the thought of that didn't even
cross my mind during development
so either i'm an absolute god at video
games or my game has terrible controls
and i was too used to them to notice
and i'm pretty bad at video games
overall i'd consider this a success
the point of this was to get more
familiar with sdl and i definitely did
i really loved programming in sdl and i
can't wait to use it in future projects
which hopefully won't have a lack of
features and broken ui
if you want to try out cursor custodian
a link to its hitch.io page is available
in the description
and if you don't have to guess what your
score is there's a link on the page to a
build with working ui
and like i said it's open source so i'll
also leave a link to its github
repository in the description if you
want to check it out
that's everything so thanks so much for
watching and i'll see you in the next
video
[Music]
you