Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package polytester;
- import org.newdawn.slick.AppGameContainer;
- import org.newdawn.slick.BasicGame;
- import org.newdawn.slick.GameContainer;
- import org.newdawn.slick.Graphics;
- import org.newdawn.slick.Input;
- import org.newdawn.slick.geom.Polygon;
- import org.newdawn.slick.SlickException;
- import org.newdawn.slick.Color;
- import java.util.Random;
- import java.awt.Font;
- import java.util.Scanner;
- /*
- * # # # # #
- * # # 1 0 0
- * # # # # #
- * # # # # #
- * # # # # #
- */
- public class hola extends BasicGame {
- Polygon[][] rand = new Polygon[25][25];
- int[][][] grid = new int[5][25][25];
- int tempax = 0, tempay = 0;
- Random r = new Random();
- int time;
- Scanner input = new Scanner(System.in);
- Font font = new Font("Helvetica", Font.BOLD, 30);
- int x = 20, y = 20, number = 100, phase = 1;
- int xc = 32, yc = 24;
- String print;
- boolean next;
- int z, p, tempx, tempy;
- int timer;
- int checksum;
- int chance;
- int cursorx = 200, cursory = 200, cx = 1, cy = 1;
- int sex = 0;
- int countd=0;
- public hola() {
- super("polygontest");
- }
- public void init(GameContainer container) throws SlickException {
- container.setVSync(true);
- for(int z = 0; z < 25; z++){
- for(int p = 0; p < 25; p++){
- rand[z][p] = new Polygon(new float[]{
- 0,0,
- 0,y,
- x,y,
- x,0
- });
- chance = r.nextInt(2);
- grid[0][z][p] = chance;
- if(chance == 1){
- rand[z][p].setLocation(z*x, p*y);
- }else{
- rand[z][p].setLocation(900, 900);
- }
- tempx++;
- }
- tempy++;
- tempx=0;
- }
- for(int dope = 0; dope < 4; dope++){
- for(int mattb = 0; mattb < 25; mattb++){
- for(int mattx = 0; mattx < 25; mattx++){
- if(mattb-1 >= 0 && mattb+1 <=24 && mattx-1 >= 0 && mattx+1 <= 24){
- checksum=grid[dope][mattb-1][mattx-1]+grid[dope][mattb-1][mattx]+grid[dope][mattb-1][mattx+1]+
- grid[dope][mattb][mattx-1]+grid[dope][mattb][mattx+1]+grid[dope][mattb+1][mattx-1]+
- grid[dope][mattb+1][mattx]+grid[dope][mattb+1][mattx+1];
- if(checksum >= 4 && grid[dope][mattb][mattx] == 1){
- grid[dope+1][mattb][mattx] = 1;
- }
- if(checksum >= 5){
- grid[dope+1][mattb][mattx] = 1;
- }
- }
- }
- }
- }
- for(int ax = 0; ax < 25; ax++){
- for(int ay = 0; ay < 25; ay++){
- if(grid[4][ax][ay] == 1){
- rand[ax][ay].setLocation(ax*x, ay*y);
- tempax++;
- }
- }
- tempay++;
- tempax=0;
- }
- }
- public void update(GameContainer container, int delta) {
- timer--;
- if(container.getInput().isKeyDown(Input.KEY_SPACE) && timer < 0){
- timer = 30;
- countd++;
- if(countd>4)countd=0;
- for(int ax = 0; ax < 25; ax++){
- for(int ay = 0; ay < 25; ay++){
- if(grid[countd][ax][ay] == 1){
- rand[ax][ay].setLocation(ax*x, ay*y);
- tempax++;
- }
- }
- tempay++;
- tempax=0;
- }
- }
- }
- public void render(GameContainer container, Graphics g) {
- for(int d = 0; d < 25; d++){
- for(int o = 0; o < 25; o++){
- // g.draw(rand[o][d]);
- if(grid[countd][d][o]==1){
- g.drawString("#", d*x, o*y);
- System.out.print("#");
- }else{
- g.drawString(" ", d*x, o*y);
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- System.out.println("BREAKBREAKBREAK");
- }
- public static void main(String[] argv) throws SlickException {
- AppGameContainer container = new AppGameContainer(new hola(), 500, 500, false);
- container.setShowFPS(false);
- container.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment