Black Rose
An unbreakable bond
I have been wanting to do an A.I. project for a long time but I have been unable to figure out how programming is done in java. So was was hoping that someone would help me along the way. From what I know there is data in arrays/matrices and that data is manipulated by algorithms. I know more about algorithms then programming. All I need is some help rendering my algorithms on screen. I do not expect any help from anyone that doesn't want to help. But would appreciate it if anyone does help.
right now this is all the code I have left from when my computer crashed. It is supposed to display a grid of colors that randomly change color during intervals of 30fps. It needs those colors in an array 400x400.
Once that is done I will work on entering some algorithms for the program. Once it has the basics it will become clear what I/we do next.
right now this is all the code I have left from when my computer crashed. It is supposed to display a grid of colors that randomly change color during intervals of 30fps. It needs those colors in an array 400x400.
Once that is done I will work on entering some algorithms for the program. Once it has the basics it will become clear what I/we do next.
Code:
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Color;
public class Colors (Ghraphics g)extends JComponent {
Random generator = new Random();
for (int x = 0; x < 20; x++) {
for (int y = 0; y < 20; y++) {
int r = generator.nextInt(6);
graphics.fillRect(x, y, 1, 1);
if(r==0){
graphics.setColor(Color.red);
}
if(r==1){
graphics.setColor(Color.orange);
}
if(r==2){
graphics.setColor(Color.yellow);
}
if(r==3){
graphics.setColor(Color.green);
}
if(r==4){
graphics.setColor(Color.blue);
}
if(r==5){
graphics.setColor(Color.magenta);
}
}
}
int p[][] = new int [10][10];
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
int r = generator.nextInt(1);
p[x][y] = r;
}
}
for (int x = 100; x < 200; x=10) {
for (int y = 100; y < 200; y=10) {
graphics.setColor(Color.black);
if(p[x][y]==0){
graphics.setColor(Color.black);
graphics.fillRect(x, y, 10, 10);
}
if(p[x][y]==1){
graphics.setColor(Color.green);
graphics.fillRect(x, y, 10, 10);
}
}
}
public static void main(String[] args) {
JFrame f = new JFrame("Colors");
f.add(new Colors());
f.setSize(300, 300);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}