Skip to content

Instantly share code, notes, and snippets.

@ultimape
Last active November 5, 2015 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ultimape/4b7227c81d2df5796e0c to your computer and use it in GitHub Desktop.
Save ultimape/4b7227c81d2df5796e0c to your computer and use it in GitHub Desktop.
A simple matrix like display using console. A project for fun back in 2004 - did it to see how simply I could recreate the effect. Meant to run with custom windows console settings (width,height, and text color). My original exe seems to be flagged as a trojan by microsoft security essentials so I've included the makefile to see if I can recreat…
# Project: Project1
# Makefile created by Dev-C++ 4.9.9.0
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -L"G:/Program Files/Dev-Cpp/lib"
INCS = -I"G:/Program Files/Dev-Cpp/include"
CXXINCS = -I"G:/Program Files/Dev-Cpp/include/c++/3.3.1" -I"G:/Program Files/Dev-Cpp/include/c++/3.3.1/mingw32" -I"G:/Program Files/Dev-Cpp/include/c++/3.3.1/backward" -I"G:/Program Files/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"G:/Program Files/Dev-Cpp/include"
BIN = matrix.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom
all: all-before matrix.exe all-after
clean: clean-custom
rm -f $(OBJ) $(BIN)
$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "matrix.exe" $(LIBS)
main.o: main.c
$(CC) -c main.c -o main.o $(CFLAGS)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#define SIZESCREEN 249
int randomizer(int lower, int upper) //uses diffrence to get range, then lower as base (ie rand()% diff + lower)
{
return ((rand()%((upper+1)-lower))+lower);
}
int main(int argc, char *argv[])
{
srand((unsigned int)time(0)); //set seed
int i;
int j;
int k;
int l;
int m;
int end = 100;
int rand1;
int rand2;
int rand3;
int rand4;
int charconstant = 48;
int timera;
int timerd;
int pos[SIZESCREEN];
int matrix[SIZESCREEN];
for(l=0;l<SIZESCREEN;l++) pos[l]=32;
while(end!=0)
{
end--;
rand2 = randomizer(1,20);
for(k=0;k<rand2;k++)
{
for(l=0;l<79;l++)
{
rand3 = randomizer(0,SIZESCREEN);
rand4 = randomizer(0,59);
if(rand4==0) pos[rand3]=0;
if(rand4==1) pos[rand3]=1;
if(rand4>1) pos[rand3]=32;
}
for(m=0;m<SIZESCREEN;m++)
{
matrix[m]=pos[m];
}
rand1 = randomizer(5,20);
for(j=0;j<rand1;j++)
{
for(i=0;i<SIZESCREEN;i++)
{
if(matrix[i]<2 || (matrix[i]>47 && matrix[i]<123))
{
matrix[i] = randomizer(49,121);
}else{
matrix[i] = 32;
}
printf("%c", matrix[i]);
//+48
}
timera=0;
while(timera<6000000) timera++;
if(10000 == randomizer(1,10000)) {system("cls");}
printf("\n");
}
}
}
system("PAUSE");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment