<P>[<A HREF="../tags.programming.html">programming</A>:gamedev, <A HREF="../tags.programming.html">programming</A>:C]; Last updated 2026-07-15</P>
<BR>
<P>Note: this is kinda out of date, i was just trying to fix a bug</P>
- <P>So recently I learned about this game engine-type thing, <A HREF="https://raylib.com">raylib</A>. It's pretty cool; it basically gives you a lot of the most basic things for games and stuff, like ... drawing a rectangle or image on the screen, and checking whether two rectangles overlap.</P>
- <P>After getting bored with another game (in Godot), I decided to try making something in it. Turns out it's like really hard. So here are my notes on how I structured my program, mainly because I'm trying to fix a bug and I'm hoping this will help.</P>
+ <P>So recently I learned about this game engine-type thing, <A
+ HREF="https://raylib.com">raylib</A>. It's pretty cool;
+ it basically gives you a lot of the most basic things for games
+ and stuff, like ... drawing a rectangle or image on the screen,
+ and checking whether two rectangles overlap.</P>
+ <P>After getting bored with another game (in Godot), I decided
+ to try making something in it. Turns out it's like really hard.
+ So here are my notes on how I structured my program, mainly
+ because I'm trying to fix a bug and I'm hoping this will
+ help.</P>
<H2>The main loop</H2>
- <P>Ok so in main.c there's a loop that loops while <CODE>(!WindowShouldClose())</CODE>. <CODE>WindowShouldClose()</CODE> is true when Escape or the Close button on the window is pressed. This loop then has two parts — the part that gets everything ready for drawing on the screen, and the part that ... draws on the screen. This is the basic setup in all of the raylib examples.</P>
- <P> First, the loop checks if <CODE>frozen</CODE> is true (or well 1). This is true when dialogue is going on. Dialogue is all shown during the drawing part for the level, so when frozen is true it just stops any of the other stuff from being updated. (in the function <CODE>variables()</CODE>)</P>
- <P>If <CODE>frozen</CODE> is false (or 0), the like moving around stuff happens. This happens in the function <CODE>variables()</CODE>, which calls two functions — <CODE>spieler_bewegen()</CODE> (move player[m. technicially]) in <CODE>player.c</CODE>, and <CODE>physics()</CODE> in <CODE>physics.c</CODE>.</P>
+ <P>Ok so in main.c there's a loop that loops while
+ <CODE>(!WindowShouldClose())</CODE>.
+ <CODE>WindowShouldClose()</CODE> is true when Escape or the
+ Close button on the window is pressed. This loop then has two
+ parts — the part that gets everything ready for drawing on the
+ screen, and the part that ... draws on the screen. This is the
+ basic setup in all of the raylib examples.</P>
+ <P> First, the loop checks if <CODE>frozen</CODE> is true (or
+ well 1). This is true when dialogue is going on. Dialogue is
+ all shown during the drawing part for the level, so when frozen
+ is true it just stops any of the other stuff from being
+ updated. (in the function <CODE>variables()</CODE>)</P>
+ <P>If <CODE>frozen</CODE> is false (or 0), the like moving
+ around stuff happens. This happens in the function
+ <CODE>variables()</CODE>, which calls two functions —
+ <CODE>spieler_bewegen()</CODE> (move player[m. technicially])
+ in <CODE>player.c</CODE>, and <CODE>physics()</CODE> in
+ <CODE>physics.c</CODE>.</P>
<H2>Moving the player</H2>
- <P>The two functions work together to move the player — <CODE>spielerbewegen()</CODE> calculates the <CODE>velocity</CODE> (in both x and y directions) of the player based on where they are and what inputs the user inputs. Then, <CODE>physics()</CODE>sets the <CODE>x</CODE> and <CODE>y</CODE> of the player based on this.</P>
- <P>As to the player themselves, they are a <CODE>struct</CODE> with a <CODE>Rectangle</CODE> (raylib type) named <CODE>rect</CODE> defining where they are, and a <CODE>Vector2</CODE> (also raylib type iirc??) named <CODE>velocity</CODE> defining how they will move in pixels per second.</P>
- <P>A lot of the structure of this is just taken from some godot code I had because it seemed like it worked.</P>
+ <P>The two functions work together to move the player —
+ <CODE>spielerbewegen()</CODE> calculates the
+ <CODE>velocity</CODE> (in both x and y directions) of the
+ player based on where they are and what inputs the user inputs.
+ Then, <CODE>physics()</CODE>sets the <CODE>x</CODE> and
+ <CODE>y</CODE> of the player based on this.</P>
+ <P>As to the player themselves, they are a <CODE>struct</CODE>
+ with a <CODE>Rectangle</CODE> (raylib type) named
+ <CODE>rect</CODE> defining where they are, and a
+ <CODE>Vector2</CODE> (also raylib type iirc??) named
+ <CODE>velocity</CODE> defining how they will move in pixels per
+ second.</P>
+ <P>A lot of the structure of this is just taken from some godot
+ code I had because it seemed like it worked.</P>
<H3><CODE lang="de">spielerbewegen()</CODE></H3>
- <P>First, <CODE>spielerbewegen</CODE> sets a file-wide variable to the frametime/delta. This is for animation purposes.</P>
- <P>The next part checks whether the player is on the floor, using a function defined in <CODE>level.c</CODE>. If they are <i>not</i>, the constant <CODE>GRAVITY</CODE> defined in <CODE>game.h</CODE> is added to their y velocity. Otherwise, their y velocity is reset to 0.</P>
- <P>The next if/else checks whether the player should jump. If <CODE>inputs[2]</CODE> is pressed down, and <CODE>on_floor</CODE> returns 1, they jump and their y velocity is changed to the constant <CODE>JUMPVELOCITY</CODE>.</P>
+ <P>First, <CODE>spielerbewegen</CODE> sets a file-wide variable
+ to the frametime/delta. This is for animation purposes.</P>
+ <P>The next part checks whether the player is on the floor,
+ using a function defined in <CODE>level.c</CODE>. If they are
+ <i>not</i>, the constant <CODE>GRAVITY</CODE> defined in
+ <CODE>game.h</CODE> is added to their y velocity. Otherwise,
+ their y velocity is reset to 0.</P>
+ <P>The next if/else checks whether the player should jump. If
+ <CODE>inputs[2]</CODE> is pressed down, and
+ <CODE>on_floor</CODE> returns 1, they jump and their y velocity
+ is changed to the constant <CODE>JUMPVELOCITY</CODE>.</P>
<DETAILS>
<SUMMARY>how <CODE>on_floor()</CODE> works!</SUMMARY>
- <P>First, I had to decide how I would define "on the floor". I decided that the best choice would be if the player is right on top of a platform but not colliding with it.</P>
- <P>Each level is made up of an array of platforms (a <CODE>struct</CODE> with a <CODE>Rectangle</CODE> named <CODE>rect</CODE> and a <CODE>Color</CODE> named <CODE>colour</CODE>), so this function loops through them and checks each seperately.</P>
- <P>This is checked in two parts. First, the y-value is checked. If the player is on the floor, the y-value of the bottom of their rectangle should be equal to the y-value of the top of the platform. The x/y coordinates in raylib are of the upper left corner, so this is <CODE>if ((rect->y + rect->h) == (check>y))</CODE>.</P>
- <P>After that, the x-values are checked. I decided the easiest way to do this would be to use the built-in function in raylib to check if two rectangles are overlapping, and then just make the rectangles have the same y and height. So, this basically tests if two lines are overlapping. If they are, then the x and y both match up, and the function returns 1. Otherwise, it keeps looping. If it reaches the end of the array and none of them match, then the player is not on the floor, and it returns 0.</P>
+ <P>First, I had to decide how I would define "on the
+ floor". I decided that the best choice would be if the
+ player is right on top of a platform but not colliding
+ with it.</P>
+ <P>Each level is made up of an array of platforms (a
+ <CODE>struct</CODE> with a <CODE>Rectangle</CODE> named
+ <CODE>rect</CODE> and a <CODE>Color</CODE> named
+ <CODE>colour</CODE>), so this function loops through
+ them and checks each seperately.</P>
+ <P>This is checked in two parts. First, the y-value is
+ checked. If the player is on the floor, the y-value of
+ the bottom of their rectangle should be equal to the
+ y-value of the top of the platform. The x/y coordinates
+ in raylib are of the upper left corner, so this is
+ <CODE>if ((rect->y + rect->h) ==
+ (check>y))</CODE>.</P>
+ <P>After that, the x-values are checked. I decided the
+ easiest way to do this would be to use the built-in
+ function in raylib to check if two rectangles are
+ overlapping, and then just make the rectangles have the
+ same y and height. So, this basically tests if two
+ lines are overlapping. If they are, then the x and y
+ both match up, and the function returns 1. Otherwise,
+ it keeps looping. If it reaches the end of the array
+ and none of them match, then the player is not on the
+ floor, and it returns 0.</P>
</DETAILS>
- <P>After this, the program sets the variable <CODE>direction</CODE> to 1 for right, -1 for left, or 0 for neither. It does this by looking at what keys are pressed. Then, <CODE>player.velocity.x</CODE> is set to <CODE>SPEED * direction</CODE>, and that's the end of the function. (It returns 1 in case I want to add errors later.)</P>
+ <P>After this, the program sets the variable
+ <CODE>direction</CODE> to 1 for right, -1 for left, or 0 for
+ neither. It does this by looking at what keys are pressed.
+ Then, <CODE>player.velocity.x</CODE> is set to <CODE>SPEED *
+ direction</CODE>, and that's the end of the function.
+ (It returns 1 in case I want to add errors later.)</P>
<H3><CODE>physics()</CODE></H3>
- <P>The <CODE>physics()</CODE> function does multiple things, but its main thing is that it runs the <CODE>move_player()</CODE> function in the same file. This is the function that translates the velocity of the player into its new x/y coordinates.</P>
- <P>First, it figures out how far the player actually has to move. This is done by literally just <CODE>delta*velocity</CODE> for both x/y. Then this is rounded away from 0, so that the player never moves 0 pixels.</P>
- <P>The way the function actually moves the player while making sure that they don't just go into a platform is simple. The program moves them in smaller steps; if the player has collided into a platform, they then are rewinded one step. After this, the program just moves them one pixel in both x/y until they collide with a wall so that it doesn't end with them 1 pixel above the ground and unable to jump.</P>
- <P>The amount of steps and how large they are is done so that neither x nor y is less than 1 pixel. This is done with a bunch of if statements.<P>
+ <P>The <CODE>physics()</CODE> function does multiple things,
+ but its main thing is that it runs the
+ <CODE>move_player()</CODE> function in the same file. This is
+ the function that translates the velocity of the player into
+ its new x/y coordinates.</P>
+ <P>First, it figures out how far the player actually has to
+ move. This is done by literally just
+ <CODE>delta*velocity</CODE> for both x/y. Then this is rounded
+ away from 0, so that the player never moves 0 pixels.</P>
+ <P>The way the function actually moves the player while making
+ sure that they don't just go into a platform is simple. The
+ program moves them in smaller steps; if the player has collided
+ into a platform, they then are rewinded one step. After this,
+ the program just moves them one pixel in both x/y until they
+ collide with a wall so that it doesn't end with them 1 pixel
+ above the ground and unable to jump.</P>
+ <P>The amount of steps and how large they are is done so that
+ neither x nor y is less than 1 pixel. This is done with a bunch
+ of if statements.<P>
<OL>
- <LI>If both the x distance and the y distance are 0, there are... 0 steps and all steps are 0 pixels, because uh. they don't have to be moved at all.</LI>
- <LI>If only x is 0, the amount of steps is |y| (since negative steps wouldn't work), and each step for y is <CODE>distance.y/steps_phys</CODE> (steps physics, idk why i think i was worried steps would conflict with something). This is so that if <CODE>distance.y</CODE> is negative, <CODE>stepy</CODE> is still negative.</LI>
- <LI>If only y is 0, it's the same thing, but with x instead of y. so <CODE>steps_phys = abs(distance.x); stepx = distance.x/steps_phys;</CODE></LI>
- <LI>If neither is 0, but the absolute value of x is greater than that of y, <CODE>steps_phys</CODE> becomes the absolute value of <CODE>distance.y</CODE>. This is so that <CODE>stepy</CODE> isn't less than 1/-1. Then, <CODE>stepy</CODE> becomes <CODE>distance.y/steps_phys</CODE>, so -1 if distance.y is negative, or 1 if it's positive. <CODE>stepx</CODE> becomes <CODE>ceil(distance.x/steps_phys</CODE>, or literally just the amount needed to accomplish the distance within the steps given.</LI>
- <LI>If the absolute value of y is greater, it's literally the same as the last one, just swap "x" and "y".</LI>
+ <LI>If both the x distance and the y distance are 0,
+ there are... 0 steps and all steps are 0
+ pixels, because uh. they don't have to be moved
+ at all.</LI>
+ <LI>If only x is 0, the amount of steps is |y| (since
+ negative steps wouldn't work), and each step
+ for y is <CODE>distance.y/steps_phys</CODE>
+ (steps physics, idk why i think i was worried
+ steps would conflict with something). This is
+ so that if <CODE>distance.y</CODE> is negative,
+ <CODE>stepy</CODE> is still negative.</LI>
+ <LI>If only y is 0, it's the same thing, but with x
+ instead of y. so <CODE>steps_phys =
+ abs(distance.x); stepx =
+ distance.x/steps_phys;</CODE></LI>
+ <LI>If neither is 0, but the absolute value of x is
+ greater than that of y, <CODE>steps_phys</CODE>
+ becomes the absolute value of
+ <CODE>distance.y</CODE>. This is so that
+ <CODE>stepy</CODE> isn't less than 1/-1. Then,
+ <CODE>stepy</CODE> becomes
+ <CODE>distance.y/steps_phys</CODE>, so -1 if
+ distance.y is negative, or 1 if it's positive.
+ <CODE>stepx</CODE> becomes
+ <CODE>ceil(distance.x/steps_phys</CODE>, or
+ literally just the amount needed to accomplish
+ the distance within the steps given.</LI>
+ <LI>If the absolute value of y is greater, it's
+ literally the same as the last one, just swap
+ "x" and "y".</LI>
</OL>
- <P>After figuring out the steps and how large they are, there is a for loop that loops for each step and adds <CODE>stepx</CODE> to <CODE>position.x</CODE> and <CODE>stepy</CODE> to <CODE>position.y</CODE>. After that, it checks if the player is in the ground. If this is true, it subtracts <CODE>stepx</CODE> from <CODE>position.x</CODE> and <CODE>stepy</CODE> from <CODE>position.y</CODE>, and enters another loop.</P>
- <P>This second loop uses the same variable (<CODE>i</CODE>) as the first one, so it only continues for as many loops as the first one had left. It literally just adds or subtracts 1 (based on whether stepx or stepy was positive or negative) from <CODE>position.x</CODE> and <CODE>position.y</CODE> until the player goes into a wall, where it then moves back 1 in both directions. The idea of this loop is so that the player doesn't end up just floating a couple pixels off of any platform. Then, the function is ended.</P>
- <P>The rest of <CODE>physics()</CODE> is very simple. All it does is check if the player is off the right side of the screen. If so, it changes to the next level, sets <CODE>frozen</CODE> to 1 in order to allow dialogue to play, and moves the player up to the top left of the screen. <I>Also, it breaks the game somehow. When I added the <CODE>frozen=1</CODE>it started closing the window on reaching it. This doesn't happen when <CODE>main()</CODE> does this, so I have no idea why it happens here.</I> (that's also partially why I'm writing this, I hope i can figure it out...)</P>
+ <P>After figuring out the steps and how large they are, there
+ is a for loop that loops for each step and adds
+ <CODE>stepx</CODE> to <CODE>position.x</CODE> and
+ <CODE>stepy</CODE> to <CODE>position.y</CODE>. After that, it
+ checks if the player is in the ground. If this is true, it
+ subtracts <CODE>stepx</CODE> from <CODE>position.x</CODE> and
+ <CODE>stepy</CODE> from <CODE>position.y</CODE>, and enters
+ another loop.</P>
+ <P>This second loop uses the same variable (<CODE>i</CODE>) as
+ the first one, so it only continues for as many loops as the
+ first one had left. It literally just adds or subtracts 1
+ (based on whether stepx or stepy was positive or negative) from
+ <CODE>position.x</CODE> and <CODE>position.y</CODE> until the
+ player goes into a wall, where it then moves back 1 in both
+ directions. The idea of this loop is so that the player doesn't
+ end up just floating a couple pixels off of any platform. Then,
+ the function is ended.</P>
+ <P>The rest of <CODE>physics()</CODE> is very simple. All it
+ does is check if the player is off the right side of the
+ screen. If so, it changes to the next level, sets
+ <CODE>frozen</CODE> to 1 in order to allow dialogue to play,
+ and moves the player up to the top left of the screen. <I>Also,
+ it breaks the game somehow. When I added the
+ <CODE>frozen=1</CODE>it started closing the window on
+ reaching it. This doesn't happen when
+ <CODE>main()</CODE> does this, so I have no idea why it
+ happens here.</I> (that's also partially why I'm
+ writing this, I hope i can figure it out...)</P>
<H2>Drawing on the screen</H2>
- <P>The next part of the main loop is the part that draws on the screen. This is begun with <CODE>BeginDrawing()</CODE> and ended with <CODE>EndDrawing()</CODE>.</P>
- <P>There are two parts here as well: <CODE>bühnezeichnen()</CODE> (draw "stage", idk why i called it that i think i used too much scratch), which draws the level + the dialogue; and <CODE>spielerzeichnen()</CODE> (draw player), which ... draws the player.</P>
+ <P>The next part of the main loop is the part that draws on the
+ screen. This is begun with <CODE>BeginDrawing()</CODE> and
+ ended with <CODE>EndDrawing()</CODE>.</P>
+ <P>There are two parts here as well:
+ <CODE>bühnezeichnen()</CODE> (draw "stage", idk why i called it
+ that i think i used too much scratch), which draws the level +
+ the dialogue; and <CODE>spielerzeichnen()</CODE> (draw player),
+ which ... draws the player.</P>
<H3>Drawing the level</H3>
<P>First, the function just loops through every platform in the current level, drawing them on the screen. It's literally that easy.</P>
<DETAILS>
<SUMMARY>How the level data is structured</SUMMARY>
- <P>The data for each level is stored in <CODE>level_data.h</CODE> in 3 big arrays. First, there's an array with all the dialogue and one with all the platforms, and then there's another array that links those together. (along with giving the level a name)</P>
- <P>The array of dialogue is an array of structs.The dialogue struct consists of a string for the character speaking it's name, the filename of an image of said character, and what they are saying; additionally, there is a <CODE>Color</CODE> (raylib type i think) for the colour the character's name should be shown as.</P>
- <P>The array of platforms is also an array of structs. The platform struct consists of a <CODE>Rectangle</CODE> defining where on the screen the platform is and a <CODE>Color</CODE> defining what colour it should be displayed in.</P>
- <P>The array linking these is called <CODE>stages</CODE>, and it is also an array of structs. The <CODE>stage</CODE> struct has first a string for the name of the level. Then, it has a pointer to the first <CODE>struct platform</CODE> in the <CODE>platforms</CODE> array used in the level, and an <CODE>int</CODE> (<CODE>platform_count</CODE>) for how many platforms are in it (all the platforms must be consecutive in the array). The part for the dialogue works the same way, with a pointer to the first one and the amount of dialogues.</P>
+ <P>The data for each level is stored in
+ <CODE>level_data.h</CODE> in 3 big arrays. First,
+ there's an array with all the dialogue and one with all
+ the platforms, and then there's another array that
+ links those together. (along with giving the level a
+ name)</P>
+ <P>The array of dialogue is an array of structs.The
+ dialogue struct consists of a string for the character
+ speaking it's name, the filename of an image of said
+ character, and what they are saying; additionally,
+ there is a <CODE>Color</CODE> (raylib type i think) for
+ the colour the character's name should be shown as.</P>
+ <P>The array of platforms is also an array of structs.
+ The platform struct consists of a
+ <CODE>Rectangle</CODE> defining where on the screen the
+ platform is and a <CODE>Color</CODE> defining what
+ colour it should be displayed in.</P>
+ <P>The array linking these is called
+ <CODE>stages</CODE>, and it is also an array of
+ structs. The <CODE>stage</CODE> struct has first a
+ string for the name of the level. Then, it has a
+ pointer to the first <CODE>struct platform</CODE> in
+ the <CODE>platforms</CODE> array used in the level, and
+ an <CODE>int</CODE> (<CODE>platform_count</CODE>) for
+ how many platforms are in it (all the platforms must be
+ consecutive in the array). The part for the dialogue
+ works the same way, with a pointer to the first one and
+ the amount of dialogues.</P>
</DETAILS>
- <P>Then, it checks if <CODE>frozen</CODE> is 1, aka if dialogue is currently going on. If this is true, it runs <CODE>drawdialogue()</CODE>, which draws the dialogue on the screen.</P>
+ <P>Then, it checks if <CODE>frozen</CODE> is 1, aka if dialogue
+ is currently going on. If this is true, it runs
+ <CODE>drawdialogue()</CODE>, which draws the dialogue on the
+ screen.</P>
<DETAILS>
- <SUMMARY>How <CODE>drawdialogue()</CODE> works</SUMMARY>
- <P><CODE>drawdialogue</CODE> is pretty simple. It basically just draws everything in order. (some of the numbers are a bit confusing though).</P>
+ <SUMMARY>How <CODE>drawdialogue()</CODE>
+ works</SUMMARY>
+ <P><CODE>drawdialogue</CODE> is pretty simple. It
+ basically just draws everything in order. (some of the
+ numbers are a bit confusing though).</P>
<OL>
- <LI><CODE>DrawRectangle(0, DLGY, 640, DLGHEIGHT, RAYWHITE);</CODE> — this just draws a rectangle spanning the whole width of the screen from <CODE>DLGY</CODE> to the bottom of the screen. (DLGHEIGHT is the distance between DLGY and the bottom of the screen)</LI>
- <LI><CODE>drawcharname(dlg->charaname, dlg->characolour)</CODE> — This is also really easy. It just draws text with the proper colour and font size <CODE>CHARANAMETEXTSIZE</CODE> <CODE>DLGPADDING</CODE> pixels away from the top left of the dialogue box.</LI>
- <LI><CODE>drawcharimage(dlg->image);</CODE> — this scales the image to fit under the name and make the width of the character info part equal to <CODE>CHARADISPLAYWIDTH</CODE>, so it has a width and height of <CODE>CHARADISPLAYWIDTH - DLGPADDING * 2</CODE>. But first, it checks whether the file is the same as the last time it ran, in which case it just reuses the texture from last time.</LI>
- <LI><CODE>drawdialogueline(dlg->line);</CODE> — Right now, this only draws the text at the correct spot, but I want to add a way to break lines later.</LI>
+ <LI><CODE>DrawRectangle(0, DLGY, 640,
+ DLGHEIGHT, RAYWHITE);</CODE> —
+ this just draws a rectangle spanning
+ the whole width of the screen from
+ <CODE>DLGY</CODE> to the bottom of the
+ screen. (DLGHEIGHT is the distance
+ between DLGY and the bottom of the
+ screen)</LI>
+ <LI><CODE>drawcharname(dlg->charaname,
+ dlg->characolour)</CODE> — This
+ is also really easy. It just draws text
+ with the proper colour and font size
+ <CODE>CHARANAMETEXTSIZE</CODE>
+ <CODE>DLGPADDING</CODE> pixels away
+ from the top left of the dialogue
+ box.</LI>
+ <LI><CODE>drawcharimage(dlg->image);</CODE> —
+ this scales the image to fit under the
+ name and make the width of the
+ character info part equal to
+ <CODE>CHARADISPLAYWIDTH</CODE>, so it
+ has a width and height of
+ <CODE>CHARADISPLAYWIDTH - DLGPADDING *
+ 2</CODE>. But first, it checks
+ whether the file is the same as the
+ last time it ran, in which case it just
+ reuses the texture from last time.</LI>
+ <LI><CODE>drawdialogueline(dlg->line);</CODE> —
+ Right now, this only draws the text at
+ the correct spot, but I want to add a
+ way to break lines later.</LI>
</OL>
- <P>maybe ill add an image here later to show how the numbers work later idk</P>
+ <P>maybe ill add an image here later to show how the
+ numbers work later idk</P>
</DETAILS>
- <P>After that, it adds 1 to <CODE>current_dialogue</CODE>, and checks if its new value is equal to the amount of dialogues in the stage. If this is true (aka there is no more dialogue to play), it sets <CODE>current__dialogue</CODE> to 0 for the next stage, and then sets <CODE>frozen</CODE> to 0 so that the level can be played.</P>
+ <P>After that, it adds 1 to <CODE>current_dialogue</CODE>, and
+ checks if its new value is equal to the amount of dialogues in
+ the stage. If this is true (aka there is no more dialogue to
+ play), it sets <CODE>current__dialogue</CODE> to 0 for the next
+ stage, and then sets <CODE>frozen</CODE> to 0 so that the level
+ can be played.</P>
<H3>Drawing the player</H3>
- <P>Drawing the player is pretty easy. Basically, it just ... draws the image onto the screen at the correct x and y. However, there is also animation partially implemented.</P>
- <P>Right now, it doesn't actually draw the correct frame, instead drawing the static version, but the way it works is adding <CODE>delta</CODE> to <CODE>time_since_switch</CODE> each time and then checking if that is greater than or equal to <CODE>FRAMELENGTH</CODE>. Then, it's supposed to draw the correct frame from the spritesheet.</P>
+ <P>Drawing the player is pretty easy. Basically, it just ...
+ draws the image onto the screen at the correct x and y.
+ However, there is also animation partially implemented.</P>
+ <P>Right now, it doesn't actually draw the correct frame,
+ instead drawing the static version, but the way it works is
+ adding <CODE>delta</CODE> to <CODE>time_since_switch</CODE>
+ each time and then checking if that is greater than or equal to
+ <CODE>FRAMELENGTH</CODE>. Then, it's supposed to draw the
+ correct frame from the spritesheet.</P>
<H2>At the end</H2>
- <P>This repeats until the user either closes the window or presses Escape. Then, the program... ends. like what else would it do idk </P>
- <P>uh that's all ty for reading (this is really mainly for my own reference tbh), maybe ill update this when i update the project</P>
+ <P>This repeats until the user either closes the window or
+ presses Escape. Then, the program... ends. like what else would
+ it do idk </P>
+ <P>uh that's all ty for reading (this is really mainly for my
+ own reference tbh), maybe ill update this when i update the
+ project</P>
<P><A HREF = "../pages.html"><back to all pages</A></P>
<P><A HREF = "../index.html"><back to home</A></P>