From ec2aa74d36670d74c153aa0022ab22e79502a061 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Tue, 2 May 2023 01:33:25 -0600 Subject: update to new version of pyssg --- live/blog/rss.xml | 144 +++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'live/blog/rss.xml') diff --git a/live/blog/rss.xml b/live/blog/rss.xml index 45dbe21..ef21a4e 100644 --- a/live/blog/rss.xml +++ b/live/blog/rss.xml @@ -14,7 +14,7 @@ david@luevano.xyz (David Luévano Alvarado) - pyssg v0.8.1 + pyssg v0.9.0 https://validator.w3.org/feed/docs/rss2.html 30 @@ -59,20 +59,20 @@

You can also find the jam entry here.

Similarly with the my FlappyBird clone, I plan to update this to a better state.

-

Initial setup

+

Initial setup

Again, similar to the FlappyBird clone I developed, I’m using the directory structure I wrote about on Godot project structure with slight modifications to test things out. Also using similar Project settings as those from the FlappyBird clone like the pixel art texture imports, keybindings, layers, etc..

I’ve also setup GifMaker, with slight modifications as the AssetLib doesn’t install it correctly and contains unnecessry stuff: moved necessary files to the res://addons directory, deleted test scenes and files in general, and copied the license to the res://docs directory. Setting this up was a bit annoying because the tutorial it’s bad (with all due respect). I might do a separate entry just to explain how to set it up, because I couldn’t find it anywhere other than by inspecting some of the code/scenes.I ended up not leaving this enabled in the game as it lagged the game out, but it’s an option I’ll end up researching more.

This time I’m also going to be using an Event bus singleton (which I’m going to just call Event) as managing signals was pretty annoying on my last project; as well as a Global singleton for essential stuff so I don’t have to do as many cross references between nodes/scenes.

-

Assets

+

Assets

This time I’ll be creating my own assets in Aseprite, wont be that good, but enough to prototype and get things going.

Other than that I used few key sprites from vryell: Controller & Keyboard Icons and a font from datagoblin: Monogram.

-

The snake

+

The snake

This is the most challenging part in my opinion as making all the body parts follow the head in a user defined path it’s kinda hard. I tried with like 4-5 options and the one I’m detailing here is the only one that worked as I wanted for me. This time the directory structure I’m using is the following:

FileSystem - Snake dir structure
FileSystem - Snake dir structure
-

Basic movement

+

Basic movement

The most basic thing is to move the head, this is what we have control of. Create a scene called Head.tscn and setup the basic KinematicBody2D with it’s own Sprite and CollisionShape2D (I used a small circle for the tip of the head), and set the Collision Layer/Mask accordingly, for now just layer = bit 1. And all we need to do, is keep moving the snake forwards and be able to rotate left or right. Created a new script called head.gd attached to the root (KinematicBody2D) and added:

extends KinematicBody2D
 
@@ -106,7 +106,7 @@ func _rotate_to(direction: int) -> void:
 Snake - Basic movement (left and right controls)
 
Snake - Basic movement (left and right controls)
-

Setting up path following

+

Setting up path following

To move other snake parts by following the snake head the only solution I found was to use the Path2D and PathFollow2D nodes. Path2D basically just handles the curve/path that PathFollow2D will use to move its child node; and I say “child node” in singular… as PathFollow2D can only handle one damn child, all the other ones will have weird transformations and/or rotations. So, the next thing to do is to setup a way to compute (and draw so we can validate) the snake’s path/curve.

Added the signal snake_path_new_point(coordinates) to the Event singleton and then add the following to head.gd:

var _time_elapsed: float = 0.0
@@ -143,7 +143,7 @@ func _on_Head_snake_path_new_point(coordinates: Vector2) -> void:
 Snake - Basic movement with path
 
Snake - Basic movement with path
-

Define body parts for the snake

+

Define body parts for the snake

At this point the only thing to do is to add the corresponding next body parts and tail of the snake. To do so, we need a PathFollow2D to use the live-generating Path2D, the only caveat is that we need one of these per body part/tail (this took me hours to figure out, thanks documentation).

Create a new scene called Body.tscn with a PathFollow2D as its root and an Area2D as its child, then just add the necessary Sprite and CollisionShap2D for the Area2D, I’m using layer = bit 2 for its collision. Create a new script called generic_segment.gd with the following code:

extends PathFollow2D
@@ -155,7 +155,7 @@ func _physics_process(delta: float) -> void:
     offset += Global.SNAKE_SPEED * delta
 

And this can be attached to the Body‘s root node (PathFollow2D), no extra setup needed. Repeat the same steps for creating the Tail.tscn scene and when attaching the generic_segment.gd script just configure the Type parameter to tail in the GUI (by selecting the node with the script attached and editing in the Inspector).

-

Adding body parts

+

Adding body parts

Now it’s just a matter of handling when to add new body parts in the snake.gd script. For now I’ve only setup for adding body parts to fulfill the initial length of the snake (this doesn’t include the head or tail). The extra code needed is the following:

export(PackedScene) var BODY_SEGMENT_NP: PackedScene
 export(PackedScene) var TAIL_SEGMENT_NP: PackedScene
@@ -239,13 +239,13 @@ func _add_segment_to_queue() -> void:
     _snake.propagate_call("set_process_input", [on_off])
 

Which will stop the snake node and all children.

-

Fix on body segments following head

+

Fix on body segments following head

After a while of testing and developing, I noticed that sometimes the head “detaches” from the body when a lot of rotations happen (moving the snake left or right), because of how imprecise the Curve2D is. To do this I just send a signal (snake_rotated) whenever the snake rotates and make a small correction (in generic_segment.gd):

func _on_snake_rotated() -> void:
     offset -= 0.75 * Global.SNAKE_SPEED * pow(get_physics_process_delta_time(), 2)
 

This is completely random, I tweaked it manually after a lot of iterations.

-

The food

+

The food

For now I just decided to setup a simple system to see everything works fine. The idea is to make some kind of generic food node/scene and a “food manager” to spawn them, for now in totally random locations. For this I added the following signals: food_placing_new_food(type), food_placed_new_food(type) and food_eaten(type).

First thing is creating the Food.tscn which is just an Area2D with its necessary children with an attached script called food.gd. The script is really simple:

class_name Food # needed to access Type enum outside of the script, this registers this script as a node
@@ -293,7 +293,7 @@ func _on_body_entered(body: Node) -> void:
 Snake - Food basic interaction
 
Snake - Food basic interaction
-

Za warudo! (The world)

+

Za warudo! (The world)

It just happend that I saw a video to create random maps by using a method called random walks, this video was made by NAD LABS: Nuclear Throne Like Map Generation In Godot. It’s a pretty simple but powerful script, he provided the source code from which I based my random walker, just tweaked a few things and added others. Some of the maps than can be generated with this method (already aded some random sprites):

World map generator - Random map 1 @@ -321,7 +321,7 @@ func get_centered_world_position(location: Vector2) -> Vector2:

Where get_cells_around is just a function that gets the safe cells around the origin. And this get_valid_map_coords just returns used cells minus the safe cells, to place food. get_centered_world_position is so we can center the food in the tiles.

Some signals I used for the world gen: world_gen_walker_started(id), world_gen_walker_finished(id), world_gen_walker_died(id) and world_gen_spawn_walker_unit(location).

-

Food placement

+

Food placement

The last food algorithm doesn’t check anything related to the world, and thus the food could spawn in the walls and outside the map.

First thing is I generalized the food into a single script and added basic food and special food which inherit from base food. The most important stuff for the base food is to be able to set all necessary properties at first:

func update_texture() -> void:
@@ -371,9 +371,9 @@ func _ready():
     return [world_generator.get_centered_world_position(location), location]
 

Other than that, there are some differences between placing normal and special food (specially the signal they send, and if an extra “special points” property is set). Some of the signals that I used that might be important: food_placing_new_food(type), food_placed_new_food(type, location) and food_eaten(type, location).

-

Stats clas and loading/saving data

+

Stats clas and loading/saving data

I got the idea of saving the current stats (points, max body segments, etc.) in a separate Stats class for easier load/save data. This option I went with didn’t work as I would liked it to work, as it was a pain in the ass to setup and each time a new property is added you have to manually setup the load/save helper functions… so not the best option. This option I used was json but saving a Node directly could work better or using resources (saving tres files).

-

Stats class

+

Stats class

The Stats “class” is just a script that extends from Node called stats.gd. It needs to define the class_name as Stats. The main content:

# main
 var points: int = 0
@@ -436,7 +436,7 @@ func set_stats(stats: Dictionary) -> void:
         trait_jump = stats["trait_jump"]
 

And this is not scalable at all, but I had to do this at the end of the jam so no way of optimizing and/or doing it correctly, sadly.

-

Load/save data

+

Load/save data

The load/save function is pretty standard. It’s a singleton/autoload called SavedData with a script that extends from Node called save_data.gd:

const DATA_PATH: String = "user://data.save"
 
@@ -480,7 +480,7 @@ func _handle_new_file() -> void:
         file.close()
 

It uses json as the file format, but I might end up changing this in the future to something else more reliable and easier to use (Stats class related issues).

-

Scoring

+

Scoring

For this I created a scoring mechanisms and just called it ScoreManager (score_manager.gd) which just basically listens to food_eaten signal and adds points accordingly to the current Stats object loaded. The main function is:

func _on_food_eaten(properties: Dictionary) -> void:
     var is_special: bool = properties["special"]
@@ -549,7 +549,7 @@ func _get_max_stats() -> Stats:
 

Then this sends a signal display_stats to activate UI elements that shows the progression.

Naturally, the saved Stats are loaded whenever needed. For example, for the Snake, we load the stats and setup any value needed from there (like a flag to know if any ability is enabled), and since we’re saving the new Stats at the end, then on restart we load the updated one.

-

Snake redesigned with the state machine pattern

+

Snake redesigned with the state machine pattern

I redesigned the snake code (the head, actually) to use the state machine pattern by following this guide which is definitely a great guide, straight to the point and easy to implement.

Other than what is shown in the guide, I implemented some important functions in the state_machine.gd script itself, to be used by each of the states as needed:

func rotate_on_input() -> void:
@@ -623,7 +623,7 @@ func physics_process(delta: float) -> void:
 

Where the important parts happen in the enter and exit functions. We need to change the Global.SNAKE_SPEED with the Global.SNAKE_DASH_SPEED on startand start the timer for how long should the dash last. And on the exit we reset the Global.SNAKE_SPEED back to normal. There is probably a better way of updating the Global.SNAKE_SPEED but this works just fine.

For the other ones is the same. Only difference with the jump_state.gd is that the collision from head to body is disabled, and no rotation is allowed (by not calling the rotate_on_input function).

-

Other minor stuff

+

Other minor stuff

Not as important but worth mentioning:

  • Added restartability function.
  • @@ -637,7 +637,7 @@ func physics_process(delta: float) -> void:
  • Refactored the nodes to make it work with change_scene_to, and added a main menu.
  • Added GUI for dead screen, showing the progress.
-

Final notes

+

Final notes

I actually didn’t finish this game (as how I visualized it), but I got it in a playable state which is good. My big learning during this jam is the time management that it requires to plan and design a game. I lost a lot of time trying to implement some mechanics because I was facing many issues, because of my lack of practice (which was expected) as well as trying to blog and create the necessary sprites myself. Next time I should just get an asset pack and do something with it, as well as keeping the scope of my game shorter.

For exporting and everything else, I went with what I did for my FlappyBird Godot clone

]]> @@ -663,17 +663,17 @@ func physics_process(delta: float) -> void:

The source code can be found in my GitHub here, it also contains the exported versions for HTML5, Windows and Linux (be aware that the sound might be too high and I’m too lazy to make it configurable, it was the last thing I added), or you could also go to the itch.io page I setup where it’s playable in the browser:

-

Initial project setup

-

Directory structure

+

Initial project setup

+

Directory structure

I’m basically going with what I wrote on Godot project structure recently, and probably with minor changes depending on the situation.

-

Config

-

Default import settings

+

Config

+
Default import settings

Since this is just pixel art, the importing settings for textures needs to be adjusted so the sprites don’t look blurry. Go to Project -> Project settings… -> Import defaults and on the drop down select Texture, untick everything and make sure Compress/Mode is set to Lossless.

Project settings - Import defaults - Texture settings
Project settings - Import defaults - Texture settings
-

General settings

+
General settings

It’s also a good idea to setup some config variables project-wide. To do so, go to Project -> Project settings… -> General, select Application/config and add a new property (there is a text box at the top of the project settings window) for game scale: application/config/game_scale for the type use float and then click on add; configure the new property to 3.0; On the same window, also add application/config/version as a string, and make it 1.0.0 (or whatever number you want).

Project settings - General - Game scale and version properties @@ -689,21 +689,21 @@ func physics_process(delta: float) -> void: Project settings - General - Initial window size
Project settings - General - Initial window size
-

Keybindings

+
Keybindings

I only used 3 actions (keybindings): jump, restart and toggle_debug (optional). To add custom keybindings (so that the Input.something() API can be used), go to Project -> Project settings… -> Input Map and on the text box write “jump” and click add, then it will be added to the list and it’s just a matter of clicking the + sign to add a “Physical key”, press any key you want to be used to jump and click ok. Do the same for the rest of the actions.

Project settings - Input Map - Adding necessary keybindings
Project settings - Input Map - Adding necessary keybindings
-

Layers

+
Layers

Finally, rename the physics layers so we don’t lose track of which layer is which. Go to Project -> Layer Names -> 2d Physics and change the first 5 layer names to (in order): “player”, “ground”, “pipe”, “ceiling” and “score”.

Project settings - Layer Names - 2D Physics
Project settings - Layer Names - 2D Physics
-

Assets

+

Assets

For the assets I found out about a pack that contains just what I need: flappy-bird-assets by MegaCrash; I just did some minor modifications on the naming of the files. For the font I used Silver, and for the sound the resources from FlappyBird-N64 (which seems to be taken from 101soundboards.com which the orignal copyright holder is .Gears anyways).

-

Importing

+

Importing

Create the necessary directories to hold the respective assets and it’s just a matter of dragging and dropping, I used directories: res://entities/actors/player/sprites/, res://fonts/, res://levels/world/background/sprites/, res://levels/world/ground/sprites/, res://levels/world/pipe/sprites/, res://sfx/. For the player sprites, the “FileSystem” window looks like this (entities/actor directories are really not necessary):

FileSystem - Player sprite imports @@ -714,9 +714,9 @@ func physics_process(delta: float) -> void: FileSystem - SFX imports
FileSystem - SFX imports
-

Scenes

+

Scenes

Now it’s time to actually create the game, by creating the basic scenes that will make up the game. The hardest part and the most confusing is going to be the TileMaps, so that goes first.

