Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ManunGar authored Feb 25, 2024
1 parent 5f88f3b commit 457423e
Show file tree
Hide file tree
Showing 80 changed files with 161,474 additions and 0 deletions.
Binary file added bin/fonts/8-BIT WONDER.TTF
Binary file not shown.
Binary file added bin/fonts/Fuentes.class
Binary file not shown.
Binary file added bin/fonts/PixCon.ttf
Binary file not shown.
Binary file added bin/fonts/Pixellari.ttf
Binary file not shown.
Binary file added bin/img/Cartel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/Cartel.pxo
Binary file not shown.
Binary file added bin/img/CartelLetras.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/Flecha.pxo
Binary file not shown.
Binary file added bin/img/FlechaDer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/FlechaIzq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/Fondo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/Fondo.pxo
Binary file not shown.
Binary file added bin/img/FondoImg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/TablaAhorcado.png.pxo
Binary file not shown.
Binary file added bin/img/black/TablaAhorcado0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/black/TablaAhorcado6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/img/lucky/TablaAhorcado6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/main/Main.class
Binary file not shown.
Binary file added bin/modelo/Palabra.class
Binary file not shown.
Binary file added bin/modelo/Personaje.class
Binary file not shown.
Binary file added bin/modelo/RutaPersonaje.class
Binary file not shown.
Binary file added bin/modelo/imagen.class
Binary file not shown.
Binary file added bin/module-info.class
Binary file not shown.
80,379 changes: 80,379 additions & 0 deletions bin/resources/palabras.txt

Large diffs are not rendered by default.

Binary file added bin/vistas/Base$1.class
Binary file not shown.
Binary file added bin/vistas/Base$2.class
Binary file not shown.
Binary file added bin/vistas/Base$3.class
Binary file not shown.
Binary file added bin/vistas/Base$4.class
Binary file not shown.
Binary file added bin/vistas/Base$5.class
Binary file not shown.
Binary file added bin/vistas/Base$6.class
Binary file not shown.
Binary file added bin/vistas/Base$7.class
Binary file not shown.
Binary file added bin/vistas/Base$8.class
Binary file not shown.
Binary file added bin/vistas/Base.class
Binary file not shown.
Binary file added src/fonts/8-BIT WONDER.TTF
Binary file not shown.
29 changes: 29 additions & 0 deletions src/fonts/Fuentes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package fonts;

import java.awt.Font;
import java.io.InputStream;

public class Fuentes {
private Font font = null;
public String BIT8 = "8-BIT WONDER.TTF";
public String PC = "PixCon.ttf";
public String PLL = "Pixellari.ttf";

/* Font.PLAIN = 0 , Font.BOLD = 1 , Font.ITALIC = 2
* tamaño = float
*/
public Font fuente( String fontName, int estilo, float tamanio)
{
try {
//Se carga la fuente
InputStream is = getClass().getResourceAsStream(fontName);
font = Font.createFont(Font.TRUETYPE_FONT, is);
} catch (Exception ex) {
//Si existe un error se carga fuente por defecto ARIAL
System.err.println(fontName + " No se cargo la fuente");
font = new Font("Arial", Font.PLAIN, 14);
}
Font tfont = font.deriveFont(estilo, tamanio);
return tfont;
}
}
Binary file added src/fonts/PixCon.ttf
Binary file not shown.
Binary file added src/fonts/Pixellari.ttf
Binary file not shown.
Binary file added src/img/Cartel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/Cartel.pxo
Binary file not shown.
Binary file added src/img/CartelLetras.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/Flecha.pxo
Binary file not shown.
Binary file added src/img/FlechaDer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/FlechaIzq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/Fondo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/Fondo.pxo
Binary file not shown.
Binary file added src/img/FondoImg.png
Binary file added src/img/TablaAhorcado.png.pxo
Binary file not shown.
Binary file added src/img/black/TablaAhorcado0.png
Binary file added src/img/black/TablaAhorcado1.png
Binary file added src/img/black/TablaAhorcado2.png
Binary file added src/img/black/TablaAhorcado3.png
Binary file added src/img/black/TablaAhorcado4.png
Binary file added src/img/black/TablaAhorcado5.png
Binary file added src/img/black/TablaAhorcado6.png
Binary file added src/img/lucky/TablaAhorcado0.png
Binary file added src/img/lucky/TablaAhorcado1.png
Binary file added src/img/lucky/TablaAhorcado2.png
Binary file added src/img/lucky/TablaAhorcado3.png
Binary file added src/img/lucky/TablaAhorcado4.png
Binary file added src/img/lucky/TablaAhorcado5.png
Binary file added src/img/lucky/TablaAhorcado6.png
13 changes: 13 additions & 0 deletions src/main/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main;

import vistas.Base;

public class Main {

public static void main(String[] args) {
// TODO Auto-generated method stub
Base frame = new Base();
frame.setVisible(true);
}

}
115 changes: 115 additions & 0 deletions src/modelo/Palabra.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package modelo;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public record Palabra(String palabra, Integer longitud, List<String> letras) {

public static Palabra of(String palabra) {
Integer longitud = palabra.length();
List<String> ls = new ArrayList<String>();
String[] letras = palabra.split("");
for(int i = 0; i < letras.length; i++) {
ls.add(letras[i].toUpperCase());
}
return new Palabra(palabra.toUpperCase(), longitud, ls);
}

// Parseo de las Palabras de txt a lista
@SuppressWarnings("finally")
public static ArrayList<Palabra> obtener() {
final String NOMBRE_ARCHIVO = "src/resources/palabras.txt";
ArrayList<Palabra> palabras = new ArrayList<>();
FileReader fileReader = null;
BufferedReader bufferedReader = null;
try {
fileReader = new FileReader(NOMBRE_ARCHIVO);
bufferedReader = new BufferedReader(fileReader);
String linea;
while ((linea = bufferedReader.readLine()) != null) {
if(linea.length() < 12) {
palabras.add(Palabra.of(linea));
}
}
} catch (IOException e) {
System.out.println("Excepción leyendo archivo: " + e.getMessage());
} finally {
try {
if (fileReader != null) {
fileReader.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e) {
System.out.println("Excepción cerrando: " + e.getMessage());
}
return palabras;
}
}

//Seleccion de Palabra Aleatoria
public static Palabra palabraAleatoria(List<Palabra> ls) {
Random rand = new Random();
return ls.get(rand.nextInt(ls.size()));
}

//Crea una lista de guiones con el mismo tamaño que el tamaño de la palabra
public List<String> listaGuiones() {
List<String> ls = new ArrayList<String>();
for(int i = 0; i < this.longitud;i++) {
ls.add("_");
}
return ls;
}

//Combierte una lista en cadena
public static String concatena(List<String> ls) {
String guiones = " ";
for(String letra: ls) {
guiones += letra + " ";
}
return guiones;
}

/*
* MODIFICA LA PALABRA DADA LA LETRA SUSTITUYE LOS GUIONES POR LA/S LETRAS Y VICEBERSA
*/
public Map<List<String>, List<String>> modificaPalabra(String letra, List<String> listaGuiones, List<String> listaPalabra) {
int ind = 0;
letra = letra.toUpperCase();
Map<List<String>,List<String>> mp = new HashMap<>();
while(listaPalabra.contains(letra)) {
ind = listaPalabra.indexOf(letra);

listaPalabra.remove(ind);
listaPalabra.add(ind, "_");

listaGuiones.remove(ind);
listaGuiones.add(ind, letra);
}
mp.put(listaPalabra, listaGuiones);
return mp;

}


public static void main(String[] args) {
List<Palabra> ls = Palabra.obtener();
Palabra p = Palabra.palabraAleatoria(ls);
System.out.println(p);
List<String> listaPalabra = new ArrayList<String>();
listaPalabra.addAll(p.letras());
List<String> listaGuiones = p.listaGuiones();
System.out.println(listaGuiones);
System.out.println(p.modificaPalabra("a", listaGuiones, listaPalabra));
System.out.println(ls);

}
}
7 changes: 7 additions & 0 deletions src/modelo/Personaje.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package modelo;

public enum Personaje {
LUCKYLUKE, LUCKYBLACK
}


19 changes: 19 additions & 0 deletions src/modelo/RutaPersonaje.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package modelo;

public class RutaPersonaje {

public static String personaje(Personaje personaje) {
if (personaje == Personaje.LUCKYLUKE) return "Lucky Luke,lucky";
if (personaje == Personaje.LUCKYBLACK) return "Lucky Reverse,black";
else return "";
}

public static String ruta(Personaje personaje) {
return "/img/"+personaje(personaje).split(",")[1]+"/";

}

public static String nombre(Personaje personaje ) {
return personaje(personaje).split(",")[0];
}
}
35 changes: 35 additions & 0 deletions src/modelo/imagen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package modelo;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class imagen extends JLabel{
private static final long serialVersionUID = 1L;
private String ruta = "";

@Override
protected void paintComponent(Graphics gg) {
Graphics2D g = (Graphics2D)gg;
URL rutaAbsoluta = getClass().getResource(ruta);

if(rutaAbsoluta != null) {
ImageIcon imagen = new ImageIcon(rutaAbsoluta);
g.drawImage(imagen.getImage(),0,0,this.getWidth(),this.getHeight(), null);
}

g.dispose();
}


public String getRuta() {
return ruta;
}

public void setRuta(String ruta) {
this.ruta = ruta;
}
}
9 changes: 9 additions & 0 deletions src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
*
*/
/**
*
*/
module Ahorcado {
requires java.desktop;
}
Loading

0 comments on commit 457423e

Please sign in to comment.