Showing posts with label Devlog. Show all posts
Showing posts with label Devlog. Show all posts

Devlog #16 Sprite Batching

Perhaps the most important critique in game development is performance. The features that I have added to my project so far inevitably reflect negatively on the game performance. Because At this stage, of course, I have to implement to more efficient ways. Basically, if you try to expand the game, you have to call more draw methods. For example, I had to call too many draw methods while adding the semi-dynamic lighting to the project. Well, my prototype didn't slow down much, but in case I use a bigger map, that's going to be problem for me. Fortunately, I learned that it is a technique that I can easily apply to my entire project. This is a system called sprite batching.

So what is this sprite batching? In short, calling multiple game objects a single draw method. For instance, that is calling 10 draw methods or 1 draw method instead of calling 100 draw methods for 100 objects. This system is a well known and used system. I have never used it until now.

Before I started typing this devlog, I had to type this system myself in a small project. I will add some benchmarks. I will evaluate the CPU, GPU, and RAM usage side of the benchmark through Task Manager. In addition, I will already get the FPS values through the program.

Firsly, I will draw each of 32px square sprites on the screen one by one. So I'm going to draw 100000 objects on the screen. In this case I have to call 100000 draw methods. 

According to the values that I got:

  • CPU usage(max.): 14.9%
  • GPU usage(max.): 30.5%
  • RAM usage: 102.1MB
  • FPS: 4
I will draw 102000 objects on the screen by batching sprites, and using only one draw method:

  • CPU usage(max.): 7.2%
  • GPU usage(max.): 60%
  • RAM usage: 89MB
  • FPS(max. - theoric): 359
Frankly, the sprite batcing system made a big difference. Obviously, there is a serious GPU usage increase. It may be due to the fact that I do not use sprite batching system properly. It may not be a good idea to send a lot of data at once with just one call. I will not make a game with several hundred thousand objects. So this will be a really small but nice and efficient improvement for my prototype.
Devamını Oku »

Devlog #15 Semi-Dynamic 2D Lighting

Dynamic lighting was something I wanted to do for a long time. I wanted to use it in one way or another in my project. Until now, I was using the static type of lighting in the project, it is called basic lighting. However, I will probably switch the project to the dynamic lighting side when I type this post.

First of all, since I do not use any game engine, there is no default support for lighting.I had to do what I had to do from scratch. However, the dynamic lighting issue is a complex concept, it brought along many questions such as how it affects the performance of the game, and whether a better view can be obtained. Frankly, I am not very positive about dynamic lighting at first. One of the biggest reasons for this was that the lighting obtained with the Raycasting method would not look very good in the game. Also, to use this method efficiently, the good optimization was required and the coding side of the method seemed too complicated to me. Of course, I still tried and ran it successfully, but I did not like it. For this reason, I put this dynamic lighting issue on the shelf for a while.

Fortunately, I decided to use a different method that came to my mind these few days. This method is the flood fill method I mentioned before. Then I took a look at the lighting projects used with this method. I could have developed a similar method for my own project and in a sense provided dynamic lighting in the game.

After two days of work, I managed to prototype the dynamic lighting required for my project, as in the video below:

Well, there are still some strange glitches in the lighting, but these are processes that will be fixed over time.Judging by the demo, it's pretty efficient in terms of performance. In other words, it doesn't look much different from static lighting. However, the CPU usage may increase in moving lighting.

Now it's time to adapt this prototype to the actual project. After the adaptation, let's see if I can get the result I want. 

One eternity later:
Grid-based Lighting
Finally, I got result what I want. Well, there are some performance issues. But I have some solutions that will solved these issues. 
Devamını Oku »

Devlog #14 Shadow System and Daylight System

I decided to add a shadow system because I think this system will make more nice effect on the game visually. The game currently does not have dynamic lighting. In fact, there is no connection between the shadow system and the lighting system. The way the shadow system works will depend on an imaginary sun. The shadows will also move from east to west. However, as I said, this shadow system will not work exactly as intended. At some points, there will be obvious mistakes in the visual sense.

I have prepared a small demo where this shadow system is implemented. I get this result that's not bad for me:
Shadow System
Now it's time to associate it with the daylight system. But first, we will need to determine the duration of the day. I think 15 minutes is a reasonable amount of time in the real time. In other words, the length of the night and the length of the day will be 7.5 minutes. We will be able to follow the day-night cycle through the interface as a representative. Although I am not sure about the positioning part, I have a nice design in my mind. Let's start working on the GUI part.

I added a GUI as basic to track the daynight cycle. It's time to animate it in accordance with the daylight system.
Daynight Cycle Tracker
I adapted the moving process exactly as I wanted it:
Animate Daynight Cycle Tracker
So, how it works? I used RenderTexture feature of SFML. In a sense, I draw the textures of daylight cycle on an inactive canvas which the canvas becomes the rendertexture itself.. Then I take the texture of this canvas and give it to the object I created, and then render that object in the main window. The logic I used afterwards is quite simple. A picture frame and a picture inside it. You probably don't understand much from this part. If you don't know the point of SFML, it's normal that you don't understand.

I'm not sure about the design. I'm not sure about the use of this topbar panel. It seems like it's enough to make transparent the background color of topbar panel.
Just Daynight Cycle Tracker
As I said, I'm not sure how the design will be. However, this is not a top priority. Our priority is to ensure that the system works correctly.

Finally, I connected the shadow system and the daynight system. There are two type shadows. They are morning shadow and afternoon shadow. Also, I changed a little the angle of shadow.

Seems like a lot of progress has been made so far. However, there is still an ugliness. This ugliness is about the view of shadow. The areas where the shadows intersect are darker. 

Three hours later... I prevented the transparent shadows from overlapping too simply. I tried to understand how to use BlendMode for this simple solution but I still couldn't understand. Fortunately, it's no longer needed. Of course I have to learn about the BlendMode thing later. I have found a very limited but effective solution, and the result is as follows:
Shadows of Objecs in SFML
Now it's time to add these systems to our main game. 

Waiting...

It took me a while, but somehow I was able to implement it, and this is the test show:
Shadows in SFML
The shadows are only active for trees currently. Of course, it is not possible to achieve a perfect result in such a use. But still I am happy with the result. After this progress, I will deal with the design and positioning of the daynight cycle timebar. Let's end this devlog here for now. 
Devamını Oku »

Devlog #13 Making Inventory for the Game

Hello from another devlog. I'm working on inventory for the game I'm working on. As I said in the previous devlog, I was going to work on inventory. To be clear, interface programming has been painful for me. Because I had only done beginner level work on the gui before. Anyway, I think I've developed a successful inventory interface prototype as of today. I started making the prototype last week. I even shared a few tutorials about it. These tutorials can be viewed below:

After these posts, I made serious improvements in the inventory. After the improvement, the final version of the inventory can be seen on the video recording:
After fixing a few more shortcomings, I will try to implement the inventory in the main project.

Update (October/20/2021)
I implemented this inventory in the main project. As I expected, the implementation brought frustrating errors along with it. Therefore, I had to make some changes about the invetory in the main project. After 3-4 hours, the results were obtained as follows:

Devamını Oku »

Devlog #12 - Pathfinding and Lighting

I mentioned my computer crushed in previous devlog. For reason, I couldn't continue where I left off on my project. Because my source code of prototype is awful and not really clean. I did not remember any thing what should I do. Therefore, I create a new project and I moved with it. Of course, I didn't reinvent something, instead I copied certain parts from the old prototype. Now, the new project looks better than the old project as a code struct not the view of the prototype. 

So, where am i at the development of the game?

  • I implemented A*(star) pathfinding algorithm. I can use it for movement of my units basically. However, this implementation needs some optimizations.
  • Lighting, this is important detail for my game. I actually want to use dynamic lighting. I even implemented a basic version of it but.. For now, I hibernated that part, instead I used static lighting.
  • I added some basic action operation to the player. This is not done, it is under development.
  • Sensible zoom action for camera.
  • Selection area for units and also left click action for selected or not selected.
I have to improve the game assets as visual. The art part is my weak part in the development. Also, I will start to working on UI. This part is critical because it should be simple and extendable. 


Devamını Oku »

Devlog #11 Everything has changed both times

Date: 6/9/2021

Now, I changed everything and I'm starting to use Unity Game Engine and I'm developing a game currently. Yesterday(06.08.2021), I made a decision to use Unity. Well, I took one course from Coursera to help adapt to Unity and I finished the course. So, here we are. Why did I change my mind? ....

I'm using Aseprite to draw assets of the game and it's a really useful and powerful tool. Well, My drawing is not good but it belongs to me at least.

Tilemap in Unity

Look at this dude:

Player Aseprite

Well, I write some scripts for the depth of the 2d map. However, implementing this feature to the sprites of tilemap is complex. So I decided to use obstacles as prefabs. In this way, implementing was so easy. Also, I redesign arts of the tileset and draw something in addition:

Top-down game in Unity

There are some problems with the sorting operation, so I can't say it works perfectly but still enough. And also I don't like the view of the base. For this, I might write some script to create a seamless view of the base.....

Date: 7/13/2021

LMAO! Well, I typed this article a month ago and left it as a draft. Obviously, I can't do it with Unity. Why:
    • I was very slow in development. Because I don't know Unity.exactly. But this is not a problem I can learn it, the real problem is that it's really slow. When I run the project everything occurs after 5 seconds. The interesting thing is that there is nothing in the project except the above pieces of stuff. Maybe, My computer is not enough for this, and probably it is.
    • I don't need that many advanced features from the engine in my game. I hope.
    • Also, was there Unity before? :D
So, what did I do? I decided to use SFML and also I created some basic tutorials about it, actually, this reason is to learn the library myself. SFML is a really powerful multimedia library. This is not an engine but it makes easier important things like drawing operations via graphics cards that use OpenGL API but not Modern OpenGL. But you have to create too many things yourself what do you want. So after that, I started to make a new project as an RPG game. But, I can't give any idea of the game because I don't have anything in my mind right now. But the game prototype looks like it for now:

And I think, I have too many things that I must do. But I got some big problems. I came to most important case for game development, the lighting system of the game.
 
Date: 8/3/21

My computer crashed and everything stopped about the game until today. I bought new computer. 😑 I already made some light system for my game, you can see in this video. But this was two weeks ago. 

Now, I'm working on inventory system for my game. An image from game prototype:
inventory in the game

I want to finish this eleventh devlog in here. 


Devamını Oku »

Devlog #10 Working on Game Engine

It's been a long time since the previous post. I have to stop myself from working on the project. The problem is about the performance of the game. The game fps drop got me stuck. There is a huge mistake that I made. Because my project wasn't suitable for Pygame. Pygame is a framework that just uses a CPU. Maybe this is no problem for better computers, but my computer isn't powerful to render the game. Maybe, I couldn't optimize the game in a good way, Let's accept that, we're talking about a map size 640(tiles)x640(tiles). Pygame fails to render too many surfaces, and yes we can solve this problem with one big surface and chunking, however it's not invalid for terrain map. So I decided to make my own custom game engine in brief.

 

Development of Custom Game Engine

I use OpenGL and Python to create custom game engine. Also, I already use Pygame to create window and handle keyboard and mouse. You can see the project as open source. https://github.com/gurb/melden/ I named the game engine as melden. I suppose, there is no special meaning of it as a word. Why did I call like it? I don't want to say for now. So what's going on it? I'm not profession on OpenGL, so I study on it, and I guess it will go like this for a while. I'm using Modern OpenGL and currently I'm working on camera movement. 

Melden's first priority is going to be 2D game engine. Now, I can zoom-in and zoom-out easily with power of OpenGL. Unlimited power!

The another plan for engine is about ECS. I don't know should I implement it because I'm using Python not C++ or Rust. I don't know if it will be beneficial in terms of performance, but we can get a more concise code in terms of readability.
Devamını Oku »

Devlog #9 Designing Game Map - II

Our game map looked so monotonous, so I decided to give effect to it. I used Perlin Noise for it and it's really working on it. Unfortunately, It causes fps drop in the game. Even so, I think it worth it.

noise on tile-map
I mentioned trees and stones in the previous post. So let's draw various trees and stones:
various trees assets and grass color changed
I drew a pine pixel art and I used it. Also, I changed the color of the grass because it affects the view of pine negatively. 



Devamını Oku »

Devlog #8 Designing Game Map - I

I applied framerate independence to my game. This feature provides stable game speed. There are useful sources about it that you can find easily how to apply to your game on the internet. It's a small update for my game. 

This post is about the design of a game map. When I generate the map, the game map just occurs base tiles without any trees or stones or whatever should be there. Therefore, I want to add part of the trees to the map. So I just used Perlin noise for it:

Procedural Generated Jungle

Well, This is not really looks of the nature that we see outside. It's understandable because I used Perlin noise according to generating of the map. So I need to create a new function with different amplitude and frequency values when using Perlin noise. I mentioned this topic in my first devlog post.

It's better now:

Game Map
There is uniformity as I use the same tree image. But if you add 100 kinds of an image of trees and choose one of them randomly, we will get a more natural view of the map. But first I want to add some big stones. Let's add it:
added stones on the game map

That's "wundebar".
Devamını Oku »

Devlog #7 Loading Bar Screen

When I ran the project, the window of the prototype was waiting for a while on a black screen in the generating. In the meantime, I want a loading bar to appear on the screen, and for this, I'm going to use threading. Two hours later... Yep, I did some palpable things:

loading screen
For the next step, I want to get data from the generating thread. These data contain about which function was active when thread was alive. After that, These data will be shown on top of the loading bar. I just create variable called info_thread and assigned it to each function stage. I tested via print function and it works. I need to print this data on the screen, and here we go:
loading screen

We could add some other things like loading percentage or a fancy background. That's just the detail of the job. Consequently, the thread worked to do it.
Devamını Oku »

Devlog #6 Optimization of the Generating Map

I don't want to put off optimization of the game anymore. I have recently searched about threading and have some keywords like threadpool, threading, parallel programming, etc., and their connotations that remain in my mind. So I'm going to investigate these threads on this post and I will try to implement these to prototype.

The loading of the game takes a lot of time. I assume I'm able to solve this issue with threadpool. But we shouldn't move fast. Let's break the loading of the prototype into pieces. One of the important sections on the initialization of the game is using the Perlin noise to generating a smooth-random tilemap. I remember when Perlin noise was created by using three octaves were causing the loading to be slow. I found the first part. (func. "genNoise")

The other part can be generating of the chunks. I generated two chunks, one for the lower layer and one for the upper layer. Their run-time takes time obviously. This function seems complex compared to function "genNoise". It can be related to bad code.😑 Anyway, the second function is (func. "generate_chunk")

So, the last function is about generating the map data. (func. "generate_map"). The common of these functions is nested-loop. So, we have to go on this.

But first, it would be more accurate if we read these articles and threads:
I looked at my system that how many cores in it with Task Manager. (ctrl+shift+esc). We can see cores and logical processors exactly. But we can learn how many processors in our system with Python.
task manager
These conditions are optional from system to system. Therefore, we can optimize the system itself. There are too many options for this in Python. 

I'm going to use multiprocessing module. We can learn more things about it from this official document. Also, I will measure the time of the execution of the processor with the time module.

I typed an imitation code from the original my project. This function (func. "example_generate") ends in 5 seconds, exactly as expected:
import time
start = time.perf_counter()

def genNoise(i,j):
    time.sleep(0.05)

def example_generate():
    for i in range(650):
        for j in range(650):
            genNoise(i, j)

start = time.perf_counter()

example_generate()

finish = time.perf_counter()

print("Time of execution {0} seconds".format(round(finish-start, 3)))
So, I decided to use itertools which is a python module, to create the necessary parameters (i,j) for the noise function. thus I could use with pool which is a feature of multiprocessing easily. Finally, I can implement the multiprocessing usage to generate_map function. In the end, I compared to new method with the old method according to the time of execution. After the test results, everything seems fine:
the generating of map
This results by the test, we achieved 66% efficiency approximately. Let's implement this new function to the prototype. So, I did but there is awkward output when I applied to multiprocessing operation on the prototype, like this:
Multiprocessing pygame
Maybe, It's not a good idea to use multiprocessing with pygame. BTW, The prototype works, and generating operation has happened earlier. But I canceled on it. I have to study multithreading in Python. These things didn't go as I thought. But in the meantime, I have learned useful information. Also, It is good study for the loading screen on prototype, for the next devlog.
Devamını Oku »

Devlog #5 Adding GUI

I need to GUI for my game. So, I'm going to type some different components for GUI that is going to be a user-defined module. So firstly, I'm going to create a Canvas component. This component has some features that should contain. These features are color, texture, opacity, size, and position, etc.
canvas in pygame
Of course, I won't use GUI like the image above, it's just a test. Now, we need to add text on our yellow canvas, and it was easy. The important goal is to create a button on the canvas for now. I try to change the building type with this button which I will implement. There is a significant factor about clicking on the button. If we click the button or the canvas, this event shouldn't affect the game map.
inventory of prototype
The buttons that I added it works fine, however, we build this building on the map at the same time. This issue can be seen in the gif above. So, let's prevent this double-event process. As a solution, I made up the ownership of the mouse location and it worked.  

Devamını Oku »

Devlog #4 Building System

I have a sensible idea for building system at last. My game should be fit according to the tileable system. I think to use a mask image when the building system will be activated. The first thing I do emphasize the tile areas and chunks as just views:isometric grid map

Okay, that's good-looking. However, there is a too important problem with the building system and mouse positions on the chunks. Normally, the mouse position is related to the just coordinates of the world, but it should be related to the chunks as relative in this program. So, I'm able to manipulate the layers of the map according to these relative positions. That seems easy but it's just a pseudo-to-sum solution to the problem. The other problem is the chunks overlapping each other. Actually, the reason for it, the map has an isometric view and it's totally normal. Therefore, I used weird way at least I think so, colors of the mask. I located this mask depending on the chunks. Of course, the mask won't be shown visually in the game. But I didn't use it just for the overlapping problem. I will use it to solve building something as tileable on the map. So the mask has the same size as every chunk and also there are tiles with different colors as look like tiles on the chunk. Every color represents a position on the chunk. In this way, we can manipulate the layers of the map data and I think it means, we can build something on the map. 

I've done most of these things. It can be seen in the video below:

And I added an info table for the prototype and I named it as a proof-of-concept version and it shows the position of tiles and chunks. So, the next goal is building something on the map. 

I rendered the map with two layers, that's okay, but there is a problem with FPS. I have never looked to fps until this time. The FPS of the prototype was very low. 😶 It was about 25 FPS. So, some after deactivation (some stuff of rendering), the FPS is increased to over 100, now. But I increased render operations for the second layer of the map necessarily. As a result, there is a decrease in FPS. It's a long-term issue.

I made some attempts to build a tree as a test. But, I guess, the image was positioned relative to the top-left like the below:
Build entity on the map
Also, there is another issue at the same time. The overflow of trees, but I can't get why it happens. The first issue, I suppose it is about the rendering of the tile. Because tiles are rendered based 64x32 and I realized the dimension of the tree image is bigger than the dimension of the base tile. Oh boy! I made a huge mistake! I have to render the isometric map relative to 64x64, (height size can be changeable).

As a solution, I cleaned the chunks and there is no overflow anymore. Also, the size of textures is changed easily and the result is like this:
building in tilemap
These solutions caused new issues and one of these issues can be seen via grid from the image above. 
I had trouble with the building system. One of these issues is a shift in the positioning of the tiles. I solved this problem by increasing the size of the tile's surface. (width:32px -> 64px) Also, the performance of the prototype is very low because of tile images. If I load them in different ways, fps can be increased.  But the first thing I did is giving effect to chosen tile area:
Improvement of the building system
Well, that looks nice. But the chosen tile is already filled by some building then the color of the edge shouldn't be green. It should be red.
building system
Devamını Oku »

Devlog #3 Optimization of Rendering

In the previous post, I changed my project's view as isometric instead of top-down. Although, the game while was running, gave bad performance results according to the task manager. Therefore, I decided to type a chunking algorithm to obtain efficient results of performance from the game prototype. Additionally, I implemented isometric movement to the character that is controlled by the keyboard. But I couldn't make it about apply the chunking algorithm to the game as a failure, anyways, until this post. If I should sum up how to do it, I used the colliding system and it works, ta-da! Let's look at how the chunking algorithm is work in the video below:
Of course, we will not see the generating map during the game. I just resized the window of the prototype to see chunks of how are load. 

Let's put a little nature on the map, the character's velocity is increased to see the map quickly:
Okay, that's part of the show. The important thing is the performance of the game:
performance of the open world
After that ram usage in the past, this progress is very efficient. The ram was using 896 MB, but now it's using just 41 MB. Finally, my next goal in the long term to reduce CPU usage as much as possible. There are too many loops in my game, how dare you, loops!? 

The short goals of the demo are in first priority currently. Let's add some trees to the game. That's part of the layered tilemap that isn't supported feature by the prototype for now. The other thing that I should add is the minimap. This minimap will not show the entire map at the first stage. I guess it will look dark at first however when the character went around on the map, these places that visited will be seen in the minimap. 
Devamını Oku »

Devlog #2 Isometric Projection

I want to render the map of the game as isometric. So, I need to use basic math tricks for it. Let's draw a sketch for it. Normally, the map's structure could be represented by a 2d grid. If we convert the map to isometric, the tiles of the map's positions look like it visually:


The red dot on the map represents the top left of the tiles. The isometric tile's height size could be half of the tile's width as the lowest value: I use pygame for making a game that doesn't work according to the cartesian coordinate system. The display just shows objects with (|x|, |y|) (positive) coordinates. Anyway, It's not important for now. I need to create an algorithm with reference to the above image. There are some calculations in the below image that contains what we use the formula for locating tiles on the screen correctly:
If we code according to what we've got and the result:
Isometric Tilemap
I can generate a texture for square texture, but it's not valid for the diamond shape. My next goal is creating a texture for use in an isometric map. ❔

That's our struct of isometric tile:
struct of isometric tile

So I generated an isometric surface according to the above image's struct. The function is returned this result. Well, I didn't remove the black background from the surface, but I will.
Also, we have to give a texture effect to this surface. I will do it via bitwise operations on the pixels' color. Finally, I can generate isometric tiles with a texture like the below image:
The game map has to be an isometric view. We're going to convert the top-down map to the isometric map. That's going to be tough.. (15 minutes later) No, it's not 🐣.
isometric game programming

But I couldn't see half of the map as can be seen from the above image  That's normal, because if you look at the second image in the post gives an idea of why we got this result.

When I look at the task manager:

Oh boy! I have to find a more efficient rendering system for my prototype. Normally, I'm using the render method that is every tile blitting on the one surface before the game loop. This method could be useful in some situations like low size map. However, we want to generate an immense world and there is bound for surface's dimension and of course, it's the reason for the high ram usage, I guess. Pygame uses CPU instead of GPU. So, I settled to use the chunk method. Make it clear, we have tiles and some parts of these tiles will be located on the chunk, so this chunk will contain tiles as we determine the amount. These chunks have a position to render it. Let's draw somethings about the chunk:
Chunk Render Method
I made inferences about chunks data structs in the below image:
Chunking Algorithm

This change will be not easy on the current project with broken form therefore, I'm creating a new template for it, IMO the less the better.

I created an example map array and I try to my chunk function to split the array into chunk:
Split array into chunk with python
It fits my array and we got part of the solution. Those chunks will appear if certain conditions are valid. The range values calculated for the chunks between range values will be displayed in the image below:
chunking algorithm

Finally, I could start implementing this chunking algorithm for rendering maps according to the image above in my code(in template code). So it's the result:
Chunks in Pygame

It doesn't work as well, but it works. I looked Task Manager for prototype:
Pygame Efficient Usage
When the program started, surfaces of the chunks are created at the beginning. But what if, we are just creating the surfaces on the running loop when the conditions are met. We wouldn't store surfaces in brief, we will just render them when they are needed:
Pygame Performance Optimization
Looks like there is no difference (ram usage efficiency 15%) between them, however, there are very few surfaces, I suppose It is going to be useful for creating a massive map. In addition, if you have noticed, then we can generate an unlimited world. Because we are no longer dependent on surface maximum size.

So I created a map that is occurred by 800x800 = 640,000 tiles. Each tile's dimension is 64x64, so the map's width is 800x64 = 51200px and when I looked at the task manager, I think the results are good:
Final Result of tilemap
According to these results, If I implement this chunking algorithm in my original code, I hope I will get better efficient results.

The project code is a mess for reviewing and reusable. Before implementing of chunking algorithm, I have to make better my code with an understandable struct of the project.

I arranged my project, and that looks fine except chunking algorithm. The algorithm works well at top-down rendering but there is a problem according to isometric rendering in the running of the game. Probably, It's about the location of the chunks. I'm putting this issue aside currently. I would like to work on the isometric movement of the character(temporary object). 

I typed a converter function called cartesian_to_isometric. After a few struggling problems, the character can move according to isometric calculations. Okay, I think that's enough for a devlog. I'm going to play BF3 now.
Devamını Oku »

Devlog #1 Introduce to making RPG-Strategy Game

I decided to make a game that will be kind of RPG and strategy. Well, I want to make a little complex game for me. I want to finish it as my first game. BTW, these devlogs haven't a relationship with the "Make an RPG Game" tutorial. I'm not explaining everything and sharing codes about this for now. Because somebody can be impressed(!) and can share it on some platforms. No offence, it happened just one time. Well, there are no visitors for now on this blog and probably I'm paranoid about it. 

I already made progress on my game. This game will be two-dimensional and tile-based. I used a procedural generation algorithm to create a map. This algorithm is Perlin Noise. You can find a lot of things about it. I'm not really familiar with it and I'm struggling. This algorithm provides beautiful smooth random design on the map like our world's, lakes, beaches, the moon's surface, etc.

The other thing that I added to the game, is a minimap and it's primitive version. I'm going to some buttons and give movement animation on it.

I didn't draw images for the game. Instead of, I used some manipulating operations to the pixels of surfaces and I created textures. Should I have used it? No, but it's feel good to me when you don't need to use file handling and using file paths. So I just created a couple of functions to generate textures, characters, etc. I used this textures to create my game map's design in likes below:

Tilemap design

If you notice, textures of tiles seem different each other same kind of tile. I created 100 textures for every tiles in the game. For example, the grass tile has 100 different views in the game and those textures are located on the map randomly. So, the game's view doesn't give a grid effect. Is it really necessary? Nope. We could draw tile in tile-mode instead of it. There are programs to make it like Aseprite, Pyxel Edit, etc, however, I want to make everything on code-based.

My player that you can see in the center of the above image, is created from the list called human_being. I'm not sure it is an efficient way. But it can be useful when I need to give animation to any objects in the game. 

My first priority is generating a natural-looking world. I said I added a basic minimap to the game and it gives the view of the world like below:

The red dot represents our character in the minimap. The problem is about generating the map. I don't want to my game doesn't look like the Caribbean Islands, it's not a pirate game. I need to optimize Perlin noise algorithm. Maybe I shouldn't use Perlin noise. The game map should be like below that is made as a prototype by me:

Well, I have no choice for now. I have to study about Perlin Noise.

I'm working on generating a tilemap. So, I'm trying to use Perlin Noise. This post created to showing just some effects on the map. What are we got as output when the changes in frequency and amplitude are applied.

For instance, if we pass 0.01 to noise2d function as a frequency value. That's the result what we got:

If we pass a value bigger than the last frequency value like 0.1:

So, it looks so complicated. So I'm taking back the frequency value to 0.01 and now we are going to pass a different value as amplitude value:

Amplitude: 1.0

Amplitude: 2.0


Amplitude: 10.0


Amplitude: 0.5

If we use three octaves:

  • frequency: 0.01  -  amplitude: 0.5
  • frequency: 0.05  -  amplitude: 0.25
  • frequency: 0.1    -  amplitude: 0.125
That's NOICE! 

To-do list in the next post:
  • Giving an Isometric view to the game.
  • Implementing auto-tiling for getting a better view of the game map.

Devamını Oku »