aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2022-10-16 23:51:43 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2022-10-16 23:51:43 +0200
commit854ae471a01bb13cb73a38143f43d97a9ca62ce5 (patch)
tree3929f9f2b54db993bda6cc717ac465409f50acbf /content
parent5c39d767ffbecefa447dac60b8f0adc0ef2064dc (diff)
downloadmitjafelicijan.com-854ae471a01bb13cb73a38143f43d97a9ca62ce5.tar.gz
Added new draft post
Diffstat (limited to 'content')
-rwxr-xr-xcontent/posts/2022-10-10-sentiment-based-on-political-bias.md (renamed from content/posts/2022-06-28-sentiment-based-on-political-bias.md)4
-rwxr-xr-xcontent/posts/2022-10-11-handling-massive-worlds-in-godot.md87
2 files changed, 89 insertions, 2 deletions
diff --git a/content/posts/2022-06-28-sentiment-based-on-political-bias.md b/content/posts/2022-10-10-sentiment-based-on-political-bias.md
index 5b7816c..fc03a5e 100755
--- a/content/posts/2022-06-28-sentiment-based-on-political-bias.md
+++ b/content/posts/2022-10-10-sentiment-based-on-political-bias.md
@@ -1,13 +1,13 @@
1--- 1---
2title: Sentiment distribution analysis based on political bias in online publications 2title: Sentiment distribution analysis based on political bias in online publications
3url: sentiment-based-on-political-bias.html 3url: sentiment-based-on-political-bias.html
4date: 2022-06-28 4date: 2022-10-10
5draft: true 5draft: true
6--- 6---
7 7
8I have been wondering for a long time what would sentiment differences look based on political leaning from popular publications. Is it the left that is more optimistic, center or the right. 8I have been wondering for a long time what would sentiment differences look based on political leaning from popular publications. Is it the left that is more optimistic, center or the right.
9 9
10> Before people loose their minds, I don't care about political stuff and this is data we are talking about and not my personal feelings about it. So, before saying anything have this in mind and let data speak for itself. 10> **Before people loose their minds**, I don't care about political stuff in the context of this post and this is data we are talking about and not my personal feelings about it. So, before saying anything have this in mind and let data speak for itself.
11 11
12## Preparing the data 12## Preparing the data
13 13
diff --git a/content/posts/2022-10-11-handling-massive-worlds-in-godot.md b/content/posts/2022-10-11-handling-massive-worlds-in-godot.md
new file mode 100755
index 0000000..9603022
--- /dev/null
+++ b/content/posts/2022-10-11-handling-massive-worlds-in-godot.md
@@ -0,0 +1,87 @@
1---
2title: Handling big worlds in Godot by splitting and lazy loading chunks of it
3url: handling-big-worlds-in-godot.html
4date: 2022-10-11
5draft: true
6---
7
8**Table of contents**
9
101. [Handling lazy loading in 2D world](#handling-lazy-loading-in-2d-world)
11 1. [Player movement](#player-movement)
12
13> Because these examples are exported from **Godot to WebAssembly** and the packaging produces **large files**, you will need to **click to lazy load them**
14
15I have seen a couple of examples on the net, but never really a comprehensive guide how this would be achieved. My solution is nowhere perfect, but it will get you started. This code is also not optimized, so buyer beware.
16
17For the sake of simplicity, I will keep the terrain plain. I have been working on a terrain generation tool in my spare time, but due to the other obligations, that project was put on the back burner. If you however interested in it you can check it out on my personal Git repository [https://git.mitjafelicijan.com/village-creator.git/](https://git.mitjafelicijan.com/village-creator.git/).
18
19![Village Creator](/assets/godot-dynamic-tile-loading/village-creator.png)
20
21It's using a node system to generate a terrain mesh, and it's utilizing cellular automata for special effects like sand erosion and wind erosion, etc. Example of using cellular automata rule in an image below.
22
23![Cellular automata](/assets/godot-dynamic-tile-loading/cellular-automata.png)
24
25As I mentioned previously, still far away from being useful. Always, enough about that. Let’s move on to the topic of this post.
26
27## Handling lazy loading in 2D world
28
29To simplify things, we will try doing in 2D world first. It makes for a simpler exercise and eliminates a lot of complexity that comes with additional axis.
30
31### Player movement
32
33First, we need to take care of player movement. I will not go into many details here, since there are plenty of good tutorials on this topic on the interwebs. Suffice it to say, I created a [KinematicBody2D](https://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html) node that gives us goodies like `move_and_slide` and added input maps for [move_up, move_down, move_right, move_left] movement.
34
35```gdscript
36# Player2D.gd
37
38extends KinematicBody2D
39
40# Exported variables.
41export var speed = 300
42
43# Utility variables for later use.
44# Can be ignored for now.
45export var player_scale = 1
46export var camera_zoom = 1
47
48# Internal variables.
49var velocity = Vector2.ZERO
50
51func _ready():
52 # Can be ignored for now.
53 $Model.scale = Vector2(player_scale, player_scale)
54 $Camera.zoom = Vector2(camera_zoom, camera_zoom)
55
56# Executes on every physics frame (60, 144, etc).
57# This game has vsync enabled.
58func _physics_process(delta):
59 handle_player_movement()
60
61# Handles player movement.
62func handle_player_movement():
63 velocity = Vector2.ZERO
64 if Input.is_action_pressed('move_right'):
65 velocity.x += 1
66 if Input.is_action_pressed('move_left'):
67 velocity.x -= 1
68 if Input.is_action_pressed('move_down'):
69 velocity.y += 1
70 if Input.is_action_pressed('move_up'):
71 velocity.y -= 1
72
73 # Make sure diagonal movement isn't faster.
74 # Therefore vector needs to be normalized.
75 velocity = velocity.normalized() * speed
76 velocity = move_and_slide(velocity)
77```
78
79[Read more about vector normalization.](https://www.fundza.com/vectors/normalize/)
80
81`$Model` is just a sprite loaded and positioned into the scene. For the background, I again loaded just a normal sprite and positioned it to center. This makes it easier to test if the movement is working properly. Background will be removed when we will start dynamically loading the world.
82
83<video src="/assets/godot-dynamic-tile-loading/2d-player-movement.webm" controls></video>
84
85Code for player movement can be [downloaded from my Git server](https://git.mitjafelicijan.com/big-worlds-godot.git/snapshot/big-worlds-godot-55bcad79c11bd67e8268925d7edbf571aa31e3bf.zip).
86
87<!--<div class="ll-iframe w-full h-80" data-src="/assets/godot-dynamic-tile-loading/example1/"></div>-->