Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | catafest |
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):
matrix.append([])
for y in range(38):
if y == 0 :
randomize();
matrix[f].append(Vector2(randi()&1, int(randi()%11)));
else:
matrix[f].append(Vector2(0,1));
set_fixed_process(true)
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:
matrix[f].push_front(Vector2(matrix[f][0].x,matrix[f][0].y-1));
matrix[f].pop_back();
elif matrix[f][upd].y <=0 :
matrix[f].push_front(Vector2(randi()&1, int(randi()%11)));
matrix[f].pop_back();
upd +=1
func _fixed_process(delta):
move += delta;
if ( move > 0.15 ):
mtrx();
move=0;
update();
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);
else:
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)
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.
Ertain | 2019-01-05 19:11