Help on Matrix falling rain code

7 次查看(过去 30 天)
Ryan
Ryan 2015-5-25
编辑: Ryan 2015-5-25
Hey guys so I got into my head to try to recreate the the falling rain effect from the Matrix movies in Matlab.
Here's what I've got so far
clear all
close all
clc
cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;
listeners = cmdWinDoc.getDocumentListeners;
for i = 3:4
jTextArea = listeners(i);
jTextArea.setBackground(java.awt.Color.black);
jTextArea.setBackground(java.awt.Color(0,0,0));
set(jTextArea,'Background','black');
set(jTextArea,'Background',[0,0,0]);
jTextArea.setForeground(java.awt.Color.green);
jTextArea.setForeground(java.awt.Color(0,1,0));
set(jTextArea,'Foreground','green');
set(jTextArea,'Foreground',[0,1,0]);
end
for j = 1:10000
A9=['A':'Z' '0':'9' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ';];
Data=zeros(length(A9),105);
for k=1:size(Data,2)
Data(:,k)=randperm(length(A9));
end
Data=A9(Data)
end
for i = 3:4
jTextArea = listeners(i);
jTextArea.setBackground(java.awt.Color.white);
jTextArea.setBackground(java.awt.Color(1,1,1));
set(jTextArea,'Background','white');
set(jTextArea,'Background',[1,1,1]);
jTextArea.setForeground(java.awt.Color.black);
jTextArea.setForeground(java.awt.Color(0,0,0));
set(jTextArea,'Foreground','black');
set(jTextArea,'Foreground',[0,0,0]);
end
clc
I would want to change that central for-loop to a while-loop, but I was having issues trying to figure out how to leave the while loop with a keypress.
I'm wondering if anyone has any better ideas for how to achieve this falling rain effect as right now this code more spams random letters than having them rain.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by