-

TileMaps

+

TileMaps

I’m using a scene called “WorldTiles” with a Node2D node as root called the same. With 2 different TileMap nodes as children named “GroundTileMap” and “PipeTileMap” (these are their own scene); yes 2 different TileMaps because we need 2 different physics colliders (In Godot 4.0 you can have a single TileMap with different physics colliders in it). Each node has its own script. It should look something like this:

Scene - WorldTiles (TileMaps) @@ -759,13 +759,13 @@ func physics_process(delta: float) -> void:
TileMap - Cell size and collision configuration

Now it’s just a matter of repeating the same for the pipes (“PipeTileMap”), only difference is that when selecting the tiles you need to select 2 tiles, as the pipe is 2 tiles wide, or just set the Snap Options/Step to 32x16, for example, just keep the cell size to 16x16.

-

Default ground tiles

+
Default ground tiles

I added few default ground tiles to the scene, just for testing purposes but I left them there. These could be place programatically, but I was too lazy to change things. On the “WorldTiles” scene, while selecting the “GroundTileMap”, you can select the tiles you want to paint with, and left click in the grid to paint with the selected tile. Need to place tiles from (-8, 7) to (10, 7) as well as the tile below with the filler ground (the tile position/coordinates show at the bottom left, refer to the image below):

Scene - WorldTiles - Default ground tiles
Scene - WorldTiles - Default ground tiles
-

Player

+

Player

On a new scene called “Player” with a KinematicBody2D node named “Player” as the root of the scene, then for the children: AnimatedSprite as “Sprite”, CollisionShape2D as “Collision” (with a circle shape) and 3 AudioStreamPlayers for “JumpSound”, “DeadSound” and “HitSound”. Not sure if it’s a good practice to have the audio here, since I did that at the end, pretty lazy. Then, attach a script to the “Player” node and then it should look like this:

Scene - Player - Node setup @@ -788,7 +788,7 @@ func physics_process(delta: float) -> void:
Scene - Player - SpriteFrames window with sprite sheet configured

Finally, make sure the “Sprite” node has the AnimatedSprite/Animation is set to “bird_1” and that the “Collision” node is configured correctly for its size and position (I just have it as a radius of 7). As well as dropping the SFX files into the corresponding AudioStreamPlayer (into the AudioStreamPlayer/Stream property).

-

Other

+

Other

These are really simple scenes that don’t require much setup:

  • “CeilingDetector”: just an Area2D node with a CollisionShape2D in the form of a rectangle (CollisionShape2D/Shape/extents to (120, 10)), stretched horizontally so it fits the whole screen. CollisionObject2D/Collision/Layer set to bit 4 (ceiling) and CollisionObject2D/Collision/Mask set to bit 1 (player).
  • @@ -800,7 +800,7 @@ func physics_process(delta: float) -> void:
-

Game

+

Game

This is the actual “Game” scene that holds all the playable stuff, here we will drop in all the previous scenes; the root node is a Node2D and also has an attached script. Also need to add 2 additional AudioStreamPlayers for the “start” and “score” sounds, as well as a Sprite for the background (Sprite/Offset/Offset set to (0, 10)) and a Camera2D (Camera2D/Current set to true (checked)). It should look something like this:

Scene - Game - Node setup @@ -811,8 +811,8 @@ func physics_process(delta: float) -> void: Scene - Game - Viewport
Scene - Game - Viewport
-

UI

-

Fonts

+

UI

+
Fonts

We need some font “Resources” to style the Label fonts. Under the FileSystem window, right click on the fonts directory (create one if needed) and click on “New Resource…” and select DynamicFontData, save it in the “fonts” directory as “SilverDynamicFontData.tres” (“Silver” as it is the font I’m using) then double click the just created resource and set the DynamicFontData/Font Path to the actual “Silver.ttf” font (or whatever you want).

Then create a new resource and this time select DynamicFont, name it “SilverDynamicFont.tres”, then double click to edit and add the “SilverDynamicFontData.tres” to the DynamicFont/Font/Font Data property (and I personally toggled off the DynamicFont/Font/Antialiased property), now just set the DynamicFont/Settings/(Size, Outline Size, Outline Color) to 32, 1 and black, respectively (or any other values you want). It should look something like this:

@@ -824,7 +824,7 @@ func physics_process(delta: float) -> void: Resource - Dynamicfont - Directory structure
Resource - Dynamicfont - Directory structure
-

Scene setup

+
Scene setup

