Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ld29;
- import java.util.*;
- import java.io.*;
- public class LevelCreator {
- private static Scanner x;
- public static void main (String[] args) throws IOException{
- int count1 = 0, count2 =0, count3=0;
- for(int k=1;k<=3;k++){
- if (k == 1){
- try{
- x = new Scanner(new File("background.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- while(x.hasNextLine()){
- count1++;
- x.nextLine();
- }
- x.close();
- }
- else if (k == 2){
- try{
- x = new Scanner(new File("objects.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- while(x.hasNextLine()){
- count2++;
- x.nextLine();
- }
- x.close();
- }
- else{
- try{
- x = new Scanner(new File("characters.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- while(x.hasNextLine()){
- count3++;
- x.nextLine();
- }
- x.close();
- }
- }
- System.out.println(count1+" "+count2+" "+count3);
- int Lengths1[] = new int [count1];
- int Lengths2[] = new int [count2];
- int Lengths3[] = new int [count3];
- for(int l=1;l<=3;l++){
- if (l == 1){
- try{
- x = new Scanner(new File("background.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- for(int i=0;i<count1;i++){
- while(x.hasNextLine()){
- String a = x.next();
- Lengths1[i] = a.length();
- System.out.print(Lengths1[i]+" ");
- break;
- }
- }
- x.close();
- }
- else if (l == 2){
- try{
- x = new Scanner(new File("objects.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- System.out.println(" ");
- for(int i=0;i<count1;i++){
- while(x.hasNextLine()){
- String a = x.next();
- Lengths2[i] = a.length();
- System.out.print(Lengths2[i]+" ");
- break;
- }
- }
- x.close();
- }
- else{
- try{
- x = new Scanner(new File("characters.txt"));
- }
- catch(Exception e){
- System.out.println("Could not find file");
- }
- System.out.println(" ");
- for(int i=0;i<count1;i++){
- while(x.hasNextLine()){
- String a = x.next();
- Lengths3[i] = a.length();
- System.out.print(Lengths3[i]+" ");
- break;
- }
- }
- }
- }
- System.out.println(" ");
- int max1=0, max2=0, max3=0;
- for(int m=1;m<=3;m++){
- if (m==1){
- for (int i=0;i<count1;i++){
- if (Lengths1[i] > max1){
- max1 = Lengths1[i];
- }
- }
- System.out.println(max1);
- }
- else if (m == 2){
- for (int i=0;i<count3;i++){
- if (Lengths2[i] > max2){
- max2 = Lengths2[i];
- }
- }
- System.out.println(max2);
- }
- else{
- for (int i=0;i<count3;i++){
- if (Lengths3[i] > max3){
- max3 = Lengths3[i];
- }
- }
- System.out.println(max3);
- }
- }
- char background[][] = new char [count1][max1];
- char objects[][] = new char [count2][max2];
- char characters[][] = new char [count3][max3];
- for(int n=0;n<=3;n++){
- if (n == 1){
- try {
- FileInputStream fileinput = new FileInputStream("background.txt");
- int r;
- for(int i=0;i<count1;i++){
- for(int j=0;j<max1;j++){
- while((r = fileinput.read()) != -1){
- char c = (char) r;
- background[i][j] = c;
- break;
- }
- }
- }
- fileinput.close();
- }
- catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- for (int i=0;i<count1;i++){
- for(int j=0;j<max1;j++){
- System.out.print(background[i][j]);
- }
- }
- System.out.println(background[13][19]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement