From: parking_turkeys Date: Wed, 15 Jul 2026 08:50:21 +0000 (-0400) Subject: almost finish writing notes on platformer (hopefully i can finally find the issue... X-Git-Url: http://git.parking-turkeys.net/?a=commitdiff_plain;h=b655b9f8a44fc31847ac899babaa2b31e41d4cd1;p=website-v3%2F.git almost finish writing notes on platformer (hopefully i can finally find the issue now) --- diff --git a/pages/2026-07-14_raylib_platformer.html b/pages/2026-07-14_raylib_platformer.html index af10e47..54b9d45 100644 --- a/pages/2026-07-14_raylib_platformer.html +++ b/pages/2026-07-14_raylib_platformer.html @@ -47,3 +47,27 @@

This second loop uses the same variable (i) 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 position.x and position.y 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.

The rest of physics() 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 frozen to 1 in order to allow dialogue to play, and moves the player up to the top left of the screen. Also, it breaks the game somehow. When I added the frozen=1it started closing the window on reaching it. This doesn't happen when main() does this, so I have no idea why it happens here. (that's also partially why I'm writing this, I hope i can figure it out...)

Drawing on the screen

+

The next part of the main loop is the part that draws on the screen. This is begun with BeginDrawing() and ended with EndDrawing().

+

There are two parts here as well: bühnezeichnen() (draw "stage", idk why i called it that i think i used too much scratch), which draws the level + the dialogue; and spielerzeichnen() (draw player), which ... draws the player.

+

Drawing the level

+

First, the function just loops through every platform in the current level, drawing them on the screen. It's literally that easy.

+
+ How the level data is structured +

The data for each level is stored in level_data.h 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)

+

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 Color (raylib type i think) for the colour the character's name should be shown as.

+

The array of platforms is also an array of structs. The platform struct consists of a Rectangle defining where on the screen the platform is and a Color defining what colour it should be displayed in.

+

The array linking these is called stages, and it is also an array of structs. The stage struct has first a string for the name of the level. Then, it has a pointer to the first struct platform in the platforms array used in the level, and an int (platform_count) 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.

+
+

Then, it checks if frozen is 1, aka if dialogue is currently going on. If this is true, it runs drawdialogue(), which draws the dialogue on the screen.

+
+ How drawdialogue() works +
+

After that, it adds 1 to current_dialogue, 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 current__dialogue to 0 for the next stage, and then sets frozen to 0 so that the level can be played.

+

Drawing the player

+

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.

+

Right now, it doesn't actually draw the correct frame, instead drawing the static version, but the way it works is adding delta to time_since_switch each time and then checking if that is greater than or equal to FRAMELENGTH. Then, it's supposed to draw the correct frame from the spritesheet.

+

At the end

+

This repeats until the user either closes the window or presses Escape. Then, the program... ends. like what else would it do idk

+ + +