This has a bunch of nested nodes, so I’ll try to be concise here. The root node is a CanvasLayer named “UI” with its own script attached, and for the children:

  • “MarginContainer”: MarginContainer with Control/Margin/(Left, Top) set to 10 and Control/Margin/(Right, Bottom) set to -10.
      @@ -853,13 +853,13 @@ func physics_process(delta: float) -> void: Scene - UI - Node setup
      Scene - UI - Node setup
      -

      Main

      +

      Main

      This is the final scene where we connect the Game and the UI. It’s made of a Node2D with it’s own script attached and an instance of “Game” and “UI” as it’s children.

      This is a good time to set the default scene when we run the game by going to Project -> Project settings… -> General and in Application/Run set the Main Scene to the “Main.tscn” scene.

      -

      Scripting

      +

      Scripting

      I’m going to keep this scripting part to the most basic code blocks, as it’s too much code, for a complete view you can head to the source code.

      As of now, the game itself doesn’t do anything if we hit play. The first thing to do so we have something going on is to do the minimal player scripting.

      -

      Player

      +

      Player

      The most basic code needed so the bird goes up and down is to just detect “jump” key presses and add a negative jump velocity so it goes up (y coordinate is reversed in godot…), we also check the velocity sign of the y coordinate to decide if the animation is playing or not.

      class_name Player
       extends KinematicBody2D
      @@ -909,7 +909,7 @@ func _physics_process(delta: float) -> void:
           dead_sound.play()
       

      Finally need to add the actual checks for when the player dies (like collision with ground or pipe) as well as a function that listens to a signal for when the player goes to the ceiling.

      -

      WorldDetector

      +

      WorldDetector

      The code is pretty simple, we just need a way of detecting if we ran out of ground and send a signal, as well as sending as signal when we start detecting ground/pipes behind us (to remove it) because the world is being generated as we move. The most basic functions needed are:

      func _was_colliding(detector: RayCast2D, flag: bool, signal_name: String) -> bool:
           if detector.is_colliding():
      @@ -928,7 +928,7 @@ func _now_colliding(detector: RayCast2D, flag: bool, signal_name: String) ->
           return false
       

      We need to keep track of 3 “flags”: ground_was_colliding, ground_now_colliding and pipe_now_colliding (and their respective signals), which are going to be used to do the checks inside _physics_process. For example for checking for new ground: ground_now_colliding = _now_colliding(old_ground, ground_now_colliding, "ground_started_colliding").

      -

      WorldTiles

      +

      WorldTiles

      This script is what handles the “GroundTileMap” as well as the “PipeTileMap” and just basically functions as a “Signal bus” connecting a bunch of signals from the “WorldDetector” with the TileMaps and just tracking how many pipes have been placed:

      export(int, 2, 20, 2) var PIPE_SEP: int = 6
       var tiles_since_last_pipe: int = PIPE_SEP - 1
      @@ -950,7 +950,7 @@ func _on_WorldDetector_ground_started_colliding() -> void:
       func _on_WorldDetector_pipe_started_colliding() -> void:
           emit_signal("remove_pipe")
       
      -

      GroundTileMap

      +
      GroundTileMap

      This is the node that actually places the ground tiles upong receiving a signal. In general, what you want is to keep track of the newest tile that you need to place (empty spot) as well as the last tile that is in the tilemap (technically the first one if you count from left to right). I was experimenting with enums so I used them to define the possible Ground tiles:

      enum Ground {
           TILE_1,
      @@ -981,7 +981,7 @@ func _remove_first_ground() -> void:
           old_tile_position += Vector2.RIGHT
       

      Where you might notice that the _initial_new_tile_x is 11, instead of 10, refer to Default ground tiles where we placed tiles from -8 to 10, so the next empty one is 11. These _place_new_ground and _remove_first_ground functions are called upon receiving the signal.

      -

      PipeTileMap

      +
      PipeTileMap

      This is really similar to the “GroundTileMap” code, instead of defining an enum for the ground tiles, we define it for the pipe patterns (because each pipe is composed of multiple pipe tiles). If your pipe tile set looks like this (notice the index):

      PipeTileMap - Tile set indexes @@ -1043,7 +1043,7 @@ var detector_stack: Array detector.queue_free()

These functions are called when receiving the signal to place/remove pipes.

-

Saved data

+

Saved data

Before proceeding, we require a way to save/load data (for the high scores). We’re going to use the ConfigFile node that uses a custom version of the “ini” file format. Need to define where to save the data:

const DATA_PATH: String = "user://data.cfg"
 const SCORE_SECTION: String = "score"
@@ -1089,7 +1089,7 @@ func get_high_score() -> int:
 Project settings - AutoLoad - SavedData singleton
 
Project settings - AutoLoad - SavedData singleton
-

Game

+

Game

The game script it’s also like a “Signal bus” in the sense that it connects all its childs’ signals together, and also has the job of starting/stopping the _process and _physics_process methods from the childs as needed. First, we need to define the signals and and references to all child nodes:

signal game_started
 signal game_over
@@ -1160,7 +1160,7 @@ func _on_ScoreDetector_body_entered(body: Node2D) -> void:
     score_sound.play()
 

When the player dies, we set all processing to false, except for the player itself (so it can drop all the way to the ground). Also, when receiving a “scoring” signal, we manage the current score, as well as saving the new high score when applicable, note that we need to read the high_score at the beginning by calling SavedData.get_high_score(). This signal we emit will be received by the UI so it updates accordingly.

-

UI

+

UI

First thing is to get a reference to all the child Labels, an initial reference to the high score as well as the version defined in the project settings:

onready var fps_label: Label = $MarginContainer/DebugContainer/FPS
 onready var version_label: Label = $MarginContainer/VersionContainer/Version
@@ -1204,7 +1204,7 @@ func _on_Game_new_score(score: int, high_score: int) -> void:
     score_label.set_text(String(score))
     high_score_label.set_text("High score: %s" % high_score)
 
-

Main

+

Main

This is the shortest script, it just connects the signals between the “Game” and the “UI”:

onready var game: Game = $Game
 onready var ui: UI = $UI
@@ -1217,11 +1217,11 @@ func _ready() -> void:
     game.connect("game_over", ui, "_on_Game_game_over")
     game.connect("new_score", ui, "_on_Game_new_score")
 
-

Final notes and exporting

+

Final notes and exporting

At this point the game should be fully playable (if any detail missing feel free to look into the source code linked at the beginning). Only thing missing is an icon for the game; I did one pretty quicly with the assets I had.

-

Preparing the files

+

Preparing the files

If you followed the directory structure I used, then only thing needed is to transform the icon to a native Windows ico format (if exporting to Windows, else ignore this part). For this you need ImageMagick or some other program that can transform png (or whatever file format you used for the icon) to ico. I used [Chocolatey][https://chocolatey.org/] to install imagemagick, then to convert the icon itself used: magick convert icon.png -define icon:auto-resize=256,128,64,48,32,16 icon.ico as detailed in Godot‘s Changing application icon for Windows.

-

Exporting

+

Exporting

You need to download the templates for exporting as detailed in Godot‘s Exporting projects. Basically you go to Editor -> Manage Export Templates… and download the latest one specific to your Godot version by clicking on “Download and Install”.

If exporting for Windows then you also need to download rcedit from here. Just place it wherever you want (I put it next to the Godot executable).

Then go to Project -> Export… and the Window should be empty, add a new template by clicking on “Add…” at the top and then select the template you want. I used HTML5, Windows Desktop and Linux/X11. Really the only thing you need to set is the “Export Path” for each template, which is te location of where the executable will be written to, and in the case of the Windows Desktop template you could also setup stuff like “Company Name”, “Product Name”, “File/Product Version”, etc..

@@ -1446,13 +1446,13 @@ func _ready() -> void: I’ve been wanting to do this entry, but had no time to do it since I also have to set up the VPN service as well to make sure what I’m writing makes sense, today is the day.

Like with any other of my entries I based my setup on the Arch Wiki, this install script and this profile generator script.

This will be installed and working alongside the other stuff I’ve wrote about on other posts (see the server tag). All commands here are executes as root unless specified otherwise. Also, this is intended only for IPv4 (it’s not that hard to include IPv6, but meh).

-

Prerequisites

+

Prerequisites

Pretty simple:

  • Working server with root access, and with Ufw as the firewall.
  • Depending on what port you want to run the VPN on, the default 1194, or as a fallback on 443 (click here for more). I will do mine on port 1194 but it’s just a matter of changing 2 lines of configuration and one Ufw rule.
-

Create PKI from scratch

+

Create PKI from scratch

PKI stands for Public Key Infrastructure and basically it’s required for certificates, private keys and more. This is supposed to work between two servers and one client: a server in charge of creating, signing and verifying the certificates, a server with the OpenVPN service running and the client making the request.

This is supposed to work something like: 1) a client wants to use the VPN service, so it creates a requests and sends it to the signing server, 2) this server checks the requests and signs the request, returning the certificates to both the VPN service and the client and 3) the client can now connect to the VPN service using the signed certificate which the OpenVPN server knows about. In a nutshell, I’m no expert.

