This commit is contained in:
Ki Rill 2023-04-20 23:09:00 +06:00
parent b8e4ba8a75
commit 4a1cc600fb
8 changed files with 0 additions and 356 deletions

View File

@ -1,42 +0,0 @@
Fractals | Mandelbrot Fractal
Hello everybody and welcome. Today we are going to implement the
Mandelbrot fractal. I will also show you how to implement zooming and
camera movements.
I am going to use D programming language and Raylib graphics library. But
I will upload the C version as well. The intrinsic logic is identical
though. So, you shouldn't have any problems following me in a language
of your choice.
I have already created a new project. All it does at the moment is open
an empty window.
Mandelbrot fractal is basically a set of complex numbers, which are
constructed on a complex plane and which we will visualize in a 2D plane. As
a result, we get this amazing pattern.
So, how does it work? If you do some research you will find that Mandelbrot
set is a simple function of the form f(x) = z^2 + c, which we iterate
through starting from z = 0, where c is complex number that I will explain in
a moment.
The idea behind it is simple. We iterate throught the function and check
whether it's value vanishes at infinity. And then we draw each pixel based off
the result.
Here is an example:
// onto coding
Firstly, we need to create some
preliminary variables.

View File

@ -1,89 +0,0 @@
Setting up D with Raylib | Update 2021
Alright, hello everyone. This is going to be an update on how to setup your D
and Raylib project on all three major platforms: Linux, OSX and Windows.
To follow this tutorial, you need a D compiler, DUB package
manager and Raylib graphics library already installed on your system. This
video won't show you how to install them, but will just give general
directions. Please refer to online tutorials and documentation. I will,
however, provide all the necessary links to such sources in the video
description.
Let's begin. Firstly, we need to create a new dub project using 'dub init'
command. It will ask you a few things about your project, but you can skip
this part and edit dub.json file instead.
At this point, your project folder should contain a dub.json configuration
file. It may be dub.sdl if you have chosen the sdl file format. Open the
file.
Secondly, we need to add the 'configurations' section. I prefer to put it
right below 'dependencies'.
Then, using the curly braces, we add a new subsection containing
platform-specific information. By default, the configuration that matches
the target type and the current platform DUB selects automatically. Thus,
we can support multiple platforms simoultaneously.
=== Configuring D and Raylib on OSX ===
I will first create a configuration for OSX, then Linux and lastly Windows.
Each configuration will follow the same pattern.
- Firstly, comes the configuration name.
- Secondly, the supported platforms. In this case it is OSX.
- Thirdly, we need to add the target type. We need an executable.
- Then we need to tell dub what libraries it should link. In my case,
it's only raylib. If you have any other libraries, for instance, glfw,
put them here.
- Finally, we may need to specify the linker flags additionally. On Mac
you need to link the following frameworks. Just copy-paste it into your
file.
Thats it. Our project should now compile and run successfully on OSX.
=== Configuring D and Raylib on Linux ===
Alright, let's create a new configuration for Linux. I am going to copy and
paste the above configuration, and change its name and platform to linux.
I will also delete the 'lflags' subsection as it is not needed here.
Instead, we need to tell dub to link against the following libraries... Put
them into the 'libs' subsection. These are raylib dependencies.
The configuration is done. Now we can compile our code both on linux and
MacOS. I am using Debian 10 in this example.
=== Configuring D and Raylib on Linux ===
Finally, let's create our last configuration for Windows.
I am going to copy the above configuration again and modify the name and the
platform replacing it with windows keyword.
The next step, is to add raylib library to libs subsection. Please note,
instead of raylib, it should be raylibdll.
And the last thing to do, is to download the raylib binaries from the official
Raylib github repository. Just go to releases, and download the Microsoft
Visual Studio version. Unzip the file, and copy the raylib.dll and
raylibdll.lib into your project's folder.
We are done. It should compile and run. Here's our raylib window.
Now you can configure Raylib and D for all three platforms. I highly
recommend you add all three configurations into your dub.json file. It
will help newcomers and other people to easily compile and run your code
without burdening them with reading the documentation and/or scaring them
away because of build errors.
That's it for today. Happy coding!

View File

@ -1,33 +0,0 @@
Setting up D with SDL2
Hello and welcome. In this video we are going to set up a D and SDL2 project for Windows, Linux and MacOS.
We are going to use DUB and bindbc-sdl package. Make sure you have SDL2 libraries installed on your system.
If you are on windows, all you need are the dlls and put them into a libs folder in your project.
Let's begin. Initialize a new project and add the bindbc-sdl package. Then we need to modify the dub.json
configuration file. In the 'versions' section, specify the SDL libraries you plan to use. I am going to add
SDL2_2020 version as the minimal required version, SDL_image, ttf, mixer and net.
We are done with the dub config file. Let's move on to the source file.
I will create a new function to dynamically load the SDL libraries. The algorithm is simple. We are going to
load the library, check for the error code and output an error message.
Before we continue, we need to specify the dll look up path if we compile on windows... That's it.
Now, let's load the SDL libraries... If we fail to load the library, then we output an error message, otherwise,
we have an old version the library installed on our system. So, we need to tell the user to install a newer
version of the library.
I will do the same for SDL_image, ttf, mixer and net...
Alright, at this point we can already use the SDL functionality. So, I will create a new function to initialize
the SDL libraries... It should load the SDL libraries automatically, check for errors and return.
That's it! Now, we can initialize the libraries and start using the SDL functionality.
... coding ...
That is it! It should now compile on all three platforms. I have tested it myself and it works fine.
If you have any questions, write a comment below. Have a nice day and enjoy!

View File

@ -1,43 +0,0 @@
Hello and welcome.
In this video we are going to explore a new feature of D called importC.
importC is a C11 compiler embedded into D, thus, enabling direct usage of C code.
And today we are going create a Raylib project in D without using any of the
available bindings. We are going to use the Raylib library directly in our D
code.
I have created project folder. For now it contains just the D source file.
It imports a raylib module, creates a window and renders some text to
its surface.
I am using the D version 2.100.
Now, lets use importC to build our project.
The first thing we need to do is to create a raylib.c file and include the
raylib header. There is one important thing I'd like to highlight before
we continue. importC does not have a preprocessor. So all the macros
and defines won't be available in D. Therefore, if you need a macro from the C
library, you need to redefine it using the C language.
For example, raylib uses defines to define a basic set of colors. To use those
in my project I am going to create global color variables.
The next step is to run that C file through the C preprocessor. And I will save
the output of to raylib.i.
We are done. That's it. The final step is to compile our project using the
preprocessed raylib.i file and link the raylib library itself.
It has successfully compiled the project and if run it... yeah, it works!
Alright, that's it for today. importC is still being developed, so I will
update this video in the future, once it is finalized.
Have a nice day, and see you next time.

View File

@ -1,23 +0,0 @@
#0 | Introduction | Let's learn DLang game dev
Hi and welcome to this series of learning game development in D programming language.
D language succesfully combines high-level constructs of modern programming languages
simultaneously retaining low-level features of of C/C++ programming language. Therefore,
in my opinion, D is a perfect fit for game development.
In this tutorial series we will learn how to write 2D games in D programming language. We
will start by learning the basics of D language by writing simple games such as Hangman,
Tic Tac Toe and Battleship. This games will be run from the terminal. Once we get comfortable
with the language, we will start making 2D games using raylib graphics library.
At first, we will create a graphical version of our Tic Tac Toe game just to get aquanted
with the library, then we will do a snake game, and finally, a simple Rogue-like game or a
platformer containing a main menu, settings and a few levels.
You will need a DMD compiler, DUB package manager and any text editor. In the next video
I will show how to install each of the software. Have a nice day!

View File

@ -1,27 +0,0 @@
#1 | Installing DMD, DUB, Sublime Text | Let's learn DLang game dev
Welcome back. In this video we are going to install the D compiler, DMD, Sublime Text editor,
and DUB package manager.
Let's start with the DMD compiler. Go to the dlang.org, the official D website, click on the
"Downloads" and download the official installer for the DMD compiler. There are 3 compilers
available. In general, the GDC and LDC offer advanced optimization and faster executables,
however, the DMD compiler is the official implementation of the language. It is developed
by the D community itself, hence, it is updated first and offers the latest featuers. For
what we plan to do, DMD is a great starting point.
Next, let's install Sublime Text. Go to the sublimetext.com. Click on "Download", choose
your platform and install Sublime Text.
Finally, we need to install DUB. DUB is the official package manager for D applications
and libraries. The main purpose of DUB is to simplify the development process. It is
especially useful when you need an external library. It will fetch, download and build
the required libraries itself.
To install DUB, navigate to github.com/dlang/dub/releases, choose your platform and
download the official installer.
In the next video, we will create our first program, we will learn how to use the
Terminal, output text to the terminal window, compile and run our program. Have a nice day!

View File

@ -1,77 +0,0 @@
#26 | Drawing a player | Let's learn Dlang game dev
Hello and welcome. Today we are going learn how to draw textures to the
screen. More specifically, we are going to draw a player figure that the user
will use to interact with our game world. All the resources I use, are
freely available for download from my github repo. The link is in the
description section.
Alright, the first thing we are going to do, is to move all files to a
game package to avoid clutter. Then we need to rename the modules and,
finally, fix the imports. Compile and run to check if all is well.
Now we can start working on new functionality.
We have a player, and we want to display it in our game window.
A player has certain size, position and a texture. It may also have a
draw and move functions.
Now suppose we have an enemy instead. It has the same properties as the
player, doesn't it?
What about an obstacle? A building, tree, rock? They too have the same
properties, but the only difference is they are stationary.
So instead of creating a player, monster and an obstacle class, we can
generalize it into an Entity and implement the base functionality only
once. Thus, we will be able to inherit that base functionality later on
in our game and expand any further functionality if needed. For instance, an
attack or a heal function for the player or enemy.
Let's implement what we have just discussed.
I am going to create an Entity class. It will have the following private
members: a texture, a frame for animations and a position.
Then I am going to implement a constructor taking in texture, frame and
position as arguments and just copying those values.
We also need to implement a move and a draw function that we will be able to
override in the future.
Finally, we may need an update and a processEvents function. Since their
implementations strongly depend on the type of object, they are going to
be abstract. This will enforce custom implementation upon inheritance.
That's it! Now we can go ahead and create our player class. It is going
to inherit all the default behaviour from the Entity class. It will also use
the entity's constructor upon initialization. We also must implement the
abstract update and processEvents functions. I am going to leave them
empty for now.
Alright, let's go to our play state. I am going to load player texture.
Here it is. As you can see, it has multiple frames that can be used to
animate the player. Each frame is 80 by 110 pixels.
So, let's create a player instance and initialize it.
Finally, all that is left to do is to draw the player to the screen using
the draw method we defined earlier. Compile and run.
Now, do not forget to press 'P' in order to switch to the player state. Here
is our player!
In the next video we are going to implements player movement and basic
animation.
Have a nice day.

View File

@ -1,22 +0,0 @@
#26 | Drawing a player | Let's learn Dlang game dev
Hello and welcome. In this video we are going to implement sprite animation. I
am going to use the textures I found on the internet. You find them in the
asserts folder in the git repo.
In the next video we are going to implements player movement and basic
animation.
Have a nice day.