0 votes

I try to recreate this matrix effect, see https://www.youtube.com/watch?v=bmSlL3xbchU
I don't have a font type fnt
I try to use the ttf and otf:
Any idea?
This is the script code matrix.gd :

extends Node2D

#export (Font) var font; 
var font; 
var col;
var matrix = [];
var upd = 0;
var move = 0;

func _ready():
    font = load("res://FreeSans.ttf")
    for f in range(65):
        for y in range(38):
            if y == 0 : 
                matrix[f].append(Vector2(randi()&1, int(randi()%11)));

func mtrx():
    if upd == 10: upd = 0;
    for f in range(65): matrix[f][0] = Vector2(int(rand_range(0,9)), int(randi()%11))
    for f in range(65):
        if matrix[f][0].y > 0: 
        elif matrix[f][upd].y <=0 :
            matrix[f].push_front(Vector2(randi()&1, int(randi()%11)));
    upd +=1

func _fixed_process(delta): 
    move += delta;
    if ( move > 0.15 ): 

func _draw():
    for i in range(65):
        for j in range(38):
            if matrix[f][y].y ==10:
                col = Color(1,1,1,matrix[f][y].y*0.1);
                col = Color(0,1,0,matrix[f][y].y*0.1);
                draw_string(font, Vector2(f*16,y*16+16), str(matrix[f][y].x),col)
in Engine by (41 points)

The font file "fnt" is an imported file, i.e. it was imported into the engine. From the looks of it, Airvikar was using version 2.1 of the engine. If you're using version 3.0 (or greater) of the engine, you'll have to change the code appropriately. I would attempt it myself, but I'm currently on my mobile phone. :(

1 Answer

0 votes
  1. Save your ttf file inside your project
  2. Right click on a folder and choose "New Resource..."
  3. Search and select "DynamicFont"
  4. Save as XXX.tres (XXX=any name)
  5. Select XXX.tres and open it on Inspector
  6. Drag your ttf in Font => Font Data
  7. In your script put:
    font = load("res://XXX.tres") or font = load("res://folder_name/XXX.tres)
by (26 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.