… but, to be honest, all of this is a hassle and (in my case) I want something simple to use and manage. So I’m gonna do all on one server and then just give away the configuration file for the clients, effectively generating files that anyone can run and will work, meaning that you need to be careful who you give this files (it also comes with a revoking mechanism, so no worries).

@@ -1496,7 +1496,7 @@ openssl dhparam -out dh.pem 2048 openvpn --genkey secret ta.key

That’s it for the PKI stuff and general certificate configuration.

-

OpenVPN

+

OpenVPN

OpenVPN is a robust and highly flexible VPN daemon, that’s pretty complete feature wise.

Install the openvpn package:

pacman -S openvpn
@@ -1644,7 +1644,7 @@ ufw reload
 systemctl enable openvpn-server@server.service
 

Where the server after @ is the name of your configuration, server.conf without the .conf in my case.

-

Create client configurations

+

Create client configurations

You might notice that I didn’t specify how to actually connect to our server. For that we need to do a few more steps. We actually need a configuration file similar to the server.conf file that we created.

The real way of doing this would be to run similar steps as the ones with easy-rsa locally, send them to the server, sign them, and retrieve them. Nah, we’ll just create all configuration files on the server as I was mentioning earlier.

Also, the client configuration file has to match the server one (to some degree), to make this easier you can create a client-common file in /etc/openvpn/server with the following content:

@@ -1769,7 +1769,7 @@ cd $CPWD Recently I set up an XMPP server (and a Matrix one, too) for my personal use and for friends if they want one; made one for EL ELE EME for example. So, here are the notes on how I set up the server that is compatible with the Conversations app and the Movim social network. You can see my addresses in contact and the XMPP compliance/score of the server.

One of the best resources I found that helped me a lot was Installing and Configuring Prosody XMPP Server on Debian 9, and of course the Arch Wiki and the oficial documentation.

As with my other entries, this is under a server running Arch Linux, with the Nginx web server and Certbot certificates. And all commands here are executed as root (unless specified otherwise)

-

Prerequisites

+

Prerequisites

Same as with my other entries (website, mail and git) plus:

  • A and (optionally) AAA DNS records for:
      @@ -1790,7 +1790,7 @@ cd $CPWD
    • Email addresses for admin, abuse, contact, security, etc. Or use your own email for all of them, doesn’t really matter much as long as you define them in the configuration and are valid, I have aliases so those emails are forwarded to me.
    • Allow ports 5000, 5222, 5269, 5280 and 5281 for Prosody and, 3478 and 5349 for Turnserver which are the defaults for coturn.
    -

    Prosody

    +

    Prosody

    Prosody is an implementation of the XMPP protocol that is flexible and extensible.

    Install the prosody package (with optional dependencies) and the mercurial package:

    pacman -S prosody, mercurial, lua52-sec, lua52-dbi, lua52-zlib
    @@ -2134,7 +2134,7 @@ ln -s your.domain.key SUBDOMAIN.your.domain.key
     ...
     

    That’s basically all the configuration that needs Prosody itself, but we still have to configure Nginx and Coturn before starting/enabling the prosody service.

    -

    Nginx configuration file

    +

    Nginx configuration file

    Since this is not an ordinary configuration file I’m going to describe this too. Your prosody.conf file should have the following location blocks under the main server block (the one that listens to HTTPS):

    # HTTPS server block
     server {
    @@ -2232,7 +2232,7 @@ server {
     
    nginx -t
     systemctl restart nginx.service
     
    -

    Coturn

    +

    Coturn

    Coturn is the implementation of TURN and STUN server, which in general is for (at least in the XMPP world) voice support and external service discovery.

    Install the coturn package:

    pacman -S coturn
    @@ -2248,7 +2248,7 @@ static-auth-secret=YOUR SUPER SECRET TURN PASSWORD
     systemctl enable turnserver.service
     

    You can test if your TURN server works at Trickle ICE. You may need to add a user in the turnserver.conf to test this.

    -

    Wrapping up

    +

    Wrapping up

    At this point you should have a working XMPP server, start/enable the prosody service now:

    systemctl start prosody.service
     systemctl enable prosody.service
    @@ -2320,13 +2320,13 @@ systemctl enable prosody.service
           How to create a git server using cgit on a server running Nginx. This is a follow up on post about creating a website with Nginx and Certbot.
           My git server is all I need to setup to actually kill my other server (I’ve been moving from servers on these last 2-3 blog entries), that’s why I’m already doing this entry. I’m basically following git’s guide on setting up a server plus some specific stuff for (btw i use) Arch Linux (Arch Linux Wiki: Git server and Step by step guide on setting up git server in arch linux (pushable)).

    Note that this is mostly for personal use, so there’s no user/authentication control other than that of SSH. Also, most if not all commands here are run as root.

    -

    Prerequisites

    +

    Prerequisites

    I might get tired of saying this (it’s just copy paste, basically)… but you will need the same prerequisites as before (check my website and mail entries), with the extras:

    • (Optional, if you want a “front-end”) A CNAME for “git” and (optionally) “www.git”, or some other name for your sub-domains.
    • An SSL certificate, if you’re following the other entries, add a git.conf and run certbot --nginx to extend the certificate.
    -

    Git

    +

    Git

    Git is a version control system.

    If not installed already, install the git package:

    pacman -S git
    @@ -2364,7 +2364,7 @@ chown -R git:git repo_name.git
     

    Those two lines above will need to be run each time you want to add a new repository to your server (yeah, kinda lame… although there are options to “automate” this, I like it this way).

    After that you can already push/pull to your repository. I have my repositories (locally) set up so I can push to more than one remote at the same time (my server, GitHub, GitLab, etc.); to do so, check this gist.

    -

    Cgit

    +

    Cgit

    Cgit is a fast web interface for git.

    This is optionally since it’s only for the web application.

    Install the cgit and fcgiwrap packages:

    @@ -2449,14 +2449,14 @@ exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2&g How to create mail server using Postfix, Dovecot, SpamAssassin and OpenDKIM. This is a follow up on post about creating a website with Nginx and Certbot. The entry is going to be long because it’s a tedious process. This is also based on Luke Smith’s script, but adapted to Arch Linux (his script works on debian-based distributions). This entry is mostly so I can record all the notes required while I’m in the process of installing/configuring the mail server on a new VPS of mine; also I’m going to be writing a script that does everything in one go (for Arch Linux), that will be hosted here.

    This configuration works for local users (users that appear in /etc/passwd), and does not use any type of SQL Database. And note that most if not all commands executed here are run with root privileges.

    -

    Prerequisites

    +

    Prerequisites

    Basically the same as with the website with Nginx and Certbot, with the extras:

    • You will need a CNAME for “mail” and (optionally) “www.mail”, or whatever you want to call the sub-domains (although the RFC 2181 states that it NEEDS to be an A record, fuck the police).
    • An SSL certificate. You can use the SSL certificate obtained following my last post using certbot (just create a mail.conf and run certbot --nginx again).
    • Ports 25, 587 (SMTP), 465 (SMTPS), 143 (IMAP) and 993 (IMAPS) open on the firewall.
    -

    Postfix

    +

    Postfix

    Postfix is a “mail transfer agent” which is the component of the mail server that receives and sends emails via SMTP.

    Install the postfix package:

    pacman -S postfix
    @@ -2545,7 +2545,7 @@ newaliases
     
    systemctl start postfix.service
     systemctl enable postfix.service
     
    -

    Dovecot

    +

    Dovecot

    Dovecot is an IMAP and POP3 server, which is what lets an email application retrieve the mail.

    Install the dovecot and pigeonhole (sieve for dovecot) packages:

    pacman -S dovecot pigeonhole
    @@ -2660,7 +2660,7 @@ account required pam_unix.so
     
    systemctl start dovecot.service
     systemctl enable dovecot.service
     
    -

    OpenDKIM

    +

    OpenDKIM

    OpenDKIM is needed so services like G**gle (we don’t mention that name here [[[this is a meme]]]) don’t throw the mail to the trash. DKIM stands for “DomainKeys Identified Mail”.

    Install the opendkim package:

    pacman -S opendkim
    @@ -2728,7 +2728,7 @@ systemctl enable opendkim.service
     
  • And at this point you could test your mail for spoofing and more.

    -

    SpamAssassin

    +

    SpamAssassin

    SpamAssassin is just a mail filter to identify spam.

    Install the spamassassin package (which will install a bunch of ugly perl packages…):

    pacman -S spamassassin
    @@ -2781,7 +2781,7 @@ ExecStart=/usr/bin/vendor_perl/spamd -x -u spamd -g spamd --listen=/run/spamd/sp
     
    systemctl start spamassassin.service
     systemctl enable spamassassin.service
     
    -

    Wrapping up

    +

    Wrapping up

    We should have a working mail server by now. Before continuing check your journal logs (journalctl -xe --unit={unit}, where {unit} could be spamassassin.service for example) to see if there was any error whatsoever and try to debug it, it should be a typo somewhere (the logs are generally really descriptive) because all the settings and steps detailed here just (literally just finished doing everything on a new server as of the writing of this text) worked (((it just werks on my machine))).

    Now, to actually use the mail service: first of all, you need a normal account (don’t use root) that belongs to the mail group (gpasswd -a user group to add a user user to group group) and that has a password.

    Next, to actually login into a mail app/program/whateveryouwanttocallit, you will use the following settings, at least for thunderdbird(I tested in windows default mail app and you don’t need a lot of settings):

    @@ -2815,7 +2815,7 @@ systemctl enable spamassassin.service How to create website that runs on Nginx and uses Certbot for SSL certificates. This is a base for future blog posts about similar topics. These are general notes on how to setup a Nginx web server plus Certbot for SSL certificates, initially learned from Luke’s video and after some use and research I added more stuff to the mix. And, actually at the time of writing this entry, I’m configuring the web server again on a new VPS instance, so this is going to be fresh.

    As a side note, (((i use arch btw))) so everything here es aimed at an Arch Linux distro, and I’m doing everything on a VPS. Also note that most if not all commands here are executed with root privileges.

    -

    Prerequisites

    +

    Prerequisites

    You will need two things:

    • A domain name (duh!). I got mine on Epik (affiliate link, btw).
        @@ -2829,7 +2829,7 @@ systemctl enable spamassassin.service
    -

    Nginx

    +

    Nginx

    Nginx is a web (HTTP) server and reverse proxy server.

    You have two options: nginx and nginx-mainline. I prefer nginx-mainline because it’s the “up to date” package even though nginx is labeled to be the “stable” version. Install the package and enable/start the service:

    pacman -S nginx-mainline
    @@ -2918,7 +2918,7 @@ systemctl restart nginx
         try_files $uri/index.html $uri.html $uri/ $uri =404;
         ...
     
    -

    Certbot

    +

    Certbot

    Certbot is what provides the SSL certificates via Let’s Encrypt.

    The only “bad” (bloated) thing about Certbot, is that it uses python, but for me it doesn’t matter too much. You may want to look up another alternative if you prefer. Install the packages certbot and certbot-nginx:

    pacman -S certbot certbot-nginx
    -- 
    cgit v1.2.3-54-g00ecf